Package platformids :: Package dist :: Module oraclelinux

Source Code for Module platformids.dist.oraclelinux

 1  # -*- coding: utf-8 -*- 
 2  """Oracle Enterprise Linux releases. 
 3  """ 
 4  from __future__ import absolute_import 
 5   
 6  import re 
 7   
 8  from pythonids import PYV35Plus 
 9  from platformids import RTE_LINUX, rte2num, num2rte, num2pretty, decode_version_str_to_segments, \ 
10      PlatformIDsFileCheck 
11   
12   
13  __author__ = 'Arno-Can Uestuensoez' 
14  __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints" 
15  __copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \ 
16                  " @Ingenieurbuero Arno-Can Uestuensoez" 
17  __version__ = '0.1.35' 
18  __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9" 
19   
20   
21   
22  RTE_OEL       = RTE_LINUX   + 0x00080000     #: Oracle Enterprise Linux 
23   
24  RTE_OEL6      = RTE_OEL     + 0x00001800  #: Oracle Enterprise Linux 6 
25  RTE_OEL6U9    = RTE_OEL     + 0x00001920  #: Oracle Enterprise Linux 6 Update-9 
26   
27  RTE_OEL7      = RTE_OEL     + 0x00001c00  #: Oracle Enterprise Linux 7 
28  RTE_OEL7U6    = RTE_OEL     + 0x00001cc0  #: Oracle Enterprise Linux 7 Update-6 
29       
30  RTE_OEL8      = RTE_OEL     + 0x00002000  #: Oracle Enterprise Linux 8 
31  RTE_OEL8U0    = RTE_OEL     + 0x00002000  #: Oracle Enterprise Linux 8 Update-0 
32  RTE_OEL8U1    = RTE_OEL     + 0x00002020  #: Oracle Enterprise Linux 8 Update-1 
33       
34  #: mapping of the rte string and numeric representation to the numeric value 
35  rte2num.update( 
36      { 
37          'oel': RTE_OEL, 
38          'oel6': RTE_OEL6, 
39          'oel6u9': RTE_OEL6U9, 
40          'oel7': RTE_OEL7, 
41          'oel7u6': RTE_OEL7U6, 
42          RTE_OEL: RTE_OEL, 
43          RTE_OEL6: RTE_OEL6, 
44          RTE_OEL6U9: RTE_OEL6U9, 
45          RTE_OEL7: RTE_OEL7, 
46          RTE_OEL7U6: RTE_OEL7U6, 
47      } 
48  ) 
49   
50   
51  #: mapping of the rte numeric representation to the string value 
52  num2rte.update( 
53      { 
54          RTE_OEL: 'oel', 
55          RTE_OEL6: 'oel6', 
56          RTE_OEL6U9: 'oel6u9', 
57          RTE_OEL7: 'oel7', 
58          RTE_OEL7U6: 'oel7u6', 
59      } 
60  ) 
61   
62  #: mapping of the rte numeric representation to the pretty string value 
63  num2pretty.update( 
64      { 
65          RTE_OEL: 'Oracle Linux', 
66          RTE_OEL6: 'Oracle Enterprise Linux 6', 
67          RTE_OEL6U9: 'Oracle Enterprise Linux 6 Update 9', 
68          RTE_OEL7: 'Oracle Enterprise Linux 7', 
69          RTE_OEL7U6: 'Oracle Enterprise Linux 7 Update 6', 
70      } 
71  ) 
72   
73   
74  dist = ['', '', '', 'OracleLinux', '', ''] 
75   
76  try: 
77   
78      with open("/etc/redhat-release", 'r') as f: 
79          for l in f: 
80              _d = re.split(r'(?s)^([^0-9]*) release *([0-9.]*[^ ]*) [^(]*[(]([^)]*)[)][\n\t ]*$', l) 
81       
82      if _d[1].startswith('Oracle'): 
83          dist[1] = _d[2] 
84          dist[4] = decode_version_str_to_segments(_d[2]) 
85          dist[0] = 'oel%d%d' % (dist[4][0], dist[4][1]) 
86          dist[2] = "OracleLinux-" + _d[2] 
87          dist[5] = 'oel' 
88   
89   
90  except PlatformIDsFileCheck: 
91      # not on OracleLinux platform, so scan will fail 
92      pass     
93   
94   
95  if dist[5] != 'oel': 
96      # does not actually match OracleLinux 
97      dist = ['oel', '0.0.0', 'OracleLinux-0.0.0', 'OracleLinux', (0, 0, 0,), 'oel'] 
98