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