From 8c25aab63c02a8fb63eabced85b23c4fde87cb53 Mon Sep 17 00:00:00 2001 From: isummer Date: Wed, 12 Oct 2022 14:56:48 +0800 Subject: [PATCH] =?UTF-8?q?flyapps-cli=E5=A2=9E=E5=8A=A0=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker.md | 6 ++++++ fir_ser/Dockerfile | 1 - fir_ser/Dockerfile.cli | 14 ++++++++++++++ fir_ser/api/views/uploads.py | 7 +++++-- fir_ser/cli.py | 3 ++- 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 fir_ser/Dockerfile.cli diff --git a/docker.md b/docker.md index bde16a4..25d479f 100644 --- a/docker.md +++ b/docker.md @@ -46,6 +46,12 @@ const pro_base_env = { cd /data/FlyApps/docker/scripts sh build.sh ``` +##### 构建flyapps-cli +```shell +cd /data/FlyApps/fir_ser +docker build -t flyapps-cli -f Dockerfile.cli . +``` + ##### 构建镜像的同时,下载依赖镜像 ```shell docker pull 'bitnami/mariadb:10.7.3' diff --git a/fir_ser/Dockerfile b/fir_ser/Dockerfile index 3a5dd1f..ea4a5f0 100644 --- a/fir_ser/Dockerfile +++ b/fir_ser/Dockerfile @@ -22,7 +22,6 @@ RUN cd /opt/ && tar xvf zsign-1.1.2.tar.gz && cd zsign-1.1.2/ && g++ *.cpp commo COPY requirements.txt /opt/requirements.txt RUN cd /opt/ && pip install -U setuptools pip -i ${PIP_MIRROR} --ignore-installed && pip install --no-cache-dir -r requirements.txt -i ${PIP_MIRROR} && pip install --no-cache-dir uwsgi -i ${PIP_MIRROR} -RUN rm -rf /var/cache/yum/ #COPY Docker/flyapps.conf /etc/supervisor/conf.d/flyapps.conf #COPY Docker/uwsgi.conf /data/flyapps/fir_ser/uwsgi.conf diff --git a/fir_ser/Dockerfile.cli b/fir_ser/Dockerfile.cli new file mode 100644 index 0000000..d4eca49 --- /dev/null +++ b/fir_ser/Dockerfile.cli @@ -0,0 +1,14 @@ +FROM python:3.6.14-slim + +ARG PIP_MIRROR=https://mirrors.aliyun.com/pypi/simple + +RUN pip install --upgrade pip --no-cache-dir -i ${PIP_MIRROR} && \ + pip install setuptools-rust oss2 requests-toolbelt androguard requests --no-cache-dir -i ${PIP_MIRROR} && \ + rm -rf ~/.cache/* + +WORKDIR /opt/ + +COPY cli.py /opt/cli.py + +CMD ["python", "cli.py"] + diff --git a/fir_ser/api/views/uploads.py b/fir_ser/api/views/uploads.py index 78ff6f8..3630fa1 100644 --- a/fir_ser/api/views/uploads.py +++ b/fir_ser/api/views/uploads.py @@ -15,6 +15,7 @@ from api.utils.apputils import get_random_short, save_app_infos from api.utils.modelutils import get_app_download_uri, check_bundle_id_legal, get_user_storage_used, \ get_user_storage_capacity from api.utils.response import BaseResponse +from api.utils.serializer import AppsSerializer from api.utils.signalutils import run_signal_resign_utils from common.base.baseutils import make_app_uuid, make_from_user_uuid from common.cache.state import MigrateStorageState @@ -170,9 +171,11 @@ class AppAnalyseView(APIView): storage.rename_file(app_tmp_filename, app_new_filename) storage.rename_file(png_tmp_filename, png_new_filename) - app_obj = Apps.objects.filter(bundle_id=data.get("bundleid"), user_id=request.user, type=1).first() - if app_obj: + app_obj = Apps.objects.filter(bundle_id=data.get("bundleid"), user_id=request.user).first() + if app_obj and app_obj.type == 1: run_signal_resign_utils(app_obj) + app_serializer = AppsSerializer(app_obj, context={"storage": Storage(request.user)}) + res.data = app_serializer.data else: storage.delete_file(app_tmp_filename) storage.delete_file(png_tmp_filename) diff --git a/fir_ser/cli.py b/fir_ser/cli.py index e610f34..ee890fa 100644 --- a/fir_ser/cli.py +++ b/fir_ser/cli.py @@ -112,7 +112,8 @@ class FLYCliSer(object): req = requests.put(url, json=data, headers=self._header) if req.status_code == 200: if req.json()['code'] == 1000: - print("应用 %s %s 上传更新成功" % (data.get('appname'), data.get('bundleid'))) + print("应用 %s %s 上传更新成功,下载连接 %s" % ( + data.get('appname'), data.get('bundleid'), req.json()['data'].get('preview_url'))) return raise AssertionError(req.text)