[go: up one dir, main page]

File: Platform.py

package info (click to toggle)
uranium 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,876 kB
  • sloc: python: 22,349; sh: 111; makefile: 11
file content (41 lines) | stat: -rw-r--r-- 1,203 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.

import sys


##  Convenience class to simplify OS checking and similar platform-specific handling.
class Platform:
    class PlatformType:
        Windows = 1
        Linux = 2
        OSX = 3
        Other = 4

    ##  Check to see if we are currently running on OSX.
    @classmethod
    def isOSX(cls) -> bool:
        return cls.__platform_type == cls.PlatformType.OSX

    ##  Check to see if we are currently running on Windows.
    @classmethod
    def isWindows(cls) -> bool:
        return cls.__platform_type == cls.PlatformType.Windows

    ##  Check to see if we are currently running on Linux.
    @classmethod
    def isLinux(cls) -> bool:
        return cls.__platform_type == cls.PlatformType.Linux

    ##  Get the platform type.
    @classmethod
    def getType(cls) -> int:
        return cls.__platform_type

    __platform_type = PlatformType.Other
    if sys.platform == "win32":
        __platform_type = PlatformType.Windows
    elif sys.platform == "linux":
        __platform_type = PlatformType.Linux
    elif sys.platform == "darwin":
        __platform_type = PlatformType.OSX