8.19. platformids.dist.sles

Module SuSE Enterprise Linux - SLES [doc].

8.19.1. Source

 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
# -*- coding: utf-8 -*-
"""SLES releases.
"""
from __future__ import absolute_import

from platformids import RTE_SLES, rte2num, num2rte, num2pretty, decode_version_str_to_segments, \
    DSKORG_ID, DSKORG_VERSION, PlatformIDsFileCheck

__author__ = 'Arno-Can Uestuensoez'
__license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
__copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
                " @Ingenieurbuero Arno-Can Uestuensoez"
__version__ = '0.1.29'
__uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"



RTE_SLES15  = RTE_SLES       + 0x00003400  #: RHEL-5
RTE_SLES150 = RTE_SLES       + 0x00003c00  #: RHEL-15.0
RTE_SLES151 = RTE_SLES       + 0x00003c20  #: RHEL-15.1


#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
    {
        'sles15': RTE_SLES15,
        RTE_SLES15: RTE_SLES15,
    }
)


#: mapping of the rte numeric representation to the string value
num2rte.update(
    {
        RTE_SLES15: 'sles15',
    }
)

#: mapping of the rte numeric representation to the pretty string value
num2pretty.update(
    {
        RTE_SLES15: 'SLES15',
    }
)


dist = ['', '', '', 'SLES', '', '']

try:

    with open("/etc/os-release", 'r') as f:
        for l in f:
            if l.startswith('ID='):
                dist[5] = DSKORG_ID.sub(r'\1', l)

            elif l.startswith('VERSION='):  # priority though more widespread
                dist[1] = DSKORG_VERSION.sub(r'\1', l) 
            
            elif l.startswith('NAME='):
                dist[3] = DSKORG_ID.sub(r'\1', l)

    if dist[5] == 'sles':
        dist[4] = decode_version_str_to_segments(dist[1])
        dist[0] = '%s%d%d' % (dist[5], dist[4][0], dist[4][1],)   
        dist[2] = '%s-%d.%d.%d' % (dist[3], dist[4][0], dist[4][1], dist[4][2],)   


except PlatformIDsFileCheck:
    # not on SLES platform, so scan will fail
    pass    


if dist[5] != 'sles':
    # does not actually match SLES
    dist = ['sles', '0.0.0', 'SLES-0.0.0', 'SLES', (0, 0, 0,), 'sles']


8.19.2. Download

sles.py