Last active
August 29, 2015 13:57
-
-
Save cpburnz/9573689 to your computer and use it in GitHub Desktop.
Reliably determine the name of the host system in both CPython and Jython.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Reliably determine the name of the host system in both CPython and | |
Jython. | |
""" | |
__author__ = "Caleb P. Burns" | |
__license__ = "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication" | |
__version__ = "1.0.2" | |
import platform | |
def get_system(): | |
""" | |
Reliably determine the name of the host system in both CPython and | |
Jython. | |
Returns the system name (``str``). E.g., "Darwin", "Linux", "Windows", | |
etc. | |
""" | |
# Darwin | |
# Java | |
# Linux | |
# Windows | |
system = platform.system() | |
if system == 'Java': | |
system = platform.java_ver()[3][0] | |
if system.startswith('Windows'): | |
# Windows XP | |
# Windows Vista | |
# Windows 7 | |
system = 'Windows' | |
elif system.startswith('Mac'): | |
# Mac OS | |
# Mac OS X | |
system = 'Darwin' | |
else: | |
# Linux | |
# SunOS | |
# FreeBSD | |
pass | |
return system |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment