diff --git a/NeoBoot/bin/utilsbh b/NeoBoot/bin/utilsbh new file mode 100644 index 0000000..d5dc9c9 --- /dev/null +++ b/NeoBoot/bin/utilsbh @@ -0,0 +1,189 @@ +from re import sub +from Tools.Directories import fileExists, resolveFilename, SCOPE_CURRENT_SKIN +import xml.etree.cElementTree +entities = [('ä', u'\xe4'), + ('ä', u'\xe4'), + ('ü', u'\xfc'), + ('ü', u'\xfc'), + ('ö', u'\xf6'), + ('ö', u'\xf6'), + ('Ä', u'\xc4'), + ('Ä', u'\xc4'), + ('Ü', u'\xdc'), + ('Ü', u'\xdc'), + ('Ö', u'\xd6'), + ('Ö', u'\xd6'), + ('ß', u'\xdf'), + ('ß', u'\xdf'), + ('…', u'...'), + ('–', u'-'), + (' ', u' '), + ('"', u'"'), + ('&', u'&'), + (''', u"'"), + ('<', u'<'), + ('>', u'>'), + ('<', u'<'), + ('>', u'>'), + (' ', u' '), + ('&', u'&'), + ('"', u'"'), + (''', u"'")] + +def nab_strip_html(html): + html = html.replace('\n', ' ') + html = sub('\\s\\s+', ' ', html) + html = sub('', '\n', html) + html = sub('', '\n', html) + html = sub('', '-', html) + html = html.replace('', '\n') + return nab_strip_pass1(html) + + +def nab_strip_pass1(html): + html = sub('<(.*?)>', '', html) + html.replace('Ä', '\xc3\x84') + html.replace('ä', '\xc3\xa4') + html.replace('ä', '\xc3\xa4') + html.replace('ü', '\xc3\xbc') + html.replace('ü', '\xc3\xbc') + html.replace('ö', '\xc3\xb6') + html.replace('ö', '\xc3\xb6') + html.replace('Ä', '\xc3\x84') + html.replace('Ä', '\xc3\x84') + html.replace('Ü', '\xc3\x9c') + html.replace('Ü', '\xc3\x9c') + html.replace('Ö', '\xc3\x96') + html.replace('Ö', '\xc3\x96') + html.replace('ß', '\xc3\x9f') + html.replace('ß', '\xc3\x9f') + html.replace('<', '<') + html.replace('>', '>') + html.replace(' ', ' ') + html.replace('&', '&') + html.replace('"', '"') + html.replace(''', "'") + return html + + +def nab_Read_CCCinfoCfg(): + myhost = '127.0.0.1' + myuser = mypass = '' + myport = '16001' + if fileExists('/etc/delcccaminfo'): + f = open('/etc/delcccaminfo', 'r') + for line in f.readlines(): + line = line.strip() + if line.find('HOST ADDRESS:') != -1: + myhost = line[13:] + elif line.find('WEBINFO USERNAME:') != -1: + myuser = line[17:] + elif line.find('WEBINFO PASSWORD:') != -1: + mypass = line[17:] + elif line.find('WEBINFO LISTEN PORT:') != -1: + myport = line[20:] + + f.close() + myurl = 'http://' + myhost + ':' + myport + if myuser and mypass: + myurl = 'http://' + myuser + ':' + mypass + '@' + myhost + ':' + myport + return [myhost, + myuser, + mypass, + myport, + myurl] + + +def nab_Write_CCCinfoCfg(mycfg): + out = open('/etc/delcccaminfo', 'w') + strview = 'HOST ADDRESS:' + mycfg[0] + '\n' + out.write(strview) + strview = 'WEBINFO USERNAME:' + mycfg[1] + '\n' + out.write(strview) + strview = 'WEBINFO PASSWORD:' + mycfg[2] + '\n' + out.write(strview) + strview = 'WEBINFO LISTEN PORT:' + mycfg[3] + '\n' + out.write(strview) + out.close() + + +def DeliteGetSkinPath(): + myskinpath = resolveFilename(SCOPE_CURRENT_SKIN, '') + if myskinpath == '/usr/share/enigma2/': + myskinpath = '/usr/share/enigma2/skin_default/' + return myskinpath + + +def nab_Detect_Machine(): + machine = 'dm8000' + if fileExists('/etc/bhmachine'): + f = open('/etc/bhmachine', 'r') + machine = f.readline().strip() + f.close() + return machine + + +def BhU_get_Version(): + ver = '' + if fileExists('/boot/blackhole/version'): + f = open('/boot/blackhole/version', 'r') + ver = f.readline().strip() + f.close() + return ver + + +def BhU_check_proc_version(): + ver = '' + if fileExists('/boot/blackhole/version'): + f = open('/boot/blackhole/version', 'r') + ver = f.readline().strip() + f.close() + return ver + + +def BhU_checkSkinVersion(skinfile): + version = '2.0.0' + authors = ['Army', 'Matrix10', 'capa'] + ret = 'Sorry this skin is not compatible with the current Black Hole image version.' + curversion = int(version.replace('.', '')) + fullfile = '/usr/share/enigma2/' + skinfile + checkver = False + checkauth = False + if fileExists(fullfile): + f = open(fullfile) + for line in f.readlines(): + if line.find('black hole version:') != -1: + parts = line.strip().split(':') + ver = int(parts[1].strip().replace('.', '')) + if ver >= curversion: + checkver = True + elif line.find('skin author:') != -1: + parts = line.strip().split(':') + auth = parts[1].strip() + for a in authors: + if a == auth: + checkauth = True + + f.close() + if checkver == True: + if checkauth == True: + ret = 'passed' + return ret + + +def BhU_find_hdd(): + hdd = '' + hdds = ['sda', + 'sdb', + 'sdc', + 'sdd', + 'sde', + 'sdf'] + for device in hdds: + filename = '/sys/block/%s/removable' % device + if fileExists(filename): + if file(filename).read().strip() == '0': + hdd = device + break + + return hdd \ No newline at end of file