From 884a736c23ca8caa95406cf64629ac4e8904ed31 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Tue, 23 Aug 2011 02:28:58 -0700 Subject: [PATCH] Get OS version, stop conflict between sys.platform and platform module --- ostools.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ostools.py b/ostools.py index 294437f..f3d0126 100644 --- a/ostools.py +++ b/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 ''