代码优化
This commit is contained in:
parent
b5399f5be6
commit
914761adb8
|
|
@ -110,7 +110,7 @@ class DealAccount:
|
|||
logger.info(f"<UNK>{data['account_id']} 开始修改数据状态,修改结果为:{result_sql}")
|
||||
if result_sql:
|
||||
restore = self.task_all.restore_system(pad_code=[data["pad_code"]], backup_name=res_dict["backup_name"])
|
||||
logger.info(f"<UNK>{data['pad_code']}备份结果为: {restore}")
|
||||
logger.info(f"<UNK>{data['pad_code']}还原结果为: {restore}")
|
||||
if restore:
|
||||
result_status = self.task_all.check_phone_status(pad_code=[data["pad_code"]], file_name="test_abc.js")
|
||||
logger.info(f"<UNK>:{data['pad_code']}{result_status}")
|
||||
|
|
|
|||
|
|
@ -13,19 +13,20 @@ from public_function.arm_cloud_signature_v2 import ArmCloudSignatureV2
|
|||
|
||||
|
||||
class DealAllTask:
|
||||
def __init__(self):
|
||||
def __init__(self, logger):
|
||||
self.end_point = "https://openapi-hk.armcloud.net"
|
||||
# 性能配置
|
||||
self.secret_key = '3yc8c8bg1dym0zaiwjh867al'
|
||||
self.access_key_id = 'gz8f1u0t63byzdu6ozbx8r5qs3e5lipt'
|
||||
self.logger = logger
|
||||
|
||||
def send_post_get(self, api_endpoint, payload, is_check=False):
|
||||
print(f"{api_endpoint}: 参数为{payload}")
|
||||
logger.info(f"{api_endpoint}: 参数为{payload}")
|
||||
try:
|
||||
arm_obj = ArmCloudSignatureV2(self.access_key_id, self.secret_key, self.end_point)
|
||||
response = arm_obj.post(api_endpoint, payload)
|
||||
result = response.json()
|
||||
print(f"接口:{api_endpoint}返回结果为{result} ")
|
||||
logger.info(f"接口:{api_endpoint}返回结果为{result} ")
|
||||
if result.get("code") == 200:
|
||||
if isinstance(result['data'], dict):
|
||||
return [result['data']]
|
||||
|
|
@ -39,7 +40,7 @@ class DealAllTask:
|
|||
time.sleep(random.randint(1, 3))
|
||||
return []
|
||||
except Exception as e:
|
||||
print(f"<UNK>: {str(e)}")
|
||||
logger.info(f"<UNK>: {str(e)}")
|
||||
return []
|
||||
|
||||
def one_click_new_device(self, pad_code: list[str], country: str):
|
||||
|
|
@ -53,12 +54,12 @@ class DealAllTask:
|
|||
@staticmethod
|
||||
def set_network_proxy(pad_code: list[str], country: str, proxy_platform="kkoip"):
|
||||
if proxy_platform == "kkoip":
|
||||
print(f"{pad_code}使用kkoip")
|
||||
logger.info(f"{pad_code}使用kkoip")
|
||||
set_network_proxy(pad_codes=pad_code, account='6255452-2ff229fb',
|
||||
password='ef9996e4-%s-%d-60m' % (country, int(time.time() * 1000) + random.randint(0, 10000)),
|
||||
ip='gate-hk.kkoip.com', port='15636', proxy_name='socks5', proxy_type='proxy')
|
||||
if proxy_platform == "uniproxy":
|
||||
print(f"{pad_code}使用 uniproxy")
|
||||
logger.info(f"{pad_code}使用 uniproxy")
|
||||
session = random.randint(1000000, 1000000000)
|
||||
# curl -x socks5://uniproxy-zone-custom-region-US:uniproxy@adv3.uipoxy.com:3000 ipinfo.io
|
||||
set_network_proxy(pad_codes=pad_code,
|
||||
|
|
@ -69,7 +70,7 @@ class DealAllTask:
|
|||
def install_app(self, pad_code: list[str]):
|
||||
end_point = "/openapi/open/pad/installApp"
|
||||
payload = {"apps": [{"appId": 691720698, "appName": "AutoJs6", "pkgName": "org.autojs.autojs6", "padCodes": pad_code, }]}
|
||||
print(f"{self.get_local_time()};开始安装autojs")
|
||||
logger.info(f"{pad_code};开始安装autojs")
|
||||
self.send_post_get(end_point, payload)
|
||||
|
||||
def get_app_list(self, pad_code):
|
||||
|
|
@ -120,7 +121,7 @@ class DealAllTask:
|
|||
end_point = "/file-center/open/file/list"
|
||||
payload = {"page": 1, "rows": 10, "fileName": file_name}
|
||||
res = self.send_post_get(end_point, payload)
|
||||
print(res)
|
||||
logger.info(res)
|
||||
if res:
|
||||
if len(res[0]['pageData']) > 0:
|
||||
return res[0]['pageData'][0]['fileUniqueId']
|
||||
|
|
@ -145,7 +146,7 @@ class DealAllTask:
|
|||
if isinstance(result, list):
|
||||
return True
|
||||
else:
|
||||
print(f"{pad_code[0]}未就绪; 返回结果为: {result}")
|
||||
logger.info(f"{pad_code[0]}未就绪; 返回结果为: {result}")
|
||||
count += 1
|
||||
time.sleep(30)
|
||||
if count == times:
|
||||
|
|
@ -167,7 +168,7 @@ class DealAllTask:
|
|||
time_zone_list = pytz.country_timezones.get(country_code)
|
||||
time_zone = random.choice(time_zone_list)
|
||||
payload = {"padCodes": pad_code, "timeZone": time_zone}
|
||||
print(f"云机:{pad_code};将时区修改为:{time_zone}")
|
||||
logger.info(f"云机:{pad_code};将时区修改为:{time_zone}")
|
||||
return self.send_post_get(end_point, payload)
|
||||
|
||||
def backup_system(self, pad_code: list[str], backup_name: str):
|
||||
|
|
@ -218,7 +219,7 @@ class DealAllTask:
|
|||
if __name__ == '__main__':
|
||||
obj = DealAllTask()
|
||||
results = obj.async_execute_adb_command(["ACP251024MKBZTCO"], "test_abc.js", is_check=True)
|
||||
print(type(results))
|
||||
logger.info(type(results))
|
||||
if results:
|
||||
print(123113)
|
||||
print(f"1223{results}1223")
|
||||
logger.info(123113)
|
||||
logger.info(f"1223{results}1223")
|
||||
|
|
|
|||
Loading…
Reference in New Issue