File: utilsOsType.py

package info (click to toggle)
llvm-toolchain-3.5 1%3A3.5-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 282,028 kB
  • ctags: 310,872
  • sloc: cpp: 1,883,926; ansic: 310,731; objc: 86,612; python: 79,565; asm: 65,844; sh: 9,829; makefile: 6,057; perl: 5,589; ml: 5,254; pascal: 3,285; lisp: 1,640; xml: 686; cs: 239; csh: 117
file content (82 lines) | stat: -rw-r--r-- 2,426 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
""" Utility module to determine the OS Python running on

	--------------------------------------------------------------------------
	File: 			utilsOsType.py

	Overview: 		Python module to supply functions and an enumeration to 
					help determine the platform type, bit size and OS currently
					being used.
									
	Environment:	OS:			Windows/LINUX/OSX
					IDE: 	    Visual Studio 2013 Plugin Python Tools (PTVS)
					Script:		Python 2.6 x64 

	Gotchas:		None.

	Copyright:		None.
	--------------------------------------------------------------------------
	
"""

# Python modules:
import sys		# Provide system information

# Third party modules:

# In-house modules:

# Instantiations:

# Enumerations:
#-----------------------------------------------------------------------------
# Details:	Class to implement a 'C' style enumeration type.
# Gotchas:	None.
# Authors:	Illya Rudkin 28/11/2013.
# Changes:	None.
#--
class EnumOsType( object ):
	values = [	"Unknown",
				"Windows", 
				"Linux", 
				"Darwin" ]; # OSX
	class __metaclass__( type ):
#++---------------------------------------------------------------------------
# Details:	Fn acts as an enumeration.
# Args:		vName - (R) Enumeration to match.
# Returns:	Int - Matching enumeration/index.
# Throws:	None.
#--
		def __getattr__( self, vName ):
			return self.values.index( vName );

#++---------------------------------------------------------------------------
# Details:	Reverse fast lookup of the values list.
# Args:		vI - (R) Index / enumeration.
# Returns:	Str - text description matching enumeration.
# Throws:	None.
#--
		def name_of( self, vI ):
			return EnumOsType.values[ vI ];

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------

#++---------------------------------------------------------------------------
# Details:	Determine what operating system is currently running on.
# Args:		None.
# Returns:	EnumOsType - The OS type being used ATM.
# Throws:	None.
#--
def determine_os_type():
	eOSType = EnumOsType.Unknown;
	
	strOS = sys.platform
	if strOS == "win32":
		eOSType = EnumOsType.Windows;
	elif (strOS == "linux") or (strOS == "linux2"):
		eOSType = EnumOsType.Linux;
	elif strOS == "darwin":
		eOSType == EnumOsType.Darwin;
		
	return eOSType;