fix
This commit is contained in:
@@ -1,3 +1,2 @@
|
|||||||
# 基础模块现代化改进分支
|
# 基础模块现代化改进分支
|
||||||
您正浏览潜进项目的基础模块现代化改进原型分支!
|
您正浏览潜进项目的基础模块现代化改进原型分支!
|
||||||
[] - HeurAMK
|
|
||||||
@@ -1 +1,2 @@
|
|||||||
print("Hello from HeurAMS Program :)")
|
print("Hello from HeurAMS Program :)")
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,18 @@ from contextvars import ContextVar
|
|||||||
import pathlib
|
import pathlib
|
||||||
from heurams.services.config import ConfigFile
|
from heurams.services.config import ConfigFile
|
||||||
|
|
||||||
|
# 默认配置文件路径规定: 以包目录为准
|
||||||
|
# 用户配置文件路径规定: 以运行目录为准
|
||||||
|
# 数据文件路径规定: 以运行目录为准
|
||||||
|
|
||||||
root_dir = pathlib.Path(__file__).parent
|
root_dir = pathlib.Path(__file__).parent
|
||||||
|
print(f'rootdir: {rootdir}')
|
||||||
working_dir = pathlib.Path.cwd()
|
working_dir = pathlib.Path.cwd()
|
||||||
|
print(f'workdir: {workdir}')
|
||||||
config_var: ContextVar[ConfigFile] = ContextVar('config_var', default=ConfigFile(working_dir / "config" / "config.toml")) # 配置文件
|
try:
|
||||||
|
config_var: ContextVar[ConfigFile] = ContextVar('config_var', default=ConfigFile(workdir / "config" / "config.toml")) # 配置文件
|
||||||
|
except:
|
||||||
|
print('加载用户配置失败')
|
||||||
runtime_var: ContextVar = ContextVar('runtime_var', default=dict()) # 运行时共享数据
|
runtime_var: ContextVar = ContextVar('runtime_var', default=dict()) # 运行时共享数据
|
||||||
|
|
||||||
class ConfigContext:
|
class ConfigContext:
|
||||||
@@ -34,4 +40,4 @@ class ConfigContext:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
config_var.reset(self._token) # type: ignore
|
config_var.reset(self._token) # type: ignore
|
||||||
|
|||||||
@@ -27,5 +27,8 @@ class HeurAMSApp(App):
|
|||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
self.exit(event.button.id)
|
self.exit(event.button.id)
|
||||||
|
|
||||||
|
def environment_check():
|
||||||
|
from heurams.context import working_var
|
||||||
|
|
||||||
app = HeurAMSApp()
|
app = HeurAMSApp()
|
||||||
app.run()
|
app.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user