From 1c9d4d214eb34d3cd869df54cb9e043565096366 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 7 Sep 2022 22:56:49 +0800 Subject: [PATCH] =?UTF-8?q?try=20fixed=20=E7=95=8C=E9=9D=A2=E6=97=A0?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu/data/pytdx_to_h5.py | 2 ++ hikyuu/gui/data/ImportPytdxTimeToH5Task.py | 3 ++- hikyuu/gui/data/ImportPytdxToH5Task.py | 1 + hikyuu/gui/data/ImportPytdxTransToH5Task.py | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hikyuu/data/pytdx_to_h5.py b/hikyuu/data/pytdx_to_h5.py index 95fd08f9..fb1799fb 100644 --- a/hikyuu/data/pytdx_to_h5.py +++ b/hikyuu/data/pytdx_to_h5.py @@ -336,6 +336,8 @@ def import_data(connect, market, ktype, quotations, api, dest_dir, startDate=199 h5file = open_h5file(dest_dir, market, ktype) stock_list = get_stock_list(connect, market, quotations) + if not stock_list: + return 0 total = len(stock_list) for i, stock in enumerate(stock_list): diff --git a/hikyuu/gui/data/ImportPytdxTimeToH5Task.py b/hikyuu/gui/data/ImportPytdxTimeToH5Task.py index cd97594f..fb965d8b 100644 --- a/hikyuu/gui/data/ImportPytdxTimeToH5Task.py +++ b/hikyuu/gui/data/ImportPytdxTimeToH5Task.py @@ -34,7 +34,7 @@ class ProgressBar: self.src = src def __call__(self, cur, total): - progress = (cur + 1) * 100 // total + progress = (cur + 1) * 100 // total if total > 0 else 100 # hku_info(f"{self.src.market} 分时数据: {progress}%") self.src.queue.put([self.src.task_name, self.src.market, 'TIME', progress, 0]) @@ -53,6 +53,7 @@ class ImportPytdxTimeToH5: self.dest_dir = dest_dir self.max_days = int(max_days) + @hku_catch(trace=True, callback=lambda self: self.queue.put([self.task_name, self.market, 'TIME', None, 0])) def __call__(self): capture_multiprocess_all_logger(self.log_queue) count = 0 diff --git a/hikyuu/gui/data/ImportPytdxToH5Task.py b/hikyuu/gui/data/ImportPytdxToH5Task.py index c300de38..e7284681 100644 --- a/hikyuu/gui/data/ImportPytdxToH5Task.py +++ b/hikyuu/gui/data/ImportPytdxToH5Task.py @@ -56,6 +56,7 @@ class ImportPytdxToH5: self.dest_dir = dest_dir self.startDatetime = start_datetime + @hku_catch(trace=True, callback=lambda self: self.queue.put([self.task_name, self.market, self.ktype, None, 0])) def __call__(self): capture_multiprocess_all_logger(self.log_queue) if self.config.getboolean('hdf5', 'enable', fallback=True): diff --git a/hikyuu/gui/data/ImportPytdxTransToH5Task.py b/hikyuu/gui/data/ImportPytdxTransToH5Task.py index d044e074..234a8470 100644 --- a/hikyuu/gui/data/ImportPytdxTransToH5Task.py +++ b/hikyuu/gui/data/ImportPytdxTransToH5Task.py @@ -53,6 +53,7 @@ class ImportPytdxTransToH5: self.dest_dir = dest_dir self.max_days = int(max_days) + @hku_catch(trace=True, callback=lambda self: self.queue.put([self.task_name, self.market, 'TRANS', None, 0])) def __call__(self): capture_multiprocess_all_logger(self.log_queue) count = 0