|
|
@ -192,9 +192,9 @@ def get_apple_udid_key(auth): |
|
|
|
return m_key |
|
|
|
return m_key |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def err_callback(func, a, b): |
|
|
|
def err_callback(func, *args, **kwargs): |
|
|
|
def wrapper(): |
|
|
|
def wrapper(): |
|
|
|
return func(a, b) |
|
|
|
return func(*args, **kwargs) |
|
|
|
|
|
|
|
|
|
|
|
return wrapper |
|
|
|
return wrapper |
|
|
|
|
|
|
|
|
|
|
@ -327,6 +327,10 @@ class IosUtils(object): |
|
|
|
sync_device_obj = UDIDsyncDeveloper.objects.filter(udid=udid_info.get('udid'), |
|
|
|
sync_device_obj = UDIDsyncDeveloper.objects.filter(udid=udid_info.get('udid'), |
|
|
|
developerid=developer_obj).first() |
|
|
|
developerid=developer_obj).first() |
|
|
|
if sync_device_obj: |
|
|
|
if sync_device_obj: |
|
|
|
|
|
|
|
DeveloperDevicesID.objects.update_or_create(did=sync_device_obj.serial, udid=sync_device_obj, |
|
|
|
|
|
|
|
developerid=developer_obj, |
|
|
|
|
|
|
|
app_id=app_obj) |
|
|
|
|
|
|
|
|
|
|
|
device_id_lists.append(sync_device_obj.serial) |
|
|
|
device_id_lists.append(sync_device_obj.serial) |
|
|
|
udid_info = None |
|
|
|
udid_info = None |
|
|
|
add_did_flag = True |
|
|
|
add_did_flag = True |
|
|
@ -336,7 +340,7 @@ class IosUtils(object): |
|
|
|
get_profile_full_path(developer_obj, app_obj), |
|
|
|
get_profile_full_path(developer_obj, app_obj), |
|
|
|
auth, developer_app_id, device_id_lists, |
|
|
|
auth, developer_app_id, device_id_lists, |
|
|
|
err_callback(IosUtils.get_device_from_developer, |
|
|
|
err_callback(IosUtils.get_device_from_developer, |
|
|
|
developer_obj, developer_obj.user_id)) |
|
|
|
developer_obj)) |
|
|
|
if add_did_flag and sync_device_obj: |
|
|
|
if add_did_flag and sync_device_obj: |
|
|
|
result['did'] = sync_device_obj.serial |
|
|
|
result['did'] = sync_device_obj.serial |
|
|
|
result['did_exists'] = True |
|
|
|
result['did_exists'] = True |
|
|
@ -421,20 +425,11 @@ class IosUtils(object): |
|
|
|
storage_obj.upload_file(os.path.join(MEDIA_ROOT, random_file_name + ".ipa")) |
|
|
|
storage_obj.upload_file(os.path.join(MEDIA_ROOT, random_file_name + ".ipa")) |
|
|
|
|
|
|
|
|
|
|
|
def update_developer_used_data(self): |
|
|
|
def update_developer_used_data(self): |
|
|
|
appsupersign_obj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'), |
|
|
|
udid_obj = AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).first() |
|
|
|
developerid=self.developer_obj) |
|
|
|
APPSuperSignUsedInfo.objects.update_or_create(app_id=self.app_obj, |
|
|
|
if appsupersign_obj.count() == 0: |
|
|
|
user_id=self.user_obj, |
|
|
|
developer_obj = self.developer_obj |
|
|
|
|
|
|
|
developer_obj.use_number = developer_obj.use_number + 1 |
|
|
|
|
|
|
|
logger.info( |
|
|
|
|
|
|
|
f"developer {developer_obj} use_number+1 now {developer_obj.use_number} udid {self.udid_info.get('udid')} app_id {self.app_obj}") |
|
|
|
|
|
|
|
developer_obj.save(update_fields=['use_number']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not appsupersign_obj.filter(app_id=self.app_obj, user_id=self.user_obj).first(): |
|
|
|
|
|
|
|
APPSuperSignUsedInfo.objects.create(app_id=self.app_obj, user_id=self.user_obj, |
|
|
|
|
|
|
|
developerid=self.developer_obj, |
|
|
|
developerid=self.developer_obj, |
|
|
|
udid=AppUDID.objects.filter(app_id=self.app_obj, |
|
|
|
udid=udid_obj) |
|
|
|
udid=self.udid_info.get('udid')).first()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_sign_data(self, random_file_name, release_obj): |
|
|
|
def update_sign_data(self, random_file_name, release_obj): |
|
|
|
newdata = { |
|
|
|
newdata = { |
|
|
@ -530,7 +525,7 @@ class IosUtils(object): |
|
|
|
"call_loop download_profile appid:%s developer:%s count:%s" % (self.app_obj, self.developer_obj, count)) |
|
|
|
"call_loop download_profile appid:%s developer:%s count:%s" % (self.app_obj, self.developer_obj, count)) |
|
|
|
if self.developer_obj: |
|
|
|
if self.developer_obj: |
|
|
|
with cache.lock("%s_%s_%s" % ('download_profile', self.app_obj.app_id, self.developer_obj.issuer_id), |
|
|
|
with cache.lock("%s_%s_%s" % ('download_profile', self.app_obj.app_id, self.developer_obj.issuer_id), |
|
|
|
timeout=60): |
|
|
|
timeout=180): |
|
|
|
download_flag, result = IosUtils.exec_download_profile(self.app_obj, self.developer_obj, |
|
|
|
download_flag, result = IosUtils.exec_download_profile(self.app_obj, self.developer_obj, |
|
|
|
self.udid_info, sign_try_attempts) |
|
|
|
self.udid_info, sign_try_attempts) |
|
|
|
if download_flag: |
|
|
|
if download_flag: |
|
|
@ -609,10 +604,6 @@ class IosUtils(object): |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid) |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid) |
|
|
|
UDIDsyncDeveloper.objects.filter(udid=udid_obj.udid, developerid=developer_obj).delete() |
|
|
|
UDIDsyncDeveloper.objects.filter(udid=udid_obj.udid, developerid=developer_obj).delete() |
|
|
|
|
|
|
|
|
|
|
|
if developer_obj.use_number > 0: |
|
|
|
|
|
|
|
developer_obj.use_number = developer_obj.use_number - 1 |
|
|
|
|
|
|
|
developer_obj.save(update_fields=['use_number']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
udid_obj.delete() |
|
|
|
udid_obj.delete() |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
@ -679,12 +670,6 @@ class IosUtils(object): |
|
|
|
new_full_path = os.path.join(os.path.dirname(new_full_path_dir), |
|
|
|
new_full_path = os.path.join(os.path.dirname(new_full_path_dir), |
|
|
|
'%s_%s_%s' % ('remove', new_full_path_name, get_format_time())) |
|
|
|
'%s_%s_%s' % ('remove', new_full_path_name, get_format_time())) |
|
|
|
os.rename(new_full_path_dir, new_full_path) |
|
|
|
os.rename(new_full_path_dir, new_full_path) |
|
|
|
# for root, dirs, files in os.walk(full_path, topdown=False): |
|
|
|
|
|
|
|
# for name in files: |
|
|
|
|
|
|
|
# os.remove(os.path.join(root, name)) |
|
|
|
|
|
|
|
# for name in dirs: |
|
|
|
|
|
|
|
# os.rmdir(os.path.join(root, name)) |
|
|
|
|
|
|
|
# os.rmdir(full_path) |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
logger.error("clean_developer developer_obj:%s user_obj:%s delete file failed Exception:%s" % ( |
|
|
|
logger.error("clean_developer developer_obj:%s user_obj:%s delete file failed Exception:%s" % ( |
|
|
|
developer_obj, user_obj, e)) |
|
|
|
developer_obj, user_obj, e)) |
|
|
@ -777,13 +762,18 @@ class IosUtils(object): |
|
|
|
return status, result |
|
|
|
return status, result |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def get_device_from_developer(developer_obj, user_obj): |
|
|
|
def get_device_from_developer(developer_obj): |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
status, result = app_api_obj.get_device() |
|
|
|
status, result = app_api_obj.get_device() |
|
|
|
if status: |
|
|
|
if status and auth.get("issuer_id"): |
|
|
|
if auth.get("issuer_id"): |
|
|
|
|
|
|
|
UDIDsyncDeveloper.objects.filter(developerid=developer_obj, platform=1).delete() |
|
|
|
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] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
will_del_udid_list = list(set(udid_developer_list) - set(udid_result_list)) |
|
|
|
|
|
|
|
|
|
|
|
for device_obj in result: |
|
|
|
for device_obj in result: |
|
|
|
device = { |
|
|
|
device = { |
|
|
|
"serial": device_obj.id, |
|
|
|
"serial": device_obj.id, |
|
|
@ -792,39 +782,14 @@ class IosUtils(object): |
|
|
|
"version": device_obj.model, |
|
|
|
"version": device_obj.model, |
|
|
|
"platform": 1 |
|
|
|
"platform": 1 |
|
|
|
} |
|
|
|
} |
|
|
|
app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=developer_obj, udid=device.get("udid")) |
|
|
|
obj, create = UDIDsyncDeveloper.objects.update_or_create(developerid=developer_obj, |
|
|
|
if app_udid_obj: |
|
|
|
udid=device_obj.udid, defaults=device) |
|
|
|
pass |
|
|
|
if not create: |
|
|
|
else: |
|
|
|
DeveloperDevicesID.objects.filter(udid=obj, developerid=developer_obj).update( |
|
|
|
UDIDsyncDeveloper.objects.create(developerid=developer_obj, **device) |
|
|
|
**{'did': device_obj.id}) |
|
|
|
else: |
|
|
|
AppUDID.objects.filter(udid__in=will_del_udid_list, |
|
|
|
|
|
|
|
app_id__developerdevicesid__udid__in=UDIDsyncDeveloper.objects.filter( |
|
|
|
|
|
|
|
udid__in=will_del_udid_list)).delete() |
|
|
|
|
|
|
|
UDIDsyncDeveloper.objects.filter(udid__in=will_del_udid_list).delete() |
|
|
|
|
|
|
|
|
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
|
|
|
|
|
devices_info = "" |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
with open(file_format_path_name + ".devices.info", "r") as f: |
|
|
|
|
|
|
|
devices_info = f.read().replace("\n\t", "").replace("[", "").replace("]", "") |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
|
|
logger.error( |
|
|
|
|
|
|
|
"get_device_from_developer developer_obj:%s user_obj:%s delete file failed Exception:%s" % ( |
|
|
|
|
|
|
|
developer_obj, user_obj, e)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UDIDsyncDeveloper.objects.filter(developerid=developer_obj, platform=1).delete() |
|
|
|
|
|
|
|
for devicestr in devices_info.split(">"): |
|
|
|
|
|
|
|
formatdevice = re.findall(r'.*Device id="(.*)",.*name="(.*)",.*udid="(.*?)",.*model=(.*),.*', |
|
|
|
|
|
|
|
devicestr) |
|
|
|
|
|
|
|
if formatdevice: |
|
|
|
|
|
|
|
device = { |
|
|
|
|
|
|
|
"serial": formatdevice[0][0], |
|
|
|
|
|
|
|
"product": formatdevice[0][1], |
|
|
|
|
|
|
|
"udid": formatdevice[0][2], |
|
|
|
|
|
|
|
"version": formatdevice[0][3], |
|
|
|
|
|
|
|
"platform": 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=developer_obj, |
|
|
|
|
|
|
|
udid=device.get("udid")) |
|
|
|
|
|
|
|
if app_udid_obj: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
UDIDsyncDeveloper.objects.create(developerid=developer_obj, **device) |
|
|
|
|
|
|
|
return status, result |
|
|
|
return status, result |
|
|
|