首页 > 其他分享 >APP自动化-ATX集成到代码中

APP自动化-ATX集成到代码中

时间:2023-06-13 19:25:06浏览次数:45  
标签:集成 get udid APP devices device using self ATX

把atx的框架集成到代码中

把ATX-API的脚本复制到已有项目中

  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 # @Time    : 2023/6/13 10:29
  4 # @Author  : gezirui
  5 # @File    : package_atx_api.py
  6 # @Software: PyCharm
  7 from requests import get, post, delete
  8 import random
  9 import time
 10 
 11 
 12 class AtxServer:
 13     def __init__(self, host, token):
 14         self.host = host
 15         self.token = token
 16         self.headers = {"Authorization": f'Bearer {self.token}'}
 17         self.uuid = ""
 18         self.using_device_info = {}
 19 
 20     def get_user(self):
 21         user_data = get(self.host + "/api/v1/user", headers=self.headers).json()
 22 
 23         return user_data
 24 
 25     def get_all_devices(self):
 26         all_devices = get(self.host + "/api/v1/devices", headers=self.headers).json()
 27 
 28         return all_devices
 29 
 30     def get_no_using_devices(self, all_devices):
 31         no_using_devices = []
 32         for i in all_devices["devices"]:
 33             present = i.get("present")
 34             using = i.get("using")
 35             colding = i.get("colding")
 36             if present == True and using == 0 and not colding:
 37                 # print("设备正在空闲状态中")
 38                 udid = i["udid"]
 39                 no_using_devices.append(udid)
 40 
 41         return no_using_devices
 42 
 43     def random_one_device(self, no_using_devices):
 44         self.udid = random.choice(no_using_devices)
 45 
 46         return random.choice(no_using_devices)
 47 
 48     def using_device(self, udid=None):
 49 
 50         if udid:
 51             self.udid = udid
 52 
 53         result = post(self.host + "/api/v1/user/devices",
 54                       headers=self.headers,
 55                       json={"udid": self.udid}).json()
 56 
 57         return result
 58 
 59     def get_using_device_info(self, udid=None):
 60         if udid:
 61             self.udid = udid
 62 
 63         result = get(self.host + "/api/v1/user/devices/" + self.udid,
 64                      headers=self.headers).json()
 65         self.using_device_info = result
 66         return result
 67 
 68     def get_remote_connect_address(self):
 69         sources = self.using_device_info["device"]["sources"]
 70         # print("1:", sources.values)
 71         # print("2:", list(sources.values())[0])
 72         self.remoteConnectAddress = list(sources.values())[0]["remoteConnectAddress"]
 73 
 74     def release_device(self, udid=None):
 75         if udid:
 76             self.udid = udid
 77 
 78         result = delete(self.host + "/api/v1/user/devices/" + self.udid,
 79                         headers=self.headers).json()
 80         return result
 81 
 82 
 83 if __name__ == '__main__':
 84     host_ = "http://localhost:4000"
 85     token_ = "dd7fe77f7b9c400cabd29514a8341a6b"
 86     atx = AtxServer(host=host_, token=token_)
 87     all_devices = atx.get_all_devices()
 88     print("所有设备:", all_devices)
 89     no_using_devices = atx.get_no_using_devices(all_devices)
 90     print("udid列表:",no_using_devices)
 91     atx.random_one_device(no_using_devices)
 92     print("随机设备是:" ,atx.random_one_device(no_using_devices))
 93     atx.using_device()
 94     print("使用设备:",atx.using_device())
 95     atx.get_using_device_info()
 96     print("使用设备详情:",atx.get_using_device_info())
 97     atx.get_remote_connect_address()
 98     print("远程连接地址:", atx.remoteConnectAddress)
 99     time.sleep(5)
100     atx.release_device()
101     print("释放情况:",atx.release_device())
View Code

 

标签:集成,get,udid,APP,devices,device,using,self,ATX
From: https://www.cnblogs.com/gezirui/p/17478523.html

