Skip to content

Commit a80c527

Browse files
committed
fix: accommodate directories for executables, just in case
1 parent 7e15d3c commit a80c527

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/info.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
import platform
88
import os
9+
import sys
910

1011
name = "OCSysInfo"
1112
version = "0.0.1-alpha"
1213
os_ver = ""
1314
arch = platform.machine()
14-
_platform = platform.system().lower()
1515

1616
# Colours!
1717
pink = "\033[95m"
@@ -40,7 +40,6 @@ def format_text(text, formatting):
4040
final_string += end_formatting
4141
return final_string
4242

43-
4443
surprise = f"""{cyan}
4544
__ __ ______ _ _____ _
4645
\ \ / / | ____| | | |_ _| |
@@ -67,4 +66,12 @@ def format_text(text, formatting):
6766
"""
6867

6968
dir_delim = "\\" if platform.system().lower() == "windows" else "/"
70-
root_dir = dir_delim.join((os.path.dirname(os.path.realpath(__file__))).split(dir_delim)[:-1])
69+
70+
if getattr(sys, 'frozen', False):
71+
root_dir = os.path.dirname(sys.executable)
72+
os.chdir(root_dir)
73+
else:
74+
root_dir = os.path.dirname(os.path.abspath(__file__))
75+
76+
if "src" in root_dir.split(dir_delim):
77+
root_dir = dir_delim.join(root_dir.split(dir_delim)[:-1])

0 commit comments

Comments
 (0)