This commit is contained in:
fasiondog 2021-01-31 12:25:05 +08:00
parent 8ee26edf96
commit f4d0ada177
2 changed files with 10 additions and 6 deletions

View File

@ -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, '', '')

View File

@ -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)