def parseZXContact(self, id): result = None try: result = self.httpClient.geturlcon("http://56gate.com/freightlinejson/getFreightLineContact.action", data={"freightLine.lineid": id}) except Exception, e: logger.error(e)
def get_image_texts(image_name): ram_out_file = os.path.join(PNG_TEXT_DATA_RAM_PATH, 'ram.png') img = cv2.imread(image_name) background_color = get_dominant_color(img) threshold = 125 print(background_color) if background_color < threshold: logger.error('not a pure text image') rect_img = draw_rect_on_image(img) dst_img = top_hat_image(rect_img) cv2.imwrite(ram_out_file, dst_img) try: table_reader = TableTextReader(ram_out_file) text_dict_list, highlight = table_reader.get_table_text_dict( test_gerber=False, save_dict=False, highlight_readable_paras=True) new_info = [] if len(text_dict_list) == 1: loc_info = [key for key in text_dict_list[0].keys()] text_info = [text for text in text_dict_list[0].values()] for index in range(len(loc_info)): new_info.append((None, loc_info[index][0], loc_info[index][1], loc_info[index][0] + loc_info[index][2], loc_info[index][1] + loc_info[index][3], text_info[index])) except Exception as e: print('get image text failed:{}'.format(e)) new_info = None os.remove(ram_out_file) return new_info
def __thread_addimages(self, data, images_name, images_tag, db_update_insert): logger.info('开启一个线程去创建images镜像,镜像地址为:%s:%s' % (images_name, images_tag)) images = Dockers_Start.Add_Images(images_name, images_tag) if not images: return False images_name = images.tags[0] images_id = images.id data.append(images_name) data.append(images_id) sql = 'DELETE FROM tb_images WHERE images_name = ? ;' if db_update_insert(sql, [images_name,]): logger.info('成功创建一个images镜像并删除数据库中旧的数据!') else: logger.error('成功创建一个images镜像,但是在删除数据库中旧的数据时出错。') sql = 'INSERT INTO tb_images (name, info, isupload, types, tags, difficulty, author, images_port, flag, images_start_mode, images_name, images_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);' if db_update_insert(sql, data): logger.info('成功把images镜像信息写入数据库,镜像名字为:%s' % images_name) else: logger.error('把images镜像信息写入数据库时出错,镜像名字为:%s' % images_name)
def parseHYContact(self, id): result = None try: result = self.httpClient.geturlcon("http://56gate.com/sourcegoodsjson/getContact.action", data={"sourceGoods.sgid": id}) except Exception, e: logger.error(e)
def dowload_pdf_and_convert(): projects = db.read_data() for project in projects: if project.get("downloaded"): pass else: browser.get(project["link"]) time.sleep(5) href = browser.find_elements_by_css_selector("tr#tile30 td.vs1 a") if len(href) != 1: log.error("web format changed, cannot find downloadlink") break else: href = href[0] pdf_file = requests.get(href.get_attribute("href"), stream=True) with open("..\\data\\{}.pdf".format(project.get("title")), "wb") as f: for chunk in pdf_file.iter_content(chunk_size=128): if chunk: f.write(chunk) f.flush() project["downloaded"] = time.strftime("%d_%m_%Y") log.info("{} has been downloaded.".format(project.get("title"))) try: with pdfplumber.open("..\\data\\{}.pdf".format(project.get("title"))) as pdf: txt_filename = project.get("title") + ".txt" with codecs.open("..\\data\\{}".format(txt_filename), "w", encoding="utf-8") as new_f: for page in pdf.pages: new_f.write(page.extract_text()) log.info("{} had been converted.".format(project.get("title"))) except: log.error("{} had convert failed.".format(project.get("title"))) db.write_data(projects)
def parseCYContact(self, id): result = None try: result = self.httpClient.geturlcon("http://56gate.com/carsourcejson/getCarSourceContactDetail.action", data={"carSource.carsourceid": id}) except Exception, e: logger.error(e)
def __re_port(self, strings): result = [] logger.info('处理传入的环境端口信息!') string = re.split(r',|;', strings.lower()) if not string: logger.error('传入的环境端口信息有误!错误端口信息为:%s' % strings) return '' res = r'(\d{1,5})/(tcp|udp)' print(string) for _ in string: if _ == '': continue r = re.search(res, _) if not r : logger.error('传入的环境端口信息有误!错误端口信息为:%s' % _) return '' port = r.group(1) protocol = r.group(2) result.append({'port': port, 'protocol': protocol}) logger.info('成功处理传入的环境端口信息,获取到端口信息为:%s' % json.dumps(result)) return json.dumps(result)
def start(self): self.running = True logger.info("TCP socket server [%s:%s] start." % (self.host, self.port)) while self.running: selectors = self.selector.poll() for fd, event in selectors: if fd == self.server_socket.fileno(): sock, addr = self.server_socket.accept() # new client sock.setblocking(False) self._set_socket_opt(sock) self.clients.update({sock.fileno(): sock}) self.clients_ext.update({sock.fileno(): addr}) self.selector.register(sock.fileno(), select.EPOLLIN | select.EPOLLPRI | select.EPOLLET) logger.info("new socket client: [%s]" % str(addr)) elif event & select.EPOLLIN: try: recv_data = self.recv(self.clients[fd]) if self.handler and recv_data: self.handler.handle(self, self.clients[fd], recv_data) except Exception, e: logger.error("recv data and handle data with exception: %s" % e) if fd in self.clients_ext.keys(): logger.info("close socket [%s]" % str(self.clients_ext[fd])) #self.send(sock, "close you!", 10) self.close_socket(self.clients[fd]) elif event & select.EPOLLPRI: logger.info("EPOLLPRI") elif event & select.EPOLLERR or event & select.EPOLLHUP: logger.info("socket [%s] is error, closed it." % str(self.clients_ext[fd])) if fd in self.clients_ext.keys(): self.close_socket(self.clients[fd])
def update_word_color_in_html_save_as_html(original_file_path, result_file_path): try: original_html_content = get_original_content_from_html(original_file_path) new_html_content = update_word_color_in_original_html_content(original_html_content) save_new_content_as_html(new_html_content, result_file_path) except Exception as e: logger.error(f'错误信息为:{e}') return
def getHuoYuanpages(self, pages=pages): for page in range(1, pages): try: ids = [] ids.extend(self.getPage("goods", page)) for id in ids: self.getAndSaveHYFromId(id) except Exception, e: logger.error(e)
def getRoadDetailPages(self, pages=pages): for page in range(0, pages): try: ids = [] ids.extend(self.getPage(page)) for id in ids: self.getAndSaveFromId(id) except Exception, e: logger.error(e)
def getZhuanXianPages(self, pages=pages): for page in range(0, pages): try: ids = [] ids.extend(self.getZhuanXianPage(page)) for id in ids: self.getAndSaveZXFromId(id) except Exception, e: logger.error(e)
def getCheYuanPages(self, pages=pages): for page in range(1, pages): try: ids = [] ids.extend(self.getPage("car", page)) for id in ids: self.getAndSaveCYFromId(id) except Exception, e: logger.error(e)
def is_gerber_file(path): try: gerber.read(path) except IOError: return False except Exception as e: logger.error(f'错误信息为:{e}') return False return True
def convert_copper_standard_value(param_name, param_value, source_param_value=None): """ 铜厚值转换 :param param_name: 参数名 :param param_value: 参数值 :param source_param_value: 原始参数值 :return: """ convert_complete_copper_param_list = ['完成铜厚度'] convert_base_copper_param_list = ['基铜厚度'] not_need_convert = {'最小孔铜厚度': ['um']} standard_parameter_value = param_value if param_name and param_value: if param_name in not_need_convert and any_item_be_contain( not_need_convert[param_name], source_param_value): return get_numb_str(standard_parameter_value) if any_item_be_contain(convert_complete_copper_param_list, param_name): num_str = get_numb_str(param_value) if is_num(num_str): try: num_tmp = repair_num_str(float(num_str)) num = eval(num_tmp) # 确认铜厚度单位为um不可能小于12 if num < 12: return round(num * 35, 2) else: return num except Exception as error: logger.error({f'不能转换成数字,错误信息为:{error}'}) elif any_item_be_contain(convert_base_copper_param_list, param_name): num_str = get_numb_str(param_value) if is_num(num_str): try: num_tmp = repair_num_str(float(num_str)) num = eval(num_tmp) # 确认铜厚度单位为um不可能小于12 if num < 12: return num if num == 12: standard_parameter_value = 0.33 elif num == 18: standard_parameter_value = 0.5 elif num == 50: standard_parameter_value = 1.43 else: standard_parameter_value = copper_foil_standard_value_conversion( round(num / 35, 2)) except Exception as error: logger.error({f'不能转换成数字,错误信息为:{error}'}) return str(standard_parameter_value)
def get(self): sql = 'SELECT containers_id FROM tb_status WHERE containers_user = ? and containers_status = ?;' containers_list = self.db_select(sql, [self.current_user.decode(), 'runing']) if containers_list: logger.error('用户%s没有关闭所有的容器,无法退出登陆!' % self.current_user.decode()) self.render('logout.html') return logger.info('用户%s退出登录!' % self.current_user.decode()) self.clear_cookie("cookie_user") self.redirect("/")
def getAndSaveZXFromId(self, id): url = "http://56gate.com/html/zx/zxdetail_%s.html" % id try: GateZhuanXian.objects.get(webSiteId=id) logger.info("Zhuanxian %s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.phaseLine(text, id) except Exception, e: logger.error(e)
def get_content_from_all_version(filename): try: # os.system("taskkill /f /im word.exe /t") pythoncom.CoInitialize() if filename.endswith('doc'): docxfile = doc2docx(filename) elif filename.endswith("docx"): docxfile = filename else: return "Not Word Document" return story(docxfile) except Exception as e: logger.error("Failed to get content.", exc_info=True) return 'The file may be damaged. Please save it as .doc/.docx file and upload it again.文件可能已经损坏,请另存为doc或docx文件并重新上传。'
def getAndSaveZhuanXianFromId(self, id): url = "http://www.chinawutong.com/201/%s.html" % id result = {} try: WTZhuanXian.objects.get(webSiteId=id) logger.info("%s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) try: result = self.pharseZhuanXianMeta(text, id) except Exception, e: logger.error(traceback.format_exc())
def get(self): containers_id = self.get_argument("containers_id", '').strip() if not containers_id: logger.error('用户%s提交的容器id错误' % self.current_user.decode()) self.render('docker.html', status = '', port = '', error = True) return logger.info('用户%s提交的容器id是%s。' % (self.current_user.decode(),containers_id)) con = Dockers_Info.Get_Containers_Message(containers_id) if not con: logger.error('用户%s提交的容器id错误' % self.current_user.decode()) self.render('docker.html', status = '', port = '', error = True) return logger.info('获取到用户%s提交的容器信息。' % self.current_user.decode()) if not Dockers_Stop.Stop_Containers(con): logger.error('获取用户%s提交的容器信息,但是在关闭的时候出错。' % self.current_user.decode()) self.render('docker.html', status = '', port = '', error = True) return logger.info('成功关闭用户%s提交的容器。' % self.current_user.decode()) sql = "UPDATE tb_status SET containers_status = 'closed' WHERE containers_id = ? ;" result = self.db_update_insert(sql, [containers_id]) if not result: logger.error('成功关闭用户%s提交的容器,但是在写入数据库时出错。' % self.current_user.decode()) self.render('docker.html', status = '', port = '', error = True) return logger.info('成功关闭用户%s提交的容器,并成功写入数据库。' % self.current_user.decode()) self.render('docker.html', status='close', port='', error = False)
def getAndSaveCYFromId(self, id): url = "http://56gate.com/html/cy/cydetail_%s.html" % id try: GateCYSource.objects.get(webSiteId=id) logger.info("Zhuanxian %s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.parseCYDetailsMeta(text, id) except Exception, e: logger.error(e)
def db_update_insert(self, sql, variable = []): ''' 统一数据库插入更新删除方法 :param sql: sql语句 :param variable: sql语句的参数 :return: 返回True或False ''' try: self.application.db.execute(sql, variable) self.application.db.commit() except Exception as e: logger.error('数据库插入更改数据出错!SQL语句为:%s,错误原因为:%s' % (sql, e)) return False return True
def getAndSaveCYFromId(self, id): url = "http://wl.kywmall.com/wl_pages/wl_find_truck_details.aspx?id=%s" % id try: KYVehicle.objects.get(webSiteId=id) logger.info("HuoYuan %s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.parseCheyuanMeta(text, id) except Exception, e: logger.error(e)
def getAndSaveFromId(self, id): url = "http://land.jctrans.com/CarsInfo/roaddetails_%s.html" % id try: JctransRoadDetails.objects.get(webSiteId=id) logger.info("%s already exsists" % id) return except: pass result = {} text = self.httpClient.geturlcon(url) try: result = self.parseRoadDetailsMeta(text, id) except Exception, e: logger.error(e)
def db_select(self, sql, variable = []): ''' 统一数据库查询方法 :param sql: 查询的sql语句 :param variable: 查询语句的参数 :return: 返回一个字典,包含所有的查询结果 ''' try: cursors = self.application.db.cursor() cursors.execute(sql, variable) except Exception as e: logger.error('查询数据库出错!SQL语句为:%s,错误原因为:%s' % (sql, e)) return [] return cursors.fetchall()
def getAndSaveZXFromId(self, id): url = "http://wl.kywmall.com/wl_pages/wl_find_line_details.aspx?id=%s" % id try: KYZhuanXian.objects.get(webSiteId=id) logger.info("Zhuanxian %s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.parseZXMeta(text, id) except Exception, e: logger.error(e)
def send(self, sock, data, size): if size != len(data): logger.error("data size [%d] not equal real size [%d]", size, len(data)) return -1 logger.info("send-DATA: %s" % data) msg = DataMsg(data) buf = msg.pack() try: ret = sock.send(buf) return ret - SOCKET_HEADER_SIZE except socket.error as err: logger.error("socket exception: %s" % err) if err.errno == errno.ECONNRESET or err.errno == errno.EBADF: logger.info("client [%s:%s] is closed." % self.clients_ext[sock.fileno()]) self.close_socket(sock)
def __re_risk(self, string): if not string.strip(): return '' string = string.strip().lower() logger.info('处理传入的环境难度等级信息!') lists = ['simple', 'medium', 'advanced'] if string not in lists: logger.error('传入的环境难度等级信息有误!') return '' logger.info('成功处理传入的环境难度等级信息,获取到难度等级为:%s' % string) return string
def getAndSaveHYFromId(self, id): url = "http://56gate.com/html/hy/sgdetail_%s.html" % id try: GateHuoYuanSource.objects.get(webSiteId=id) logger.info("HuoYuan %s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.parseHYDetailsMeta(text, id) except Exception, e: traceback.print_exc() logger.error(e)
def recv(self, sock, timeout=5): end_time = time.time() + timeout head = sock.recv(SOCKET_HEADER_SIZE) if head is None or len(head) == 0: logger.info("client [%s] is closed." % str(self.clients_ext[sock.fileno()])) self.close_socket(sock) return None header_data = struct.unpack("=%dsi" % len(SOCKET_HEADER_NAME), head[:SOCKET_HEADER_SIZE]) logger.info("read-HEAD: %s" % str(header_data)) header = HeaderMsg(header_data[0], header_data[1]) total_size = data_size = header.size - SOCKET_HEADER_SIZE data = "" count = 0 while end_time > time.time(): try: buf = sock.recv(data_size) if buf is None or len(buf) == 0: logger.info("client [%s] is closed." % str(self.clients_ext[sock.fileno()])) self.close_socket(sock) return None data = data + buf if len(buf) < data_size: data_size = data_size - len(buf) time.sleep(0.1) continue if total_size == len(data): logger.info("read-DATA len(%d)" % (len(data))) return data if count > 20: logger.error("read socket timeout.") return None except socket.error as err: logger.error("socket exception: %s" % str(err)) if err.errno == errno.ECONNRESET or err.errno == errno.EBADF: logger.info("client [%s] is closed." % str(self.clients_ext[sock.fileno()])) self.close_socket(sock) return None if err.errno == errno.EAGAIN: logger.info("data is coming") count += 1 time.sleep(0.2) continue
def start(self): self.running = True logger.info("TCP socket server [%s:%s] start." % (self.host, self.port)) while self.running: selectors = self.selector.poll() for fd, event in selectors: if fd == self.server_socket.fileno(): sock, addr = self.server_socket.accept() # new client sock.setblocking(False) self._set_socket_opt(sock) self.clients.update({sock.fileno(): sock}) self.clients_ext.update({sock.fileno(): addr}) self.selector.register( sock.fileno(), select.EPOLLIN | select.EPOLLPRI | select.EPOLLET) logger.info("new socket client: [%s]" % str(addr)) elif event & select.EPOLLIN: try: recv_data = self.recv(self.clients[fd]) if self.handler and recv_data: self.handler.handle(self, self.clients[fd], recv_data) except Exception, e: logger.error( "recv data and handle data with exception: %s" % e) if fd in self.clients_ext.keys(): logger.info("close socket [%s]" % str(self.clients_ext[fd])) #self.send(sock, "close you!", 10) self.close_socket(self.clients[fd]) elif event & select.EPOLLPRI: logger.info("EPOLLPRI") elif event & select.EPOLLERR or event & select.EPOLLHUP: logger.info("socket [%s] is error, closed it." % str(self.clients_ext[fd])) if fd in self.clients_ext.keys(): self.close_socket(self.clients[fd])
def get(self): images_id = self.get_argument("images_id", '').strip() sql = 'SELECT * FROM tb_images WHERE images_id = ? ;' result = self.db_select(sql, [images_id]) if not result : logger.error('用户%s提交的镜像id错误' % self.current_user.decode()) self.render('docker.html', status = '', port = '', error = True) return port, containers_id, tf = self.__start(result[0]['images_id'], result[0]['images_port']) if not containers_id: logger.error('用户%s开启容器时错误,错误镜像id是%s' % (self.current_user.decode(), result[0]['images_id'])) self.render('docker.html', status = '', port = '', error = True) return if not tf : r = self.__insert_sql(containers_id, result[0]['images_id'], json.dumps(port)) if r : logger.info('用户%s开启容器成功,容器id是%s,数据写入数据库成功!' % (self.current_user.decode(), containers_id)) else: logger.error('用户%s开启容器成功,容器id是%s,数据写入数据库失败!' % (self.current_user.decode(), containers_id)) con = Dockers_Info.Get_Containers_Message(containers_id) Dockers_Stop.Stop_Containers(con) self.render('docker.html', status = '', port = '', error = True) return self.render('docker.html', status = 'start', port = self.__get_http(port), error = False)
def _get_image_from_file_(url, file_path): _, ext = os.path.splitext(file_path) tmp_file_name = str(uuid.uuid1()) + ext shutil.copy(file_path, tmp_file_name) img_count = 0 with open(tmp_file_name, 'rb') as f: response = requests.post(url, files={'file': f}) logger.info( f"get_images_from_word url is {url}, result status code is {response.status_code}, result is {response.text}" ) if response.status_code == 200: response_dict = ast.literal_eval(response.text) img_count = response_dict['img_count'] else: logger.error("_get_image_from_file_ error, return def image info.") os.remove(tmp_file_name) return {"img_count": img_count, "paths": ''}
def post(self): username = self.get_argument("username", '') password = self.get_argument("password", '') md = hashlib.md5() md.update(password.encode('utf-8')) sql = 'SELECT password FROM tb_userinfo WHERE username = ? LIMIT 1' pass_result = self.db_select(sql, [username]) if not pass_result: logger.error('用户%s登陆失败!用户名错误!' % username) self.render('login.html', error = True) return if md.hexdigest() == pass_result[0]['password']: self.set_secure_cookie("cookie_user", username, expires_days = None) logger.info('用户%s登陆成功!' % username) else: logger.error('用户%s登陆失败!密码错误!' % username) self.render('login.html', error = True) return self.redirect("/")
def send_mail(subject, content, receiver): message = MIMEText(content, 'plain', 'utf-8') message['From'] = Header(mail_config["user"], 'utf-8') message['To'] = Header(config.email, 'utf-8') message['Subject'] = Header(subject, 'utf-8') try: smtpObj = smtplib.SMTP() smtpObj.connect(mail_config["host"], 25) # 25 为 SMTP 端口号 smtpObj.login(mail_config["user"], mail_config["passwd"]) smtpObj.sendmail(mail_config["user"], receiver, message.as_string()) log.info("mail sent success.") except smtplib.SMTPException as e: log.error("mail sent failed") log.error(str(e)) log.error(traceback.format_exc())
from exception.exception import NoNfcReaderException from log.logger import logger from nfc_reader_manager import NfcReadersManager parser = optparse.OptionParser print( u'Welcome to our NFC Reader Application.\n\n' u'Before continue, check if your NFC Reader is connected to your computer. ' u'Press Enter to continue') input() try: nfc_reader_manager = NfcReadersManager() except NoNfcReaderException: logger.error(u'Aucun Lecteur NFC trouvé') sys.exit(1) readers = nfc_reader_manager.get_readers() readers.append('lolo') if len(readers) > 1: selected_reader = None print(u'We found more than one NFC reader connected to your computer :') for reader_id, reader_name in enumerate(readers): print('%d : %s' % (reader_id, reader_name)) print(u'Please choose the NFC reader you want to use by entering its id') while not isinstance(selected_reader, int): try: selected_reader = int(input()) except ValueError:
text = self.httpClient.geturlcon(url) result = {} try: result = self.parseCYMeta(text, id) except Exception, e: logger.info(traceback.format_exc()) if ( result.get("startPlace")): source = TK56CheYuan() try: source.save_from_a_source(result) except Exception, e: logger.info(traceback.format_exc()) else: logger.info("cheyuan %s saved" % id) else: logger.error(url + " is a null page") def getAndSaveHYFromId(self, id): url = "http://www.tk56.com/goodsdetail.aspx?id=%s&t=1" % id try: TK56HuoYuan.objects.get(webSiteId=id) logger.info("%s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.pharseHYMeta(text, id) except Exception, e:
result = {} try: result = self.parseZXMeta(text, id) except Exception, e: logger.error(e) if (result.get("telephoneNumber")) and (result.get("postedTo")): source = KYZhuanXian() try: source.save_from_dic(result) except Exception, e: logger.info(traceback.format_exc()) else: logger.info("saved") else: logger.error(url + " is a null page") def getAndSaveHYFromId(self, id): url = "http://wl.kywmall.com/wl_pages/wl_find_product_details.aspx?id=%s" % id try: KYHuoYuan.objects.get(webSiteId=id) logger.info("HuoYuan %s already exsists" % id) return except: pass text = self.httpClient.geturlcon(url) result = {} try: result = self.parseHYMeta(text, id)
def post(self): file = self.request.files.get('jsonfile', '') name = self.get_argument("name", '') tags = self.get_argument("tags", '') types = self.get_argument("type", '') info = self.get_argument("info", '') isupload = self.get_argument("isupload", '') flag = self.get_argument("flag", '') author = self.get_argument("author", '') risk = self.get_argument("risk", '') hub = self.get_argument("hub", '') port = self.get_argument("port", '') sys_pass_json = self.get_argument('syspassjson', '').strip() sys_pass_file = self.get_argument('syspassfile', '').strip() if Sys_Pass != sys_pass_json and Sys_Pass != sys_pass_file : logger.info('输入的系统密码错误!') return if file: logger.info('尝试直接上传json文件来批量添加镜像!') data = file[0]['body'] try: logger.info('尝试使用json格式化上传的数据!') data = json.loads(data) for _ in data: port = self.__re_port(_['port']) risk = self.__re_risk(_['risk']) if _['name']: name = _['name'] images_name, images_tag = self.__re_hub(_['hub']) if not images_name : continue if _['flag'] and _['types'] == 'ctf': datas = [name, _['info'], _['isupload'], _['types'], _['tags'], risk, _['author'], port, _['flag'], 'start'] elif _['types'] == 'debug': datas = [name, _['info'], _['isupload'], _['types'], _['tags'], risk, _['author'], port, 'flag{}', 'start'] else: continue t = True for _ in datas: if not _.strip(): logger.error('发送的数据错误,数据中有空参数!') t = False break if not t: continue threading.Thread(target = self.__thread_addimages,args = (datas, images_name, images_tag, self.db_update_insert)).start() except Exception as e: logger.error('尝试处理上传json数据是出错!') return elif flag and types == 'ctf' : port = self.__re_port(port) risk = self.__re_risk(risk) if name: name = name images_name, images_tag = self.__re_hub(hub) if not images_name : logger.error('发送的数据错误,不能够获取到正确的镜像名!') return data = [name, info, isupload, types, tags, risk, author, port, flag, 'start'] for _ in data: if not _.strip(): logger.error('发送的数据错误,数据中有空参数!') return threading.Thread(target = self.__thread_addimages, args=(data, images_name, images_tag, self.db_update_insert)).start() elif types == 'debug': port = self.__re_port(port) risk = self.__re_risk(risk) if name : name = name images_name, images_tag = self.__re_hub(hub) if not images_name: logger.error('发送的数据错误,不能够获取到正确的镜像名!') return data = [name, info, isupload, types.lower(), tags, risk, author, port, 'flag{}', 'start'] for _ in data: if not _.strip(): logger.error('发送的数据错误,数据中有空参数!') return threading.Thread(target = self.__thread_addimages, args = (data, images_name, images_tag, self.db_update_insert)).start() else: logger.error('发送的数据错误,不能够识别环境的类型!') return self.finish('success')