Package platformids ::
Package net ::
Module openwrt
1
2 """OpenWRT releases.
3 """
4 from __future__ import absolute_import
5
6 import re
7
8 from pythonids import PYV35Plus
9 from platformids import rte2num, num2rte, num2pretty, decode_version_str_to_segments, RTE_OPENWRT, \
10 DSKORG_ID, DSKORG_VERSION, 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.29'
18 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
19
20
21
22 RTE_OPENWRT17 = RTE_OPENWRT + 0x00004400
23 RTE_OPENWRT1701 = RTE_OPENWRT + 0x00004420
24 RTE_OPENWRT17016 = RTE_OPENWRT + 0x00004426
25
26 RTE_OPENWRT18 = RTE_OPENWRT + 0x00004800
27 RTE_OPENWRT1806 = RTE_OPENWRT + 0x000048c0
28 RTE_OPENWRT18061 = RTE_OPENWRT + 0x000048c1
29
30 RTE_OPENWRT19 = RTE_OPENWRT + 0x00004c00
31 RTE_OPENWRT1901 = RTE_OPENWRT + 0x00004c20
32 RTE_OPENWRT19011 = RTE_OPENWRT + 0x00004c21
33
34
35
36 rte2num.update(
37 {
38 'openwrt': RTE_OPENWRT,
39 'openwrt17016': RTE_OPENWRT17016,
40 'openwrt18061': RTE_OPENWRT18061,
41 RTE_OPENWRT17016: RTE_OPENWRT17016,
42 RTE_OPENWRT18061: RTE_OPENWRT18061,
43 RTE_OPENWRT: RTE_OPENWRT,
44 }
45 )
46
47
48
49 num2rte.update(
50 {
51 RTE_OPENWRT: 'openwrt',
52 RTE_OPENWRT17016: 'openwrt17016',
53 RTE_OPENWRT18061: 'openwrt18061',
54 }
55 )
56
57
58
59 num2pretty.update(
60 {
61 RTE_OPENWRT: 'OpenWRT',
62 RTE_OPENWRT17016: 'OpenWRT-17.01.6',
63 RTE_OPENWRT18061: 'OpenWRT-18.06.1',
64 }
65 )
66
67
68 dist = ['', '', '', 'OpenWRT', '', '']
69
70 try:
71
72 with open("/etc/os-release", 'r') as f:
73 for l in f:
74 if l.startswith('ID='):
75 dist[0] = dist[5] = DSKORG_ID.sub(r'\1', l)
76
77 elif l.startswith('VERSION='):
78 dist[1] = DSKORG_VERSION.sub(r'\1', l)
79
80 elif l.startswith('NAME='):
81 dist[2] = dist[3] = re.sub(r'.*NAME=["\']*([^\n"\']*)["\']*[\n]*.*$', '\\1', l)
82
83 if dist[0] == 'openwrt':
84 dist[2] = 'OpenWRT-' + dist[1]
85 dist[4] = decode_version_str_to_segments(dist[1])
86 dist[0] = 'openwrt%d%d%d' % (dist[4][0], dist[4][1], dist[4][2], )
87
88
89 except PlatformIDsFileCheck:
90
91 pass
92
93
94 if dist[5] != 'openwrt':
95
96 dist = ['openwrt', '0.0.0', 'OpenWRT-0.0.0', 'OpenWRT', (0, 0, 0,), 'openwrt']
97