-
Notifications
You must be signed in to change notification settings - Fork 10
/
open-multiboot-branding-helper.py
96 lines (90 loc) · 3.31 KB
/
open-multiboot-branding-helper.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#############################################################################
#
# Copyright (C) 2014 Impex-Sat Gmbh & Co.KG
# Written by Sandro Cavazzoni <sandro@skanetwork.com>
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#############################################################################
from __future__ import print_function
import sys
KEYS_FNC_MAP = {
'machine_build': 'boxbranding.getMachineBuild()',
'machine_proc_model': 'boxbranding.getMachineProcModel()',
'machine_brand': 'boxbranding.getMachineBrand()',
'machine_name': 'boxbranding.getMachineName()',
'machine_mtd_kernel': 'boxbranding.getMachineMtdKernel()',
'machine_kernel_file': 'boxbranding.getMachineKernelFile()',
'machine_mtd_root': 'boxbranding.getMachineMtdRoot()',
'machine_root_file': 'boxbranding.getMachineRootFile()',
'machine_mkubifs': 'boxbranding.getMachineMKUBIFS()',
'machine_ubinize': 'boxbranding.getMachineUBINIZE()',
'box_type': 'boxbranding.getBoxType()',
'brand_oem': 'boxbranding.getBrandOEM()',
'oe_version': 'boxbranding.getOEVersion()',
'driver_date': 'boxbranding.getDriverDate()',
'image_version': 'boxbranding.getImageVersion()',
'image_build': 'boxbranding.getImageBuild()',
'image_distro': 'boxbranding.getImageDistro()',
'image_folder': 'boxbranding.getImageFolder()',
'image_file_system': 'boxbranding.getImageFileSystem()'
}
def print_help():
print('Syntax:')
print(sys.argv[0] + ' enigma2_dir key')
print('')
print('Valid keys:')
for key in KEYS_FNC_MAP.keys():
print(' * ' + key)
print(' * all')
if len(sys.argv) != 3:
print_help()
else:
WORKAROUND = False
sys.path.insert(0, sys.argv[1])
try:
import boxbranding
except:
WORKAROUND = True
if not sys.argv[2] in KEYS_FNC_MAP and sys.argv[2] != 'all':
print_help()
else:
if sys.argv[2] == 'all':
for key in KEYS_FNC_MAP.keys():
print(key + ' = ' + eval(KEYS_FNC_MAP[key]))
else:
if WORKAROUND or (sys.argv[2] == 'image_distro' or sys.argv[2] == 'image_version'):
if sys.argv[2] == 'image_distro':
try:
print(open(sys.argv[1].replace("/usr/lib/enigma2/python", "") + "/etc/issue").readlines()[-2].capitalize().strip()[:-6])
except:
print("undefined")
elif sys.argv[2] == 'image_version':
print " "
elif sys.argv[2] == 'brand_oem':
try:
print(open(sys.argv[1].replace("/usr/lib/enigma2/python", "") + "/etc/.brand_oem").readline().strip())
except:
print(" ")
elif sys.argv[2] == 'box_type':
try:
print(open(sys.argv[1].replace("/usr/lib/enigma2/python", "") + "/etc/.box_type").readline().strip())
except:
print(" ")
else:
print("opps")
else:
print(eval(KEYS_FNC_MAP[sys.argv[2]]))