|
|
@ -1,3 +1,4 @@ |
|
|
|
|
|
|
|
import datetime |
|
|
|
import json |
|
|
|
import json |
|
|
|
import copy |
|
|
|
import copy |
|
|
|
|
|
|
|
|
|
|
@ -22,6 +23,7 @@ from update.utils.git_util import GitUtil, GitDbUtil |
|
|
|
from update.utils.cmd_extcute import UpdateCommandUtil, UpdateConfigUtil |
|
|
|
from update.utils.cmd_extcute import UpdateCommandUtil, UpdateConfigUtil |
|
|
|
from update.utils.db_compare import DbCompare |
|
|
|
from update.utils.db_compare import DbCompare |
|
|
|
from update.utils.client_util import ClientUtil |
|
|
|
from update.utils.client_util import ClientUtil |
|
|
|
|
|
|
|
from django.utils import timezone |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# from consumers import UpdateConsumer |
|
|
|
# from consumers import UpdateConsumer |
|
|
@ -108,6 +110,7 @@ def update_cine(request): |
|
|
|
|
|
|
|
|
|
|
|
# 获取当前版本 |
|
|
|
# 获取当前版本 |
|
|
|
org_ver = get_cinema_ver_by_ip(ip=cinema_ip) |
|
|
|
org_ver = get_cinema_ver_by_ip(ip=cinema_ip) |
|
|
|
|
|
|
|
update_time = timezone.now() |
|
|
|
|
|
|
|
|
|
|
|
# 处理命令格式 |
|
|
|
# 处理命令格式 |
|
|
|
cmd_dict = {} |
|
|
|
cmd_dict = {} |
|
|
@ -180,6 +183,9 @@ def update_cine(request): |
|
|
|
update_status['git']['msg'] = str(e) |
|
|
|
update_status['git']['msg'] = str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
# 执行setup |
|
|
|
# 执行setup |
|
|
@ -203,6 +209,9 @@ def update_cine(request): |
|
|
|
update_status['setup']['msg'] = str(e) |
|
|
|
update_status['setup']['msg'] = str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
# 数据库对比 |
|
|
|
# 数据库对比 |
|
|
@ -224,6 +233,9 @@ def update_cine(request): |
|
|
|
update_status['sql']['msg'] = str(e) |
|
|
|
update_status['sql']['msg'] = str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
# 修改设置 |
|
|
|
# 修改设置 |
|
|
@ -244,6 +256,9 @@ def update_cine(request): |
|
|
|
update_status['config']['msg'] = str(e) |
|
|
|
update_status['config']['msg'] = str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
# 执行teardown |
|
|
|
# 执行teardown |
|
|
@ -267,6 +282,9 @@ def update_cine(request): |
|
|
|
update_status['teardown']['msg'] = str(e) |
|
|
|
update_status['teardown']['msg'] = str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
# 修改设置 |
|
|
|
# 修改设置 |
|
|
@ -287,6 +305,9 @@ def update_cine(request): |
|
|
|
update_status['config']['msg'] = config_before_output + '<br/>' + str(e) |
|
|
|
update_status['config']['msg'] = config_before_output + '<br/>' + str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
# 传输客户端 |
|
|
|
# 传输客户端 |
|
|
@ -309,6 +330,9 @@ def update_cine(request): |
|
|
|
update_status['client']['msg'] = str(e) |
|
|
|
update_status['client']['msg'] = str(e) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
# redis_conn.delete(redis_key) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release, |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], |
|
|
|
|
|
|
|
result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': str(e)}) |
|
|
|
|
|
|
|
|
|
|
|
update_status['result'] = 'success' |
|
|
|
update_status['result'] = 'success' |
|
|
@ -316,6 +340,10 @@ def update_cine(request): |
|
|
|
|
|
|
|
|
|
|
|
print('update_status', update_status) |
|
|
|
print('update_status', update_status) |
|
|
|
print('redis_get', redis_conn.get(redis_key)) |
|
|
|
print('redis_get', redis_conn.get(redis_key)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('update_time', update_time) |
|
|
|
|
|
|
|
UpdateLog.objects.create(ip=cinema_ip, type='toolbox', origin_ver=org_ver, target_ver=short_release[:11], |
|
|
|
|
|
|
|
time=update_time, result=update_status['result'], result_detail=json.dumps(update_status)) |
|
|
|
return JsonResponse({'result': 'success', 'ip': cinema_ip, 'msg': ''}) |
|
|
|
return JsonResponse({'result': 'success', 'ip': cinema_ip, 'msg': ''}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|