getplatform#

getplatform(expected=None, platform=None, die=False)[source]#

Return the name of the current “main” platform (e.g. ‘mac’)

Alias to sys.platform, except maps entries onto one of ‘linux’, ‘windows’, ‘mac’, or ‘other’.

Parameters:
  • expected (str) – if not None, check if the current platform is this

  • platform (str) – if supplied, map this onto one of the “main” platforms, rather than determine it

  • die (bool) – if True and expected is defined, raise an exception

Returns:

‘linux’, ‘windows’, ‘mac’, or ‘other’

Return type:

String, one of

Examples:

sc.getplatform() # Get current name of platform
sc.getplatform('windows', die=True) # Raise an exception if not on Windows
sc.getplatform(platform='darwin') # Normalize to 'mac'