From ba658111293dbc23f3d905ecaadc936fc78c997d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=99=E5=90=9B=E5=BE=A1?= Date: Wed, 31 Jul 2024 22:30:23 +0800 Subject: [PATCH] up --- .gitignore | 17 ++++++++++++++++- build.bat | 1 + config.py | 12 +++++++++--- main.py | 29 ++++++++++++++++++----------- main.spec | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 build.bat create mode 100644 main.spec diff --git a/.gitignore b/.gitignore index fc51dff..42854f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,17 @@ -__pycache__/ \ No newline at end of file +__pycache__/ +build/ +dist/ +*.egg-info/ +*.egg +*.pyc +*.pyo +*.pyd +*.so +*.pyd +*.dll +*.dylib +*.lib +*.exp +*.ilk +*.pdb \ No newline at end of file diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..9391fa4 --- /dev/null +++ b/build.bat @@ -0,0 +1 @@ +pyinstaller -F main.py \ No newline at end of file diff --git a/config.py b/config.py index 9f447c4..8790657 100644 --- a/config.py +++ b/config.py @@ -66,6 +66,12 @@ def run_config_selector(confList): print("请选择配置文件:") for i, conf in enumerate(confList): print(f"{i+1}. {conf}") - choice = int(input("请输入选项:")) - if choice in range(1, len(confList)+1): - return confList[choice-1] + temp = input("请输入选项:") + # 整数 + if temp.isdigit(): + choice = int(temp) + if choice in range(1, len(confList)+1): + return confList[choice-1] + else: + return None + \ No newline at end of file diff --git a/main.py b/main.py index 248bf43..045cc77 100644 --- a/main.py +++ b/main.py @@ -6,22 +6,29 @@ import config as cfg def run(): # 读取配置文件 conFigList = cfg.read_config_file() - if not conFigList: print('[没有找到配置文件]') + if not conFigList: + print('[没有找到配置文件]') + input('请按任意键退出...') else: # 选择运行配置 data = cfg.run_config_selector(conFigList) - # 处理目录结构 - dirDict = cfg.config_dir_structure(data) - os.system('cls') - if not dirDict: - print('[配置文件为空]\n') + if not data: + os.system('cls') + print('[配置文件不存在]\n') run() else: - # 创建目录 - base_path = '.' - cfg.create_folders(base_path, dirDict) - print('[目录创建成功]\n') - run() + # 处理目录结构 + dirDict = cfg.config_dir_structure(data) + os.system('cls') + if not dirDict: + print('[配置文件为空]\n') + run() + else: + # 创建目录 + base_path = '.' + cfg.create_folders(base_path, dirDict) + print('[目录创建成功]\n') + run() if __name__ == '__main__': run() \ No newline at end of file diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..2ba8dd9 --- /dev/null +++ b/main.spec @@ -0,0 +1,38 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)