修复空文件生成的BUG

This commit is contained in:
pengtao 2019-08-13 14:54:43 +08:00
parent 2d37c4a477
commit f946d10a27

View File

@ -31,15 +31,16 @@ class TGA_event(GetFromTga):
cast(json_extract(button_param,'$.id') as int)""" cast(json_extract(button_param,'$.id') as int)"""
out = self.tga.get_data(sql) out = self.tga.get_data(sql)
for line in out: if out:
if line: for line in out:
temp = {} if line:
try: temp = {}
temp['id'], temp['num'] = line try:
except Exception: temp['id'], temp['num'] = line
log.error(f"write {line} 2 tga failed!", exc_info=True) except Exception:
if temp: log.error(f"write {line} 2 tga failed!", exc_info=True)
self.write_tga_files(temp) if temp:
self.write_tga_files(temp)
def event_shop_new(self): def event_shop_new(self):
sql = f"""select sql = f"""select
@ -60,15 +61,16 @@ class TGA_event(GetFromTga):
out = self.tga.get_data(sql) out = self.tga.get_data(sql)
for line in out: if out:
if line: for line in out:
temp = {} if line:
try: temp = {}
temp['id'], temp['num'] = line try:
if temp: temp['id'], temp['num'] = line
self.write_tga_files(temp) if temp:
except Exception: self.write_tga_files(temp)
log.error(f"write {line} 2 tga failed!", exc_info=True) except Exception:
log.error(f"write {line} 2 tga failed!", exc_info=True)
def event_tap(self): def event_tap(self):
for item in tap_items: for item in tap_items: