Skip to content

Commit

Permalink
加入一个用于检测是否运行成功的文件
Browse files Browse the repository at this point in the history
  • Loading branch information
duolabmeng6 committed Mar 4, 2023
1 parent 89d8bce commit 18e16fe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 自动更新模块/自动更新功能.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,24 @@ def 更新自己MacOS应用(资源压缩包, 应用名称="my_app.app"):
return False, ""


def _取运行目录():
""" PyInstaller 单文件的运行目录 """
if getattr(sys, 'frozen', False):
return os.path.dirname(os.path.realpath(sys.argv[0]))
else:
return sys.path[0]


def 初始化():
# 构建时测试运行是否正常的
传入参数 = sys.argv
if len(传入参数) == 2:
参数1 = 传入参数[1]
if 参数1 == "test":
print("app run success")
# 写出文件
with open(_取运行目录() + "test.txt", "w") as f:
f.write("app run success")
sys.exit(0)

# 如果在window系统中存在旧的文件则自动删除
Expand Down

0 comments on commit 18e16fe

Please sign in to comment.