Source code for pipeLion.utils.platformUtils

import os
import sys
from pipeLion.core.errors.coreErrors import OsNotSupportedError

[docs]def currentPlatform(): """ returns wether the current operating system is mac, linux or windows """ platform = sys.platform.lower() if platform == 'linux2': return 'linux' elif platform == 'win32' or platform == 'cygwin': return 'windows' elif platform == 'darwin' or platform == 'os2' or platform == 'os2emx': return 'mac' else: raise OSNotSupportedError(platform)
[docs]def userDirectory(): """ method returns the path to the user directory. It is platform independent for Linux, MacOsX and Windows """ return os.getenv('USERPROFILE') or os.getenv('HOME')
[docs]def launchFileWithDefaultApplication(file): """ method will launch the given file with the default application set by the os. :param file: the file, which should be opened :type file: string: """ if currentPlatform() == 'linux': os.system('xdg-open "%s"'%file) else: os.startfile(file)