From f4d0ada1772c1ca7d8c69833a27f3a9a1daddd65 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Sun, 31 Jan 2021 12:25:05 +0800 Subject: [PATCH] update --- hikyuu/gui/HikyuuTDX.py | 13 +++++++++---- hikyuu/gui/spot_server.py | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hikyuu/gui/HikyuuTDX.py b/hikyuu/gui/HikyuuTDX.py index fab1b8d7..659b4fa2 100644 --- a/hikyuu/gui/HikyuuTDX.py +++ b/hikyuu/gui/HikyuuTDX.py @@ -200,7 +200,9 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): return #普通日志输出控制台 - con = logging.StreamHandler(EmittingStream(textWritten=self.normalOutputWritten)) + if self._stream is None: + self._stream = EmittingStream(textWritten=self.normalOutputWritten) + con = logging.StreamHandler(self._stream) FORMAT = logging.Formatter( '%(asctime)-15s [%(levelname)s] - %(message)s [%(name)s::%(funcName)s]' ) @@ -218,10 +220,12 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): hku_logger.addHandler(con) def initUI(self): + self._stream = None if self._capture_output: - stream = EmittingStream(textWritten=self.normalOutputWritten) - sys.stdout = stream - sys.stderr = stream + self._stream = EmittingStream(textWritten=self.normalOutputWritten) + if self._stream is not None: + sys.stdout = self._stream + sys.stderr = self._stream self.log_textEdit.document().setMaximumBlockCount(1000) current_dir = os.path.dirname(__file__) @@ -736,6 +740,7 @@ class MyMainWindow(QMainWindow, Ui_MainWindow): if self.collect_spot_thread is not None and self.collect_spot_thread.isRunning(): self.collect_spot_thread.terminate() self.collect_spot_thread.wait() + self.logger.info("停止采集") QMessageBox.about(self, '', '已停止') diff --git a/hikyuu/gui/spot_server.py b/hikyuu/gui/spot_server.py index a0abdd42..7c39ffc0 100644 --- a/hikyuu/gui/spot_server.py +++ b/hikyuu/gui/spot_server.py @@ -203,8 +203,6 @@ def collect(use_proxy, source, seconds, phase1, phase2, ignore_weekend): hikyuu_init(config_file, ignore_preload=True) - print("采集程序运行中,可使用 Ctrl-C 终止!") - sm = StockManager.instance() stk_list = [ stk.market_code.lower() for stk in sm if stk.valid and stk.type in @@ -266,6 +264,7 @@ def run(use_proxy, source, seconds, phase1, phase2, ignore_weekend): if __name__ == '__main__': try: + print("采集程序运行中,可使用 Ctrl-C 终止!") run() except KeyboardInterrupt: exit(1)