From 027eaed12a17ae98e4c287cf47873cea7749b5ae Mon Sep 17 00:00:00 2001 From: ngfchl Date: Fri, 14 Oct 2022 22:47:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=9B=B4=E6=96=B0=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_test/views.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pt_test/views.py b/pt_test/views.py index 26e5e06..de2c77f 100644 --- a/pt_test/views.py +++ b/pt_test/views.py @@ -76,16 +76,22 @@ def test_subprocess(request): :param request: :return: """ - # update_command = [ - # # 'cp db/db.sqlite3 db/db.sqlite3-$(date "+%Y%m%d%H%M%S")', - # 'git pull', - # 'pip install -r requirements.txt', - # 'python manage.py makemigrations', - # 'python manage.py migrate', - # ] - # result = [] - # for command in update_command: - # p = subprocess.getoutput(command) - # result.append(p) - - return JsonResponse(CommonResponse.success(data='ok').to_dict(), safe=False) + update_command = [ + # 'cp db/db.sqlite3 db/db.sqlite3-$(date "+%Y%m%d%H%M%S")', + 'git pull', + # 'pip install -r requirements.txt', + # 'python manage.py makemigrations', + 'python manage.py migrate', + ] + result = [] + for command in update_command: + p = subprocess.run(command, shell=True) + print(p.stderr) + print(p.args) + print(p.returncode) + result.append({ + 'command': p.args, + 'res': p.returncode + }) + # print(result) + return JsonResponse(CommonResponse.success(data=result).to_dict(), safe=False)