From 308faf76b6f0d744744d143d744e806f89c64c46 Mon Sep 17 00:00:00 2001 From: nineven Date: Sun, 28 Feb 2021 11:45:25 +0800 Subject: [PATCH] format code --- .../0016_developerappid_developerdevicesid.py | 18 ++-- .../api/migrations/0017_auto_20210131_2108.py | 4 +- fir_ser/api/utils/app/iossignapi.py | 6 +- fir_ser/api/utils/app/supersignutils.py | 16 +++- fir_ser/api/utils/apple/appleapiv3.py | 10 +- fir_ser/fir_ser/settings.py | 2 +- fir_ser/fir_ser/urls.py | 4 - fir_ser/tests/postudid.py | 93 ++++++++++--------- 8 files changed, 83 insertions(+), 70 deletions(-) diff --git a/fir_ser/api/migrations/0016_developerappid_developerdevicesid.py b/fir_ser/api/migrations/0016_developerappid_developerdevicesid.py index 1c8415a..791fabb 100644 --- a/fir_ser/api/migrations/0016_developerappid_developerdevicesid.py +++ b/fir_ser/api/migrations/0016_developerappid_developerdevicesid.py @@ -5,7 +5,6 @@ import django.db.models.deletion class Migration(migrations.Migration): - dependencies = [ ('api', '0015_auto_20210129_1730'), ] @@ -16,9 +15,13 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('did', models.CharField(max_length=64)), - ('app_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Apps', verbose_name='属于哪个APP')), - ('developerid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppIOSDeveloperInfo', verbose_name='所使用苹果开发者账户')), - ('udid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppUDID', verbose_name='所消耗的udid')), + ('app_id', + models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Apps', verbose_name='属于哪个APP')), + ('developerid', + models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppIOSDeveloperInfo', + verbose_name='所使用苹果开发者账户')), + ('udid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppUDID', + verbose_name='所消耗的udid')), ], options={ 'verbose_name': '超级签Devices id', @@ -31,8 +34,11 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('aid', models.CharField(max_length=64)), - ('app_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Apps', verbose_name='属于哪个APP')), - ('developerid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppIOSDeveloperInfo', verbose_name='所使用苹果开发者账户')), + ('app_id', + models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Apps', verbose_name='属于哪个APP')), + ('developerid', + models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.AppIOSDeveloperInfo', + verbose_name='所使用苹果开发者账户')), ], options={ 'verbose_name': '超级签APP id', diff --git a/fir_ser/api/migrations/0017_auto_20210131_2108.py b/fir_ser/api/migrations/0017_auto_20210131_2108.py index ef0050f..d494b33 100644 --- a/fir_ser/api/migrations/0017_auto_20210131_2108.py +++ b/fir_ser/api/migrations/0017_auto_20210131_2108.py @@ -5,7 +5,6 @@ import django.db.models.deletion class Migration(migrations.Migration): - dependencies = [ ('api', '0016_developerappid_developerdevicesid'), ] @@ -14,6 +13,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='developerdevicesid', name='udid', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.UDIDsyncDeveloper', verbose_name='所消耗的udid'), + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.UDIDsyncDeveloper', + verbose_name='所消耗的udid'), ), ] diff --git a/fir_ser/api/utils/app/iossignapi.py b/fir_ser/api/utils/app/iossignapi.py index 2d46275..9a14a0a 100644 --- a/fir_ser/api/utils/app/iossignapi.py +++ b/fir_ser/api/utils/app/iossignapi.py @@ -205,7 +205,8 @@ class AppDeveloperApiV2(object): result['return_info'] = "%s" % e return False, result - def get_profile(self, bundleId, app_id, device_udid, device_name, provisionName, auth, developer_app_id, device_id_list): + def get_profile(self, bundleId, app_id, device_udid, device_name, provisionName, auth, developer_app_id, + device_id_list): result = {} try: apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key) @@ -222,7 +223,8 @@ class AppDeveloperApiV2(object): if device_obj: result['did'] = device_obj.id device_id_list.append(device_obj.id) - profile_obj = apple_obj.create_profile(developer_app_id, auth.get('certid'), provisionName.split("/")[-1], + profile_obj = apple_obj.create_profile(developer_app_id, auth.get('certid'), + provisionName.split("/")[-1], device_id_list) if profile_obj: n = base64.b64decode(profile_obj.profileContent) diff --git a/fir_ser/api/utils/app/supersignutils.py b/fir_ser/api/utils/app/supersignutils.py index 3b68084..944d581 100644 --- a/fir_ser/api/utils/app/supersignutils.py +++ b/fir_ser/api/utils/app/supersignutils.py @@ -207,8 +207,12 @@ class IosUtils(object): def get_developer_auth(self): developer_obj = self.get_developer_user_by_app_udid() - self.developer_obj = developer_obj - self.auth = get_auth_form_developer(developer_obj) + if developer_obj: + self.developer_obj = developer_obj + self.auth = get_auth_form_developer(developer_obj) + else: + logger.error("user %s has no actived apple developer" % (self.user_obj)) + raise ModuleNotFoundError("has no actived apple developer") def get_developer_user_by_app_udid(self): usedeviceobj = APPSuperSignUsedInfo.objects.filter(udid__udid=self.udid_info.get('udid'), @@ -242,6 +246,7 @@ class IosUtils(object): return get_api_obj(self.auth).get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path(), self.auth, developer_app_id, device_id_list) + # 开启超级签直接在开发者账户创建 def create_app(self, app_obj): bundleId = self.app_obj.bundle_id @@ -266,7 +271,7 @@ class IosUtils(object): return logger.info("udid %s not exists app_id %s ,need sign" % (self.udid_info.get('udid'), self.app_obj)) fcount = 3 - result={} + result = {} while fcount > 0: # apptodev_obj = APPToDeveloper.objects.filter(developerid=self.developer_obj, app_id=self.app_obj).first() device_id_list = DeveloperDevicesID.objects.filter(app_id=self.app_obj, @@ -334,7 +339,8 @@ class IosUtils(object): del_cache_response_by_short(self.app_obj.app_id, udid=self.udid_info.get('udid')) - app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=self.developer_obj, udid=self.udid_info.get('udid')).first() + app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=self.developer_obj, + udid=self.udid_info.get('udid')).first() if not app_udid_obj: appudid_obj = AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')) device = appudid_obj.values("serial", @@ -342,7 +348,7 @@ class IosUtils(object): 'udid', 'version').first() if result.get("did", None): - device['serial']=result["did"] + device['serial'] = result["did"] app_udid_obj = UDIDsyncDeveloper.objects.create(developerid=self.developer_obj, **device) DeveloperDevicesID.objects.create(did=result["did"], udid=app_udid_obj, developerid=self.developer_obj, app_id=self.app_obj) diff --git a/fir_ser/api/utils/apple/appleapiv3.py b/fir_ser/api/utils/apple/appleapiv3.py index e992e53..cfd5fbd 100644 --- a/fir_ser/api/utils/apple/appleapiv3.py +++ b/fir_ser/api/utils/apple/appleapiv3.py @@ -635,7 +635,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi } self.headers = headers - def __base_store(self, stype, req, success_code): + def __base_format(self, stype, req, success_code): if req.status_code == success_code: req_data = req.json() data = req_data.get('data') @@ -663,16 +663,16 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi raise Exception('unknown error: %s code:%s' % (req.text, req.status_code)) def __device_store(self, req, success_code=200): - return self.__base_store('devices', req, success_code) + return self.__base_format('devices', req, success_code) def __profile_store(self, req, success_code=200): - return self.__base_store('profiles', req, success_code) + return self.__base_format('profiles', req, success_code) def __certificates_store(self, req, success_code=200): - return self.__base_store('certificates', req, success_code) + return self.__base_format('certificates', req, success_code) def __bundle_ids_store(self, req, success_code=200): - return self.__base_store('bundleIds', req, success_code) + return self.__base_format('bundleIds', req, success_code) def get_all_devices(self): req = self.list_devices() diff --git a/fir_ser/fir_ser/settings.py b/fir_ser/fir_ser/settings.py index 10ffba4..2bdfc2c 100644 --- a/fir_ser/fir_ser/settings.py +++ b/fir_ser/fir_ser/settings.py @@ -170,7 +170,7 @@ REST_FRAMEWORK_EXTENSIONS = { # 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息 REGISTER = { - "enable": True, + "enable": False, "captcha": True, # 是否开启注册字母验证码 "register_type": { 'sms': False, # 短信注册 diff --git a/fir_ser/fir_ser/urls.py b/fir_ser/fir_ser/urls.py index 33c98dc..0ed7b0e 100644 --- a/fir_ser/fir_ser/urls.py +++ b/fir_ser/fir_ser/urls.py @@ -15,9 +15,6 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, re_path, include -from rest_framework.routers import DefaultRouter -from api.views.login import LoginView -from api.views.logout import LogoutView from django.views.static import serve from fir_ser import settings from api.views.download import DownloadView, InstallView @@ -25,7 +22,6 @@ from api.views.receiveudids import IosUDIDView urlpatterns = [ re_path('fly.admin/', admin.site.urls), - # path("",include(router.urls)), re_path("api/v1/fir/server/", include('api.urls')), re_path("api/v2/fir/server/", include('cli.urls')), re_path('^captcha/', include('captcha.urls')), diff --git a/fir_ser/tests/postudid.py b/fir_ser/tests/postudid.py index db0419c..8b2d3ec 100644 --- a/fir_ser/tests/postudid.py +++ b/fir_ser/tests/postudid.py @@ -1,46 +1,49 @@ -# import requests -# import random -# -# short = ["bgql", "wjbu", "vnfg", "bgql"] -# -# udid_lists = [ -# "f55df38afe5c1242b8bc478d0182bbd0d7d08929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d08929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d08922", -# "f55df38afe5c1242b8bc478d0182bbd0d7d01129", -# "f55df38afe5c1242b8bc478d0182bbd0d723929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d118929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d08929", -# "f55df38afe5c1242b8bc478d0182bbd0daed08929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d08929", -# "f55df38afe5c1242b8bc478d0182bbdfsdfe7d08929", -# "f55df38afe5c1242b8bc478d0182bbdfsdfe7d08929", -# "f55df38afe5c1242b8bc478d0182bbdfsdfe7d08929", -# "f55df38afe5c1242b8bc478d0182dsfsdd7d08929", -# "f55df38afe5c1242b8bc478d0182dsfsdd7d08929", -# "f55df38afe5c1242b8bc478d0182dsfsdd7d08929", -# "f55df38afe5c1242b8bc478d0182bbdsdfsadf8929", -# "f55df38afe5c1242b8bc478d01sdsdfsdd0d7d08929", -# "f55df38afe5c1242b8bc478sdfsdffsdafd7d08929", -# "f55df38afe5c1242b8bc478sdfsdffsdafd7d08929", -# "f55df38afe5c1242b8bc478sdfsdffsdafd7d08929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d08929", -# "f55df38afe5c1242b8bc478dsdfeasdfbbd0d7d08929", -# "f55df38afe5c1242b8bc478dfsdfseasbd0d7d08929", -# "f55df38afe5c1242b8bc478d0sdfseafsdbbd0d7d08929", -# "f55df38afe5c1242b8asdfae8ds2bbd0d7d118929", -# "f55df38afe5c1242b8bc47sfsdf2bbd0d7dd18929", -# "f55df38afe5c1242b8bc478d0182bbd0d7d0ae8929", -# "f55df38afe5c1242b8bc478d0182bbd0d7dsfe08929", -# ] -# -# for udid in udid_lists: -# data = '\n\n\n\n\tPRODUCT\n\tiPhone9,1\n\tSERIAL\n\tF71YD58GHG74\n\tUDID\n\t%s\n\tVERSION\n\t17E262\n\n\n' % ( -# udid) -# uri = "https://fly.harmonygames.cn/udid/%s" % (random.choice(short)) -# # uri = "https://fly.harmonygames.cn/udid/%s" % ("bgql") -# req = requests.post(uri, data=data) -# print(req.status_code) +import requests +import random -a = '验证码%(code)s,您正在注册成为新用户,感谢您的支持!' -print(a % {'code': 111}) +short = ["bgql", "wjbu", "vnfg", "bgql"] + +udid_lists = [ + "f55df38afe5c1242b8bc478d0182bbd0d7d08929", + "f55df38afe5c1242b8bc478d0182bbd0d7d08929", + "f55df38afe5c1242b8bc478d0182bbd0d7d08922", + "f55df38afe5c1242b8bc478d0182bbd0d7d01129", + "f55df38afe5c1242b8bc478d0182bbd0d723929", + "f55df38afe5c1242b8bc478d0182bbd0d7d118929", + "f55df38afe5c1242b8bc478d0182bbd0d7d08929", + "f55df38afe5c1242b8bc478d0182bbd0daed08929", + "f55df38afe5c1242b8bc478d0182bbd0d7d08929", + "f55df38afe5c1242b8bc478d0182bbdfsdfe7d08929", + "f55df38afe5c1242b8bc478d0182bbdfsdfe7d08929", + "f55df38afe5c1242b8bc478d0182bbdfsdfe7d08929", + "f55df38afe5c1242b8bc478d0182dsfsdd7d08929", + "f55df38afe5c1242b8bc478d0182dsfsdd7d08929", + "f55df38afe5c1242b8bc478d0182dsfsdd7d08929", + "f55df38afe5c1242b8bc478d0182bbdsdfsadf8929", + "f55df38afe5c1242b8bc478d01sdsdfsdd0d7d08929", + "f55df38afe5c1242b8bc478sdfsdffsdafd7d08929", + "f55df38afe5c1242b8bc478sdfsdffsdafd7d08929", + "f55df38afe5c1242b8bc478sdfsdffsdafd7d08929", + "f55df38afe5c1242b8bc478d0182bbd0d7d08929", + "f55df38afe5c1242b8bc478dsdfeasdfbbd0d7d08929", + "f55df38afe5c1242b8bc478dfsdfseasbd0d7d08929", + "f55df38afe5c1242b8bc478d0sdfseafsdbbd0d7d08929", + "f55df38afe5c1242b8asdfae8ds2bbd0d7d118929", + "f55df38afe5c1242b8bc47sfsdf2bbd0d7dd18929", + "f55df38afe5c1242b8bc478d0182bbd0d7d0ae8929", + "f55df38afe5c1242b8bc478d0182bbd0d7dsfe08929", +] + +shorts='pzsdaaa' +for udid in udid_lists: + data = '\n\n\n\n\tPRODUCT\n\tiPhone9,1\n\tSERIAL\n\tF71YD58GHG74\n\tUDID\n\t%s\n\tVERSION\n\t17E262\n\n\n' % ( + udid) + # uri = "https://app.hehelucky.cn/udid/%s" % (random.choice(short)) + uri = "https://app.hehelucky.cn/udid/%s" % (shorts) + req = requests.post(uri, data=data) + print(req.status_code) + print(req.text) + exit(1) + +# a = '验证码%(code)s,您正在注册成为新用户,感谢您的支持!' +# print(a % {'code': 111})