Exemplo n.º 1
0
            self.process_list.append(p)
            p.start()

        finished_count = len(self.tasks)
        while finished_count > 0:
            message = self.queue.get()
            taskname, market, ktype, progress, total = message
            if progress is None:
                finished_count -= 1
                if taskname == 'IMPORT_KDATA':
                    self.send_message(
                        ['IMPORT_KDATA', 'FINISHED', market, ktype, total])
                else:
                    self.send_message([taskname, 'FINISHED'])
                continue

            if taskname == 'IMPORT_WEIGHT':
                if market == 'INFO':
                    self.send_message(['INFO', ktype])
                self.send_message(['IMPORT_WEIGHT', market, total])
            elif taskname == 'IMPORT_KDATA':
                hdf5_import_progress[market][ktype] = progress
                current_progress = (hdf5_import_progress['SH'][ktype] +
                                    hdf5_import_progress['SZ'][ktype]) // 2
                self.send_message(['IMPORT_KDATA', ktype, current_progress])
            else:
                self.logger.error("Unknow task: {}".format(taskname))


class_logger(UseTdxImportToH5Thread)
Exemplo n.º 2
0
            self.collect_start_pushButton.setText("启动采集")
            QMessageBox.about(self, '', '已停止')
        else:
            if self.collect_spot_thread is None or self.collect_spot_thread.isFinished():
                self.collect_spot_thread = CollectSpotThread(
                    self.getCurrentConfig(),
                    self.getHikyuuConfigFileName(),
                )
                self.collect_spot_thread.start()
            self._is_collect_running = True
            self.collect_status_label.setText("运行中")
            self.collect_start_pushButton.setText("停止采集")
            QMessageBox.about(self, '', '已启动,请在控制台日志查看是否正常运行')


class_logger(MyMainWindow)


def start():
    import requests
    import urllib
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("urllib3").setLevel(logging.WARNING)
    app = QApplication(sys.argv)
    use_dark_style = False  # 使用暗黑主题
    if use_dark_style:
        import qdarkstyle
        app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
    myWin = MyMainWindow(capture_output=True, use_dark_style=use_dark_style)
    myWin.show()
    sys.exit(app.exec())
Exemplo n.º 3
0
            self.collect()
            end = time.time()
            x = end - start
            if x < self._interval:
                delta = int(self._interval - x)
                self.logger.info("{} {} 秒后重新采集".format(self.market, delta))
                self.sleep(delta)
        self.logger.info("{} 数据采集同步线程终止 ({})!".format(self.market,
                                                      self.currentThreadId()))

    def collect(self):
        self.logger.info("{} collect".format(self.market))

    def get_connect(self):
        if self._connect is None:
            try:
                self._connect = mysql.connector.connect(**self._db_config)
            except mysql.connector.Error as err:
                if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
                    self.logger.error("MYSQL密码或用户名错误!")
                elif err.errno == errorcode.ER_BAD_DB_ERROR:
                    self.logger.error("MySQL数据库不存在!")
                else:
                    self.logger.error("连接数据库失败,{}".format(err.msg))
            except:
                self.logger.error("未知原因导致无法连接数据库!")
        return self._connect


class_logger(CollectThread)