Aitron Emper
commited on
Upload installation_checker.py
Browse files
assets/installation_checker.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
now_dir = os.getcwd()
|
| 5 |
+
sys.path.append(now_dir)
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class InstallationError(Exception):
|
| 9 |
+
def __init__(self, message="InstallationError"):
|
| 10 |
+
self.message = message
|
| 11 |
+
super().__init__(self.message)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def check_installation():
|
| 15 |
+
try:
|
| 16 |
+
system_drive = os.getenv("SystemDrive")
|
| 17 |
+
current_drive = os.path.splitdrive(now_dir)[0]
|
| 18 |
+
if current_drive.upper() != system_drive.upper():
|
| 19 |
+
raise InstallationError(
|
| 20 |
+
f"Error: Current working directory is not on the default system drive ({system_drive}). Please move Applio in the correct drive."
|
| 21 |
+
)
|
| 22 |
+
except:
|
| 23 |
+
pass
|
| 24 |
+
else:
|
| 25 |
+
if "OneDrive" in now_dir:
|
| 26 |
+
raise InstallationError(
|
| 27 |
+
"Error: Current working directory is on OneDrive. Please move Applio in another folder."
|
| 28 |
+
)
|
| 29 |
+
elif " " in now_dir:
|
| 30 |
+
raise InstallationError(
|
| 31 |
+
"Error: Current working directory contains spaces. Please move Applio in another folder."
|
| 32 |
+
)
|
| 33 |
+
try:
|
| 34 |
+
now_dir.encode("ascii")
|
| 35 |
+
except UnicodeEncodeError:
|
| 36 |
+
raise InstallationError(
|
| 37 |
+
"Error: Current working directory contains non-ASCII characters. Please move Applio in another folder."
|
| 38 |
+
)
|