Skip to content

Instantly share code, notes, and snippets.

@AndrewHazelden
Created December 6, 2015 17:16
Show Gist options
  • Save AndrewHazelden/d3a6fab0ef98229bdb49 to your computer and use it in GitHub Desktop.
Save AndrewHazelden/d3a6fab0ef98229bdb49 to your computer and use it in GitHub Desktop.
Use Python to check the current operating system
# Check the operating system
# Example: mxPlatform = getPlatform()
def getPlatform():
import platform
osPlatform = str(platform.system())
mxPlatform = ''
if osPlatform == 'Windows':
mxPlatform = 'Windows'
elif osPlatform == 'win32':
mxPlatform = 'Windows'
elif osPlatform == 'Darwin':
mxPlatform = "Mac"
elif osPlatform== 'Linux':
mxPlatform = 'Linux'
elif osPlatform == 'Linux2':
mxPlatform = 'Linux'
else:
mxPlatform = 'Linux'
# print('Running on ' + mxPlatform + '\n')
return mxPlatform
mxPlatform = getPlatform()
print('Running on ' + mxPlatform + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment