苹果设备状态异常,导致注册失败【苹果设备状态还可能为 INELIGIBLE 和 PROCESSING】,当设备存在该状态,则该开发者将无法注册新设备号,需要禁用该开发者

pull/37/head
nineven 3 years ago
parent 32c3058d57
commit 05669b8d3e
  1. 4
      fir_ser/common/base/magic.py
  2. 6
      fir_ser/common/libs/apple/appleapiv3.py
  3. 40
      fir_ser/xsign/utils/supersignutils.py

@ -30,7 +30,7 @@ def run_function_by_locker(timeout=60 * 5):
res = func(*args, **kwargs)
else:
res = func(*args, **kwargs)
logger.info(f"{new_locker_key} exec {func} finished. used time:{time.time() - start_time}")
logger.info(f"{new_locker_key} exec {func} finished. used time:{time.time() - start_time} result:{res}")
return res
return wrapper
@ -58,7 +58,7 @@ def call_function_try_attempts(try_attempts=3, sleep_time=2, failed_callback=Non
if failed_callback:
logger.error(f'exec {func} failed and exec failed callback {failed_callback.__name__}')
failed_callback(*args, **kwargs, result=res)
logger.info(f"exec {func} finished. time:{time.time() - start_time}")
logger.info(f"exec {func} finished. time:{time.time() - start_time} result:{res}")
return res
return wrapper

@ -723,10 +723,10 @@ def call_function_try_attempts(try_attempts=3, sleep_time=3):
if 'FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED' in str(e):
raise Exception(res)
time.sleep(sleep_time)
logger.info(f"exec {func} finished. time:{time.time() - start_time}")
if not flag:
logger.error(f'exec {func} failed after the maximum number of attempts. Failed:{res}')
raise Exception(res)
logger.info(f"exec {func} finished. time:{time.time() - start_time} result:{res}")
return res
return wrapper
@ -900,7 +900,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
req = super().register_device(device_name, device_udid, platform)
return self.__device_store(req, 201)
@call_function_try_attempts()
# @call_function_try_attempts()
def enabled_device(self, device_id, device_name, udid):
if device_id and device_name:
req = super().enabled_device(device_id, device_name)
@ -912,7 +912,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
req = self.modify_registered_device(device_obj.id, device_obj.name, 'ENABLED')
return self.__device_store(req)
@call_function_try_attempts()
# @call_function_try_attempts()
def disabled_device(self, device_id, device_name, udid):
if device_id and device_name:
req = super().disabled_device(device_id, device_name)

@ -593,7 +593,13 @@ class IosUtils(object):
"There are no current ios devices",
"Device obj is None"
]
}
},
{
'func_list': [err_callback(IosUtils.check_device_status, developer_obj)],
'err_match_msg': [
"ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE",
]
},
]
sync_device_obj = UDIDsyncDeveloper.objects.filter(udid=device_udid,
@ -621,6 +627,10 @@ class IosUtils(object):
if not status:
return status, device_obj
if device_obj and device_obj.status not in ['ENABLED', 'DISABLED']:
if not IosUtils.check_device_status(developer_obj)[0]:
return False, 'UNEXPECTED_ERROR'
sync_device_obj, _ = update_or_create_developer_udid_info(device_obj, developer_obj)
# 更新设备状态
@ -682,6 +692,20 @@ class IosUtils(object):
AppUDID.objects.filter(app_id=app_obj, udid__developerid_id=developer_obj, sign_status=1).update(sign_status=2)
return True, developer_app_id_obj
@staticmethod
@call_function_try_attempts(try_attempts=2)
def check_device_status(developer_obj, device_obj_list=None):
status = True
if device_obj_list is None:
status, device_obj_list = get_api_obj(developer_obj).get_device()
if status:
for device_obj in device_obj_list:
if device_obj.status not in ['ENABLED', 'DISABLED']:
developer_obj.status = 5
developer_obj.save(update_fields=['status'])
return False, f'device status unexpected. device_obj:{device_obj}'
return True, ''
@staticmethod
@call_function_try_attempts()
def make_and_download_profile(app_obj, developer_obj, failed_call_prefix, developer_app_id_obj=None,
@ -701,6 +725,10 @@ class IosUtils(object):
{
'func_list': [err_callback(IosUtils.active_developer, developer_obj, True)],
'err_match_msg': ["There are no current certificates on this team matching the provided certificate"]
},
{
'func_list': [err_callback(IosUtils.check_device_status, developer_obj)],
'err_match_msg': ["There are no current ios devices on this team matching the provided device IDs"]
}
])
device_id_list = DeveloperDevicesID.objects.filter(app_id=app_obj,
@ -926,15 +954,19 @@ class IosUtils(object):
@staticmethod
def do_enable_device_by_sync(developer_obj, udid_sync_obj):
app_api_obj = get_api_obj(developer_obj)
app_api_obj.set_device_status("enable", udid_sync_obj.serial, udid_sync_obj.product, udid_sync_obj.udid,
status, result = app_api_obj.set_device_status("enable", udid_sync_obj.serial, udid_sync_obj.product,
udid_sync_obj.udid,
udid_sync_obj.udid)
if status:
UDIDsyncDeveloper.objects.filter(pk=udid_sync_obj.pk, developerid=developer_obj).update(status=True)
@staticmethod
def do_disable_device_by_sync(developer_obj, udid_sync_obj):
app_api_obj = get_api_obj(developer_obj)
app_api_obj.set_device_status("disable", udid_sync_obj.serial, udid_sync_obj.product, udid_sync_obj.udid,
status, result = app_api_obj.set_device_status("disable", udid_sync_obj.serial, udid_sync_obj.product,
udid_sync_obj.udid,
udid_sync_obj.udid)
if status:
UDIDsyncDeveloper.objects.filter(pk=udid_sync_obj.pk, developerid=developer_obj).update(status=False)
@staticmethod
@ -1126,6 +1158,8 @@ class IosUtils(object):
status, result = app_api_obj.get_device()
if status and developer_obj.issuer_id:
IosUtils.check_device_status(developer_obj, result)
udid_developer_obj_list = UDIDsyncDeveloper.objects.filter(developerid=developer_obj).values_list('udid')
udid_developer_list = [x[0] for x in udid_developer_obj_list if len(x) > 0]
udid_result_list = [device.udid for device in result]

Loading…
Cancel
Save