相关文章

  • python+uiautomator2判断app是否进入到闪屏广告页面
    前提背景:app内部存在多处广告,需要进行进行自动化:1.查看app是否成功跳转了页面2.页面是否空白3.大致经历的耗时主要思路如下:点击前进行截图操作,点击后进行判断判断图片是否空白defis_blank(image_path,gray_value=250,threshold=0.9):"""函数会计算一幅图像中......
  • 手机APP的开发费用是多少?
    随着移动互联网的快速发展,越来越多的企业和个人开始涉足手机app开发领域。然而,手机APP开发的费用是开发者们最为关心的问题之一。下面思久科技将介绍手机app开发费用的一般预算和主要影响因素,以供参考。一般预算手机APP开发费用的预算因多种因素而异,包括所在地区、开发团队规模、开......
  • uni-app请求封装
    1.http.js//你的请求地址(线上或线下)exportconstBASE_URL='http://xxx.xxx.xx.xxx:xxxx/'; exportconsthttp=(options)=>{returnnewPromise((resolve,reject)=>{lettoken="",tokenName='';letheader={......
  • uni-app开启消息通知
    场景:uni-app开启移动app,如果用户没开启消息通知提示开启因为uni-app升级到androidx,之前的android.support.v4.app.NotificationManagerCompat已经找不到了,androidx中采用androidx.core.app.NotificationManagerCompat判断是否开启了消息通知 varmain=plus.android.runtime......
  • GO语言集成开发工具环境-JetBrains GoLand 2023
    Go是一种开源编程语言,适用于开发高效、可扩展的软件。由于其高效性和可扩展性,Go已经成为了一种流行的编程语言。为了更好地开发Go应用程序,JetBrains公司开发了一款Go语言集成开发工具环境——GoLand。→→↓↓载GoLand2023mac/win版 GoLand提供了一系列功能和工具,帮助开发......
  • 苹果自研Apple M1芯片对机器学习意味着什么?
    正文字数:3049 阅读时长:4分钟苹果在iPad和iPhone系列中首次推出了基于苹果A系列处理器的苹果硅片台式机/笔记本电脑处理器。他们推出了这一新的处理器的同时,也推出了三款新的Mac,包括新的M1MacBookAir、M1MacBookPro和M1Macmini。作者/ TommyShrovehttps://netflixtechbl......
  • HP 288G9 主机安装Esxi6.7报错Shutting down firmware services Using simple offset'
    ShuttingdownfirmwareservicesUsingsimpleoffset'UEFIRTSmappingpolicy找了好多方法都不行,尝试1:添加ignoreHeadless=TRUE参数也没救回我电脑,失败尝试2:BIOS中将PCI64bitResourcesHandling里的Above4GDecoding,找不到失败尝试3:PC主板里有一个设置选项叫CSM兼容性......
  • 基于.NET的Web Service技术的分布式异构数据库的集成
    摘要:本文分析了WebService的特点,提出了一种基于Microsoft.NET的WebService技术访问分布异构数据库的体系结构,并采用.NET技术实现了原型系统。在原型系统中,使用WebService将分布于Internet上的不同的数据库系统中的数据集成,向访问数据库的应用程序提供统一的数据操作接口,实现......
  • uniapp开发公众号H5时用户缓存无法清除问题
     业务场景:  此项目是一个vx公众号h5项目,每次更新版的时候用户端由于有缓存,每次都是使用滞后的版本解决方案:一、index.html文件如何保证不缓存,每次都使用服务器上最新的代码?此时需要一下标签:<metahttp-equiv="Cache-Control"content="no-cache,no-store,must-revali......
  • 直播软件app开发,vue里tab菜单横向展示,可分页功能组件实现
    直播软件app开发,vue里tab菜单横向展示,可分页功能组件实现子组件: <template><div>  <el-buttonv-if="move!=0&&!dataLen"size='small'icon="el-icon-arrow-left"@click="navPrev"></el-button>   <ulref......