From 9d0d36ca6319a4f1223a1ac941f90cc5eef4170a Mon Sep 17 00:00:00 2001 From: youngS Date: Fri, 10 Dec 2021 20:39:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96api=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/tasks.py | 2 +- fir_ser/api/utils/app/supersignutils.py | 10 ++++++++-- fir_ser/api/utils/apple/appleapiv3.py | 5 ++++- fir_ser/config.py | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fir_ser/api/tasks.py b/fir_ser/api/tasks.py index 3338f09..9dd62bf 100644 --- a/fir_ser/api/tasks.py +++ b/fir_ser/api/tasks.py @@ -47,7 +47,7 @@ def run_sign_task(format_udid_info, short, client_ip): elif code in [1004, 1001, 1009]: msg = msg.get('msg', '未知错误') else: - msg = '系统内部错误' + msg = '系统内部错误,请稍后再试或联系管理员' else: msg = "" return msg diff --git a/fir_ser/api/utils/app/supersignutils.py b/fir_ser/api/utils/app/supersignutils.py index b2e7f22..61dca1d 100644 --- a/fir_ser/api/utils/app/supersignutils.py +++ b/fir_ser/api/utils/app/supersignutils.py @@ -663,7 +663,7 @@ class IosUtils(object): add_new_bundles_prefix = f"check_or_add_new_bundles_{self.developer_obj.issuer_id}_{self.app_obj.app_id}" download_profile_prefix = f"make_and_download_profile_{self.developer_obj.issuer_id}_{self.app_obj.app_id}" - with cache.lock(register_devices_prefix, timeout=60): + with cache.lock(register_devices_prefix, timeout=360): if CleanErrorBundleIdSignDataState(add_new_bundles_prefix).get_state(): return True, True # 程序错误,进行清理的时候,拦截多余的设备注册 if not get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj): @@ -674,14 +674,18 @@ class IosUtils(object): self.udid_info, client_ip, add_new_bundles_prefix) if not status: + if 'UNEXPECTED_ERROR' in str(did_udid_result): + return False, {} msg = f"app_id {self.app_obj} register devices failed. {did_udid_result}" self.sign_failed_fun(d_result, msg) continue if status and 'continue' in [str(did_udid_result)]: return True, True - with cache.lock(add_new_bundles_prefix, timeout=60): + with cache.lock(add_new_bundles_prefix, timeout=360): status, bundle_result = IosUtils.check_or_add_new_bundles(self.app_obj, self.developer_obj) if not status: + if 'UNEXPECTED_ERROR' in str(bundle_result): + return False, {} msg = f"app_id {self.app_obj} create bundles failed. {bundle_result}" self.sign_failed_fun(d_result, msg) continue @@ -704,6 +708,8 @@ class IosUtils(object): did_udid in did_udid_lists]) if not status: + if 'UNEXPECTED_ERROR' in str(download_profile_result): + return False, {} msg = f"app_id {self.app_obj} download profile failed. {download_profile_result}" self.sign_failed_fun(d_result, msg) continue diff --git a/fir_ser/api/utils/apple/appleapiv3.py b/fir_ser/api/utils/apple/appleapiv3.py index b8582b8..0e816e1 100644 --- a/fir_ser/api/utils/apple/appleapiv3.py +++ b/fir_ser/api/utils/apple/appleapiv3.py @@ -25,7 +25,7 @@ logger = logging.getLogger(__name__) proxies = settings.APPLE_DEVELOPER_API_PROXY if settings.APPLE_DEVELOPER_API_PROXY else {} -timeout = settings.APPLE_DEVELOPER_API_TIMEOUT if settings.APPLE_DEVELOPER_API_TIMEOUT else 180 +timeout = settings.APPLE_DEVELOPER_API_TIMEOUT if settings.APPLE_DEVELOPER_API_TIMEOUT else 120 def request_format_log(req): @@ -784,6 +784,9 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi raise Exception(req.text) elif req.status_code == 429: # 请求超过每小时限制 {'user-hour-lim': '3600', 'user-hour-rem': '3586'} raise Exception(req.text) + elif req.status_code == 500: + time.sleep(60) + raise Exception(req.text) else: raise Exception('unknown error: %s code:%s' % (req.text, req.status_code)) diff --git a/fir_ser/config.py b/fir_ser/config.py index 98e3564..cc39fc6 100644 --- a/fir_ser/config.py +++ b/fir_ser/config.py @@ -251,7 +251,7 @@ class IPACONF(object): # 'http': '47.243.172.202:17897', # 'https': '47.243.172.202:17897' } - APPLE_DEVELOPER_API_TIMEOUT = 180 # 访问苹果api超时时间,默认3分钟 + APPLE_DEVELOPER_API_TIMEOUT = 120 # 访问苹果api超时时间,默认3分钟 MOBILE_CONFIG_SIGN_SSL = { # 描述文件是否签名,默认是关闭状态;如果开启,并且ssl_key_path 和 ssl_pem_path 正常,则使用填写的ssl进行签名,否则默认不签名 'open': True,