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
|
import os, sys
|
||||||
from sys import platform
|
import platform
|
||||||
from PyQt4.QtGui import QDesktopServices
|
from PyQt4.QtGui import QDesktopServices
|
||||||
|
|
||||||
def isOSX():
|
def isOSX():
|
||||||
return platform == "darwin"
|
return sys.platform == "darwin"
|
||||||
|
|
||||||
def isWin32():
|
def isWin32():
|
||||||
return platform == "win32"
|
return sys.platform == "win32"
|
||||||
|
|
||||||
|
def isLinux():
|
||||||
|
return sys.platform.startswith("linux")
|
||||||
|
|
||||||
def isOSXBundle():
|
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():
|
def getDataDir():
|
||||||
if isOSX():
|
if isOSX():
|
||||||
return path.join(str(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/")
|
return os.path.join(str(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/")
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in a new issue