| | |
| | | # 心跳信息 |
| | | from huaxin_client import socket_util |
| | | from huaxin_client.client_network import SendResponseSkManager |
| | | from log_module.log import logger_debug |
| | | from utils import middle_api_protocol |
| | | |
| | | MSG_TYPE_HEART = "heart" |
| | |
| | | def __heart_beats(cls, _type, client_id, sk): |
| | | while True: |
| | | try: |
| | | sk.send(SendResponseSkManager.format_response( |
| | | json.dumps({"type": "heart", "client_id": client_id}).encode('utf-8'))) |
| | | sk.send(socket_util.load_header(json.dumps({"type": "heart", "client_id": client_id}).encode('utf-8'))) |
| | | logger_debug.debug("心跳信息发送:{}",client_id) |
| | | # print("心跳信息发送成功", client_id) |
| | | except Exception as e: |
| | | logging.error("错误") |
| | |
| | | def OnExportL2(self, client_id, request_id, data): |
| | | try: |
| | | code = data["code"] |
| | | data_export_util.export_l2_excel(code) |
| | | excel_file_name = data_export_util.export_l2_excel(code) |
| | | print("导出L2数据目录:",excel_file_name) |
| | | self.send_response({"code": 0, "data": {}, "msg": ""}, client_id, request_id) |
| | | except Exception as e: |
| | | self.send_response({"code": 1, "msg": str(e)}, client_id, request_id) |
| | |
| | | local_time = time.strftime("%Y%m%dT%H%M%S", time.localtime(time.time())) |
| | | file_name = "{}/{}_{}.xls".format(dest_dir, code, local_time) |
| | | file_name_txt = "{}/{}_{}.txt".format(dest_dir, code, local_time) |
| | | openfile = open(file_name_txt, 'w') |
| | | try: |
| | | with open(file_name_txt, 'w') as openfile: |
| | | for data in datas: |
| | | openfile.write(json.dumps(data) + "\n") |
| | | finally: |
| | | openfile.close() |
| | | wb = xlwt.Workbook(encoding="utf-8") |
| | | ws = wb.add_sheet('sheet1') |
| | | ws.write(0, 0, '序号') |