Skip to content
Permalink
Browse files

Add support for OS X in the platform detection.

  • Loading branch information...
kdart committed Oct 14, 2015
1 parent a7c912c commit af4db366b9171165ad5843f9496f87988401357c
Showing with 102 additions and 0 deletions.
  1. +17 −0 QA/platutils.py
  2. +17 −0 WWW/platutils.py
  3. +17 −0 aid/pycopia/platutils.py
  4. +17 −0 doc/platutils.py
  5. +17 −0 net/platutils.py
  6. +17 −0 storage/platutils.py
@@ -74,6 +74,9 @@ def is_redhat(self): # rpm-based
dist = self.distribution
return dist.startswith("Red") or dist.startswith("Cent")

def is_osx(self):
return self.distribution.startswith("Mac OS X")


def _get_linux_dist():
for fname in LINUX_RELEASE_FILES:
@@ -86,6 +89,13 @@ def _get_linux_dist():
pass
return "Unknown", "Unknown"


def _get_darwin_dist():
import subprocess
text = subprocess.check_output(["sw_vers"], shell=False)
return re.search(r"^ProductName:\t(.*)\nProductVersion:\t(.*)", text, re.M).groups()


def get_platform():
global os
rv = OSInfo()
@@ -97,6 +107,13 @@ def get_platform():
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_linux_dist()
elif sys.platform.startswith("darwin"):
import os # making this global breaks on IronPython
osname, _, kernel, _, arch = os.uname()
rv.arch = arch
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_darwin_dist()
elif sys.platform in ("win32", "cli"):
import os
rv.arch = os.environ["PROCESSOR_ARCHITECTURE"]
@@ -74,6 +74,9 @@ def is_redhat(self): # rpm-based
dist = self.distribution
return dist.startswith("Red") or dist.startswith("Cent")

def is_osx(self):
return self.distribution.startswith("Mac OS X")


def _get_linux_dist():
for fname in LINUX_RELEASE_FILES:
@@ -86,6 +89,13 @@ def _get_linux_dist():
pass
return "Unknown", "Unknown"


def _get_darwin_dist():
import subprocess
text = subprocess.check_output(["sw_vers"], shell=False)
return re.search(r"^ProductName:\t(.*)\nProductVersion:\t(.*)", text, re.M).groups()


def get_platform():
global os
rv = OSInfo()
@@ -97,6 +107,13 @@ def get_platform():
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_linux_dist()
elif sys.platform.startswith("darwin"):
import os # making this global breaks on IronPython
osname, _, kernel, _, arch = os.uname()
rv.arch = arch
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_darwin_dist()
elif sys.platform in ("win32", "cli"):
import os
rv.arch = os.environ["PROCESSOR_ARCHITECTURE"]
@@ -74,6 +74,9 @@ def is_redhat(self): # rpm-based
dist = self.distribution
return dist.startswith("Red") or dist.startswith("Cent")

def is_osx(self):
return self.distribution.startswith("Mac OS X")


def _get_linux_dist():
for fname in LINUX_RELEASE_FILES:
@@ -86,6 +89,13 @@ def _get_linux_dist():
pass
return "Unknown", "Unknown"


def _get_darwin_dist():
import subprocess
text = subprocess.check_output(["sw_vers"], shell=False)
return re.search(r"^ProductName:\t(.*)\nProductVersion:\t(.*)", text, re.M).groups()


def get_platform():
global os
rv = OSInfo()
@@ -97,6 +107,13 @@ def get_platform():
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_linux_dist()
elif sys.platform.startswith("darwin"):
import os # making this global breaks on IronPython
osname, _, kernel, _, arch = os.uname()
rv.arch = arch
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_darwin_dist()
elif sys.platform in ("win32", "cli"):
import os
rv.arch = os.environ["PROCESSOR_ARCHITECTURE"]
@@ -74,6 +74,9 @@ def is_redhat(self): # rpm-based
dist = self.distribution
return dist.startswith("Red") or dist.startswith("Cent")

def is_osx(self):
return self.distribution.startswith("Mac OS X")


def _get_linux_dist():
for fname in LINUX_RELEASE_FILES:
@@ -86,6 +89,13 @@ def _get_linux_dist():
pass
return "Unknown", "Unknown"


def _get_darwin_dist():
import subprocess
text = subprocess.check_output(["sw_vers"], shell=False)
return re.search(r"^ProductName:\t(.*)\nProductVersion:\t(.*)", text, re.M).groups()


def get_platform():
global os
rv = OSInfo()
@@ -97,6 +107,13 @@ def get_platform():
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_linux_dist()
elif sys.platform.startswith("darwin"):
import os # making this global breaks on IronPython
osname, _, kernel, _, arch = os.uname()
rv.arch = arch
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_darwin_dist()
elif sys.platform in ("win32", "cli"):
import os
rv.arch = os.environ["PROCESSOR_ARCHITECTURE"]
@@ -74,6 +74,9 @@ def is_redhat(self): # rpm-based
dist = self.distribution
return dist.startswith("Red") or dist.startswith("Cent")

def is_osx(self):
return self.distribution.startswith("Mac OS X")


def _get_linux_dist():
for fname in LINUX_RELEASE_FILES:
@@ -86,6 +89,13 @@ def _get_linux_dist():
pass
return "Unknown", "Unknown"


def _get_darwin_dist():
import subprocess
text = subprocess.check_output(["sw_vers"], shell=False)
return re.search(r"^ProductName:\t(.*)\nProductVersion:\t(.*)", text, re.M).groups()


def get_platform():
global os
rv = OSInfo()
@@ -97,6 +107,13 @@ def get_platform():
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_linux_dist()
elif sys.platform.startswith("darwin"):
import os # making this global breaks on IronPython
osname, _, kernel, _, arch = os.uname()
rv.arch = arch
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_darwin_dist()
elif sys.platform in ("win32", "cli"):
import os
rv.arch = os.environ["PROCESSOR_ARCHITECTURE"]
@@ -74,6 +74,9 @@ def is_redhat(self): # rpm-based
dist = self.distribution
return dist.startswith("Red") or dist.startswith("Cent")

def is_osx(self):
return self.distribution.startswith("Mac OS X")


def _get_linux_dist():
for fname in LINUX_RELEASE_FILES:
@@ -86,6 +89,13 @@ def _get_linux_dist():
pass
return "Unknown", "Unknown"


def _get_darwin_dist():
import subprocess
text = subprocess.check_output(["sw_vers"], shell=False)
return re.search(r"^ProductName:\t(.*)\nProductVersion:\t(.*)", text, re.M).groups()


def get_platform():
global os
rv = OSInfo()
@@ -97,6 +107,13 @@ def get_platform():
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_linux_dist()
elif sys.platform.startswith("darwin"):
import os # making this global breaks on IronPython
osname, _, kernel, _, arch = os.uname()
rv.arch = arch
rv.osname = osname
rv.osversion = kernel
rv.distribution, rv.release = _get_darwin_dist()
elif sys.platform in ("win32", "cli"):
import os
rv.arch = os.environ["PROCESSOR_ARCHITECTURE"]

0 comments on commit af4db36

Please sign in to comment.
You can’t perform that action at this time.