|
|
@ -124,6 +124,41 @@ def get_post_udid_url(request, short): |
|
|
|
return udid_url |
|
|
|
return udid_url |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_auth_form_developer(developer_obj): |
|
|
|
|
|
|
|
if developer_obj.email: |
|
|
|
|
|
|
|
auth = { |
|
|
|
|
|
|
|
"username": developer_obj.email, |
|
|
|
|
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif developer_obj.issuer_id: |
|
|
|
|
|
|
|
auth = { |
|
|
|
|
|
|
|
"issuer_id": developer_obj.issuer_id, |
|
|
|
|
|
|
|
"private_key_id": developer_obj.private_key_id, |
|
|
|
|
|
|
|
"p8key": developer_obj.p8key, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
auth = {} |
|
|
|
|
|
|
|
return auth |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_api_obj(auth): |
|
|
|
|
|
|
|
if auth.get("username"): |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
|
|
|
|
elif auth.get("issuer_id"): |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApiV2(**auth) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
app_api_obj = None |
|
|
|
|
|
|
|
return app_api_obj |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_apple_udid_key(auth): |
|
|
|
|
|
|
|
mpkey = auth.get("username") |
|
|
|
|
|
|
|
if auth.get("issuer_id"): |
|
|
|
|
|
|
|
mpkey = auth.get("issuer_id") |
|
|
|
|
|
|
|
return mpkey |
|
|
|
|
|
|
|
|
|
|
|
def get_http_server_doamin(request): |
|
|
|
def get_http_server_doamin(request): |
|
|
|
server_domain = SERVER_DOMAIN.get('POST_UDID_DOMAIN', None) |
|
|
|
server_domain = SERVER_DOMAIN.get('POST_UDID_DOMAIN', None) |
|
|
|
if not server_domain or not server_domain.startswith("http"): |
|
|
|
if not server_domain or not server_domain.startswith("http"): |
|
|
@ -170,24 +205,8 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
def get_developer_auth(self): |
|
|
|
def get_developer_auth(self): |
|
|
|
developer_obj = self.get_developer_user_by_app_udid() |
|
|
|
developer_obj = self.get_developer_user_by_app_udid() |
|
|
|
if developer_obj.email: |
|
|
|
|
|
|
|
auth = { |
|
|
|
|
|
|
|
"username": developer_obj.email, |
|
|
|
|
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif developer_obj.issuer_id: |
|
|
|
|
|
|
|
auth = { |
|
|
|
|
|
|
|
"issuer_id": developer_obj.issuer_id, |
|
|
|
|
|
|
|
"private_key_id": developer_obj.private_key_id, |
|
|
|
|
|
|
|
"p8key": developer_obj.p8key, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
auth={} |
|
|
|
|
|
|
|
self.developer_obj = developer_obj |
|
|
|
self.developer_obj = developer_obj |
|
|
|
self.auth = auth |
|
|
|
self.auth = get_auth_form_developer(developer_obj) |
|
|
|
|
|
|
|
|
|
|
|
def get_developer_user_by_app_udid(self): |
|
|
|
def get_developer_user_by_app_udid(self): |
|
|
|
usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'), |
|
|
|
usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'), |
|
|
@ -214,22 +233,15 @@ class IosUtils(object): |
|
|
|
return developer_obj |
|
|
|
return developer_obj |
|
|
|
|
|
|
|
|
|
|
|
def download_profile(self): |
|
|
|
def download_profile(self): |
|
|
|
if self.auth.get("username",None): |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApi(**self.auth) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApiV2(**self.auth) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bundleId = self.app_obj.bundle_id |
|
|
|
bundleId = self.app_obj.bundle_id |
|
|
|
app_id = self.app_obj.app_id |
|
|
|
app_id = self.app_obj.app_id |
|
|
|
device_udid = self.udid_info.get('udid') |
|
|
|
device_udid = self.udid_info.get('udid') |
|
|
|
device_name = self.udid_info.get('product') |
|
|
|
device_name = self.udid_info.get('product') |
|
|
|
return app_api_obj.get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path(),self.auth) |
|
|
|
return get_api_obj(self.auth).get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path(), |
|
|
|
|
|
|
|
self.auth) |
|
|
|
|
|
|
|
|
|
|
|
def get_profile_full_path(self): |
|
|
|
def get_profile_full_path(self): |
|
|
|
mpkey = self.auth.get("username") |
|
|
|
cert_dir_name = make_app_uuid(self.user_obj, get_apple_udid_key(self.auth)) |
|
|
|
if self.auth.get("issuer_id"): |
|
|
|
|
|
|
|
mpkey = self.auth.get("issuer_id") |
|
|
|
|
|
|
|
cert_dir_name = make_app_uuid(self.user_obj, mpkey) |
|
|
|
|
|
|
|
cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name, "profile") |
|
|
|
cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name, "profile") |
|
|
|
if not os.path.isdir(cert_dir_path): |
|
|
|
if not os.path.isdir(cert_dir_path): |
|
|
|
os.makedirs(cert_dir_path) |
|
|
|
os.makedirs(cert_dir_path) |
|
|
@ -331,16 +343,12 @@ class IosUtils(object): |
|
|
|
usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid=udid_obj, app_id_id=app_id) |
|
|
|
usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid=udid_obj, app_id_id=app_id) |
|
|
|
if usedeviceobj: |
|
|
|
if usedeviceobj: |
|
|
|
developer_obj = usedeviceobj.first().developerid |
|
|
|
developer_obj = usedeviceobj.first().developerid |
|
|
|
auth = { |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
"username": developer_obj.email, |
|
|
|
|
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 需要判断该设备在同一个账户下 的多个应用,若存在,则不操作 |
|
|
|
# 需要判断该设备在同一个账户下 的多个应用,若存在,则不操作 |
|
|
|
udid_lists = list(APPSuperSignUsedInfo.objects.values_list("udid__udid").filter(developerid=developer_obj)) |
|
|
|
udid_lists = list(APPSuperSignUsedInfo.objects.values_list("udid__udid").filter(developerid=developer_obj)) |
|
|
|
if udid_lists.count((udid_obj.udid,)) == 1: |
|
|
|
if udid_lists.count((udid_obj.udid,)) == 1: |
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid) |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid) |
|
|
|
|
|
|
|
|
|
|
|
if developer_obj.use_number > 0: |
|
|
|
if developer_obj.use_number > 0: |
|
|
@ -351,10 +359,10 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
# 通过开发者id判断 app_id 是否多个,否则删除profile 文件 |
|
|
|
# 通过开发者id判断 app_id 是否多个,否则删除profile 文件 |
|
|
|
if APPSuperSignUsedInfo.objects.filter(developerid=developer_obj, app_id_id=app_id).count() == 0: |
|
|
|
if APPSuperSignUsedInfo.objects.filter(developerid=developer_obj, app_id_id=app_id).count() == 0: |
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
app_obj = Apps.objects.filter(pk=app_id).first() |
|
|
|
app_obj = Apps.objects.filter(pk=app_id).first() |
|
|
|
app_api_obj.del_profile(app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj.del_profile(app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj2 = AppDeveloperApi(**auth) |
|
|
|
app_api_obj2 = get_api_obj(auth) |
|
|
|
app_api_obj2.del_app(app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj2.del_app(app_obj.bundle_id, app_obj.app_id) |
|
|
|
delete_app_to_dev_and_file(developer_obj, app_id) |
|
|
|
delete_app_to_dev_and_file(developer_obj, app_id) |
|
|
|
delete_app_profile_file(developer_obj, app_obj) |
|
|
|
delete_app_profile_file(developer_obj, app_obj) |
|
|
@ -362,11 +370,7 @@ class IosUtils(object): |
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def clean_udid_by_app_obj(app_obj, developer_obj): |
|
|
|
def clean_udid_by_app_obj(app_obj, developer_obj): |
|
|
|
|
|
|
|
|
|
|
|
auth = { |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
"username": developer_obj.email, |
|
|
|
|
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 需要判断该设备在同一个账户下 的多个应用,若存在,则不操作 |
|
|
|
# 需要判断该设备在同一个账户下 的多个应用,若存在,则不操作 |
|
|
|
udid_lists = list(APPSuperSignUsedInfo.objects.values_list("udid__udid").filter(developerid=developer_obj)) |
|
|
|
udid_lists = list(APPSuperSignUsedInfo.objects.values_list("udid__udid").filter(developerid=developer_obj)) |
|
|
@ -375,7 +379,7 @@ class IosUtils(object): |
|
|
|
udid_obj = SuperSignUsed_obj.udid |
|
|
|
udid_obj = SuperSignUsed_obj.udid |
|
|
|
|
|
|
|
|
|
|
|
if udid_lists.count((udid_obj.udid,)) == 1: |
|
|
|
if udid_lists.count((udid_obj.udid,)) == 1: |
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid) |
|
|
|
app_api_obj.set_device_status("disable", udid_obj.udid) |
|
|
|
|
|
|
|
|
|
|
|
if developer_obj.use_number > 0: |
|
|
|
if developer_obj.use_number > 0: |
|
|
@ -406,14 +410,11 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def clean_app_by_developer_obj(app_obj, developer_obj): |
|
|
|
def clean_app_by_developer_obj(app_obj, developer_obj): |
|
|
|
auth = { |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
"username": developer_obj.email, |
|
|
|
|
|
|
|
"password": developer_obj.password, |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
|
|
|
|
app_api_obj.del_profile(app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj.del_profile(app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj2 = AppDeveloperApi(**auth) |
|
|
|
app_api_obj2 = get_api_obj(auth) |
|
|
|
app_api_obj2.del_app(app_obj.bundle_id, app_obj.app_id) |
|
|
|
app_api_obj2.del_app(app_obj.bundle_id, app_obj.app_id) |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
@ -448,24 +449,8 @@ class IosUtils(object): |
|
|
|
:param code: |
|
|
|
:param code: |
|
|
|
:return: |
|
|
|
:return: |
|
|
|
''' |
|
|
|
''' |
|
|
|
if developer_obj.email: |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
auth = { |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
"username": developer_obj.email, |
|
|
|
|
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif developer_obj.issuer_id: |
|
|
|
|
|
|
|
auth = { |
|
|
|
|
|
|
|
"issuer_id": developer_obj.issuer_id, |
|
|
|
|
|
|
|
"private_key_id": developer_obj.private_key_id, |
|
|
|
|
|
|
|
"p8key": developer_obj.p8key, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApiV2(**auth) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return False, {} |
|
|
|
|
|
|
|
status, result = app_api_obj.active(user_obj) |
|
|
|
status, result = app_api_obj.active(user_obj) |
|
|
|
if status: |
|
|
|
if status: |
|
|
|
developer_obj.is_actived = True |
|
|
|
developer_obj.is_actived = True |
|
|
@ -474,12 +459,8 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def create_developer_cert(developer_obj, user_obj): |
|
|
|
def create_developer_cert(developer_obj, user_obj): |
|
|
|
auth = { |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
"username": developer_obj.email, |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.create_cert(user_obj) |
|
|
|
status, result = app_api_obj.create_cert(user_obj) |
|
|
|
if status: |
|
|
|
if status: |
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
@ -498,14 +479,27 @@ class IosUtils(object): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def get_device_from_developer(developer_obj, user_obj): |
|
|
|
def get_device_from_developer(developer_obj, user_obj): |
|
|
|
auth = { |
|
|
|
auth = get_auth_form_developer(developer_obj) |
|
|
|
"username": developer_obj.email, |
|
|
|
app_api_obj = get_api_obj(auth) |
|
|
|
"password": developer_obj.password, |
|
|
|
|
|
|
|
"certid": developer_obj.certid |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app_api_obj = AppDeveloperApi(**auth) |
|
|
|
|
|
|
|
status, result = app_api_obj.get_device(user_obj) |
|
|
|
status, result = app_api_obj.get_device(user_obj) |
|
|
|
if status: |
|
|
|
if status: |
|
|
|
|
|
|
|
if auth.get("issuer_id"): |
|
|
|
|
|
|
|
UDIDsyncDeveloper.objects.filter(developerid=developer_obj, platform=1).delete() |
|
|
|
|
|
|
|
for device_obj in result: |
|
|
|
|
|
|
|
device = { |
|
|
|
|
|
|
|
"serial": device_obj.id, |
|
|
|
|
|
|
|
"product": device_obj.name, |
|
|
|
|
|
|
|
"udid": device_obj.udid, |
|
|
|
|
|
|
|
"version": device_obj.model, |
|
|
|
|
|
|
|
"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) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
|
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
|
file_format_path_name = file_format_path(user_obj, auth) |
|
|
|
devices_info = "" |
|
|
|
devices_info = "" |
|
|
|
try: |
|
|
|
try: |
|
|
|