1 Star 0 Fork 231

asdafewzx / StockAnalysisSystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.py 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
Yufei QIU 提交于 2021-05-08 13:47 . Fix interface interactive issue.
import os
import sys
import traceback
from PyQt5.QtWidgets import QApplication
from StockAnalysisSystem.ui.main_ui import MainWindow
from StockAnalysisSystem.ui.Utility.ui_context import UiContext
from StockAnalysisSystem.core.Utility.ui_utility import WrapperQDialog
from StockAnalysisSystem.ui.if_selector_ui import InterfaceSelectUi
from StockAnalysisSystem.interface.interface_rest import RestInterface
from StockAnalysisSystem.interface.interface_local import LocalInterface
from StockAnalysisSystem.interface.interface import SasInterface as sasIF
def init_if(local: bool = True, local_project_path: str = '',
remote_url: str = 'http://127.0.0.1:80/api', remote_token: str = '') -> sasIF or None:
if local:
if local_project_path is None or local_project_path == '':
local_project_path = os.getcwd()
local_if = LocalInterface()
local_if.if_init(local_project_path)
return local_if
else:
remote_if = RestInterface()
remote_if.if_init(api_uri=remote_url, token=remote_token)
return remote_if
def main():
app = QApplication(sys.argv)
if_sel_ui = InterfaceSelectUi()
dlg = WrapperQDialog(if_sel_ui)
dlg.exec()
if not if_sel_ui.is_ok():
exit(0)
is_local = if_sel_ui.is_local()
url, port = if_sel_ui.get_remote_host_config()
user, passwd, token = if_sel_ui.get_remote_host_authentication()
sasif = init_if(is_local, remote_url=url, remote_token=token)
prob = sasif.sas_service_prob()
if prob is None:
print('Interface access FAIL. Quit.')
exit(1)
ui_ctx = UiContext()
ui_ctx.set_sas_interface(sasif)
main_wnd = MainWindow(ui_ctx)
main_wnd.show()
sys.exit(app.exec())
print('Process Quit.')
# ----------------------------------------------------------------------------------------------------------------------
def exception_hook(_type, value, tback):
# log the exception here
print('Exception hook triggered.')
print(_type)
print(value)
print(tback)
# then call the default handler
sys.__excepthook__(_type, value, tback)
if __name__ == "__main__":
sys.excepthook = exception_hook
try:
main()
except Exception as e:
print('Error =>', e)
print('Error =>', traceback.format_exc())
exit()
finally:
pass
Python
1
https://gitee.com/paqcom/StockAnalysisSystem.git
git@gitee.com:paqcom/StockAnalysisSystem.git
paqcom
StockAnalysisSystem
StockAnalysisSystem
master

搜索帮助