Get OS version, stop conflict between sys.platform and platform module
This commit is contained in:
parent
8f1f73bc7a
commit
884a736c23
1 changed files with 24 additions and 6 deletions
30
ostools.py
30
ostools.py
|
@ -1,18 +1,36 @@
|
|||
from os import path
|
||||
from sys import platform
|
||||
import os, sys
|
||||
import platform
|
||||
from PyQt4.QtGui import QDesktopServices
|
||||
|
||||
def isOSX():
|
||||
return platform == "darwin"
|
||||
return sys.platform == "darwin"
|
||||
|
||||
def isWin32():
|
||||
return platform == "win32"
|
||||
return sys.platform == "win32"
|
||||
|
||||
def isLinux():
|
||||
return sys.platform.startswith("linux")
|
||||
|
||||
def isOSXBundle():
|
||||
return isOSX() and (path.abspath('.').find(".app") != -1)
|
||||
return isOSX() and (os.path.abspath('.').find(".app") != -1)
|
||||
|
||||
def osVer():
|
||||
if isWin32():
|
||||
return " ".join(platform.win32_ver())
|
||||
elif isOSX():
|
||||
ret = ""
|
||||
for i in platform.mac_ver():
|
||||
if type(i) == type(tuple()):
|
||||
for j in i:
|
||||
ret += " %s" % (j)
|
||||
else:
|
||||
ret += " %s" % (i)
|
||||
return ret[1:]
|
||||
elif isLinux():
|
||||
return " ".join(platform.linux_distribution())
|
||||
|
||||
def getDataDir():
|
||||
if isOSX():
|
||||
return path.join(str(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/")
|
||||
return os.path.join(str(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/")
|
||||
else:
|
||||
return ''
|
||||
|
|
Loading…
Reference in a new issue