# Copyright (c) 2019 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
"""
# Methods to centralize the OS tests and provide a standard way of determining
# the current OS.
"""
import sys
[docs]def is_windows(platform=None):
"""
Determine if the current platform is Windows.
:param platform: sys.platform style string, e.g 'linux2', 'win32' or
'darwin'. If not provided, sys.platform will be used.
:returns: True if the current platform is Windows, otherwise False.
:rtype: bool
"""
if platform:
return platform == "win32"
return sys.platform == "win32"
[docs]def is_linux(platform=None):
"""
Determine if the current platform is Linux.
:param platform: sys.platform style string, e.g 'linux2', 'win32' or
'darwin'. If not provided, sys.platform will be used.
:returns: True if the current platform is Linux, otherwise False.
:rtype: bool
"""
if platform:
return platform.startswith("linux")
return sys.platform.startswith("linux")
[docs]def is_macos(platform=None):
"""
Determine if the current platform is MacOS.
:param platform: sys.platform style string, e.g 'linux2', 'win32' or
'darwin'. If not provided, sys.platform will be used.
:returns: True if the current platform is MacOS, otherwise False.
:rtype: bool
"""
if platform:
return platform == "darwin"
return sys.platform == "darwin"