|
|
|
@ -62,23 +62,30 @@ class GetVersion(object): |
|
|
|
|
'connect_timeout': 5, |
|
|
|
|
} |
|
|
|
|
db_conn = pymysql.Connect(**db_config) |
|
|
|
|
db_cursor = db_conn.cursor(cursor=DictCursor) |
|
|
|
|
db_cursor.execute(sql_str) |
|
|
|
|
res = db_cursor.fetchone() |
|
|
|
|
update_data = { |
|
|
|
|
'name': res['cinema_name'], |
|
|
|
|
'zz_num': res['cinema_num'], |
|
|
|
|
'inner_id': res['cinema_id'], |
|
|
|
|
'sys_ver': res['server_version'], |
|
|
|
|
'client_ver': res['client_version'], |
|
|
|
|
# 'update_time': datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') |
|
|
|
|
'update_time': timezone.now(), |
|
|
|
|
'is_cloud': '云版本' if res.get('dx_sys_version', '--') == 'CLOUD' else '--', |
|
|
|
|
'remote_label': res.get('cinema_label', '--') if res.get('cinema_label', '--') != '' else '--', |
|
|
|
|
'ver_id': int(res['server_version'][13:17]) if res['server_version'].startswith('Cloud_') else int(res['server_version'][7:11]) |
|
|
|
|
} |
|
|
|
|
print(ip, update_data, db_config) |
|
|
|
|
cinema_obj = Cinema.objects.filter(ip=ip).update(**update_data) |
|
|
|
|
try: |
|
|
|
|
with db_conn.cursor(cursor=DictCursor) as db_cursor: |
|
|
|
|
db_cursor.execute(sql_str) |
|
|
|
|
res = db_cursor.fetchone() |
|
|
|
|
update_data = { |
|
|
|
|
'name': res['cinema_name'], |
|
|
|
|
'zz_num': res['cinema_num'], |
|
|
|
|
'inner_id': res['cinema_id'], |
|
|
|
|
'sys_ver': res['server_version'], |
|
|
|
|
'client_ver': res['client_version'], |
|
|
|
|
# 'update_time': datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') |
|
|
|
|
'update_time': timezone.now(), |
|
|
|
|
'is_cloud': '云版本' if res.get('dx_sys_version', '--') == 'CLOUD' else '--', |
|
|
|
|
'remote_label': res.get('cinema_label', '--') if res.get('cinema_label', '--') != '' else '--', |
|
|
|
|
'ver_id': int(res['server_version'][13:17]) if res['server_version'].startswith('Cloud_') else int(res['server_version'][7:11]), |
|
|
|
|
'is_online': True |
|
|
|
|
} |
|
|
|
|
print(ip, update_data, db_config) |
|
|
|
|
cinema_obj = Cinema.objects.filter(ip=ip).update(**update_data) |
|
|
|
|
except Exception as e: |
|
|
|
|
print(e) |
|
|
|
|
cinema_obj = Cinema.objects.filter(ip=ip).update(is_online=False) |
|
|
|
|
finally: |
|
|
|
|
db_conn.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cinema_ver_by_ip(ip): |
|
|
|
|