1 """
2 @copyright: 2011 Mark LaPerriere
3
4 @license:
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 U{http://www.apache.org/licenses/LICENSE-2.0}
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 @summary:
18 A default implementation of the profiler
19
20 @author: Mark LaPerriere
21 @contact: pyhai@mindmind.com
22 @organization: Mind Squared Design / www.mindmind.com
23 @version: 0.1.3
24 @date: Jan 19, 2012
25 """
26 import platform
27 import socket
28 import base
29
31 """
32 The default profiler plugin
33 """
34 __profile = None
35
50
52 """
53 Returns the system's profile
54
55 @return: A dictionary consisting of the system and architecture
56 @rtype: C{dict}
57 """
58 return self.__profile
59
61 """
62 Returns the system property of the system's profile
63
64 @return: The system property of the system's profile
65 @rtype: C{str}
66 """
67 return self.__profile['system']
68
70 """
71 Returns the system class property - windows, linux, java
72
73 @return: The type of system
74 @rtype: C{str}
75 """
76 return self.__profile['system_class']
77
79 """
80 Detects the specific type of system. For windows, the windows type and version,
81 for linux, the distribution and version
82
83 @return: A string representing the specific type of system: windows7, windowsxp, ubuntu, centos, etc
84 @rtype: C{str}
85 """
86 if system_class == 'linux':
87 if hasattr(platform, 'linux_distribution'):
88 distro = platform.linux_distribution()
89 elif hasattr(platform, 'dist'):
90 distro = platform.dist()
91 else:
92 distro = None
93 if distro and type(distro) is tuple and len(distro) > 0:
94 system = str(distro[0]).lower()
95 system_parts = system.split()
96 if system_parts[0] in ('centos'):
97 return system_parts[0]
98 else:
99 return system
100 elif system_class == 'windows':
101 return str(platform.win32_ver()[0]).lower()
102 else:
103 return None
104