-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add feat: set log dir based on executable path
- Loading branch information
Showing
7 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ __pycache__/ | |
*$py.class | ||
[Ll]og/ | ||
*.db | ||
*.bat | ||
*.sh | ||
*.zip | ||
|
||
# C extensions | ||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pyqt5 | ||
pyinstaller | ||
pyinstaller>=6.3 | ||
opencv-python==4.6.0.66 | ||
opencv-contrib-python==4.6.0.66 | ||
pycryptodome | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# author: 'zfb' | ||
# time: 2023-12-25 18:26 | ||
|
||
import sys | ||
# from os import getcwd | ||
from os.path import dirname, abspath | ||
|
||
def get_base_path(): | ||
""" | ||
获取当前运行目录,适应于Python和PyInstaller环境 | ||
""" | ||
# path = getcwd() | ||
path = dirname(abspath(__file__)) | ||
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): | ||
# 如果是PyInstaller环境 | ||
# 可以使用 sys.executable 获取当前运行的exe路径 | ||
# 也可以使用 sys._MEIPASS 获取当前运行的exe所在目录下的_internal文件夹的路径 | ||
# 例如 D:\QrScan\bin\QrScan\_internal | ||
# 获取 _internal 文件夹的路径,然后使用 dirname 获取上一级目录 | ||
path = dirname(sys._MEIPASS) | ||
return path |