def run(self): while 1: try: item = gl.CREATEDQUE.get(timeout=1) p = self.ini.get_plate(item['path']) if item['fresh']: t = time.mktime(time.strptime(p['datetime'], '%Y-%m-%d %H:%M:%S')) query = Upload.insert(timestamp=int(t), uploadflag=True, path=item['path'], plateinfo=json.dumps(p)) query.execute() else: query = Upload.update(uploadflag=True).where(Upload.id == item['id']) query.execute() print datetime.datetime.now(), self.t_name, item['path'] time.sleep(1) except Queue.Empty: pass except Exception as e: print e time.sleep(1) finally: if self.is_quit: break
def add_data(): u = Upload.insert(timestamp=1433952012, uploadflag=False, path=u'ImageFile\20150611\00\交警支队卡口\进城\0000126200200000000', plateinfo='{"specialpiclocalpath": "ImageFile\\20150611\\00\\\u4ea4\u8b66\u652f\u961f\u5361\u53e3\\\u8fdb\u57ce\\0000126200200000000", "platecolor": "\u84dd\u724c", "roadname": "\u4ea4\u8b66\u652f\u961f\u5361\u53e3", "speedd": "60", "platecode": "\u7ca4LQZ388", "channelid": "2", "filename": "ImageFile\\20150611\\00\\\u4ea4\u8b66\u652f\u961f\u5361\u53e3\\\u8fdb\u57ce\\0000126200200000000", "datetime": "2015-06-11 00:00:12", "passdatetime": "2015-06-11 00:00:12", "flag": "1", "carspeed": "50", "deviceid": "", "directionid": "1", "cameraip": "192.168.188.55", "channelname": "2", "speed": "50", "roadid": "", "triggermode": "196", "speedx": "80"}') u.execute()