Skip to content

Commit

Permalink
Use platform for detecting OS
Browse files Browse the repository at this point in the history
  • Loading branch information
HotaruBlaze committed Dec 15, 2022
1 parent 83cf2cf commit f81c46f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion client/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import webbrowser
import base64
import os
import platform
import hashlib
import re
import pickle
Expand All @@ -17,7 +18,7 @@ def getAppPath():
# Windows allows you to move your UserProfile subfolders, Such as Documents, Videos, Music etc.
# However os.path.expanduser does not actually check and assumes its in the default location.
# This tries to correctly resolve the Documents path and fallbacks to default if it fails.
if os.name == 'nt':
if platform.system() == 'Windows':
try:
import ctypes.wintypes
CSIDL_PERSONAL = 5 # My Documents
Expand Down
14 changes: 7 additions & 7 deletions client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
log(e)
raise e

# Helpful Wrapper code for handling autostar dependencies
# Helpful Wrapper code for handling autostart dependencies
if getattr(sys, 'frozen', False):
isScriptBundled = True
else:
isScriptBundled = False
if not isScriptBundled:
if os.name == 'nt':
if platform.system() == 'Windows':
try:
import win32com.client
import winshell
Expand All @@ -41,9 +41,9 @@
os.system('python -m pip install pypiwin32 winshell')
from win32com.client import Dispatch
from winshell import Shortcut
if os.name == "darwin":
if platform.system() == "Darwin":
raise Exception('not implemented yet')
if os.name == "linux":
if platform.system() == "Linux":
raise Exception('not implemented yet')

# PyQt5 Variables
Expand Down Expand Up @@ -183,7 +183,7 @@ def setVisability(self,mode):
def setLaunchMode(self,mode):
global settings
try:
if os.name == 'nt':
if platform.system() == 'Windows':
from win32com.client import Dispatch
from winshell import Shortcut
StartupFolder = os.path.join(os.getenv('APPDATA'), "Microsoft\Windows\Start Menu\Programs\Startup")
Expand All @@ -200,9 +200,9 @@ def setLaunchMode(self,mode):
Shortcut.save()
elif settings['startOnLaunch'] == True:
os.remove(os.path.join(StartupFolder, "NSO-RPC.lnk"))
elif sys.platform.startswith('darwin'): # This is where macOS code should go
elif platform.system() == 'Darwin': # This is where macOS code should go
raise Exception('not implemented yet')
elif sys.platform.startswith('linux'): # This is where Linux code should go
elif platform.system() == "Linux": # This is where Linux code should go
raise Exception('not implemented yet')
else:
raise Exception('not implemented yet')
Expand Down

0 comments on commit f81c46f

Please sign in to comment.