From a2056edbbdd3b0eea2a5db50ab68fd66efd620cd Mon Sep 17 00:00:00 2001 From: vapao Date: Fri, 27 Aug 2021 22:59:56 +0800 Subject: [PATCH] fix issue --- .../account/management/commands/update.py | 2 +- spug_api/apps/repository/utils.py | 3 +- spug_api/spug/settings.py | 2 +- spug_api/tools/migrate.py | 35 +++++-------------- spug_web/src/pages/monitor/Step1.js | 2 +- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/spug_api/apps/account/management/commands/update.py b/spug_api/apps/account/management/commands/update.py index e33c1f8..4821792 100644 --- a/spug_api/apps/account/management/commands/update.py +++ b/spug_api/apps/account/management/commands/update.py @@ -67,7 +67,7 @@ class Command(BaseCommand): f'cd {settings.BASE_DIR}', f'python3 ./manage.py makemigrations ' + ' '.join(apps), f'python3 ./manage.py migrate', - f'python3 ./tools/migrate.py {version}' + f'python3 ./tools/migrate.py {settings.SPUG_VERSION}' ] task = subprocess.Popen(' && '.join(commands), shell=True) if task.wait() != 0: diff --git a/spug_api/apps/repository/utils.py b/spug_api/apps/repository/utils.py index 5f30076..aa318e6 100644 --- a/spug_api/apps/repository/utils.py +++ b/spug_api/apps/repository/utils.py @@ -14,6 +14,7 @@ import uuid import os REPOS_DIR = settings.REPOS_DIR +BUILD_DIR = settings.BUILD_DIR def dispatch(rep: Repository, helper=None): @@ -65,7 +66,7 @@ def _build(rep: Repository, helper, env): extras = json.loads(rep.extra) git_dir = os.path.join(REPOS_DIR, str(rep.deploy_id)) build_dir = os.path.join(REPOS_DIR, rep.spug_version) - tar_file = os.path.join(REPOS_DIR, 'build', f'{rep.spug_version}.tar.gz') + tar_file = os.path.join(BUILD_DIR, f'{rep.spug_version}.tar.gz') env.update(SPUG_DST_DIR=extend.dst_dir) if extras[0] == 'branch': tree_ish = extras[2] diff --git a/spug_api/spug/settings.py b/spug_api/spug/settings.py index cdce16f..3d69e74 100644 --- a/spug_api/spug/settings.py +++ b/spug_api/spug/settings.py @@ -109,7 +109,7 @@ MONITOR_WORKER_KEY = 'spug:monitor:worker' EXEC_WORKER_KEY = 'spug:exec:worker' REQUEST_KEY = 'spug:request' BUILD_KEY = 'spug:build' -REPOS_DIR = os.path.join(BASE_DIR, 'repos') +REPOS_DIR = os.path.join(os.path.dirname(os.path.dirname(BASE_DIR)), 'repos') BUILD_DIR = os.path.join(REPOS_DIR, 'build') # Internationalization diff --git a/spug_api/tools/migrate.py b/spug_api/tools/migrate.py index 2c208a9..ed08a94 100644 --- a/spug_api/tools/migrate.py +++ b/spug_api/tools/migrate.py @@ -9,34 +9,15 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "spug.settings") django.setup() from django.conf import settings -from apps.app.models import App +import shutil import sys - - -class Version: - def __init__(self, version): - self.version = version.lstrip('vV').split('.') - - def __gt__(self, other): - if not isinstance(other, Version): - raise TypeError('required type Version') - for v1, v2 in zip(self.version, other.version): - if int(v1) == int(v2): - continue - elif int(v1) > int(v2): - return True - else: - return False - return False +import os if __name__ == '__main__': - old_version = Version(sys.argv[1]) - now_version = Version(settings.SPUG_VERSION) - if old_version < Version('v2.3.14'): - app = App.objects.first() - if app and hasattr(app, 'sort_id') and app.sort_id == 0: - print('执行v2.3.14数据初始化') - for app in App.objects.all(): - app.sort_id = app.id - app.save() + version = sys.argv[1] + if version < 'v3.0.1-beta.8': + print('执行 v3.0.1-beta.8 repos目录迁移') + old_path = os.path.join(settings.BASE_DIR, 'repos') + new_path = os.path.join(settings.REPOS_DIR) + shutil.move(old_path, new_path) diff --git a/spug_web/src/pages/monitor/Step1.js b/spug_web/src/pages/monitor/Step1.js index dff8eb7..957c41c 100644 --- a/spug_web/src/pages/monitor/Step1.js +++ b/spug_web/src/pages/monitor/Step1.js @@ -132,7 +132,7 @@ export default observer(function () { {store.record.targets?.length > 0 && `已选择 ${store.record.targets.length} 台`} - +