Skip to content

Commit

Permalink
fix: 修复打包无法找到read_conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassianvale committed Feb 1, 2024
1 parent 5c92084 commit 8663692
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyinstaller.py → src/pyinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def package_scripts():
os.remove('palworld-python-script.zip')
print('已删除原palworld-python-script.zip')

scripts = ['src/task_scheduler.py', 'src/backup.py']
scripts = ['task_scheduler.py', 'backup.py']
print('正在打包:', scripts)

for script in scripts:

command = 'pyinstaller', '--onefile', script
subprocess.run(command)

shutil.copy('src/config.ini', 'dist')
shutil.copy('config.ini', 'dist')

shutil.make_archive('palworld-python-script', 'zip', 'dist')
print("palworld-python-script 打包成功!")
Expand Down
3 changes: 1 addition & 2 deletions src/read_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
def read_config():
# 读取配置文件
config = configparser.ConfigParser()
config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
with codecs.open(config_path, 'r', encoding='utf-8-sig') as f:
with codecs.open('config.ini', 'r', encoding='utf-8-sig') as f:
config.read_file(f)
main_directory = config.get('Settings', 'main_directory')
backup_dir = config.get('Settings', 'backup_dir')
Expand Down
4 changes: 2 additions & 2 deletions src/task_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import time
import psutil
import os
import read_conf
from src import read_conf
import threading
from utils.log_control import INFO
from src.utils.log_control import INFO
from rcon.source import Client
from rcon.source.proto import Packet
from rcon.exceptions import WrongPassword
Expand Down

0 comments on commit 8663692

Please sign in to comment.