Package platformids ::
Package dist ::
Module solaris
1
2 """Solaris releases.
3 """
4 from __future__ import absolute_import
5
6 import os
7 import sys
8 import re
9 import platform
10
11
12 from pythonids import PYV35Plus
13 from platformids import RTE_SOLARIS, rte2num, num2rte, num2pretty, decode_version_str_to_segments, \
14 PlatformIDsError, PlatformIDsFileCheck
15
16 __author__ = 'Arno-Can Uestuensoez'
17 __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
18 __copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
19 " @Ingenieurbuero Arno-Can Uestuensoez"
20 __version__ = '0.1.29'
21 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
22
23
24
25 RTE_SUNOS510 = RTE_SOLARIS + 0x00002800
26 RTE_SOLARIS10 = RTE_SOLARIS + 0x00002800
27
28 RTE_SUNOS511 = RTE_SOLARIS + 0x00002c00
29 RTE_SOLARIS11 = RTE_SOLARIS + 0x00002c00
30 RTE_SOLARIS110 = RTE_SOLARIS + 0x00002c00
31 RTE_SOLARIS111 = RTE_SOLARIS + 0x00002c20
32 RTE_SOLARIS112 = RTE_SOLARIS + 0x00002c40
33 RTE_SOLARIS113 = RTE_SOLARIS + 0x00002c60
34 RTE_SOLARIS114 = RTE_SOLARIS + 0x00002c80
35 RTE_SOLARIS115 = RTE_SOLARIS + 0x00002ca0
36 RTE_SOLARIS116 = RTE_SOLARIS + 0x00002cc0
37 RTE_SOLARIS117 = RTE_SOLARIS + 0x00002ce0
38
39
40
41 rte2num.update(
42 {
43 'solaris10': RTE_SOLARIS10,
44 'solaris11': RTE_SOLARIS11,
45 'solaris11': RTE_SOLARIS110,
46 'solaris111': RTE_SOLARIS111,
47 'solaris112': RTE_SOLARIS112,
48 'solaris113': RTE_SOLARIS113,
49 'solaris114': RTE_SOLARIS114,
50 'solaris115': RTE_SOLARIS115,
51 'sunos5': RTE_SOLARIS,
52 'sunos5.10': RTE_SOLARIS10,
53 'sunos5.11': RTE_SOLARIS11,
54 RTE_SOLARIS10: RTE_SOLARIS10,
55 RTE_SOLARIS110: RTE_SOLARIS110,
56 RTE_SOLARIS111: RTE_SOLARIS111,
57 RTE_SOLARIS112: RTE_SOLARIS112,
58 RTE_SOLARIS113: RTE_SOLARIS113,
59 RTE_SOLARIS114: RTE_SOLARIS114,
60 RTE_SOLARIS115: RTE_SOLARIS115,
61 RTE_SOLARIS11: RTE_SOLARIS11,
62 }
63 )
64
65
66
67 num2rte.update(
68 {
69 RTE_SOLARIS10: 'solaris10',
70 RTE_SUNOS510: 'solaris10',
71 RTE_SOLARIS11: 'solaris11',
72 RTE_SOLARIS110: 'solaris110',
73 RTE_SOLARIS111: 'solaris111',
74 RTE_SOLARIS112: 'solaris112',
75 RTE_SOLARIS113: 'solaris113',
76 RTE_SOLARIS114: 'solaris114',
77 RTE_SOLARIS115: 'solaris115',
78 RTE_SUNOS511: 'solaris11',
79 }
80 )
81
82
83 num2pretty.update(
84 {
85 RTE_SOLARIS: 'Solaris',
86 RTE_SOLARIS10: 'Solaris10',
87 RTE_SOLARIS11: 'Solaris11',
88 }
89 )
90
91
92 dist = ['', '', '', 'Solaris', '', '']
93
94 try:
95
96 if sys.platform.startswith('sunos5'):
97
98
99 dist[1] = platform.release()
100
101 if dist[1] == '5.10':
102 dist[0] = 'solaris10'
103 dist[1] = '10'
104 dist[2] = 'Solaris10'
105 dist[4] = (10, 0, 0)
106
107 elif dist[1] == '5.11':
108 dist[1] = platform.version()
109 dist[4] = decode_version_str_to_segments(dist[1])
110 dist[0] = 'solaris' + re.sub(r'[.]', '', dist[1])
111 dist[2] = 'Solaris11'
112
113 else:
114 raise PlatformIDsError("release not suppported: " + str(dist[1]))
115
116 elif os.path.exists('/etc/release'):
117
118
119 x = open('/etc/release')
120 _r = x.readline()
121 x.close()
122 _r = re.sub(r'[^S]*(Solaris) *([0-9.]*).*$', r'\1:\2', _r).split(':')
123
124 if _r[0] == 'Solaris':
125 _r = _r[1].split('.')
126 dist[0] = 'solaris' + _r[0]
127 dist[1] = _r[1]
128 dist[2] = 'Solaris' + _r[1]
129 dist[4] = decode_version_str_to_segments(_r[1])
130
131 else:
132 raise PlatformIDsError("release not suppported: " + str(dist[1]))
133
134
135 except PlatformIDsFileCheck:
136
137 pass
138
139
140 if dist[5] != 'solaris':
141
142 dist = ['solaris', '0.0.0', 'Solaris-0.0.0', 'Solaris', (0, 0, 0,), 'solaris']
143