|
1 | 1 | """ Utility module to determine the OS Python running on
|
2 | 2 |
|
3 |
| - -------------------------------------------------------------------------- |
4 |
| - File: utilsOsType.py |
| 3 | + -------------------------------------------------------------------------- |
| 4 | + File: utilsOsType.py |
5 | 5 |
|
6 |
| - Overview: Python module to supply functions and an enumeration to |
7 |
| - help determine the platform type, bit size and OS currently |
8 |
| - being used. |
9 |
| - |
10 |
| - Environment: OS: Windows/LINUX/OSX |
11 |
| - IDE: Visual Studio 2013 Plugin Python Tools (PTVS) |
12 |
| - Script: Python 2.6 x64 |
| 6 | + Overview: Python module to supply functions and an enumeration to |
| 7 | + help determine the platform type, bit size and OS currently |
| 8 | + being used. |
| 9 | + -------------------------------------------------------------------------- |
13 | 10 |
|
14 |
| - Gotchas: None. |
15 |
| -
|
16 |
| - Copyright: None. |
17 |
| - -------------------------------------------------------------------------- |
18 |
| - |
19 | 11 | """
|
20 | 12 |
|
21 | 13 | # Python modules:
|
22 |
| -import sys # Provide system information |
| 14 | +import sys # Provide system information |
23 | 15 |
|
24 | 16 | # Third party modules:
|
25 | 17 |
|
|
29 | 21 |
|
30 | 22 | # Enumerations:
|
31 | 23 | #-----------------------------------------------------------------------------
|
32 |
| -# Details: Class to implement a 'C' style enumeration type. |
33 |
| -# Gotchas: None. |
34 |
| -# Authors: Illya Rudkin 28/11/2013. |
35 |
| -# Changes: None. |
| 24 | +# Details: Class to implement a 'C' style enumeration type. |
| 25 | +# Gotchas: None. |
| 26 | +# Authors: Illya Rudkin 28/11/2013. |
| 27 | +# Changes: None. |
36 | 28 | #--
|
37 | 29 | class EnumOsType( object ):
|
38 |
| - values = [ "Unknown", |
39 |
| - "Windows", |
40 |
| - "Linux", |
41 |
| - "Darwin" ]; # OSX |
42 |
| - class __metaclass__( type ): |
| 30 | + values = [ "Unknown", |
| 31 | + "Windows", |
| 32 | + "Linux", |
| 33 | + "Darwin" ]; # OSX |
| 34 | + class __metaclass__( type ): |
43 | 35 | #++---------------------------------------------------------------------------
|
44 |
| -# Details: Fn acts as an enumeration. |
45 |
| -# Args: vName - (R) Enumeration to match. |
46 |
| -# Returns: Int - Matching enumeration/index. |
47 |
| -# Throws: None. |
| 36 | +# Details: Fn acts as an enumeration. |
| 37 | +# Args: vName - (R) Enumeration to match. |
| 38 | +# Returns: Int - Matching enumeration/index. |
| 39 | +# Throws: None. |
48 | 40 | #--
|
49 |
| - def __getattr__( self, vName ): |
50 |
| - return self.values.index( vName ); |
| 41 | + def __getattr__( self, vName ): |
| 42 | + return self.values.index( vName ); |
51 | 43 |
|
52 | 44 | #++---------------------------------------------------------------------------
|
53 |
| -# Details: Reverse fast lookup of the values list. |
54 |
| -# Args: vI - (R) Index / enumeration. |
55 |
| -# Returns: Str - text description matching enumeration. |
56 |
| -# Throws: None. |
| 45 | +# Details: Reverse fast lookup of the values list. |
| 46 | +# Args: vI - (R) Index / enumeration. |
| 47 | +# Returns: Str - text description matching enumeration. |
| 48 | +# Throws: None. |
57 | 49 | #--
|
58 |
| - def name_of( self, vI ): |
59 |
| - return EnumOsType.values[ vI ]; |
| 50 | + def name_of( self, vI ): |
| 51 | + return EnumOsType.values[ vI ]; |
60 | 52 |
|
61 | 53 | #-----------------------------------------------------------------------------
|
62 | 54 | #-----------------------------------------------------------------------------
|
63 | 55 | #-----------------------------------------------------------------------------
|
64 | 56 |
|
65 | 57 | #++---------------------------------------------------------------------------
|
66 |
| -# Details: Determine what operating system is currently running on. |
67 |
| -# Args: None. |
68 |
| -# Returns: EnumOsType - The OS type being used ATM. |
69 |
| -# Throws: None. |
| 58 | +# Details: Determine what operating system is currently running on. |
| 59 | +# Args: None. |
| 60 | +# Returns: EnumOsType - The OS type being used ATM. |
| 61 | +# Throws: None. |
70 | 62 | #--
|
71 | 63 | def determine_os_type():
|
72 |
| - eOSType = EnumOsType.Unknown; |
73 |
| - |
74 |
| - strOS = sys.platform |
75 |
| - if strOS == "win32": |
76 |
| - eOSType = EnumOsType.Windows; |
77 |
| - elif (strOS == "linux") or (strOS == "linux2"): |
78 |
| - eOSType = EnumOsType.Linux; |
79 |
| - elif strOS == "darwin": |
80 |
| - eOSType == EnumOsType.Darwin; |
81 |
| - |
82 |
| - return eOSType; |
| 64 | + eOSType = EnumOsType.Unknown; |
| 65 | + |
| 66 | + strOS = sys.platform |
| 67 | + if strOS == "win32": |
| 68 | + eOSType = EnumOsType.Windows; |
| 69 | + elif (strOS == "linux") or (strOS == "linux2"): |
| 70 | + eOSType = EnumOsType.Linux; |
| 71 | + elif strOS == "darwin": |
| 72 | + eOSType == EnumOsType.Darwin; |
| 73 | + |
| 74 | + return eOSType; |
0 commit comments