release
This commit is contained in:
@@ -22,30 +22,37 @@ def get_config_path() -> Path:
|
||||
|
||||
return base_path / 'config.ini'
|
||||
|
||||
def create_default_config():
|
||||
def save_config(miniQmtPath:str, account_no:str):
|
||||
"""创建默认配置文件"""
|
||||
config = configparser.ConfigParser()
|
||||
config['config'] = {
|
||||
'miniQMTPath': r'D:/Programs/QMT/userdata_mini',
|
||||
'account_no': '00000000',
|
||||
'log_level' : 'INFO'
|
||||
'miniQMTPath': miniQmtPath,
|
||||
'account_no': account_no
|
||||
}
|
||||
config_path = get_config_path()
|
||||
with open(config_path, 'w') as configfile:
|
||||
config.write(configfile)
|
||||
print(f'已创建默认配置文件: {config_path}')
|
||||
|
||||
def initConfig():
|
||||
global miniQMTPath, grid_price, grid_volume, account_no
|
||||
def exist_config() -> bool:
|
||||
"""检查配置文件是否存在"""
|
||||
config_path = get_config_path()
|
||||
return config_path.exists()
|
||||
|
||||
def initConfig() -> bool:
|
||||
global miniQMTPath, account_no
|
||||
|
||||
# 获取配置文件路径
|
||||
config_path = get_config_path()
|
||||
|
||||
# 检查配置文件是否存在,不存在则创建
|
||||
if not config_path.exists():
|
||||
create_default_config()
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_path, encoding='utf-8')
|
||||
miniQMTPath = config.get('config','miniQMTPath')
|
||||
account_no = config.get('config','account_no')
|
||||
|
||||
# 判断miniQMTPath是否为空,并且目录是否存在
|
||||
if not miniQMTPath or not Path(miniQMTPath).exists():
|
||||
print('请先配置miniQMTPath')
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user