测试更新脚本

This commit is contained in:
ngfchl
2022-10-14 22:47:00 +08:00
parent d9131b5cce
commit 027eaed12a

View File

@@ -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)