diff --git a/NeoBoot/__init__.py b/NeoBoot/__init__.py index a76ce93..3d598c1 100644 --- a/NeoBoot/__init__.py +++ b/NeoBoot/__init__.py @@ -1,27 +1,28 @@ -# -*- coding: utf-8 -*- - - from Components.Language import language from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE import os import gettext -PluginLanguageDomain = 'NeoBoot' -PluginLanguagePath = 'Extensions/NeoBoot/locale' + +PluginLanguageDomain = "NeoBoot" +PluginLanguagePath = "Extensions/NeoBoot/locale" def localeInit(): lang = language.getLanguage()[:2] - os.environ['LANGUAGE'] = lang + os.environ["LANGUAGE"] = lang print("[NeoBoot] set language to "), lang - gettext.bindtextdomain(PluginLanguageDomain, resolveFilename( - SCOPE_PLUGINS, PluginLanguagePath)) + gettext.bindtextdomain( + PluginLanguageDomain, + resolveFilename( + SCOPE_PLUGINS, + PluginLanguagePath)) def _(txt): t = gettext.dgettext(PluginLanguageDomain, txt) if t == txt: print("[NeoBoot] fallback to default translation for"), txt - t = gettext.dgettext('enigma2', txt) + t = gettext.dgettext("enigma2", txt) return t diff --git a/NeoBoot/ex_init.py b/NeoBoot/ex_init.py index c8f64c5..1894814 100644 --- a/NeoBoot/ex_init.py +++ b/NeoBoot/ex_init.py @@ -1,9 +1,33 @@ -#!/usr/bin/python - import sys -from . import extract -if len(sys.argv) < 17: - pass +import extract + +if len(sys.argv) < 18: + print( + f"Error: Incorrect number of arguments. Expected 17, got { + len( + sys.argv) - + 1}", + file=sys.stderr, + ) + print(f"Usage: {sys.argv[0]} ... ", file=sys.stderr) + sys.exit(1) else: - extract.NEOBootMainEx(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], - sys.argv[9], sys.argv[10], sys.argv[11], sys.argv[12], sys.argv[13], sys.argv[14], sys.argv[15], sys.argv[16], sys.argv[17]) + extract.NEOBootMainEx( + sys.argv[1], + sys.argv[2], + sys.argv[3], + sys.argv[4], + sys.argv[5], + sys.argv[6], + sys.argv[7], + sys.argv[8], + sys.argv[9], + sys.argv[10], + sys.argv[11], + sys.argv[12], + sys.argv[13], + sys.argv[14], + sys.argv[15], + sys.argv[16], + sys.argv[17], + ) diff --git a/NeoBoot/extract.py b/NeoBoot/extract.py index 76511de..e9e7c9f 100644 --- a/NeoBoot/extract.py +++ b/NeoBoot/extract.py @@ -1,483 +1,790 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - +from __future__ import absolute_import import sys import os import struct import shutil - -# ver. gutosie -# --------------------------------------------- 2024 ---------------------------------------------# +import subprocess -def NEOBootMainEx(source, target, CopyFiles, CopyKernel, TvList, LanWlan, Sterowniki, Montowanie, InstallSettings, ZipDelete, RepairFTP, SoftCam, MediaPortal, PiconR, Kodi, BlackHole, Nandsim): - NEOBootR(source, target, CopyFiles, CopyKernel, TvList, LanWlan, Sterowniki, Montowanie, - InstallSettings, ZipDelete, RepairFTP, SoftCam, MediaPortal, PiconR, Kodi, BlackHole, Nandsim) +def NEOBootMainEx( + source, + target, + CopyFiles, + CopyKernel, + TvList, + LanWlan, + Sterowniki, + Montowanie, + InstallSettings, + ZipDelete, + RepairFTP, + SoftCam, + MediaPortal, + PiconR, + Kodi, + BlackHole, + Nandsim, +): + NEOBootR( + source, + target, + CopyFiles, + CopyKernel, + TvList, + LanWlan, + Sterowniki, + Montowanie, + InstallSettings, + ZipDelete, + RepairFTP, + SoftCam, + MediaPortal, + PiconR, + Kodi, + BlackHole, + Nandsim, + ) def LanguageUsed(): - language = '' - lang = open('/etc/enigma2/settings', 'r') - usedlang = 'config.osd.language=pl_PL' - bak = lang.read().find(usedlang) - if bak != -1: - language = 'Yes' - else: - language = 'No' + language = "" + usedlang = "config.osd.language=pl_PL" + try: + with open( + "/etc/enigma2/settings", "r", encoding="utf-8", errors="ignore" + ) as lang: + bak = lang.read().find(usedlang) + if bak != -1: + language = "Yes" + else: + language = "No" + except IOError: + language = "No" return language def getBoxHostName(): - if os.path.exists('/etc/hostname'): - with open('/etc/hostname', 'r') as f: - myboxname = f.readline().strip() - f.close() + myboxname = "unknown" + if os.path.exists("/etc/hostname"): + try: + with open("/etc/hostname", "r", encoding="utf-8", errors="ignore") as f: + myboxname = f.readline().strip() + except IOError: + pass return myboxname def getCPUSoC(): - chipset = 'UNKNOWN' - if os.path.exists('/proc/stb/info/chipset'): - with open('/proc/stb/info/chipset', 'r') as f: - chipset = f.readline().strip() - f.close() - if chipset == '7405(with 3D)': - chipset == '7405' - + chipset = "UNKNOWN" + if os.path.exists("/proc/stb/info/chipset"): + try: + with open( + "/proc/stb/info/chipset", "r", encoding="utf-8", errors="ignore" + ) as f: + chipset = f.readline().strip() + if chipset == "7405(with 3D)": + chipset = "7405" + except IOError: + pass return chipset def getBoxVuModel(): - vumodel = 'UNKNOWN' - if os.path.exists("/proc/stb/info/vumodel") and not os.path.exists("/proc/stb/info/boxtype"): - with open('/proc/stb/info/vumodel', 'r') as f: - vumodel = f.readline().strip() - f.close() + vumodel = "UNKNOWN" + if os.path.exists("/proc/stb/info/vumodel") and not os.path.exists( + "/proc/stb/info/boxtype" + ): + try: + with open( + "/proc/stb/info/vumodel", "r", encoding="utf-8", errors="ignore" + ) as f: + vumodel = f.readline().strip() + except IOError: + pass return vumodel def getCPUtype(): - cpu = 'UNKNOWN' - if os.path.exists('/proc/cpuinfo'): - with open('/proc/cpuinfo', 'r') as f: - lines = f.read() - f.close() - if lines.find('ARMv7') != -1: - cpu = 'ARMv7' - elif lines.find('mips') != -1: - cpu = 'MIPS' + cpu = "UNKNOWN" + if os.path.exists("/proc/cpuinfo"): + try: + with open("/proc/cpuinfo", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "ARMv7" in lines: + cpu = "ARMv7" + elif "mips" in lines: + cpu = "MIPS" + except IOError: + pass return cpu def getKernelVersion(): - if not os.path.exists('/tmp/.isnandsim'): - if os.system('opkg list-installed | grep kernel-module-nandsim' + dev_null) != 0: - os.system('touch /tmp/.isnandsim') + if not os.path.exists("/tmp/.isnandsim"): + if ( + os.system("opkg list-installed | grep kernel-module-nandsim" + dev_null) + != 0 + ): + os.system("touch /tmp/.isnandsim") - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm520') or os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm525'): + if os.path.exists("" + + getNeoLocation() + + "ImagesUpload/dm520") or os.path.exists("" + + getNeoLocation() + + "ImagesUpload/dm525"): try: - result = popen('uname -r', 'r').read().strip('\n').split('-') + result = ( + subprocess.check_output(["uname", "-r"], text=True, errors="ignore") + .strip("\n") + .split("-") + ) kernel_version = result[0] return kernel_version - except: - os.system('uname -r > /tmp/.uname_r') - return open('/tmp/.uname_r').read().strip().upper() + except Exception: + os.system("uname -r > /tmp/.uname_r") + try: + with open("/tmp/.uname_r", "r", encoding="utf-8", errors="ignore") as f: + return f.read().strip().upper() + except IOError: + return "UNKNOWN" else: try: - return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] - except: - os.system('uname -r > /tmp/.uname_r') - return open('/tmp/.uname_r').read().strip().upper() + with open("/proc/version", "r", encoding="utf-8", errors="ignore") as f: + return f.read().split(" ", 4)[2].split("-", 2)[0] + except Exception: + os.system("uname -r > /tmp/.uname_r") + try: + with open("/tmp/.uname_r", "r", encoding="utf-8", errors="ignore") as f: + return f.read().strip().upper() + except IOError: + return "UNKNOWN" def getNeoLocation(): - locatino = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: - locatino = f.readline().strip() - f.close() + locatino = "UNKNOWN" + if os.path.exists( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location"): + try: + with open( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location", + "r", + encoding="utf-8", + errors="ignore", + ) as f: + locatino = f.readline().strip() + except IOError: + pass return locatino media = getNeoLocation() -mediahome = media + '/ImageBoot/' -extensions_path = '/usr/lib/enigma2/python/Plugins/Extensions/' -dev_null = ' > /dev/null 2>&1' -supportedTuners = 'vuplus' +mediahome = media + "/ImageBoot/" +extensions_path = "/usr/lib/enigma2/python/Plugins/Extensions/" +dev_null = " > /dev/null 2>&1" +supportedTuners = "vuplus" -def NEOBootMainEx(source, target, CopyFiles, CopyKernel, TvList, LanWlan, Sterowniki, Montowanie, InstallSettings, ZipDelete, RepairFTP, SoftCam, MediaPortal, PiconR, Kodi, BlackHole, Nandsim): +def NEOBootMainEx( + source, + target, + CopyFiles, + CopyKernel, + TvList, + LanWlan, + Sterowniki, + Montowanie, + InstallSettings, + ZipDelete, + RepairFTP, + SoftCam, + MediaPortal, + PiconR, + Kodi, + BlackHole, + Nandsim, +): media_target = mediahome + target - list_one = ['rm -r ' + media_target + dev_null, 'mkdir ' + - media_target + dev_null, 'chmod -R 0777 ' + media_target] + list_one = [ + "rm -r " + media_target + dev_null, + "mkdir " + media_target + dev_null, + "chmod -R 0777 " + media_target, + ] for command in list_one: os.system(command) rc = NEOBootExtract(source, target, ZipDelete, Nandsim) - os.system('sync; echo 1 > /proc/sys/vm/drop_caches') + os.system("sync; echo 1 > /proc/sys/vm/drop_caches") - if not os.path.exists('%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions' % (media, target)): - os.system('mkdir -p %s/ImageBoot/%s/usr/lib/' % (media, target)) - os.system('mkdir -p %s/ImageBoot/%s/usr/lib/enigma2' % (media, target)) - os.system('mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python' % - (media, target)) + if not os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions" % + (media, target)): + os.system("mkdir -p %s/ImageBoot/%s/usr/lib/" % (media, target)) + os.system("mkdir -p %s/ImageBoot/%s/usr/lib/enigma2" % (media, target)) os.system( - 'mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins' % (media, target)) + "mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python" % + (media, target)) os.system( - 'mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions' % (media, target)) + "mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins" % + (media, target)) + os.system( + "mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions" % + (media, target)) - if os.path.exists('%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' % (media, target)): + if os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + % (media, target) + ): os.system( - 'rm -r %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' % (media, target)) + "rm -r %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" % + (media, target)) - list_two = ['mkdir -p ' + media_target + '/media' + dev_null, - 'rm ' + media_target + media + dev_null, - 'rmdir ' + media_target + media + dev_null, - 'mkdir -p ' + media_target + media + dev_null, - # 'cp /etc/passwd ' + media_target + '/etc/passwd' + dev_null, - # 'cp ' + extensions_path + 'NeoBoot/bin/hdd' + media_target+'/etc/init.d/hddusb' + dev_null, - 'cp /etc/hostname ' + media_target + '/etc/hostname' + dev_null, - 'cp -a /usr/share/enigma2/rc_models/* ' + media_target + - '/usr/share/enigma2/rc_models/' + dev_null, - 'cp -r -p /usr/share/enigma2/rc_models ' + - media_target + '/usr/share/enigma2' + dev_null, - 'cp -af ' + extensions_path + 'NeoBoot ' + - media_target + extensions_path + 'NeoBoot' + dev_null, - 'mkdir -p ' + media_target + extensions_path + 'NeoReboot' + dev_null, - 'touch ' + media_target + extensions_path + 'NeoReboot/__init__.py' + dev_null, - 'chmod 644 ' + media_target + extensions_path + - 'NeoReboot/__init__.py' + dev_null, - 'cp -af ' + extensions_path + 'NeoBoot/files/backflash ' + - media_target + extensions_path + 'NeoReboot/backflash.sh' + dev_null, - 'cp -af ' + extensions_path + 'NeoBoot/files/neoreboot ' + media_target + extensions_path + 'NeoReboot/plugin.py' + dev_null] + list_two = [ + "mkdir -p " + + media_target + + "/media" + + dev_null, + "rm " + + media_target + + media + + dev_null, + "rmdir " + + media_target + + media + + dev_null, + "mkdir -p " + + media_target + + media + + dev_null, + "cp /etc/hostname " + + media_target + + "/etc/hostname" + + dev_null, + "cp -a /usr/share/enigma2/rc_models/* " + + media_target + + "/usr/share/enigma2/rc_models/" + + dev_null, + "cp -r -p /usr/share/enigma2/rc_models " + + media_target + + "/usr/share/enigma2" + + dev_null, + "cp -af " + + extensions_path + + "NeoBoot " + + media_target + + extensions_path + + "NeoBoot" + + dev_null, + "mkdir -p " + + media_target + + extensions_path + + "NeoReboot" + + dev_null, + "touch " + + media_target + + extensions_path + + "NeoReboot/__init__.py" + + dev_null, + "chmod 644 " + + media_target + + extensions_path + + "NeoReboot/__init__.py" + + dev_null, + "cp -af " + + extensions_path + + "NeoBoot/files/backflash " + + media_target + + extensions_path + + "NeoReboot/backflash.sh" + + dev_null, + "cp -af " + + extensions_path + + "NeoBoot/files/neoreboot " + + media_target + + extensions_path + + "NeoReboot/plugin.py" + + dev_null, + ] for command in list_two: os.system(command) - if CopyFiles == 'False': + if CopyFiles == "False": os.system('echo "No copying of files..."') - os.system('touch ' + getNeoLocation() + - 'ImageBoot/.without_copying; sleep 5') + os.system( + "touch " + + getNeoLocation() + + "ImageBoot/.without_copying; sleep 5") - if CopyKernel == 'True': - # mips vuplus - if getBoxHostName() == 'vuultimo' or getCPUSoC() == '7405' and os.path.exists('%s/ImageBoot/%s/etc/vtiversion.info' % (media, target)): - if os.path.exists('%s/ImageBoot/%s/lib/modules' % (media, target)): - cmd = 'rm -r %s/ImageBoot/%s/lib/modules' % (media, target) + if CopyKernel == "True": + if ( + getBoxHostName() == "vuultimo" + or getCPUSoC() == "7405" + and os.path.exists("%s/ImageBoot/%s/etc/vtiversion.info" % (media, target)) + ): + if os.path.exists("%s/ImageBoot/%s/lib/modules" % (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/modules" % (media, target) rc = os.system(cmd) - cmd = 'mkdir -p %s/ImageBoot/%s/lib/modules > /dev/null 2>&1' % ( - media, target) + cmd = "mkdir -p %s/ImageBoot/%s/lib/modules > /dev/null 2>&1" % ( + media, + target, + ) rc = os.system(cmd) - cmd = 'cp -af /lib/modules %s/ImageBoot/%s/lib > /dev/null 2>&1' % ( - media, target) + cmd = "cp -af /lib/modules %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) - if os.path.exists('%s/ImageBoot/%s/lib/firmware' % (media, target)): - cmd = 'rm -r %s/ImageBoot/%s/lib/firmware' % (media, target) + if os.path.exists( + "%s/ImageBoot/%s/lib/firmware" % + (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/firmware" % (media, target) rc = os.system(cmd) - cmd = 'mkdir -p %s/ImageBoot/%s/lib/firmware > /dev/null 2>&1' % ( - media, target) + cmd = "mkdir -p %s/ImageBoot/%s/lib/firmware > /dev/null 2>&1" % ( + media, + target, + ) rc = os.system(cmd) - cmd = 'cp -af /lib/firmware %s/ImageBoot/%s/lib > /dev/null 2>&1' % ( - media, target) + cmd = "cp -af /lib/firmware %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) os.system( - 'echo "Copied system drivers. Not recommended copied kernel.bin for Ultimo HD."') - elif getCPUtype() == "MIPS" and getBoxHostName() == 'vuultimo' or getBoxHostName() == 'bm750' or getBoxHostName() == 'vuduo' or getBoxHostName() == 'vuuno' or getBoxHostName() == 'vusolo' or getBoxHostName() == 'vuduo' or getBoxHostName() == 'vusolo2' or getBoxHostName() == 'vusolose' or getBoxHostName() == 'vuduo2' or getBoxHostName() == 'vuzero' or getBoxHostName() == 'mbultra': - os.system('mv ' + getNeoLocation() + 'ImagesUpload/vuplus/' + getBoxVuModel() + - '/kernel_cfe_auto.bin ' + media_target + '/boot/' + getBoxHostName() + '.vmlinux.gz' + dev_null) + 'echo "Copied system drivers. Not recommended copied kernel.bin for Ultimo HD."' + ) + elif ( + getCPUtype() == "MIPS" + and getBoxHostName() == "vuultimo" + or getBoxHostName() == "bm750" + or getBoxHostName() == "vuduo" + or getBoxHostName() == "vuuno" + or getBoxHostName() == "vusolo" + or getBoxHostName() == "vuduo" + or getBoxHostName() == "vusolo2" + or getBoxHostName() == "vusolose" + or getBoxHostName() == "vuduo2" + or getBoxHostName() == "vuzero" + or getBoxHostName() == "mbultra" + ): + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/vuplus/" + + getBoxVuModel() + + "/kernel_cfe_auto.bin " + + media_target + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz" + + dev_null + ) os.system('echo "Copied kernel.bin STB-MIPS"') - elif getCPUtype() == "MIPS" and getBoxHostName() == 'et5x00': - os.system('mv ' + getNeoLocation() + 'ImagesUpload/' + getBoxHostName() + - '/kernel.bin ' + media_target + '/boot/' + getBoxHostName() + '.vmlinux.gz' + dev_null) + elif getCPUtype() == "MIPS" and getBoxHostName() == "et5x00": + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + getBoxHostName() + + "/kernel.bin " + + media_target + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz" + + dev_null + ) os.system('echo "Copied kernel.bin STB-MIPS Clarke-Tech & Xtrend"') - # arm vuplus arms - elif getCPUtype() == "ARMv7" and getBoxHostName() == "vuultimo4k" or getBoxHostName() == "vusolo4k" or getBoxHostName() == "vuuno4k" or getBoxHostName() == "vuuno4kse" or getBoxHostName() == "vuduo4k" or getBoxHostName() == "vuduo4kse" or getBoxHostName() == "vuzero4k": - os.system('mv ' + getNeoLocation() + 'ImagesUpload/vuplus/' + getBoxVuModel() + - '/kernel_auto.bin ' + media_target + '/boot/zImage.' + getBoxHostName() + '' + dev_null) + elif ( + getCPUtype() == "ARMv7" + and getBoxHostName() == "vuultimo4k" + or getBoxHostName() == "vusolo4k" + or getBoxHostName() == "vuuno4k" + or getBoxHostName() == "vuuno4kse" + or getBoxHostName() == "vuduo4k" + or getBoxHostName() == "vuduo4kse" + or getBoxHostName() == "vuzero4k" + ): + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/vuplus/" + + getBoxVuModel() + + "/kernel_auto.bin " + + media_target + + "/boot/zImage." + + getBoxHostName() + + "" + + dev_null + ) os.system('echo "Copied kernel.bin STB-ARM"') - if not os.path.exists('' + getNeoLocation() + 'ImageBoot/.without_copying'): - if os.path.exists('/usr/sbin/nandwrite'): - cmd = 'cp -af /usr/sbin/nandwrite %s/ImageBoot/%s/usr/sbin/nandwrite > /dev/null 2>&1' % ( - media, target) + if not os.path.exists( + "" + + getNeoLocation() + + "ImageBoot/.without_copying"): + if os.path.exists("/usr/sbin/nandwrite"): + cmd = ( + "cp -af /usr/sbin/nandwrite %s/ImageBoot/%s/usr/sbin/nandwrite > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/usr/bin/fullwget'): - cmd = 'cp -af /usr/bin/fullwget %s/ImageBoot/%s/usr/bin/fullwget > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/usr/bin/fullwget"): + cmd = ( + "cp -af /usr/bin/fullwget %s/ImageBoot/%s/usr/bin/fullwget > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/etc/init.d/inadyn-mt'): - cmd = 'cp -af /etc/init.d/inadyn-mt %s/ImageBoot/%s/etc/init.d/inadyn-mt > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/init.d/inadyn-mt"): + cmd = ( + "cp -af /etc/init.d/inadyn-mt %s/ImageBoot/%s/etc/init.d/inadyn-mt > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/usr/bin/inadyn-mt'): - cmd = 'cp -af /usr/bin/inadyn-mt %s/ImageBoot/%s/usr/bin/inadyn-mt > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/usr/bin/inadyn-mt"): + cmd = ( + "cp -af /usr/bin/inadyn-mt %s/ImageBoot/%s/usr/bin/inadyn-mt > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/etc/inadyn.conf'): - cmd = 'cp -af /etc/inadyn.conf %s/ImageBoot/%s/etc/inadyn.conf > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/inadyn.conf"): + cmd = ( + "cp -af /etc/inadyn.conf %s/ImageBoot/%s/etc/inadyn.conf > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/usr/lib/enigma2/python/Plugins/SystemPlugins/FanControl'): - cmd = 'cp -af /usr/lib/enigma2/python/Plugins/SystemPlugins/FanControl %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/SystemPlugins > /dev/null 2>&1' % ( - media, target) + if os.path.exists( + "/usr/lib/enigma2/python/Plugins/SystemPlugins/FanControl"): + cmd = ( + "cp -af /usr/lib/enigma2/python/Plugins/SystemPlugins/FanControl %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/SystemPlugins > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'EmuManager'): - cmd = 'cp -af ' + extensions_path + \ - 'EmuManager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "EmuManager"): + cmd = ( + "cp -af " + + extensions_path + + "EmuManager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'CamdMenager'): - cmd = 'cp -af ' + extensions_path + \ - 'CamdMenager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "CamdMenager"): + cmd = ( + "cp -af " + + extensions_path + + "CamdMenager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'IPTVPlayer'): - cmd = 'cp -af ' + extensions_path + \ - 'IPTVPlayer %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "IPTVPlayer"): + cmd = ( + "cp -af " + + extensions_path + + "IPTVPlayer %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - cmd = 'cp /usr/lib/python*.*/htmlentitydefs.pyo %s/ImageBoot/%s/usr/lib/python*.* > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp /usr/lib/python*.*/htmlentitydefs.pyo %s/ImageBoot/%s/usr/lib/python*.* > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'FeedExtra'): - cmd = 'cp -af ' + extensions_path + \ - 'FeedExtra %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "FeedExtra"): + cmd = ( + "cp -af " + + extensions_path + + "FeedExtra %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'MyUpdater'): - cmd = 'cp -af ' + extensions_path + \ - 'MyUpdater %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "MyUpdater"): + cmd = ( + "cp -af " + + extensions_path + + "MyUpdater %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'AlternativeSoftCamManager'): - cmd = 'cp -af ' + extensions_path + \ - 'AlternativeSoftCamManager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "AlternativeSoftCamManager"): + cmd = ( + "cp -af " + + extensions_path + + "AlternativeSoftCamManager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - if os.path.exists('' + extensions_path + 'TempFanControl'): - cmd = 'cp -af ' + extensions_path + \ - 'TempFanControl %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/TempFanControl > /dev/null 2>&1' % ( - media, target) + if os.path.exists("" + extensions_path + "TempFanControl"): + cmd = ( + "cp -af " + + extensions_path + + "TempFanControl %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/TempFanControl > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - if not os.path.exists('%s/ImageBoot/%s/usr/lib/enigma2/python/boxbranding.so' % (media, target)): - cmd = 'cp -af /usr/lib/enigma2/python/boxbranding.so %s/ImageBoot/%s/usr/lib/enigma2/python/boxbranding.so > /dev/null 2>&1' % ( - media, target) + if not os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/boxbranding.so" % + (media, target)): + cmd = ( + "cp -af /usr/lib/enigma2/python/boxbranding.so %s/ImageBoot/%s/usr/lib/enigma2/python/boxbranding.so > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/HbbTV' % (media, target)): + if os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/HbbTV" + % (media, target) + ): os.system( - 'rm -rf %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/HbbTV' % (media, target)) + "rm -rf %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/HbbTV" % + (media, target)) - if TvList == 'True': - if not os.path.exists('%s/ImageBoot/%s/etc/enigma2' % (media, target)): - cmd = 'mkdir -p %s/ImageBoot/%s/etc/enigma2' % (media, target) + if TvList == "True": + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % (media, target) rc = os.system(cmd) - cmd = 'cp /etc/enigma2/*.tv %s/ImageBoot/%s/etc/enigma2' % ( + cmd = "cp /etc/enigma2/*.tv %s/ImageBoot/%s/etc/enigma2" % ( media, target) rc = os.system(cmd) - cmd = 'cp /etc/enigma2/*.radio %s/ImageBoot/%s/etc/enigma2' % ( + cmd = "cp /etc/enigma2/*.radio %s/ImageBoot/%s/etc/enigma2" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "cp /etc/enigma2/*.tv %s/ImageBoot/%s/etc/enigma2" % ( media, target) rc = os.system(cmd) - cmd = 'cp /etc/enigma2/*.tv %s/ImageBoot/%s/etc/enigma2' % ( - media, target) - rc = os.system(cmd) - cmd = 'cp /etc/enigma2/lamedb %s/ImageBoot/%s/etc/enigma2' % ( + cmd = "cp /etc/enigma2/lamedb %s/ImageBoot/%s/etc/enigma2" % ( media, target) rc = os.system(cmd) os.system('echo "Copied TV list..."') - if LanWlan == 'True': - if os.path.exists('%s/ImageBoot/%s/etc/vtiversion.info' % (media, target)): + if LanWlan == "True": + if os.path.exists( + "%s/ImageBoot/%s/etc/vtiversion.info" % + (media, target)): os.system( 'echo "Not copied LAN-WLAN, not recommended for this image."') - elif os.path.exists('/etc/vtiversion.info') and os.path.exists('%s/usr/lib/enigma2/python/Plugins/PLi' % (media, target)): + elif os.path.exists("/etc/vtiversion.info") and os.path.exists( + "%s/usr/lib/enigma2/python/Plugins/PLi" % (media, target) + ): os.system( 'echo "Not copied LAN-WLAN, not recommended for this image."') - elif os.path.exists('/etc/bhversion') and os.path.exists('%s/usr/lib/enigma2/python/Plugins/PLi' % (media, target)): + elif os.path.exists("/etc/bhversion") and os.path.exists( + "%s/usr/lib/enigma2/python/Plugins/PLi" % (media, target) + ): os.system( 'echo "Not copied LAN-WLAN, not recommended for this image."') - if os.path.exists('/etc/wpa_supplicant.wlan0.conf'): - cmd = 'cp -af /etc/wpa_supplicant.wlan0.conf %s/ImageBoot/%s/etc/wpa_supplicant.wlan0.conf > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/wpa_supplicant.wlan0.conf"): + cmd = ( + "cp -af /etc/wpa_supplicant.wlan0.conf %s/ImageBoot/%s/etc/wpa_supplicant.wlan0.conf > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/etc/network/interfaces'): - cmd = 'cp -af /etc/network/interfaces %s/ImageBoot/%s/etc/network/interfaces > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/network/interfaces"): + cmd = ( + "cp -af /etc/network/interfaces %s/ImageBoot/%s/etc/network/interfaces > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/etc/wpa_supplicant.conf'): - cmd = 'cp -af /etc/wpa_supplicant.conf %s/ImageBoot/%s/etc/wpa_supplicant.conf > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/wpa_supplicant.conf"): + cmd = ( + "cp -af /etc/wpa_suppligetinstallscant.conf %s/ImageBoot/%s/etc/wpa_supplicant.conf > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/etc/resolv.conf'): - cmd = 'cp -af /etc/resolv.conf %s/ImageBoot/%s/etc/resolv.conf > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/resolv.conf"): + cmd = ( + "cp -af /etc/resolv.conf %s/ImageBoot/%s/etc/resolv.conf > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if os.path.exists('/etc/wl.conf.wlan3'): - cmd = 'cp -af /etc/wl.conf.wlan3 %s/ImageBoot/%s/etc/wl.conf.wlan3 > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/wl.conf.wlan3"): + cmd = ( + "cp -af /etc/wl.conf.wlan3 %s/ImageBoot/%s/etc/wl.conf.wlan3 > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) os.system('echo "Copied LAN-WLAN..."') - if Sterowniki == 'True': - if os.path.exists('%s/ImageBoot/%s/lib/modules' % (media, target)): - cmd = 'rm -r %s/ImageBoot/%s/lib/modules' % (media, target) + if Sterowniki == "True": + if os.path.exists("%s/ImageBoot/%s/lib/modules" % (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/modules" % (media, target) rc = os.system(cmd) - cmd = 'mkdir -p %s/ImageBoot/%s/lib/modules > /dev/null 2>&1' % ( - media, target) + cmd = "mkdir -p %s/ImageBoot/%s/lib/modules > /dev/null 2>&1" % ( + media, + target, + ) rc = os.system(cmd) - cmd = 'cp -af /lib/modules %s/ImageBoot/%s/lib > /dev/null 2>&1' % ( - media, target) + cmd = "cp -af /lib/modules %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) - if os.path.exists('%s/ImageBoot/%s/lib/firmware' % (media, target)): - cmd = 'rm -r %s/ImageBoot/%s/lib/firmware' % (media, target) + if os.path.exists( + "%s/ImageBoot/%s/lib/firmware" % + (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/firmware" % (media, target) rc = os.system(cmd) - cmd = 'mkdir -p %s/ImageBoot/%s/lib/firmware > /dev/null 2>&1' % ( - media, target) + cmd = "mkdir -p %s/ImageBoot/%s/lib/firmware > /dev/null 2>&1" % ( + media, + target, + ) rc = os.system(cmd) - cmd = 'cp -af /lib/firmware %s/ImageBoot/%s/lib > /dev/null 2>&1' % ( - media, target) + cmd = "cp -af /lib/firmware %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) os.system('echo "System drivers copied..."') - if Montowanie == 'True': + if Montowanie == "True": if getCPUtype() == "MIPS": - if os.path.exists('%s/ImageBoot/%s/etc/fstab' % (media, target)): - cmd = 'mv %s/ImageBoot/%s/etc/fstab %s/ImageBoot/%s/etc/fstab.org' % (media, - target, - media, - target) + if os.path.exists( + "%s/ImageBoot/%s/etc/fstab" % + (media, target)): + cmd = ( + "mv %s/ImageBoot/%s/etc/fstab %s/ImageBoot/%s/etc/fstab.org" % + (media, target, media, target)) rc = os.system(cmd) - if os.path.exists('%s/ImageBoot/%s/etc/init.d/volatile-media.sh' % (media, target)): - cmd = 'mv %s/ImageBoot/%s/etc/init.d/volatile-media.sh %s/ImageBoot/%s/etc/init.d/volatile-media.sh.org' % (media, - target, - media, - target) + if os.path.exists( + "%s/ImageBoot/%s/etc/init.d/volatile-media.sh" % + (media, target)): + cmd = ( + "mv %s/ImageBoot/%s/etc/init.d/volatile-media.sh %s/ImageBoot/%s/etc/init.d/volatile-media.sh.org" % + (media, target, media, target)) rc = os.system(cmd) - cmd = 'cp -r /etc/fstab %s/ImageBoot/%s/etc/fstab' % ( + cmd = "cp -r /etc/fstab %s/ImageBoot/%s/etc/fstab" % ( media, target) rc = os.system(cmd) os.system('echo "The fstab mount file was copied..."') elif getCPUtype() == "ARMv7": os.system('echo "No copied mount ARM..."') - if InstallSettings == 'True': - if not os.path.exists('%s/ImageBoot/%s/etc/enigma2' % (media, target)): - cmd = 'mkdir -p %s/ImageBoot/%s/etc/enigma2' % (media, target) + if InstallSettings == "True": + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % (media, target) rc = os.system(cmd) - cmd = 'cp /etc/enigma2/settings %s/ImageBoot/%s/etc/enigma2' % ( - media, target) + cmd = "cp /etc/enigma2/settings %s/ImageBoot/%s/etc/enigma2" % ( + media, + target, + ) rc = os.system(cmd) - if not os.path.exists('%s/ImageBoot/%s/etc/tuxbox/config' % (media, target)): - cmd = 'mkdir -p /etc/tuxbox/config %s/ImageBoot/%s/etc/tuxbox/config' % ( - media, target) + if not os.path.exists( + "%s/ImageBoot/%s/etc/tuxbox/config" % (media, target) + ): + cmd = ( + "mkdir -p /etc/tuxbox/config %s/ImageBoot/%s/etc/tuxbox/config" % + (media, target)) rc = os.system(cmd) - cmd = 'mkdir -p /etc/tuxbox/scce %s/ImageBoot/%s/etc/tuxbox/scce' % ( - media, target) + cmd = "mkdir -p /etc/tuxbox/scce %s/ImageBoot/%s/etc/tuxbox/scce" % ( + media, target, ) rc = os.system(cmd) - cmd = 'cp -af /etc/tuxbox/* %s/ImageBoot/%s/etc/tuxbox' % ( + cmd = "cp -af /etc/tuxbox/* %s/ImageBoot/%s/etc/tuxbox" % ( media, target) rc = os.system(cmd) os.system( 'touch /tmp/settings_copied; echo "System settings copied..."') - if RepairFTP == 'True': - if os.path.exists('%s/ImageBoot/%s/etc/vsftpd.conf' % (media, target)): - filename = media + '/ImageBoot/' + target + '/etc/vsftpd.conf' - if os.path.exists(filename): - filename2 = filename + '.tmp' - out = open(filename2, 'w') - f = open(filename, 'r') - for line in f.readlines(): - if line.find('listen=NO') != -1: - line = 'listen=YES\n' - elif line.find('listen_ipv6=YES') != -1: - line = 'listen_ipv6=NO\n' - out.write(line) + if RepairFTP == "True": + filename = media + "/ImageBoot/" + target + "/etc/vsftpd.conf" + if os.path.exists(filename): + filename2 = filename + ".tmp" + try: + with open(filename, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + + with open(filename2, "w", encoding="utf-8", errors="ignore") as out: + for line in lines: + if line.find("listen=NO") != -1: + line = "listen=YES\n" + elif line.find("listen_ipv6=YES") != -1: + line = "listen_ipv6=NO\n" + out.write(line) - f.close() - out.close() os.rename(filename2, filename) + except Exception as e: + os.system(f'echo "Failed to patch {filename}: {e}"') + if os.path.exists(filename2): + os.remove(filename2) os.system('echo "Repair ftp."') - if SoftCam == 'True': - if os.path.exists('/etc/CCcam.cfg'): - cmd = 'cp -af /etc/CCcam.cfg %s/ImageBoot/%s/etc > /dev/null 2>&1' % ( - media, target) + if SoftCam == "True": + if os.path.exists("/etc/CCcam.cfg"): + cmd = "cp -af /etc/CCcam.cfg %s/ImageBoot/%s/etc > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) - if os.path.exists('/etc/tuxbox/config'): - cmd = 'cp -af /etc/tuxbox/config %s/ImageBoot/%s/etc/tuxbox > /dev/null 2>&1' % ( - media, target) + if os.path.exists("/etc/tuxbox/config"): + cmd = ( + "cp -af /etc/tuxbox/config %s/ImageBoot/%s/etc/tuxbox > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) os.system('echo "Copied softcam files to the installed image..."') - if MediaPortal == 'True': - if os.path.exists('' + extensions_path + 'MediaPortal'): - cmd = 'cp -af ' + extensions_path + \ - 'MediaPortal %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + if MediaPortal == "True": + if os.path.exists("" + extensions_path + "MediaPortal"): + cmd = ( + "cp -af " + + extensions_path + + "MediaPortal %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - cmd = 'cp -af ' + extensions_path + \ - 'mpgz %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af " + + extensions_path + + "mpgz %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/python2.7/argparse.pyo %s/ImageBoot/%s/usr/lib/python2.7 > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af /usr/lib/python2.7/argparse.pyo %s/ImageBoot/%s/usr/lib/python2.7 > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/python2.7/robotparser.pyo %s/ImageBoot/%s/usr/lib/python2.7 > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af /usr/lib/python2.7/robotparser.pyo %s/ImageBoot/%s/usr/lib/python2.7 > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/python2.7/site-packages/Crypto %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/Crypto %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/python2.7/site-packages/mechanize %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/mechanize %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/python2.7/site-packages/requests %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/requests %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/python2.7/site-packages/requests-2.11.1-py2.7.egg-info %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1' % ( - media, target) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/requests-2.11.1-py2.7.egg-info %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) rc = os.system(cmd) - if not os.path.exists('%s/ImageBoot/%s/etc/enigma2' % (media, target)): - cmd = 'mkdir -p %s/ImageBoot/%s/etc/enigma2' % ( + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % ( media, target) rc = os.system(cmd) - if os.path.exists('/etc/enigma2/mp_2s4p'): - cmd = 'cp /etc/enigma2/mp_2s4p %s/ImageBoot/%s/etc/enigma2' % ( - media, target) + if os.path.exists("/etc/enigma2/mp_2s4p"): + cmd = "cp /etc/enigma2/mp_2s4p %s/ImageBoot/%s/etc/enigma2" % ( + media, target, ) rc = os.system(cmd) - if os.path.exists('/etc/enigma2/mp_config'): - cmd = 'cp /etc/enigma2/mp_config %s/ImageBoot/%s/etc/enigma2' % ( - media, target) + if os.path.exists("/etc/enigma2/mp_config"): + cmd = "cp /etc/enigma2/mp_config %s/ImageBoot/%s/etc/enigma2" % ( + media, target, ) rc = os.system(cmd) - if os.path.exists('/etc/enigma2/mp_pluginliste'): - cmd = 'cp /etc/enigma2/mp_pluginliste %s/ImageBoot/%s/etc/enigma2' % ( - media, target) + if os.path.exists("/etc/enigma2/mp_pluginliste"): + cmd = ( + "cp /etc/enigma2/mp_pluginliste %s/ImageBoot/%s/etc/enigma2" % + (media, target)) rc = os.system(cmd) os.system('echo "Copied MediaPortal..."') - elif not os.path.exists('' + extensions_path + 'MediaPortal'): + elif not os.path.exists("" + extensions_path + "MediaPortal"): os.system('echo "MediaPortal not found."') - if PiconR == 'True': - if os.path.exists('/usr/share/enigma2/picon'): - cmd = 'cp -af /usr/share/enigma2/picon %s/ImageBoot/%s/usr/share/enigma2' % ( - media, target) + if PiconR == "True": + if os.path.exists("/usr/share/enigma2/picon"): + cmd = ( + "cp -af /usr/share/enigma2/picon %s/ImageBoot/%s/usr/share/enigma2" % + (media, target)) rc = os.system(cmd) os.system('echo "Copied picon..."') - elif not os.path.exists('/usr/share/enigma2/picon'): + elif not os.path.exists("/usr/share/enigma2/picon"): os.system('echo "Picon flash not found."') - if Kodi == 'True': - cmd = 'mkdir -p %s/ImageBoot/%s/home/root/.kodi > /dev/null 2>&1' % ( - media, target) + if Kodi == "True": + cmd = "mkdir -p %s/ImageBoot/%s/home/root/.kodi > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) - if os.path.exists('/home/root/.kodi'): + if os.path.exists("/home/root/.kodi"): os.system('echo "Kodi set ok."') else: - if not os.path.exists('/home/root/.kodi'): - if not os.path.exists('/.multinfo'): - if os.path.exists('/media/hdd/.kodi'): + if not os.path.exists("/home/root/.kodi"): + if not os.path.exists("/.multinfo"): + if os.path.exists("/media/hdd/.kodi"): cmd = 'mv /media/hdd/.kodi /media/hdd/.kodi_flash; ln -sf "/media/hdd/.kodi_flash" "/home/root/.kodi"; ln -sf "/home/root/.kodi" "/media/hdd/.kodi" ' rc = os.system(cmd) os.system('echo "Kodi fix ok."') @@ -488,1817 +795,5020 @@ def NEOBootMainEx(source, target, CopyFiles, CopyKernel, TvList, LanWlan, Sterow else: os.system('echo "Kodi not found."') - if BlackHole == 'True': - if 'BlackHole' in source or os.path.exists('%s/ImageBoot/%s/usr/lib/enigma2/python/Blackhole' % (media, target)): - cmd = 'mkdir -p ' + getNeoLocation() + 'ImageBoot/%s/boot/blackhole' % target + if BlackHole == "True": + if "BlackHole" in source or os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Blackhole" % + (media, target)): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/boot/blackhole" % target + ) rc = os.system(cmd) - cmd = 'mv ' + getNeoLocation() + 'ImageBoot/' + target + '/usr/lib/enigma2/python/Blackhole/BhUtils.pyo ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/lib/enigma2/python/Blackhole/BhUtils.pyo.org' % target + cmd = ( + "mv " + + getNeoLocation() + + "ImageBoot/" + + target + + "/usr/lib/enigma2/python/Blackhole/BhUtils.pyo " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Blackhole/BhUtils.pyo.org" % + target) rc = os.system(cmd) - cmd = 'cp -af ' + extensions_path + 'NeoBoot/bin/utilsbh ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/lib/enigma2/python/Blackhole/BhUtils.py' % target + cmd = ( + "cp -af " + + extensions_path + + "NeoBoot/bin/utilsbh " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Blackhole/BhUtils.py" % + target) rc = os.system(cmd) - ver = source.replace('BlackHole-', '') + ver = source.replace("BlackHole-", "") try: - text = ver.split('-')[0] - except: - text = '' - localfile = '' + getNeoLocation() + 'ImageBoot/%s/boot/blackhole/version' % target - temp_file = open(localfile, 'w') - temp_file.write(text) - temp_file.close() - cmd = 'mv ' + getNeoLocation() + 'ImageBoot/' + target + '/usr/bin/enigma2 ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/bin/enigma2-or' % target - rc = os.system(cmd) - fail = '' + getNeoLocation() + 'ImageBoot/%s/usr/bin/enigma2-or' % target - f = open(fail, 'r') - content = f.read() - f.close() - localfile2 = '' + getNeoLocation() + 'ImageBoot/%s/usr/bin/enigma2' % target - temp_file2 = open(localfile2, 'w') - temp_file2.write(content.replace( - '/proc/blackhole/version', '/boot/blackhole/version')) - temp_file2.close() - cmd = 'chmod -R 0755 %s' % localfile2 - rc = os.system(cmd) - cmd = 'rm -r ' + getNeoLocation() + 'ImageBoot/%s/usr/bin/enigma2-or' % target - rc = os.system(cmd) - # cmd = 'cp -af' + getNeoLocation() + 'ImageBoot/' + target + '/etc/bhversion ' + getNeoLocation() + 'ImageBoot/%s/boot/blackhole/version' % target - # rc = os.system(cmd) - # cmd = 'cp -f ' + extensions_path + 'NeoBoot/bin/version ' + getNeoLocation() + 'ImageBoot/%s/boot/blackhole/version' % target - # rc = os.system(cmd) + text = ver.split("-")[0] + except Exception: + text = "" + localfile = ( + "" + + getNeoLocation() + + "ImageBoot/%s/boot/blackhole/version" % target + ) + try: + with open( + localfile, "w", encoding="utf-8", errors="ignore" + ) as temp_file: + temp_file.write(text) + except Exception as e: + os.system(f'echo "Failed to write {localfile}: {e}"') -# for all image: - # copying zerotier script if exists - if os.path.exists('/var/lib/zerotier-one/identity.secret'): - cmd = 'mkdir -p ' + getNeoLocation() + 'ImageBoot/%s/var/lib/zerotier-one' % target + cmd = ( + "mv " + + getNeoLocation() + + "ImageBoot/" + + target + + "/usr/bin/enigma2 " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2-or" % target + ) + rc = os.system(cmd) + + fail = ( + "" + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2-or" % + target) + content = "" + try: + with open(fail, "r", encoding="utf-8", errors="ignore") as f: + content = f.read() + except Exception as e: + os.system(f'echo "Failed to read {fail}: {e}"') + + if content: + localfile2 = ( + "" + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2" % + target) + try: + with open( + localfile2, "w", encoding="utf-8", errors="ignore" + ) as temp_file2: + temp_file2.write( + content.replace( + "/proc/blackhole/version", + "/boot/blackhole/version")) + + cmd = "chmod -R 0755 %s" % localfile2 + rc = os.system(cmd) + cmd = ( + "rm -r " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2-or" % target + ) + rc = os.system(cmd) + except Exception as e: + os.system(f'echo "Failed to write {localfile2}: {e}"') + + if os.path.exists("/var/lib/zerotier-one/identity.secret"): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/var/lib/zerotier-one" % target + ) rc = os.system(cmd) - cmd1 = 'cp -af /var/lib/zerotier-one/identity.secret ' + \ - getNeoLocation() + 'ImageBoot/%s/var/lib/zerotier-one/' % target + cmd1 = ( + "cp -af /var/lib/zerotier-one/identity.secret " + + getNeoLocation() + + "ImageBoot/%s/var/lib/zerotier-one/" % target + ) rc = os.system(cmd1) - # copying tailscale if exists - if os.path.exists('/var/lib/tailscale/tailscaled.state'): - cmd = 'mkdir -p ' + getNeoLocation() + 'ImageBoot/%s/var/lib/tailscale' % target + if os.path.exists("/var/lib/tailscale/tailscaled.state"): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/var/lib/tailscale" % target + ) rc = os.system(cmd) - cmd1 = 'cp -af /var/lib/tailscale/* ' + \ - getNeoLocation() + 'ImageBoot/%s/var/lib/tailscale/' % target + cmd1 = ( + "cp -af /var/lib/tailscale/* " + + getNeoLocation() + + "ImageBoot/%s/var/lib/tailscale/" % target + ) rc = os.system(cmd1) - cmd2 = 'cp -af /var/lib/tailscale/* ' + \ - getNeoLocation() + 'ImageBoot/%s/var/lib/tailscale/' % target + cmd2 = ( + "cp -af /var/lib/tailscale/* " + + getNeoLocation() + + "ImageBoot/%s/var/lib/tailscale/" % target + ) rc = os.system(cmd2) - if os.path.exists('/usr/sbin/tailscaled'): - cmd3 = 'cp -af /usr/sbin/tailscaled ' + \ - getNeoLocation() + 'ImageBoot/%s/susr/sbin/' % target + if os.path.exists("/usr/sbin/tailscaled"): + cmd3 = ( + "cp -af /usr/sbin/tailscaled " + + getNeoLocation() + + "ImageBoot/%s/susr/sbin/" % target + ) rc = os.system(cmd3) - elif os.path.exists('/usr/bin/tailscaled'): - cmd3 = 'cp -af /usr/bin/tailscaled ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/bin/' % target + elif os.path.exists("/usr/bin/tailscaled"): + cmd3 = ( + "cp -af /usr/bin/tailscaled " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/" % target + ) rc = os.system(cmd3) - cmd4 = 'cp -af /usr/bin/tailscale ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/bin/' % target + cmd4 = ( + "cp -af /usr/bin/tailscale " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/" % target + ) rc = os.system(cmd4) - cmd5 = 'cp -af /etc/init.d/tailscal* ' + \ - getNeoLocation() + 'ImageBoot/%s/etc/init.d/' % target + cmd5 = ( + "cp -af /etc/init.d/tailscal* " + + getNeoLocation() + + "ImageBoot/%s/etc/init.d/" % target + ) rc = os.system(cmd5) - if not os.path.exists('%s/ImageBoot/%s/lib/modules/kernel/drivers/net/tun.ko' % (media, target)): - if not os.path.exists('%s/ImageBoot/%s/lib/modules/kernel/drivers/net' % (media, target)): - # cmd = 'mkdir -p ' + getNeoLocation() + 'ImageBoot/%s/lib/modules/' + getKernelVersion() + '/kernel/drivers/net/' % target - cmd = 'mkdir -p %s/ImageBoot/%s/lib/modules/kernel/drivers/net/' % ( - media, target) + if not os.path.exists( + "%s/ImageBoot/%s/lib/modules/kernel/drivers/net/tun.ko" + % (media, target) + ): + if not os.path.exists( + "%s/ImageBoot/%s/lib/modules/kernel/drivers/net" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/lib/modules/kernel/drivers/net/" % ( + media, target, ) rc = os.system(cmd) - cmd = 'cp -af /lib/modules/' + getKernelVersion() + \ - '/kernel/drivers/net/tun.ko %s/ImageBoot/%s/lib/modules/kernel/drivers/net/' % ( - media, target) + cmd = ( + "cp -af /lib/modules/" + + getKernelVersion() + + "/kernel/drivers/net/tun.ko %s/ImageBoot/%s/lib/modules/kernel/drivers/net/" % + (media, + target)) rc = os.system(cmd) - if not os.path.exists('%s/ImageBoot/%s/var/run/tailscale' % (media, target)): - cmd = 'mkdir -p ' + getNeoLocation() + '/ImageBoot/%s/run/tailscale/' % target + if not os.path.exists( + "%s/ImageBoot/%s/var/run/tailscale" % (media, target) + ): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "/ImageBoot/%s/run/tailscale/" % target + ) rc = os.system(cmd) - if os.path.exists('/run/tailscale'): - cmd = 'cp -aRf /run/tailscale/tailscaled.sock ' + \ - getNeoLocation() + 'ImageBoot/%s/run/tailscale/' % target + if os.path.exists("/run/tailscale"): + cmd = ( + "cp -aRf /run/tailscale/tailscaled.sock " + + getNeoLocation() + + "ImageBoot/%s/run/tailscale/" % target + ) rc = os.system(cmd) - cmd1 = 'cp -aRf /run/resolvconf/interfaces/tailscale ' + \ - getNeoLocation() + 'ImageBoot/%s/run/tailscale/' % target + cmd1 = ( + "cp -aRf /run/resolvconf/interfaces/tailscale " + + getNeoLocation() + + "ImageBoot/%s/run/tailscale/" % target + ) rc = os.system(cmd1) - if os.path.exists('%s/ImageBoot/%s/etc/init.d' % (media, target)): - cmd = 'ln -s %sImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh %sImageBoot/%s/etc/rcS.d/S99neo.local' % (media, - target, - media, - target) + if os.path.exists("%s/ImageBoot/%s/etc/init.d" % (media, target)): + cmd = ( + "ln -s %sImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh %sImageBoot/%s/etc/rcS.d/S99neo.local" % + (media, target, media, target)) - elif not os.path.exists('%s/ImageBoot/%s/etc/init.d' % (media, target)): + elif not os.path.exists("%s/ImageBoot/%s/etc/init.d" % (media, target)): os.system('echo "/etc/init.d not found."') os.system('echo "Copied file neo_userscript.sh"') - if not os.path.exists('' + getNeoLocation() + 'ImageBoot/.without_copying') and not os.path.exists(' /tmp/settings_copied'): - for line in open("/etc/hostname"): - if getCPUtype() == 'MIPS' and "dm500hd" in line or "dm800se" in line or "dm800" in line or "dm800se" in line or "dm8000" in line: - if os.path.exists('%s/ImageBoot/%s/etc/enigma2' % (media, target)): - cmd = 'rm -r %s/ImageBoot/%s/etc/enigma2' % (media, target) - rc = os.system(cmd) - else: - if not os.path.exists('%s/ImageBoot/%s/etc/enigma2' % (media, target)): - cmd = 'mkdir -p %s/ImageBoot/%s/etc/enigma2' % ( - media, target) - rc = os.system(cmd) - cmd = 'touch %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd) - cmd = 'grep "config.Nims" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd) - cmd1 = 'grep "av.videomode.DVI" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd1) - cmd2 = 'grep "config.OpenWebif" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd2) - cmd3 = 'grep "config.osd" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd3) - cmd4 = 'grep "config.timezone.val" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd4) - cmd5 = 'grep "config.servicelist.startuproot" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % ( - media, target) - rc = os.system(cmd5) - cmd6 = 'grep "UUID=" /etc/fstab >> %s/ImageBoot/%s/etc/fstab' % ( - media, target) - rc = os.system(cmd6) + if not os.path.exists( + "" + getNeoLocation() + "ImageBoot/.without_copying" + ) and not os.path.exists(" /tmp/settings_copied"): + try: + with open("/etc/hostname", "r", encoding="utf-8", errors="ignore") as f: + for line in f: + if ( + getCPUtype() == "MIPS" + and "dm500hd" in line + or "dm800se" in line + or "dm800" in line + or "dm800se" in line + or "dm8000" in line + ): + if os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % (media, target) + ): + cmd = "rm -r %s/ImageBoot/%s/etc/enigma2" % ( + media, target) + rc = os.system(cmd) + else: + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % (media, target) + ): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "touch %s/ImageBoot/%s/etc/enigma2/settings" % ( + media, target, ) + rc = os.system(cmd) + cmd = ( + 'grep "config.Nims" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd) + cmd1 = ( + 'grep "av.videomode.DVI" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd1) + cmd2 = ( + 'grep "config.OpenWebif" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd2) + cmd3 = ( + 'grep "config.osd" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd3) + cmd4 = ( + 'grep "config.timezone.val" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd4) + cmd5 = ( + 'grep "config.servicelist.startuproot" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd5) + cmd6 = ( + 'grep "UUID=" /etc/fstab >> %s/ImageBoot/%s/etc/fstab' % + (media, target)) + rc = os.system(cmd6) + except Exception as e: + os.system(f'echo "Failed reading /etc/hostname: {e}"') -##################################### - if not os.path.exists('' + media_target + '/boot/zImage.' + getBoxHostName() + '') and getCPUtype() == 'MIPS': - namefile = media + '/ImageBoot/' + target + '/etc/fstab' - namefile2 = namefile + '.tmp' - if os.path.exists(namefile2): - out = open(namefile2, 'w') - f = open(namefile, 'r') - for line in f.readlines(): - if line.find('/dev/mmcblk0p2') != -1: - line = '#' + line - elif line.find('/dev/root') != -1: - line = '#' + line - out.write(line) + if ( + not os.path.exists( + "" + media_target + "/boot/zImage." + getBoxHostName() + "" + ) + and getCPUtype() == "MIPS" + ): + namefile = media + "/ImageBoot/" + target + "/etc/fstab" + namefile2 = namefile + ".tmp" + if os.path.exists(namefile): # Check if source exists + try: + with open(namefile, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + with open(namefile2, "w", encoding="utf-8", errors="ignore") as out: + for line in lines: + if line.find("/dev/mmcblk0p2") != -1: + line = "#" + line + elif line.find("/dev/root") != -1: + line = "#" + line + out.write(line) + os.rename(namefile2, namefile) + except Exception as e: + os.system(f'echo "Failed to patch {namefile}: {e}"') + if os.path.exists(namefile2): + os.remove(namefile2) - f.close() - out.close() - os.rename(namefile2, namefile) - - tpmd = media + '/ImageBoot/' + target + '/etc/init.d/tpmd' + tpmd = media + "/ImageBoot/" + target + "/etc/init.d/tpmd" if os.path.exists(tpmd): - os.system('rm ' + tpmd) + os.system("rm " + tpmd) - fname = media + '/ImageBoot/' + target + \ - '/usr/lib/enigma2/python/Components/config.py' + fname = ( + media + + "/ImageBoot/" + + target + + "/usr/lib/enigma2/python/Components/config.py" + ) if os.path.exists(fname): - fname2 = fname + '.tmp' - out = open(fname2, 'w') - f = open(fname, 'r') - for line in f.readlines(): - if line.find('if file(""/proc/stb/info/vumodel")') != -1: - line = '#' + line - out.write(line) + fname2 = fname + ".tmp" + try: + with open(fname, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + with open(fname2, "w", encoding="utf-8", errors="ignore") as out: + for line in lines: + if line.find( + 'if file(""/proc/stb/info/vumodel")') != -1: + line = "#" + line + out.write(line) + os.rename(fname2, fname) + except Exception as e: + os.system(f'echo "Failed to patch {fname}: {e}"') + if os.path.exists(fname2): + os.remove(fname2) - f.close() - out.close() - os.rename(fname2, fname) - - targetfile = media + '/ImageBoot/' + target + '/etc/vsftpd.conf' + targetfile = media + "/ImageBoot/" + target + "/etc/vsftpd.conf" if os.path.exists(targetfile): - targetfile2 = targetfile + '.tmp' - out = open(targetfile2, 'w') - f = open(targetfile, 'r') - for line in f.readlines(): - if not line.startswith('nopriv_user'): - out.write(line) + targetfile2 = targetfile + ".tmp" + try: + with open(targetfile, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + with open( + targetfile2, "w", encoding="utf-8", errors="ignore" + ) as out: + for line in lines: + if not line.startswith("nopriv_user"): + out.write(line) + os.rename(targetfile2, targetfile) + except Exception as e: + os.system(f'echo "Failed to patch {targetfile}: {e}"') + if os.path.exists(targetfile2): + os.remove(targetfile2) - f.close() - out.close() - os.rename(targetfile2, targetfile) - - mypath = media + '/ImageBoot/' + target + '/usr/lib/opkg/info/' - cmd = 'mkdir -p %s/ImageBoot/%s/var/lib/opkg/info > /dev/null 2>&1' % ( - media, target) + mypath = media + "/ImageBoot/" + target + "/usr/lib/opkg/info/" + cmd = "mkdir -p %s/ImageBoot/%s/var/lib/opkg/info > /dev/null 2>&1" % ( + media, target, ) rc = os.system(cmd) if not os.path.exists(mypath): - mypath = media + '/ImageBoot/' + target + '/var/lib/opkg/info/' - for fn in os.listdir(mypath): - if fn.find('kernel-image') != -1 and fn.find('postinst') != -1: - filename = mypath + fn - filename2 = filename + '.tmp' - out = open(filename2, 'w') - f = open(filename, 'r') - for line in f.readlines(): - if line.find('/boot') != -1: - line = line.replace( - '/boot', '/boot > /dev/null 2>\\&1; exit 0') - out.write(line) + mypath = media + "/ImageBoot/" + target + "/var/lib/opkg/info/" - if f.close(): - out.close() - os.rename(filename2, filename) - cmd = 'chmod -R 0755 %s' % filename + if os.path.exists(mypath): # Check if path exists before listing + for fn in os.listdir(mypath): + if ((fn.find("kernel-image") != - + 1 and fn.find("postinst") != - + 1) or fn.find("-bootlogo.postinst") != - + 1 or fn.find("-bootlogo.postrm") != - + 1 or fn.find("-bootlogo.preinst") != - + 1 or fn.find("-bootlogo.prerm") != - + 1): + + filename = os.path.join(mypath, fn) + filename2 = filename + ".tmp" + try: + with open( + filename, "r", encoding="utf-8", errors="ignore" + ) as f: + lines = f.readlines() + + with open( + filename2, "w", encoding="utf-8", errors="ignore" + ) as out: + for line in lines: + if line.find("/boot") != -1: + line = line.replace( + "/boot", "/boot > /dev/null 2>\\&1; exit 0") + out.write(line) + + os.rename(filename2, filename) + cmd = "chmod -R 0755 %s" % filename + rc = os.system(cmd) + except Exception as e: + os.system( + f'echo "Failed to patch {filename}: {e}"') + if os.path.exists(filename2): + os.remove(filename2) + + if os.path.exists( + "%s/ImageBoot/%s/var/lib/opkg/status1" % + (media, target)): + cmd = ( + "mv " + + getNeoLocation() + + "ImageBoot/" + + target + + "/var/lib/opkg/status " + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status-or" % target + ) + rc = os.system(cmd) + + fail = ( + "" + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status-or" % target + ) + content = "" + try: + with open(fail, "r", encoding="utf-8", errors="ignore") as f: + content = f.read() + except Exception as e: + os.system(f'echo "Failed to read {fail}: {e}"') + + if content: + localfile2 = ( + "" + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status" % target + ) + try: + with open( + localfile2, "w", encoding="utf-8", errors="ignore" + ) as temp_file2: + temp_file2.write( + content.replace( + "kernel-image", + "#kernel-image")) + + cmd = "chmod -R 0755 %s" % localfile2 rc = os.system(cmd) - if fn.find('-bootlogo.postinst') != -1: - filename = mypath + fn - filename2 = filename + '.tmp' - out = open(filename2, 'w') - f = open(filename, 'r') - for line in f.readlines(): - if line.find('/boot') != -1: - line = line.replace( - '/boot', '/boot > /dev/null 2>\\&1; exit 0') - out.write(line) + cmd = ( + "rm -r " + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status-or" % target + ) + rc = os.system(cmd) + except Exception as e: + os.system(f'echo "Failed to write {localfile2}: {e}"') - f.close() - out.close() - os.rename(filename2, filename) - cmd = 'chmod -R 0755 %s' % filename - rc = os.system(cmd) - if fn.find('-bootlogo.postrm') != -1: - filename = mypath + fn - filename2 = filename + '.tmp' - out = open(filename2, 'w') - f = open(filename, 'r') - for line in f.readlines(): - if line.find('/boot') != -1: - line = line.replace( - '/boot', '/boot > /dev/null 2>\\&1; exit 0') - out.write(line) - - f.close() - out.close() - os.rename(filename2, filename) - cmd = 'chmod -R 0755 %s' % filename - rc = os.system(cmd) - if fn.find('-bootlogo.preinst') != -1: - filename = mypath + fn - filename2 = filename + '.tmp' - out = open(filename2, 'w') - f = open(filename, 'r') - for line in f.readlines(): - if line.find('/boot') != -1: - line = line.replace( - '/boot', '/boot > /dev/null 2>\\&1; exit 0') - out.write(line) - - f.close() - out.close() - os.rename(filename2, filename) - cmd = 'chmod -R 0755 %s' % filename - rc = os.system(cmd) - if fn.find('-bootlogo.prerm') != -1: - filename = mypath + fn - filename2 = filename + '.tmp' - out = open(filename2, 'w') - f = open(filename, 'r') - for line in f.readlines(): - if line.find('/boot') != -1: - line = line.replace( - '/boot', '/boot > /dev/null 2>\\&1; exit 0') - out.write(line) - - f.close() - out.close() - os.rename(filename2, filename) - cmd = 'chmod -R 0755 %s' % filename - rc = os.system(cmd) - - # _______________________________________________status1 zmienione - if os.path.exists('%s/ImageBoot/%s/var/lib/opkg/status1' % (media, target)): - cmd = 'mv ' + getNeoLocation() + 'ImageBoot/' + target + '/var/lib/opkg/status ' + \ - getNeoLocation() + 'ImageBoot/%s/var/lib/opkg/status-or' % target - rc = os.system(cmd) - fail = '' + getNeoLocation() + 'ImageBoot/%s/var/lib/opkg/status-or' % target - f = open(fail, 'r') - content = f.read() - f.close() - localfile2 = '' + getNeoLocation() + 'ImageBoot/%s/var/lib/opkg/status' % target - temp_file2 = open(localfile2, 'w') - temp_file2.write(content.replace( - 'kernel-image', '#kernel-image')) - temp_file2.close() - - cmd = 'chmod -R 0755 %s' % localfile2 - rc = os.system(cmd) - cmd = 'rm -r ' + getNeoLocation() + 'ImageBoot/%s/var/lib/opkg/status-or' % target - rc = os.system(cmd) - -# cmd = 'cp -f ' + extensions_path + 'NeoBoot/bin/hdd ' + getNeoLocation() + 'ImageBoot/%s/etc/init.d/hddusb' % target -# rc = os.system(cmd) - if os.path.exists('%s/ImageBoot/%s/usr/lib' % (media, target)): - cmd = 'cp -af /usr/lib/periodon ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/lib/' % target + if os.path.exists("%s/ImageBoot/%s/usr/lib" % (media, target)): + cmd = ( + "cp -af /usr/lib/periodon " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/" % target + ) rc = os.system(cmd) - cmd = 'mkdir -p ' + getNeoLocation() + \ - 'ImageBoot/%s/usr/lib/enigma2/python/Tools/' % target + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Tools/" % target + ) rc = os.system(cmd) - cmd = 'cp -af /usr/lib/enigma2/python/Tools/Testinout.py ' + \ - getNeoLocation() + 'ImageBoot/%s/usr/lib/enigma2/python/Tools/' % target + cmd = ( + "cp -af /usr/lib/enigma2/python/Tools/Testinout.py " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Tools/" % target + ) rc = os.system(cmd) - # delet dir tmp - cmd = 'rm -r ' + getNeoLocation() + 'ImageBoot/%s/tmp' % target + cmd = "rm -r " + getNeoLocation() + "ImageBoot/%s/tmp" % target rc = os.system(cmd) - os.system('mkdir -p ' + media_target + '/media/hdd' + dev_null) - os.system('mkdir -p ' + media_target + '/media/usb' + dev_null) - os.system('mkdir -p ' + media_target + '/var/lib/opkg/info/' + dev_null) - os.system('touch ' + getNeoLocation() + 'ImageBoot/.data; echo "Data instalacji image" > ' + - getNeoLocation() + 'ImageBoot/.data; echo " "; date > ' + getNeoLocation() + 'ImageBoot/.data') - os.system('mv -f ' + getNeoLocation() + 'ImageBoot/.data ' + - getNeoLocation() + 'ImageBoot/%s/.data' % target) - cmd = 'touch /tmp/.init_reboot' + os.system("mkdir -p " + media_target + "/media/hdd" + dev_null) + os.system("mkdir -p " + media_target + "/media/usb" + dev_null) + os.system("mkdir -p " + media_target + "/var/lib/opkg/info/" + dev_null) + os.system( + "touch " + + getNeoLocation() + + 'ImageBoot/.data; echo "Data instalacji image" > ' + + getNeoLocation() + + 'ImageBoot/.data; echo " "; date > ' + + getNeoLocation() + + "ImageBoot/.data" + ) + os.system( + "mv -f " + + getNeoLocation() + + "ImageBoot/.data " + + getNeoLocation() + + "ImageBoot/%s/.data" % target + ) + cmd = "touch /tmp/.init_reboot" rc = os.system(cmd) - out = open(mediahome + '.neonextboot', 'w') - out.write(target) - out.close() - os.system('cp ' + getNeoLocation() + 'ImageBoot/.neonextboot ' + - getNeoLocation() + 'ImageBoot/%s/.multinfo' % target) - out = open(mediahome + '.neonextboot', 'w') - out.write('Flash') - out.close() - if '.tar.xz' not in source and not os.path.exists('' + getNeoLocation() + '/ImageBoot/%s/etc/issue' % target): - os.system('echo ""; echo "No system installed! The reason for the installation error may be badly packed image files or it is not a system for your model."') + + try: + with open( + mediahome + ".neonextboot", "w", encoding="utf-8", errors="ignore" + ) as out: + out.write(target) + except Exception as e: + os.system(f'echo "Failed to write .neonextboot: {e}"') + + os.system( + "cp " + + getNeoLocation() + + "ImageBoot/.neonextboot " + + getNeoLocation() + + "ImageBoot/%s/.multinfo" % target + ) + + try: + with open( + mediahome + ".neonextboot", "w", encoding="utf-8", errors="ignore" + ) as out: + out.write("Flash") + except Exception as e: + os.system(f'echo "Failed to write .neonextboot: {e}"') + + if ".tar.xz" not in source and not os.path.exists( + "" + getNeoLocation() + "/ImageBoot/%s/etc/issue" % target + ): os.system( - 'echo "The installed system may not start. Check the correctness of the installed image directory!!!"') - os.system('rm -r ' + getNeoLocation() + '/ImageBoot/%s' % target) + 'echo ""; echo "No system installed! The reason for the installation error may be badly packed image files or it is not a system for your model."' + ) + os.system( + 'echo "The installed system may not start. Check the correctness of the installed image directory!!!"' + ) + os.system("rm -r " + getNeoLocation() + "/ImageBoot/%s" % target) - if os.path.exists('' + getNeoLocation() + 'ubi'): - os.system('rm -r ' + getNeoLocation() + 'ubi') - if os.path.exists('' + getNeoLocation() + 'image_cache/'): - os.system('rm -r ' + getNeoLocation() + 'image_cache') - if os.path.exists('' + getNeoLocation() + 'ImageBoot/.without_copying'): - os.system('rm -f ' + getNeoLocation() + 'ImageBoot/.without_copying') + if os.path.exists("" + getNeoLocation() + "ubi"): + os.system("rm -r " + getNeoLocation() + "ubi") + if os.path.exists("" + getNeoLocation() + "image_cache/"): + os.system("rm -r " + getNeoLocation() + "image_cache") + if os.path.exists("" + getNeoLocation() + "ImageBoot/.without_copying"): + os.system("rm -f " + getNeoLocation() + "ImageBoot/.without_copying") rc = RemoveUnpackDirs() os.system('echo "End of installation:"; date +%T') os.system( - 'echo "If you want to save the installation process from the console press green."') + 'echo "If you want to save the installation process from the console press green."' + ) def RemoveUnpackDirs(): - os.chdir(media + '/ImagesUpload') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/unpackedzip'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/unpackedzip') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/*.bin'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/*.bin') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/*.txt'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/*.txt') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/vuplus') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf4008'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/sf4008') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmio4k'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osmio4k') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmio4kplus'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/osmio4kplus') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm900'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/dm900') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd60'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/hd60') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd61'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/hd61') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd51'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/hd51') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/bre2ze4k'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/bre2ze4k') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/multibox'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/multibox') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/multiboxse'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/multiboxse') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/unforce_multibox.txt'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/unforce_multibox.txt') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/axas'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/axas') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/miraclebox') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/e4hd'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/e4hd') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/update') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.tar.xz'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/rootfs.tar.xz') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/*.nfi'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/*.nfi') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/zgemma') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler1'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/formuler1') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler3'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/formuler3') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler4turbo'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/formuler4turbo') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/et*'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/et*') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/xpeedl*'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/xpeedl*') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmini'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osmini') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osminiplus'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osminiplus') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osnino'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osnino') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osninoplus'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osninoplus') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osninopro'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osninopro') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmini4k'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/osmini4k') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/xp1000 '): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/xp1000') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/et5x00'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/et5x00') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/dinobot') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/e2/update'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/e2') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/et1x000'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/et1x000') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/protek4k'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/protek4k') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm920 '): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/dm920') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dreamtwo '): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/dreamtwo ') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/multibox') or os.path.exists('' + getNeoLocation() + 'ImagesUpload/multiboxse'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/multibox ' + getNeoLocation() + - 'ImagesUpload/multibox; rm -r ' + getNeoLocation() + 'ImagesUpload/multibox') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/octagon/sf8008'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/usb_update.bin ' + getNeoLocation() + - 'ImagesUpload/octagon; rm -r ' + getNeoLocation() + 'ImagesUpload/octagon') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/octagon/sf8008m'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/octagon') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h5'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + getNeoLocation() + - 'ImagesUpload/h5; mv ' + getNeoLocation() + 'ImagesUpload/fastboot.bin ' + getNeoLocation() + 'ImagesUpload/h5') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h7'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + getNeoLocation() + - 'ImagesUpload/h7; mv ' + getNeoLocation() + 'ImagesUpload/fastboot.bin ' + getNeoLocation() + 'ImagesUpload/h7') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h7') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + getNeoLocation() + - 'ImagesUpload/h9; mv ' + getNeoLocation() + 'ImagesUpload/fastboot.bin ' + getNeoLocation() + 'ImagesUpload/h9') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h9') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9se'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + getNeoLocation() + 'ImagesUpload/h9se; mv ' + - getNeoLocation() + 'ImagesUpload/fastboot.bin ' + getNeoLocation() + 'ImagesUpload/h9se') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h9se') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/i55plus'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + getNeoLocation() + 'ImagesUpload/i55plus; mv ' + - getNeoLocation() + 'ImagesUpload/fastboot.bin ' + getNeoLocation() + 'ImagesUpload/i55plus') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/i55plus') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9combo'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/force_h9combo_READ.ME ' + getNeoLocation() + 'ImagesUpload/h9combo; mv ' + - getNeoLocation() + 'ImagesUpload/unforce_h9combo.txt ' + getNeoLocation() + 'ImagesUpload/h9combo') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h9combo') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9combose'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/force_h9combose_READ.ME ' + getNeoLocation() + 'ImagesUpload/h9combo; mv ' + - getNeoLocation() + 'ImagesUpload/unforce_h9combose.txt ' + getNeoLocation() + 'ImagesUpload/h9combose') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h9combose') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h10'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/force_h10_READ.ME ' + getNeoLocation() + - 'ImagesUpload/h10; mv ' + getNeoLocation() + 'ImagesUpload/unforce_h10.txt ' + getNeoLocation() + 'ImagesUpload/h10') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h10') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h11'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/force_h11_READ.ME ' + getNeoLocation() + - 'ImagesUpload/h11; mv ' + getNeoLocation() + 'ImagesUpload/unforce_h11.txt ' + getNeoLocation() + 'ImagesUpload/h11') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h11') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h8'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/h8') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/uclan'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/usb_update.bin'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/usb_update.bin ' + - getNeoLocation() + 'ImagesUpload/uclan') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/uclan') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/ustym4kpro'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/ustym4kpro') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/beyonwiz'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/apploader.bin ' + - getNeoLocation() + 'ImagesUpload/beyonwiz') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + - getNeoLocation() + 'ImagesUpload/beyonwiz') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/fastboot.bin ' + - getNeoLocation() + 'ImagesUpload/beyonwiz') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/beyonwiz') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/amiko'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/usb_update.bin ' + - getNeoLocation() + 'ImagesUpload/amiko') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/apploader.bin ' + - getNeoLocation() + 'ImagesUpload/amiko') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + - getNeoLocation() + 'ImagesUpload/amiko') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/fastboot.bin ' + - getNeoLocation() + 'ImagesUpload/amiko') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/amiko') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/x1') or os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/x34k'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/gigablue') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue') and os.path.exists('' + getNeoLocation() + 'ImagesUpload/usb_update.bin'): - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/usb_update.bin ' + - getNeoLocation() + 'ImagesUpload/gigablue') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/apploader.bin ' + - getNeoLocation() + 'ImagesUpload/gigablue') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/bootargs.bin ' + - getNeoLocation() + 'ImagesUpload/gigablue') - rc = os.system('mv ' + getNeoLocation() + 'ImagesUpload/fastboot.bin ' + - getNeoLocation() + 'ImagesUpload/gigablue') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/gigablue') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/et10000'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/et10000') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vs1000'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/vs1000') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vs1500'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/vs1500') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/pulse4k'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/pulse4k/force_pulse4k_READ.ME'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/pulse4k/force_pulse4k_READ.ME; rm -r ' + - getNeoLocation() + 'ImagesUpload/pulse4k/unforce_pulse4k.txt') - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/pulse4k') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/pulse4kmin'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/pulse4kmin/force_pulse4kmini_READ.ME'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/pulse4kmini/force_pulse4kmini_READ.ME; rm -r ' + - getNeoLocation() + 'ImagesUpload/pulse4kmini/unforce_pulse4kmini.txt') - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/pulse4kmini') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/xpeedlx'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/xpeedlx') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm520'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/dm520') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.tar.gz'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/rootfs.tar.gz') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.tar.xz'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/rootfs.tar.xz') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.tar.bz2'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/rootfs.tar.bz2') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.tar'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/rootfs.tar') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/unforce_h9combo.txt'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/unforce_h9combo.txt') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/imageversion'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/imageversion') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/kernel.bin'): - rc = os.system('rm -rf ' + getNeoLocation() + - 'ImagesUpload/kernel.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/force_multibox_READ.ME'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/force_multibox_READ.ME') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/force'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/force') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.bin'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/splash.bin'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/splash.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue'): - rc = os.system('rm -r ' + getNeoLocation() + 'ImagesUpload/gigablue') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/update_bootargs_h8'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/update_bootargs_h8') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/force_hd60_READ.ME'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/force_hd60_READ.ME') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/unforce_hd60.txt'): - rc = os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/unforce_hd60.txt') - if os.path.exists('/tmp/root_jffs2'): - rc = os.system('rm -fr /tmp/root_jffs2') - if os.path.exists('/tmp/xz-gz-tar'): - rc = os.system('rm -fr /tmp/xz-gz-tar') - if os.path.exists('/tmp/other_image'): - rc = os.system('rm -fr /tmp/other_image') - # Finish + os.chdir(media + "/ImagesUpload") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/unpackedzip"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/unpackedzip") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/*.bin"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/*.bin") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/*.txt"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/*.txt") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/vuplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/sf4008"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/sf4008") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmio4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osmio4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmio4kplus"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/osmio4kplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm900"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dm900") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd60"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/hd60") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd61"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/hd61") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd51"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/hd51") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/bre2ze4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/bre2ze4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multibox"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/multibox") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxse"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/multiboxse") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxpro"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/multiboxpro") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/unforce_multibox.txt"): + rc = os.system( + "rm -r " + getNeoLocation() + "ImagesUpload/unforce_multibox.txt" + ) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/axas"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/axas") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/miraclebox"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/miraclebox") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/e4hd"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/e4hd") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/update") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.xz"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/*.nfi"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/*.nfi") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/zgemma"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/zgemma") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/formuler1"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/formuler1") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/formuler3"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/formuler3") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/formuler4turbo"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/formuler4turbo") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et*"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et*") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedl*"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/xpeedl*") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osmini") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osminiplus"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osminiplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osnino"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osnino") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osninoplus"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osninoplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osninopro"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osninopro") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osmini4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/xp1000 "): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/xp1000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et5x00"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et5x00") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dinobot") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/e2/update"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/e2") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et1x000"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et1x000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/protek4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/protek4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm920 "): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dm920") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dreamtwo "): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dreamtwo ") + elif ( + os.path.exists("" + getNeoLocation() + "ImagesUpload/multibox") + or os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxse") + or os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxpro") + ): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/multibox " + + getNeoLocation() + + "ImagesUpload/multibox; rm -r " + + getNeoLocation() + + "ImagesUpload/multibox" + ) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/octagon/sf8008"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/octagon; rm -r " + + getNeoLocation() + + "ImagesUpload/octagon" + ) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/octagon/sf8008m"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/octagon") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h5"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h5; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h5" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h7"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h7; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h7" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h7") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h9; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h9" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9se"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h9se; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h9se" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9se") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/i55plus"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/i55plus; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/i55plus" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/i55plus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9combo"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h9combo_READ.ME " + + getNeoLocation() + + "ImagesUpload/h9combo; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h9combo.txt " + + getNeoLocation() + + "ImagesUpload/h9combo" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9combo") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9combose"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h9combose_READ.ME " + + getNeoLocation() + + "ImagesUpload/h9combo; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h9combose.txt " + + getNeoLocation() + + "ImagesUpload/h9combose" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9combose") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h10"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h10_READ.ME " + + getNeoLocation() + + "ImagesUpload/h10; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h10.txt " + + getNeoLocation() + + "ImagesUpload/h10" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h10") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h11"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h11_READ.ME " + + getNeoLocation() + + "ImagesUpload/h11; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h11.txt " + + getNeoLocation() + + "ImagesUpload/h11" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h11") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h8"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h8") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/uclan"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/usb_update.bin"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/uclan" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/uclan") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/ustym4kpro"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/ustym4kpro") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/beyonwiz"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/apploader.bin " + + getNeoLocation() + + "ImagesUpload/beyonwiz" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/beyonwiz" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/beyonwiz" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/beyonwiz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/amiko"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/apploader.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/amiko") + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/gigablue/x1" + ) or os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/x34k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/gigablue") + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/gigablue" + ) and os.path.exists("" + getNeoLocation() + "ImagesUpload/usb_update.bin"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/apploader.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/gigablue") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et10000"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et10000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1000"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/vs1000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1500"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/vs1500") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/pulse4k"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/pulse4k/force_pulse4k_READ.ME"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4k/force_pulse4k_READ.ME; rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4k/unforce_pulse4k.txt" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/pulse4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/pulse4kmin"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/pulse4kmin/force_pulse4kmini_READ.ME"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4kmini/force_pulse4kmini_READ.ME; rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4kmini/unforce_pulse4kmini.txt" + ) + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4kmini") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedlx"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/xpeedlx") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm520"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dm520") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.gz"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.gz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.xz"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.bz2"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.bz2") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/rootfs.tar") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/unforce_h9combo.txt"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/unforce_h9combo.txt") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/imageversion"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/imageversion") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/kernel.bin"): + rc = os.system( + "rm -rf " + + getNeoLocation() + + "ImagesUpload/kernel.bin") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/force_multibox_READ.ME"): + rc = os.system( + "rm -r " + getNeoLocation() + "ImagesUpload/force_multibox_READ.ME" + ) + if os.path.exists("" + getNeoLocation() + "ImagesUpload/force"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/force") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.bin"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/rootfs.bin") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/splash.bin"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/splash.bin") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/gigablue") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/update_bootargs_h8"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/update_bootargs_h8") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/force_hd60_READ.ME"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/force_hd60_READ.ME") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/unforce_hd60.txt"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/unforce_hd60.txt") + if os.path.exists("/tmp/root_jffs2"): + rc = os.system("rm -fr /tmp/root_jffs2") + if os.path.exists("/tmp/xz-gz-tar"): + rc = os.system("rm -fr /tmp/xz-gz-tar") + if os.path.exists("/tmp/other_image"): + rc = os.system("rm -fr /tmp/other_image") + + +def NEOBootMainEx( + source, + target, + CopyFiles, + CopyKernel, + TvList, + LanWlan, + Sterowniki, + Montowanie, + InstallSettings, + ZipDelete, + RepairFTP, + SoftCam, + MediaPortal, + PiconR, + Kodi, + BlackHole, + Nandsim, +): + NEOBootR( + source, + target, + CopyFiles, + CopyKernel, + TvList, + LanWlan, + Sterowniki, + Montowanie, + InstallSettings, + ZipDelete, + RepairFTP, + SoftCam, + MediaPortal, + PiconR, + Kodi, + BlackHole, + Nandsim, + ) + + +def LanguageUsed(): + language = "" + usedlang = "config.osd.language=pl_PL" + try: + with open( + "/etc/enigma2/settings", "r", encoding="utf-8", errors="ignore" + ) as lang: + bak = lang.read().find(usedlang) + if bak != -1: + language = "Yes" + else: + language = "No" + except IOError: + language = "No" + return language + + +def getBoxHostName(): + myboxname = "unknown" + if os.path.exists("/etc/hostname"): + try: + with open("/etc/hostname", "r", encoding="utf-8", errors="ignore") as f: + myboxname = f.readline().strip() + except IOError: + pass + return myboxname + + +def getCPUSoC(): + chipset = "UNKNOWN" + if os.path.exists("/proc/stb/info/chipset"): + try: + with open( + "/proc/stb/info/chipset", "r", encoding="utf-8", errors="ignore" + ) as f: + chipset = f.readline().strip() + if chipset == "7405(with 3D)": + chipset = "7405" + except IOError: + pass + return chipset + + +def getBoxVuModel(): + vumodel = "UNKNOWN" + if os.path.exists("/proc/stb/info/vumodel") and not os.path.exists( + "/proc/stb/info/boxtype" + ): + try: + with open( + "/proc/stb/info/vumodel", "r", encoding="utf-8", errors="ignore" + ) as f: + vumodel = f.readline().strip() + except IOError: + pass + return vumodel + + +def getCPUtype(): + cpu = "UNKNOWN" + if os.path.exists("/proc/cpuinfo"): + try: + with open("/proc/cpuinfo", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "ARMv7" in lines: + cpu = "ARMv7" + elif "mips" in lines: + cpu = "MIPS" + except IOError: + pass + return cpu + + +def getKernelVersion(): + if not os.path.exists("/tmp/.isnandsim"): + if ( + os.system("opkg list-installed | grep kernel-module-nandsim" + dev_null) + != 0 + ): + os.system("touch /tmp/.isnandsim") + + if os.path.exists("" + + getNeoLocation() + + "ImagesUpload/dm520") or os.path.exists("" + + getNeoLocation() + + "ImagesUpload/dm525"): + try: + result = ( + subprocess.check_output(["uname", "-r"], text=True, errors="ignore") + .strip("\n") + .split("-") + ) + kernel_version = result[0] + return kernel_version + except Exception: + os.system("uname -r > /tmp/.uname_r") + try: + with open("/tmp/.uname_r", "r", encoding="utf-8", errors="ignore") as f: + return f.read().strip().upper() + except IOError: + return "UNKNOWN" + else: + try: + with open("/proc/version", "r", encoding="utf-8", errors="ignore") as f: + return f.read().split(" ", 4)[2].split("-", 2)[0] + except Exception: + os.system("uname -r > /tmp/.uname_r") + try: + with open("/tmp/.uname_r", "r", encoding="utf-8", errors="ignore") as f: + return f.read().strip().upper() + except IOError: + return "UNKNOWN" + + +def getNeoLocation(): + locatino = "UNKNOWN" + if os.path.exists( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location"): + try: + with open( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location", + "r", + encoding="utf-8", + errors="ignore", + ) as f: + locatino = f.readline().strip() + except IOError: + pass + return locatino + + +media = getNeoLocation() +mediahome = media + "/ImageBoot/" +extensions_path = "/usr/lib/enigma2/python/Plugins/Extensions/" +dev_null = " > /dev/null 2>&1" +supportedTuners = "vuplus" + + +def NEOBootMainEx( + source, + target, + CopyFiles, + CopyKernel, + TvList, + LanWlan, + Sterowniki, + Montowanie, + InstallSettings, + ZipDelete, + RepairFTP, + SoftCam, + MediaPortal, + PiconR, + Kodi, + BlackHole, + Nandsim, +): + media_target = mediahome + target + list_one = [ + "rm -r " + media_target + dev_null, + "mkdir " + media_target + dev_null, + "chmod -R 0777 " + media_target, + ] + for command in list_one: + os.system(command) + + rc = NEOBootExtract(source, target, ZipDelete, Nandsim) + + os.system("sync; echo 1 > /proc/sys/vm/drop_caches") + + if not os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions" % + (media, target)): + os.system("mkdir -p %s/ImageBoot/%s/usr/lib/" % (media, target)) + os.system("mkdir -p %s/ImageBoot/%s/usr/lib/enigma2" % (media, target)) + os.system( + "mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python" % + (media, target)) + os.system( + "mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins" % + (media, target)) + os.system( + "mkdir -p %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions" % + (media, target)) + + if os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + % (media, target) + ): + os.system( + "rm -r %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" % + (media, target)) + + list_two = [ + "mkdir -p " + + media_target + + "/media" + + dev_null, + "rm " + + media_target + + media + + dev_null, + "rmdir " + + media_target + + media + + dev_null, + "mkdir -p " + + media_target + + media + + dev_null, + "cp /etc/hostname " + + media_target + + "/etc/hostname" + + dev_null, + "cp -a /usr/share/enigma2/rc_models/* " + + media_target + + "/usr/share/enigma2/rc_models/" + + dev_null, + "cp -r -p /usr/share/enigma2/rc_models " + + media_target + + "/usr/share/enigma2" + + dev_null, + "cp -af " + + extensions_path + + "NeoBoot " + + media_target + + extensions_path + + "NeoBoot" + + dev_null, + "mkdir -p " + + media_target + + extensions_path + + "NeoReboot" + + dev_null, + "touch " + + media_target + + extensions_path + + "NeoReboot/__init__.py" + + dev_null, + "chmod 644 " + + media_target + + extensions_path + + "NeoReboot/__init__.py" + + dev_null, + "cp -af " + + extensions_path + + "NeoBoot/files/backflash " + + media_target + + extensions_path + + "NeoReboot/backflash.sh" + + dev_null, + "cp -af " + + extensions_path + + "NeoBoot/files/neoreboot " + + media_target + + extensions_path + + "NeoReboot/plugin.py" + + dev_null, + ] + for command in list_two: + os.system(command) + + if CopyFiles == "False": + os.system('echo "No copying of files..."') + os.system( + "touch " + + getNeoLocation() + + "ImageBoot/.without_copying; sleep 5") + + if CopyKernel == "True": + if ( + getBoxHostName() == "vuultimo" + or getCPUSoC() == "7405" + and os.path.exists("%s/ImageBoot/%s/etc/vtiversion.info" % (media, target)) + ): + if os.path.exists("%s/ImageBoot/%s/lib/modules" % (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/modules" % (media, target) + rc = os.system(cmd) + cmd = "mkdir -p %s/ImageBoot/%s/lib/modules > /dev/null 2>&1" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "cp -af /lib/modules %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + if os.path.exists( + "%s/ImageBoot/%s/lib/firmware" % + (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/firmware" % (media, target) + rc = os.system(cmd) + cmd = "mkdir -p %s/ImageBoot/%s/lib/firmware > /dev/null 2>&1" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "cp -af /lib/firmware %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + os.system( + 'echo "Copied system drivers. Not recommended copied kernel.bin for Ultimo HD."' + ) + elif ( + getCPUtype() == "MIPS" + and getBoxHostName() == "vuultimo" + or getBoxHostName() == "bm750" + or getBoxHostName() == "vuduo" + or getBoxHostName() == "vuuno" + or getBoxHostName() == "vusolo" + or getBoxHostName() == "vuduo" + or getBoxHostName() == "vusolo2" + or getBoxHostName() == "vusolose" + or getBoxHostName() == "vuduo2" + or getBoxHostName() == "vuzero" + or getBoxHostName() == "mbultra" + ): + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/vuplus/" + + getBoxVuModel() + + "/kernel_cfe_auto.bin " + + media_target + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz" + + dev_null + ) + os.system('echo "Copied kernel.bin STB-MIPS"') + elif getCPUtype() == "MIPS" and getBoxHostName() == "et5x00": + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + getBoxHostName() + + "/kernel.bin " + + media_target + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz" + + dev_null + ) + os.system('echo "Copied kernel.bin STB-MIPS Clarke-Tech & Xtrend"') + elif ( + getCPUtype() == "ARMv7" + and getBoxHostName() == "vuultimo4k" + or getBoxHostName() == "vusolo4k" + or getBoxHostName() == "vuuno4k" + or getBoxHostName() == "vuuno4kse" + or getBoxHostName() == "vuduo4k" + or getBoxHostName() == "vuduo4kse" + or getBoxHostName() == "vuzero4k" + ): + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/vuplus/" + + getBoxVuModel() + + "/kernel_auto.bin " + + media_target + + "/boot/zImage." + + getBoxHostName() + + "" + + dev_null + ) + os.system('echo "Copied kernel.bin STB-ARM"') + + if not os.path.exists( + "" + + getNeoLocation() + + "ImageBoot/.without_copying"): + if os.path.exists("/usr/sbin/nandwrite"): + cmd = ( + "cp -af /usr/sbin/nandwrite %s/ImageBoot/%s/usr/sbin/nandwrite > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/usr/bin/fullwget"): + cmd = ( + "cp -af /usr/bin/fullwget %s/ImageBoot/%s/usr/bin/fullwget > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/etc/init.d/inadyn-mt"): + cmd = ( + "cp -af /etc/init.d/inadyn-mt %s/ImageBoot/%s/etc/init.d/inadyn-mt > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/usr/bin/inadyn-mt"): + cmd = ( + "cp -af /usr/bin/inadyn-mt %s/ImageBoot/%s/usr/bin/inadyn-mt > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/etc/inadyn.conf"): + cmd = ( + "cp -af /etc/inadyn.conf %s/ImageBoot/%s/etc/inadyn.conf > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists( + "/usr/lib/enigma2/python/Plugins/SystemPlugins/FanControl"): + cmd = ( + "cp -af /usr/lib/enigma2/python/Plugins/SystemPlugins/FanControl %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/SystemPlugins > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "EmuManager"): + cmd = ( + "cp -af " + + extensions_path + + "EmuManager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "CamdMenager"): + cmd = ( + "cp -af " + + extensions_path + + "CamdMenager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "IPTVPlayer"): + cmd = ( + "cp -af " + + extensions_path + + "IPTVPlayer %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + cmd = ( + "cp /usr/lib/python*.*/htmlentitydefs.pyo %s/ImageBoot/%s/usr/lib/python*.* > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "FeedExtra"): + cmd = ( + "cp -af " + + extensions_path + + "FeedExtra %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "MyUpdater"): + cmd = ( + "cp -af " + + extensions_path + + "MyUpdater %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "AlternativeSoftCamManager"): + cmd = ( + "cp -af " + + extensions_path + + "AlternativeSoftCamManager %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + if os.path.exists("" + extensions_path + "TempFanControl"): + cmd = ( + "cp -af " + + extensions_path + + "TempFanControl %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/TempFanControl > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + if not os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/boxbranding.so" % + (media, target)): + cmd = ( + "cp -af /usr/lib/enigma2/python/boxbranding.so %s/ImageBoot/%s/usr/lib/enigma2/python/boxbranding.so > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/HbbTV" + % (media, target) + ): + os.system( + "rm -rf %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/HbbTV" % + (media, target)) + + if TvList == "True": + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % (media, target) + rc = os.system(cmd) + cmd = "cp /etc/enigma2/*.tv %s/ImageBoot/%s/etc/enigma2" % ( + media, target) + rc = os.system(cmd) + cmd = "cp /etc/enigma2/*.radio %s/ImageBoot/%s/etc/enigma2" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "cp /etc/enigma2/*.tv %s/ImageBoot/%s/etc/enigma2" % ( + media, target) + rc = os.system(cmd) + cmd = "cp /etc/enigma2/lamedb %s/ImageBoot/%s/etc/enigma2" % ( + media, target) + rc = os.system(cmd) + os.system('echo "Copied TV list..."') + + if LanWlan == "True": + if os.path.exists( + "%s/ImageBoot/%s/etc/vtiversion.info" % + (media, target)): + os.system( + 'echo "Not copied LAN-WLAN, not recommended for this image."') + elif os.path.exists("/etc/vtiversion.info") and os.path.exists( + "%s/usr/lib/enigma2/python/Plugins/PLi" % (media, target) + ): + os.system( + 'echo "Not copied LAN-WLAN, not recommended for this image."') + elif os.path.exists("/etc/bhversion") and os.path.exists( + "%s/usr/lib/enigma2/python/Plugins/PLi" % (media, target) + ): + os.system( + 'echo "Not copied LAN-WLAN, not recommended for this image."') + if os.path.exists("/etc/wpa_supplicant.wlan0.conf"): + cmd = ( + "cp -af /etc/wpa_supplicant.wlan0.conf %s/ImageBoot/%s/etc/wpa_supplicant.wlan0.conf > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/etc/network/interfaces"): + cmd = ( + "cp -af /etc/network/interfaces %s/ImageBoot/%s/etc/network/interfaces > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/etc/wpa_supplicant.conf"): + cmd = ( + "cp -af /etc/wpa_suppligetinstallscant.conf %s/ImageBoot/%s/etc/wpa_supplicant.conf > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/etc/resolv.conf"): + cmd = ( + "cp -af /etc/resolv.conf %s/ImageBoot/%s/etc/resolv.conf > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + if os.path.exists("/etc/wl.conf.wlan3"): + cmd = ( + "cp -af /etc/wl.conf.wlan3 %s/ImageBoot/%s/etc/wl.conf.wlan3 > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + os.system('echo "Copied LAN-WLAN..."') + + if Sterowniki == "True": + if os.path.exists("%s/ImageBoot/%s/lib/modules" % (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/modules" % (media, target) + rc = os.system(cmd) + cmd = "mkdir -p %s/ImageBoot/%s/lib/modules > /dev/null 2>&1" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "cp -af /lib/modules %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + if os.path.exists( + "%s/ImageBoot/%s/lib/firmware" % + (media, target)): + cmd = "rm -r %s/ImageBoot/%s/lib/firmware" % (media, target) + rc = os.system(cmd) + cmd = "mkdir -p %s/ImageBoot/%s/lib/firmware > /dev/null 2>&1" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "cp -af /lib/firmware %s/ImageBoot/%s/lib > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + os.system('echo "System drivers copied..."') + + if Montowanie == "True": + if getCPUtype() == "MIPS": + if os.path.exists( + "%s/ImageBoot/%s/etc/fstab" % + (media, target)): + cmd = ( + "mv %s/ImageBoot/%s/etc/fstab %s/ImageBoot/%s/etc/fstab.org" % + (media, target, media, target)) + rc = os.system(cmd) + if os.path.exists( + "%s/ImageBoot/%s/etc/init.d/volatile-media.sh" % + (media, target)): + cmd = ( + "mv %s/ImageBoot/%s/etc/init.d/volatile-media.sh %s/ImageBoot/%s/etc/init.d/volatile-media.sh.org" % + (media, target, media, target)) + rc = os.system(cmd) + cmd = "cp -r /etc/fstab %s/ImageBoot/%s/etc/fstab" % ( + media, target) + rc = os.system(cmd) + os.system('echo "The fstab mount file was copied..."') + elif getCPUtype() == "ARMv7": + os.system('echo "No copied mount ARM..."') + + if InstallSettings == "True": + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % (media, target) + rc = os.system(cmd) + cmd = "cp /etc/enigma2/settings %s/ImageBoot/%s/etc/enigma2" % ( + media, + target, + ) + rc = os.system(cmd) + if not os.path.exists( + "%s/ImageBoot/%s/etc/tuxbox/config" % (media, target) + ): + cmd = ( + "mkdir -p /etc/tuxbox/config %s/ImageBoot/%s/etc/tuxbox/config" % + (media, target)) + rc = os.system(cmd) + cmd = "mkdir -p /etc/tuxbox/scce %s/ImageBoot/%s/etc/tuxbox/scce" % ( + media, target, ) + rc = os.system(cmd) + cmd = "cp -af /etc/tuxbox/* %s/ImageBoot/%s/etc/tuxbox" % ( + media, target) + rc = os.system(cmd) + os.system( + 'touch /tmp/settings_copied; echo "System settings copied..."') + + if RepairFTP == "True": + filename = media + "/ImageBoot/" + target + "/etc/vsftpd.conf" + if os.path.exists(filename): + filename2 = filename + ".tmp" + try: + with open(filename, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + + with open(filename2, "w", encoding="utf-8", errors="ignore") as out: + for line in lines: + if line.find("listen=NO") != -1: + line = "listen=YES\n" + elif line.find("listen_ipv6=YES") != -1: + line = "listen_ipv6=NO\n" + out.write(line) + + os.rename(filename2, filename) + except Exception as e: + os.system(f'echo "Failed to patch {filename}: {e}"') + if os.path.exists(filename2): + os.remove(filename2) + os.system('echo "Repair ftp."') + + if SoftCam == "True": + if os.path.exists("/etc/CCcam.cfg"): + cmd = "cp -af /etc/CCcam.cfg %s/ImageBoot/%s/etc > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + if os.path.exists("/etc/tuxbox/config"): + cmd = ( + "cp -af /etc/tuxbox/config %s/ImageBoot/%s/etc/tuxbox > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + os.system('echo "Copied softcam files to the installed image..."') + + if MediaPortal == "True": + if os.path.exists("" + extensions_path + "MediaPortal"): + cmd = ( + "cp -af " + + extensions_path + + "MediaPortal %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + cmd = ( + "cp -af " + + extensions_path + + "mpgz %s/ImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions > /dev/null 2>&1" % + (media, + target)) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/python2.7/argparse.pyo %s/ImageBoot/%s/usr/lib/python2.7 > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/python2.7/robotparser.pyo %s/ImageBoot/%s/usr/lib/python2.7 > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/Crypto %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/mechanize %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/requests %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/python2.7/site-packages/requests-2.11.1-py2.7.egg-info %s/ImageBoot/%s/usr/lib/python2.7/site-packages > /dev/null 2>&1" % + (media, target)) + rc = os.system(cmd) + + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % ( + media, target) + rc = os.system(cmd) + if os.path.exists("/etc/enigma2/mp_2s4p"): + cmd = "cp /etc/enigma2/mp_2s4p %s/ImageBoot/%s/etc/enigma2" % ( + media, target, ) + rc = os.system(cmd) + if os.path.exists("/etc/enigma2/mp_config"): + cmd = "cp /etc/enigma2/mp_config %s/ImageBoot/%s/etc/enigma2" % ( + media, target, ) + rc = os.system(cmd) + if os.path.exists("/etc/enigma2/mp_pluginliste"): + cmd = ( + "cp /etc/enigma2/mp_pluginliste %s/ImageBoot/%s/etc/enigma2" % + (media, target)) + rc = os.system(cmd) + os.system('echo "Copied MediaPortal..."') + elif not os.path.exists("" + extensions_path + "MediaPortal"): + os.system('echo "MediaPortal not found."') + + if PiconR == "True": + if os.path.exists("/usr/share/enigma2/picon"): + cmd = ( + "cp -af /usr/share/enigma2/picon %s/ImageBoot/%s/usr/share/enigma2" % + (media, target)) + rc = os.system(cmd) + os.system('echo "Copied picon..."') + elif not os.path.exists("/usr/share/enigma2/picon"): + os.system('echo "Picon flash not found."') + + if Kodi == "True": + cmd = "mkdir -p %s/ImageBoot/%s/home/root/.kodi > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + if os.path.exists("/home/root/.kodi"): + os.system('echo "Kodi set ok."') + else: + if not os.path.exists("/home/root/.kodi"): + if not os.path.exists("/.multinfo"): + if os.path.exists("/media/hdd/.kodi"): + cmd = 'mv /media/hdd/.kodi /media/hdd/.kodi_flash; ln -sf "/media/hdd/.kodi_flash" "/home/root/.kodi"; ln -sf "/home/root/.kodi" "/media/hdd/.kodi" ' + rc = os.system(cmd) + os.system('echo "Kodi fix ok."') + else: + os.system('echo "Kodi not found.."') + else: + os.system('echo "Kodi path possible only from flash."') + else: + os.system('echo "Kodi not found."') + + if BlackHole == "True": + if "BlackHole" in source or os.path.exists( + "%s/ImageBoot/%s/usr/lib/enigma2/python/Blackhole" % + (media, target)): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/boot/blackhole" % target + ) + rc = os.system(cmd) + cmd = ( + "mv " + + getNeoLocation() + + "ImageBoot/" + + target + + "/usr/lib/enigma2/python/Blackhole/BhUtils.pyo " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Blackhole/BhUtils.pyo.org" % + target) + rc = os.system(cmd) + cmd = ( + "cp -af " + + extensions_path + + "NeoBoot/bin/utilsbh " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Blackhole/BhUtils.py" % + target) + rc = os.system(cmd) + ver = source.replace("BlackHole-", "") + try: + text = ver.split("-")[0] + except Exception: + text = "" + localfile = ( + "" + + getNeoLocation() + + "ImageBoot/%s/boot/blackhole/version" % target + ) + try: + with open( + localfile, "w", encoding="utf-8", errors="ignore" + ) as temp_file: + temp_file.write(text) + except Exception as e: + os.system(f'echo "Failed to write {localfile}: {e}"') + + cmd = ( + "mv " + + getNeoLocation() + + "ImageBoot/" + + target + + "/usr/bin/enigma2 " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2-or" % target + ) + rc = os.system(cmd) + + fail = ( + "" + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2-or" % + target) + content = "" + try: + with open(fail, "r", encoding="utf-8", errors="ignore") as f: + content = f.read() + except Exception as e: + os.system(f'echo "Failed to read {fail}: {e}"') + + if content: + localfile2 = ( + "" + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2" % + target) + try: + with open( + localfile2, "w", encoding="utf-8", errors="ignore" + ) as temp_file2: + temp_file2.write( + content.replace( + "/proc/blackhole/version", + "/boot/blackhole/version")) + + cmd = "chmod -R 0755 %s" % localfile2 + rc = os.system(cmd) + cmd = ( + "rm -r " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/enigma2-or" % target + ) + rc = os.system(cmd) + except Exception as e: + os.system(f'echo "Failed to write {localfile2}: {e}"') + + if os.path.exists("/var/lib/zerotier-one/identity.secret"): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/var/lib/zerotier-one" % target + ) + rc = os.system(cmd) + cmd1 = ( + "cp -af /var/lib/zerotier-one/identity.secret " + + getNeoLocation() + + "ImageBoot/%s/var/lib/zerotier-one/" % target + ) + rc = os.system(cmd1) + + if os.path.exists("/var/lib/tailscale/tailscaled.state"): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/var/lib/tailscale" % target + ) + rc = os.system(cmd) + cmd1 = ( + "cp -af /var/lib/tailscale/* " + + getNeoLocation() + + "ImageBoot/%s/var/lib/tailscale/" % target + ) + rc = os.system(cmd1) + cmd2 = ( + "cp -af /var/lib/tailscale/* " + + getNeoLocation() + + "ImageBoot/%s/var/lib/tailscale/" % target + ) + rc = os.system(cmd2) + if os.path.exists("/usr/sbin/tailscaled"): + cmd3 = ( + "cp -af /usr/sbin/tailscaled " + + getNeoLocation() + + "ImageBoot/%s/susr/sbin/" % target + ) + rc = os.system(cmd3) + elif os.path.exists("/usr/bin/tailscaled"): + cmd3 = ( + "cp -af /usr/bin/tailscaled " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/" % target + ) + rc = os.system(cmd3) + cmd4 = ( + "cp -af /usr/bin/tailscale " + + getNeoLocation() + + "ImageBoot/%s/usr/bin/" % target + ) + rc = os.system(cmd4) + cmd5 = ( + "cp -af /etc/init.d/tailscal* " + + getNeoLocation() + + "ImageBoot/%s/etc/init.d/" % target + ) + rc = os.system(cmd5) + if not os.path.exists( + "%s/ImageBoot/%s/lib/modules/kernel/drivers/net/tun.ko" + % (media, target) + ): + if not os.path.exists( + "%s/ImageBoot/%s/lib/modules/kernel/drivers/net" % + (media, target)): + cmd = "mkdir -p %s/ImageBoot/%s/lib/modules/kernel/drivers/net/" % ( + media, target, ) + rc = os.system(cmd) + cmd = ( + "cp -af /lib/modules/" + + getKernelVersion() + + "/kernel/drivers/net/tun.ko %s/ImageBoot/%s/lib/modules/kernel/drivers/net/" % + (media, + target)) + rc = os.system(cmd) + if not os.path.exists( + "%s/ImageBoot/%s/var/run/tailscale" % (media, target) + ): + cmd = ( + "mkdir -p " + + getNeoLocation() + + "/ImageBoot/%s/run/tailscale/" % target + ) + rc = os.system(cmd) + if os.path.exists("/run/tailscale"): + cmd = ( + "cp -aRf /run/tailscale/tailscaled.sock " + + getNeoLocation() + + "ImageBoot/%s/run/tailscale/" % target + ) + rc = os.system(cmd) + cmd1 = ( + "cp -aRf /run/resolvconf/interfaces/tailscale " + + getNeoLocation() + + "ImageBoot/%s/run/tailscale/" % target + ) + rc = os.system(cmd1) + + if os.path.exists("%s/ImageBoot/%s/etc/init.d" % (media, target)): + cmd = ( + "ln -s %sImageBoot/%s/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh %sImageBoot/%s/etc/rcS.d/S99neo.local" % + (media, target, media, target)) + + elif not os.path.exists("%s/ImageBoot/%s/etc/init.d" % (media, target)): + os.system('echo "/etc/init.d not found."') + os.system('echo "Copied file neo_userscript.sh"') + + if not os.path.exists( + "" + getNeoLocation() + "ImageBoot/.without_copying" + ) and not os.path.exists(" /tmp/settings_copied"): + try: + with open("/etc/hostname", "r", encoding="utf-8", errors="ignore") as f: + for line in f: + if ( + getCPUtype() == "MIPS" + and "dm500hd" in line + or "dm800se" in line + or "dm800" in line + or "dm800se" in line + or "dm8000" in line + ): + if os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % (media, target) + ): + cmd = "rm -r %s/ImageBoot/%s/etc/enigma2" % ( + media, target) + rc = os.system(cmd) + else: + if not os.path.exists( + "%s/ImageBoot/%s/etc/enigma2" % (media, target) + ): + cmd = "mkdir -p %s/ImageBoot/%s/etc/enigma2" % ( + media, + target, + ) + rc = os.system(cmd) + cmd = "touch %s/ImageBoot/%s/etc/enigma2/settings" % ( + media, target, ) + rc = os.system(cmd) + cmd = ( + 'grep "config.Nims" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd) + cmd1 = ( + 'grep "av.videomode.DVI" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd1) + cmd2 = ( + 'grep "config.OpenWebif" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd2) + cmd3 = ( + 'grep "config.osd" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd3) + cmd4 = ( + 'grep "config.timezone.val" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd4) + cmd5 = ( + 'grep "config.servicelist.startuproot" /etc/enigma2/settings >> %s/ImageBoot/%s/etc/enigma2/settings' % + (media, target)) + rc = os.system(cmd5) + cmd6 = ( + 'grep "UUID=" /etc/fstab >> %s/ImageBoot/%s/etc/fstab' % + (media, target)) + rc = os.system(cmd6) + except Exception as e: + os.system(f'echo "Failed reading /etc/hostname: {e}"') + + if ( + not os.path.exists( + "" + media_target + "/boot/zImage." + getBoxHostName() + "" + ) + and getCPUtype() == "MIPS" + ): + namefile = media + "/ImageBoot/" + target + "/etc/fstab" + namefile2 = namefile + ".tmp" + if os.path.exists(namefile): # Check if source exists + try: + with open(namefile, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + with open(namefile2, "w", encoding="utf-8", errors="ignore") as out: + for line in lines: + if line.find("/dev/mmcblk0p2") != -1: + line = "#" + line + elif line.find("/dev/root") != -1: + line = "#" + line + out.write(line) + os.rename(namefile2, namefile) + except Exception as e: + os.system(f'echo "Failed to patch {namefile}: {e}"') + if os.path.exists(namefile2): + os.remove(namefile2) + + tpmd = media + "/ImageBoot/" + target + "/etc/init.d/tpmd" + if os.path.exists(tpmd): + os.system("rm " + tpmd) + + fname = ( + media + + "/ImageBoot/" + + target + + "/usr/lib/enigma2/python/Components/config.py" + ) + if os.path.exists(fname): + fname2 = fname + ".tmp" + try: + with open(fname, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + with open(fname2, "w", encoding="utf-8", errors="ignore") as out: + for line in lines: + if line.find( + 'if file(""/proc/stb/info/vumodel")') != -1: + line = "#" + line + out.write(line) + os.rename(fname2, fname) + except Exception as e: + os.system(f'echo "Failed to patch {fname}: {e}"') + if os.path.exists(fname2): + os.remove(fname2) + + targetfile = media + "/ImageBoot/" + target + "/etc/vsftpd.conf" + if os.path.exists(targetfile): + targetfile2 = targetfile + ".tmp" + try: + with open(targetfile, "r", encoding="utf-8", errors="ignore") as f: + lines = f.readlines() + with open( + targetfile2, "w", encoding="utf-8", errors="ignore" + ) as out: + for line in lines: + if not line.startswith("nopriv_user"): + out.write(line) + os.rename(targetfile2, targetfile) + except Exception as e: + os.system(f'echo "Failed to patch {targetfile}: {e}"') + if os.path.exists(targetfile2): + os.remove(targetfile2) + + mypath = media + "/ImageBoot/" + target + "/usr/lib/opkg/info/" + cmd = "mkdir -p %s/ImageBoot/%s/var/lib/opkg/info > /dev/null 2>&1" % ( + media, target, ) + rc = os.system(cmd) + if not os.path.exists(mypath): + mypath = media + "/ImageBoot/" + target + "/var/lib/opkg/info/" + + if os.path.exists(mypath): # Check if path exists before listing + for fn in os.listdir(mypath): + if ((fn.find("kernel-image") != - + 1 and fn.find("postinst") != - + 1) or fn.find("-bootlogo.postinst") != - + 1 or fn.find("-bootlogo.postrm") != - + 1 or fn.find("-bootlogo.preinst") != - + 1 or fn.find("-bootlogo.prerm") != - + 1): + + filename = os.path.join(mypath, fn) + filename2 = filename + ".tmp" + try: + with open( + filename, "r", encoding="utf-8", errors="ignore" + ) as f: + lines = f.readlines() + + with open( + filename2, "w", encoding="utf-8", errors="ignore" + ) as out: + for line in lines: + if line.find("/boot") != -1: + line = line.replace( + "/boot", "/boot > /dev/null 2>\\&1; exit 0") + out.write(line) + + os.rename(filename2, filename) + cmd = "chmod -R 0755 %s" % filename + rc = os.system(cmd) + except Exception as e: + os.system( + f'echo "Failed to patch {filename}: {e}"') + if os.path.exists(filename2): + os.remove(filename2) + + if os.path.exists( + "%s/ImageBoot/%s/var/lib/opkg/status1" % + (media, target)): + cmd = ( + "mv " + + getNeoLocation() + + "ImageBoot/" + + target + + "/var/lib/opkg/status " + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status-or" % target + ) + rc = os.system(cmd) + + fail = ( + "" + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status-or" % target + ) + content = "" + try: + with open(fail, "r", encoding="utf-8", errors="ignore") as f: + content = f.read() + except Exception as e: + os.system(f'echo "Failed to read {fail}: {e}"') + + if content: + localfile2 = ( + "" + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status" % target + ) + try: + with open( + localfile2, "w", encoding="utf-8", errors="ignore" + ) as temp_file2: + temp_file2.write( + content.replace( + "kernel-image", + "#kernel-image")) + + cmd = "chmod -R 0755 %s" % localfile2 + rc = os.system(cmd) + cmd = ( + "rm -r " + + getNeoLocation() + + "ImageBoot/%s/var/lib/opkg/status-or" % target + ) + rc = os.system(cmd) + except Exception as e: + os.system(f'echo "Failed to write {localfile2}: {e}"') + + if os.path.exists("%s/ImageBoot/%s/usr/lib" % (media, target)): + cmd = ( + "cp -af /usr/lib/periodon " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/" % target + ) + rc = os.system(cmd) + cmd = ( + "mkdir -p " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Tools/" % target + ) + rc = os.system(cmd) + cmd = ( + "cp -af /usr/lib/enigma2/python/Tools/Testinout.py " + + getNeoLocation() + + "ImageBoot/%s/usr/lib/enigma2/python/Tools/" % target + ) + rc = os.system(cmd) + + cmd = "rm -r " + getNeoLocation() + "ImageBoot/%s/tmp" % target + rc = os.system(cmd) + + os.system("mkdir -p " + media_target + "/media/hdd" + dev_null) + os.system("mkdir -p " + media_target + "/media/usb" + dev_null) + os.system("mkdir -p " + media_target + "/var/lib/opkg/info/" + dev_null) + os.system( + "touch " + + getNeoLocation() + + 'ImageBoot/.data; echo "Data instalacji image" > ' + + getNeoLocation() + + 'ImageBoot/.data; echo " "; date > ' + + getNeoLocation() + + "ImageBoot/.data" + ) + os.system( + "mv -f " + + getNeoLocation() + + "ImageBoot/.data " + + getNeoLocation() + + "ImageBoot/%s/.data" % target + ) + cmd = "touch /tmp/.init_reboot" + rc = os.system(cmd) + + try: + with open( + mediahome + ".neonextboot", "w", encoding="utf-8", errors="ignore" + ) as out: + out.write(target) + except Exception as e: + os.system(f'echo "Failed to write .neonextboot: {e}"') + + os.system( + "cp " + + getNeoLocation() + + "ImageBoot/.neonextboot " + + getNeoLocation() + + "ImageBoot/%s/.multinfo" % target + ) + + try: + with open( + mediahome + ".neonextboot", "w", encoding="utf-8", errors="ignore" + ) as out: + out.write("Flash") + except Exception as e: + os.system(f'echo "Failed to write .neonextboot: {e}"') + + if ".tar.xz" not in source and not os.path.exists( + "" + getNeoLocation() + "/ImageBoot/%s/etc/issue" % target + ): + os.system( + 'echo ""; echo "No system installed! The reason for the installation error may be badly packed image files or it is not a system for your model."' + ) + os.system( + 'echo "The installed system may not start. Check the correctness of the installed image directory!!!"' + ) + os.system("rm -r " + getNeoLocation() + "/ImageBoot/%s" % target) + + if os.path.exists("" + getNeoLocation() + "ubi"): + os.system("rm -r " + getNeoLocation() + "ubi") + if os.path.exists("" + getNeoLocation() + "image_cache/"): + os.system("rm -r " + getNeoLocation() + "image_cache") + if os.path.exists("" + getNeoLocation() + "ImageBoot/.without_copying"): + os.system("rm -f " + getNeoLocation() + "ImageBoot/.without_copying") + + rc = RemoveUnpackDirs() + + os.system('echo "End of installation:"; date +%T') + os.system( + 'echo "If you want to save the installation process from the console press green."' + ) + + +def RemoveUnpackDirs(): + os.chdir(media + "/ImagesUpload") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/unpackedzip"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/unpackedzip") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/*.bin"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/*.bin") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/*.txt"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/*.txt") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/vuplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/sf4008"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/sf4008") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmio4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osmio4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmio4kplus"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/osmio4kplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm900"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dm900") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd60"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/hd60") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd61"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/hd61") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd51"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/hd51") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/bre2ze4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/bre2ze4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multibox"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/multibox") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxse"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/multiboxse") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxpro"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/multiboxpro") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/unforce_multibox.txt"): + rc = os.system( + "rm -r " + getNeoLocation() + "ImagesUpload/unforce_multibox.txt" + ) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/axas"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/axas") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/miraclebox"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/miraclebox") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/e4hd"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/e4hd") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/update") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.xz"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/*.nfi"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/*.nfi") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/zgemma"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/zgemma") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/formuler1"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/formuler1") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/formuler3"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/formuler3") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/formuler4turbo"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/formuler4turbo") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et*"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et*") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedl*"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/xpeedl*") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osmini") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osminiplus"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osminiplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osnino"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osnino") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osninoplus"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osninoplus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osninopro"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osninopro") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/osmini4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/xp1000 "): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/xp1000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et5x00"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et5x00") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dinobot") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/e2/update"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/e2") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et1x000"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et1x000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/protek4k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/protek4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm920 "): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dm920") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dreamtwo "): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dreamtwo ") + elif ( + os.path.exists("" + getNeoLocation() + "ImagesUpload/multibox") + or os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxse") + or os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxpro") + ): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/multibox " + + getNeoLocation() + + "ImagesUpload/multibox; rm -r " + + getNeoLocation() + + "ImagesUpload/multibox" + ) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/octagon/sf8008"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/octagon; rm -r " + + getNeoLocation() + + "ImagesUpload/octagon" + ) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/octagon/sf8008m"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/octagon") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h5"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h5; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h5" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h7"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h7; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h7" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h7") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h9; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h9" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9se"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/h9se; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/h9se" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9se") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/i55plus"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/i55plus; mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/i55plus" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/i55plus") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9combo"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h9combo_READ.ME " + + getNeoLocation() + + "ImagesUpload/h9combo; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h9combo.txt " + + getNeoLocation() + + "ImagesUpload/h9combo" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9combo") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h9combose"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h9combose_READ.ME " + + getNeoLocation() + + "ImagesUpload/h9combo; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h9combose.txt " + + getNeoLocation() + + "ImagesUpload/h9combose" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h9combose") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h10"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h10_READ.ME " + + getNeoLocation() + + "ImagesUpload/h10; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h10.txt " + + getNeoLocation() + + "ImagesUpload/h10" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h10") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h11"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/force_h11_READ.ME " + + getNeoLocation() + + "ImagesUpload/h11; mv " + + getNeoLocation() + + "ImagesUpload/unforce_h11.txt " + + getNeoLocation() + + "ImagesUpload/h11" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h11") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h8"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/h8") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/uclan"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/usb_update.bin"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/uclan" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/uclan") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/ustym4kpro"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/ustym4kpro") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/beyonwiz"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/apploader.bin " + + getNeoLocation() + + "ImagesUpload/beyonwiz" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/beyonwiz" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/beyonwiz" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/beyonwiz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/amiko"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/apploader.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/amiko" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/amiko") + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/gigablue/x1" + ) or os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/x34k"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/gigablue") + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/gigablue" + ) and os.path.exists("" + getNeoLocation() + "ImagesUpload/usb_update.bin"): + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/usb_update.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/apploader.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/bootargs.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/fastboot.bin " + + getNeoLocation() + + "ImagesUpload/gigablue" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/gigablue") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et10000"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/et10000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1000"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/vs1000") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1500"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/vs1500") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/pulse4k"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/pulse4k/force_pulse4k_READ.ME"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4k/force_pulse4k_READ.ME; rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4k/unforce_pulse4k.txt" + ) + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/pulse4k") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/pulse4kmin"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/pulse4kmin/force_pulse4kmini_READ.ME"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4kmini/force_pulse4kmini_READ.ME; rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4kmini/unforce_pulse4kmini.txt" + ) + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/pulse4kmini") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedlx"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/xpeedlx") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm520"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/dm520") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.gz"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.gz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.xz"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar.bz2"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.bz2") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.tar"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/rootfs.tar") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/unforce_h9combo.txt"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/unforce_h9combo.txt") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/imageversion"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/imageversion") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/kernel.bin"): + rc = os.system( + "rm -rf " + + getNeoLocation() + + "ImagesUpload/kernel.bin") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/force_multibox_READ.ME"): + rc = os.system( + "rm -r " + getNeoLocation() + "ImagesUpload/force_multibox_READ.ME" + ) + if os.path.exists("" + getNeoLocation() + "ImagesUpload/force"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/force") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.bin"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/rootfs.bin") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/splash.bin"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/splash.bin") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue"): + rc = os.system("rm -r " + getNeoLocation() + "ImagesUpload/gigablue") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/update_bootargs_h8"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/update_bootargs_h8") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/force_hd60_READ.ME"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/force_hd60_READ.ME") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/unforce_hd60.txt"): + rc = os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/unforce_hd60.txt") + if os.path.exists("/tmp/root_jffs2"): + rc = os.system("rm -fr /tmp/root_jffs2") + if os.path.exists("/tmp/xz-gz-tar"): + rc = os.system("rm -fr /tmp/xz-gz-tar") + if os.path.exists("/tmp/other_image"): + rc = os.system("rm -fr /tmp/other_image") def NEOBootExtract(source, target, ZipDelete, Nandsim): RemoveUnpackDirs() - os.system('echo "Press green to hide Console or red to abort the installation\nInstallation started:"; date +%T;echo "Extracting the installation file..."') + os.system( + 'echo "Press green to hide Console or red to abort the installation\nInstallation started:"; date +%T;echo "Extracting the installation file..."' + ) - if os.path.exists('' + getNeoLocation() + 'ImageBoot/.without_copying'): - os.system('rm -f ' + getNeoLocation() + 'ImageBoot/.without_copying') - if os.path.exists('' + getNeoLocation() + 'image_cache'): - os.system('rm -rf ' + getNeoLocation() + 'image_cache') + if os.path.exists("" + getNeoLocation() + "ImageBoot/.without_copying"): + os.system("rm -f " + getNeoLocation() + "ImageBoot/.without_copying") + if os.path.exists("" + getNeoLocation() + "image_cache"): + os.system("rm -rf " + getNeoLocation() + "image_cache") - sourcefile = media + '/ImagesUpload/%s.zip' % source - sourcefile2 = media + '/ImagesUpload/%s.nfi' % source - sourcefile3 = media + '/ImagesUpload/%s.rar' % source - sourcefile4 = media + '/ImagesUpload/%s.gz' % source + sourcefile = media + "/ImagesUpload/%s.zip" % source + sourcefile2 = media + "/ImagesUpload/%s.nfi" % source + sourcefile3 = media + "/ImagesUpload/%s.rar" % source + sourcefile4 = media + "/ImagesUpload/%s.gz" % source - # Instalacja *.nfi - if os.path.exists(sourcefile2) is True: - if sourcefile2.endswith('.nfi'): + if os.path.exists(sourcefile2): + if sourcefile2.endswith(".nfi"): os.system('echo "Instalacja systemu skapowanego w plik nfi..."') - to = '' + getNeoLocation() + 'ImageBoot/' + target - cmd = 'mkdir %s > /dev/null 2<&1' % to + to = "" + getNeoLocation() + "ImageBoot/" + target + cmd = "mkdir %s > /dev/null 2<&1" % to rc = os.system(cmd) - to = '' + getNeoLocation() + 'ImageBoot/' + target - cmd = 'chmod -R 0777 %s' % to + to = "" + getNeoLocation() + "ImageBoot/" + target + cmd = "chmod -R 0777 %s" % to rc = os.system(cmd) - cmd = 'touch /tmp/root_jffs2; ' + extensions_path + 'NeoBoot/bin/nfidump ' + \ - sourcefile2 + ' ' + getNeoLocation() + 'ImageBoot/' + target + cmd = ( + "touch /tmp/root_jffs2; " + + extensions_path + + "NeoBoot/bin/nfidump " + + sourcefile2 + + " " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - if os.path.exists('%sImageBoot/%s/media/squashfs-images' % (media, target)) and os.path.exists('%s/squashfs-images' % (media)): + if os.path.exists( + "%sImageBoot/%s/media/squashfs-images" % (media, target) + ) and os.path.exists("%s/squashfs-images" % (media)): os.system( - 'cp -af %s/squashfs-images/* "%sImageBoot/%s/media/squashfs-images' % (media, media, target)) - if ZipDelete == 'True': - rc = os.system('rm -rf ' + sourcefile2) + 'cp -af %s/squashfs-images/* "%sImageBoot/%s/media/squashfs-images' % + (media, media, target)) + if ZipDelete == "True": + rc = os.system("rm -rf " + sourcefile2) else: os.system( - 'echo "NeoBoot keep the file: %s for reinstallation."' % sourcefile2) - # Instalacja *.rar - if os.path.exists(sourcefile3) is True: - if sourcefile3.endswith('.rar'): + 'echo "NeoBoot keep the file: %s for reinstallation."' + % sourcefile2 + ) + if os.path.exists(sourcefile3): + if sourcefile3.endswith(".rar"): os.system('echo "Installing iamge x.rar..."') - cmd = 'unrar e ' + sourcefile3 + ' ' + \ - getNeoLocation() + 'ImagesUpload/ > /dev/null 2>&1' + cmd = ( + "unrar e " + + sourcefile3 + + " " + + getNeoLocation() + + "ImagesUpload/ > /dev/null 2>&1" + ) rc = os.system(cmd) - if ZipDelete == 'True': - rc = os.system('rm -rf ' + sourcefile3) + if ZipDelete == "True": + rc = os.system("rm -rf " + sourcefile3) else: os.system( - 'echo "NeoBoot keep the file: %s for reinstallation."' % sourcefile3) + 'echo "NeoBoot keep the file: %s for reinstallation."' + % sourcefile3 + ) - # Instalacja *.zip - elif os.path.exists(sourcefile) is True: - os.system('unzip -o ' + sourcefile) - if ZipDelete == 'True': - os.system('rm -rf ' + sourcefile) + elif os.path.exists(sourcefile): + os.system("unzip -o " + sourcefile) + if ZipDelete == "True": + os.system("rm -rf " + sourcefile) - fn = 'NewImage' + fn = "NewImage" sourcelist = [] - for fn in os.listdir('%sImagesUpload' % getNeoLocation()): - if fn.find('.rootfs.tar.xz') != -1: - os.system('touch /tmp/other_image') - elif fn.find('.tar.xz') != -1: - os.system('touch /tmp/other_image') - elif fn.find('.tar.bz2') != -1: - os.system('touch /tmp/other_image') - elif fn.find('.tar.gz') != -1: - os.system('touch /tmp/other_image') - elif fn.find('.tar') != -1: - os.system('touch /tmp/other_image') - elif fn.find('.gz') != -1: - os.system('touch /tmp/other_image') + if os.path.exists("%sImagesUpload" % getNeoLocation()): + for fn in os.listdir("%sImagesUpload" % getNeoLocation()): + if fn.find(".rootfs.tar.xz") != -1: + os.system("touch /tmp/other_image") + elif fn.find(".tar.xz") != -1: + os.system("touch /tmp/other_image") + elif fn.find(".tar.bz2") != -1: + os.system("touch /tmp/other_image") + elif fn.find(".tar.gz") != -1: + os.system("touch /tmp/other_image") + elif fn.find(".tar") != -1: + os.system("touch /tmp/other_image") + elif fn.find(".gz") != -1: + os.system("touch /tmp/other_image") - # Instalacja MIPS - if getCPUtype() == 'MIPS' and not os.path.exists('/tmp/root_jffs2') and not os.path.exists('/tmp/other_image'): - if os.path.exists('' + getNeoLocation() + 'ubi') is False: - rc = os.system('mkdir ' + getNeoLocation() + 'ubi') - to = '' + getNeoLocation() + 'ImageBoot/' + target - cmd = 'mkdir %s > /dev/null 2<&1' % to + if ( + getCPUtype() == "MIPS" + and not os.path.exists("/tmp/root_jffs2") + and not os.path.exists("/tmp/other_image") + ): + if not os.path.exists("" + getNeoLocation() + "ubi"): + rc = os.system("mkdir " + getNeoLocation() + "ubi") + to = "" + getNeoLocation() + "ImageBoot/" + target + cmd = "mkdir %s > /dev/null 2<&1" % to rc = os.system(cmd) - cmd = 'chmod -R 0777 %s' % to + cmd = "chmod -R 0777 %s" % to rc = os.system(cmd) - rootfname = 'rootfs.bin' - brand = '' + rootfname = "rootfs.bin" + brand = "" - # NANDSIM - if Nandsim == 'True' or os.path.exists('/tmp/.isnandsim') or os.path.exists('/lib/modules/%s/kernel/drivers/mtd/nand/nandsim.ko' % getKernelVersion()): + if ( + Nandsim == "True" + or os.path.exists("/tmp/.isnandsim") + or os.path.exists( + "/lib/modules/%s/kernel/drivers/mtd/nand/nandsim.ko" + % getKernelVersion() + ) + ): for i in range(0, 20): - mtdfile = '/dev/mtd' + str(i) - if os.path.exists(mtdfile) is False: + mtdfile = "/dev/mtd" + str(i) + if not os.path.exists(mtdfile): break mtd = str(i) - os.chdir(media + '/ImagesUpload') + os.chdir(media + "/ImagesUpload") - # zgemma - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma'): - os.chdir('zgemma') - brand = 'zgemma' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/sh1'): - os.chdir('sh1') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/sh2'): - os.chdir('sh2') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h2'): - os.chdir('h2') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h3'): - os.chdir('h3') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h5'): - os.chdir('h5') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h7'): - os.chdir('h7') + if os.path.exists("" + getNeoLocation() + "ImagesUpload/zgemma"): + os.chdir("zgemma") + brand = "zgemma" + rootfname = "rootfs.bin" - # miraclebox - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox'): - os.chdir('miraclebox') - brand = 'miraclebox' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/mini'): - os.chdir('mini') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/miniplus'): - os.chdir('miniplus') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/minihybrid'): - os.chdir('minihybrid') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/twin'): - os.chdir('twin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/ultra'): - os.chdir('ultra') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/micro'): - os.chdir('micro') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/twinplus'): - os.chdir('twinplus') - # atemio - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio'): - os.chdir('atemio') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/5x00'): - os.chdir('5x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/6000'): - os.chdir('6000') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/6100'): - os.chdir('6100') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/6200'): - os.chdir('6200') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/8x00'): - os.chdir('8x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/8x00'): - os.chdir('8x00') - # Xtrend - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et10000'): - os.chdir('et10000') - brand = 'et10000' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et9x00'): - os.chdir('et9x00') - brand = 'et9x00' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et8500'): - os.chdir('et8500') - brand = 'et8500' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et8000'): - os.chdir('et8000') - brand = 'et8000' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et7x00'): - os.chdir('et7x00') - brand = 'et7x00' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et6x00'): - os.chdir('et6x00') - brand = 'et6x00' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et5x00'): - os.chdir('et5x00') - brand = 'et5x00' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et4x00'): - os.chdir('et4x00') - brand = 'et4x00' - # formuler - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler1'): - os.chdir('formuler1') - brand = 'formuler1' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler2'): - os.chdir('formuler2') - brand = 'formuler2' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler3'): - os.chdir('formuler3') - brand = 'formuler3' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler4turbo'): - os.chdir('formuler4turbo') - brand = 'formuler4turbo' - # Golden Interstar - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/xpeedlx'): - os.chdir('xpeedlx') - brand = 'xpeedlx' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/xpeedlx3'): - os.chdir('xpeedlx3') - brand = 'xpeedlx3' - # GigaBlue - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue'): - os.chdir('gigablue') - brand = 'gigablue' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/x1'): - os.chdir('x1') - # VuPlus - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus'): - os.chdir('vuplus') - brand = 'vuplus' - rootfname = 'root_cfe_auto.jffs2' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/uno'): - os.chdir('uno') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo'): - os.chdir('duo') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/ultimo'): - os.chdir('ultimo') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solo'): - os.chdir('solo') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo2'): - os.chdir('duo2') - rootfname = 'root_cfe_auto.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solo2'): - os.chdir('solo2') - rootfname = 'root_cfe_auto.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solose'): - os.chdir('solose') - rootfname = 'root_cfe_auto.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/zero'): - os.chdir('zero') - rootfname = 'root_cfe_auto.bin' + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/sh1"): + os.chdir("sh1") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/sh2"): + os.chdir("sh2") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h2"): + os.chdir("h2") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h3"): + os.chdir("h3") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h5"): + os.chdir("h5") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h7"): + os.chdir("h7") - # os_Edision - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmini'): - os.chdir('osmini') - brand = 'osmini' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osminiplus'): - os.chdir('osminiplus') - brand = 'osmini' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmega'): - os.chdir('osmega') - brand = 'osmini' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osnino'): - os.chdir('osnino') - brand = 'osnino' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osninoplus'): - os.chdir('osninoplus') - brand = 'osnino' - rootfname = 'rootfs.bin' - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osninopro'): - os.chdir('osninopro') - brand = 'osnino' - rootfname = 'rootfs.bin' - # Vimastec - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vs1000'): - os.chdir('vs1000') - brand = 'vs1000' - rootfname = 'rootfs.bin' - # - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf3038'): - os.chdir('sf3038') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/xp1000'): - os.chdir('xp1000') - brand = 'xp1000' + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/miraclebox"): + os.chdir("miraclebox") + brand = "miraclebox" + rootfname = "rootfs.bin" + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/mini" + ): + os.chdir("mini") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/miniplus" + ): + os.chdir("miniplus") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/miraclebox/minihybrid"): + os.chdir("minihybrid") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/twin" + ): + os.chdir("twin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/ultra" + ): + os.chdir("ultra") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/micro" + ): + os.chdir("micro") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/twinplus" + ): + os.chdir("twinplus") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/atemio"): + os.chdir("atemio") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/5x00"): + os.chdir("5x00") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/6000"): + os.chdir("6000") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/6100"): + os.chdir("6100") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/6200"): + os.chdir("6200") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/8x00"): + os.chdir("8x00") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/8x00"): + os.chdir("8x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et10000"): + os.chdir("et10000") + brand = "et10000" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et9x00"): + os.chdir("et9x00") + brand = "et9x00" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et8500"): + os.chdir("et8500") + brand = "et8500" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et8000"): + os.chdir("et8000") + brand = "et8000" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et7x00"): + os.chdir("et7x00") + brand = "et7x00" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et6x00"): + os.chdir("et6x00") + brand = "et6x00" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et5x00"): + os.chdir("et5x00") + brand = "et5x00" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et4x00"): + os.chdir("et4x00") + brand = "et4x00" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler1"): + os.chdir("formuler1") + brand = "formuler1" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler2"): + os.chdir("formuler2") + brand = "formuler2" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler3"): + os.chdir("formuler3") + brand = "formuler3" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler4turbo"): + os.chdir("formuler4turbo") + brand = "formuler4turbo" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedlx"): + os.chdir("xpeedlx") + brand = "xpeedlx" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedlx3"): + os.chdir("xpeedlx3") + brand = "xpeedlx3" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue"): + os.chdir("gigablue") + brand = "gigablue" + rootfname = "rootfs.bin" + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/gigablue/x1"): + os.chdir("x1") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus"): + os.chdir("vuplus") + brand = "vuplus" + rootfname = "root_cfe_auto.jffs2" + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/uno"): + os.chdir("uno") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/duo"): + os.chdir("duo") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/ultimo"): + os.chdir("ultimo") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/solo"): + os.chdir("solo") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/duo2"): + os.chdir("duo2") + rootfname = "root_cfe_auto.bin" + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/solo2"): + os.chdir("solo2") + rootfname = "root_cfe_auto.bin" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/solose"): + os.chdir("solose") + rootfname = "root_cfe_auto.bin" + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/zero"): + os.chdir("zero") + rootfname = "root_cfe_auto.bin" - # Dreambox - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm520') and not os.path.exists('/tmp/dm_image'): - os.system('touch /tmp/dm_image') - os.chdir('dm520') - brand = 'dm520' - rootfname = 'rootfs.bin' + if os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini"): + os.chdir("osmini") + brand = "osmini" + rootfname = "rootfs.bin" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/osminiplus"): + os.chdir("osminiplus") + brand = "osmini" + rootfname = "rootfs.bin" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/osmega"): + os.chdir("osmega") + brand = "osmini" + rootfname = "rootfs.bin" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/osnino"): + os.chdir("osnino") + brand = "osnino" + rootfname = "rootfs.bin" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/osninoplus"): + os.chdir("osninoplus") + brand = "osnino" + rootfname = "rootfs.bin" + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/osninopro"): + os.chdir("osninopro") + brand = "osnino" + rootfname = "rootfs.bin" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1000"): + os.chdir("vs1000") + brand = "vs1000" + rootfname = "rootfs.bin" + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf3038"): + os.chdir("sf3038") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/xp1000"): + os.chdir("xp1000") + brand = "xp1000" + + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/dm520" + ) and not os.path.exists("/tmp/dm_image"): + os.system("touch /tmp/dm_image") + os.chdir("dm520") + brand = "dm520" + rootfname = "rootfs.bin" - # Instalacja image nandsim os.system('echo "Instalacja - nandsim w toku..."') os.system( - 'echo "If the image installation failed, try disabling the use of nandsim installation"') - # rc = os.system('insmod /lib/modules/' + getKernelVersion() + '/kernel/drivers/mtd/nand/nandsim.ko cache_file=' + getNeoLocation() + 'image_cache first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15;sleep 5')#% getKernelVersion()) - if not os.path.exists('/lib/modules/%s/kernel/drivers/mtd/nand/nandsim.ko' % getKernelVersion()): - rc = os.system('insmod /tmp/nandsim.ko cache_file=' + getNeoLocation() + - # % getKernelVersion()) - 'image_cache first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15;sleep 5') + 'echo "If the image installation failed, try disabling the use of nandsim installation"' + ) + if not os.path.exists( + "/lib/modules/%s/kernel/drivers/mtd/nand/nandsim.ko" + % getKernelVersion() + ): + rc = os.system( + "insmod /tmp/nandsim.ko cache_file=" + + getNeoLocation() + + "image_cache first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15;sleep 5" + ) # % getKernelVersion()) else: - rc = os.system('insmod /lib/modules/' + getKernelVersion() + '/kernel/drivers/mtd/nand/nandsim.ko cache_file=' + getNeoLocation( - # % getKernelVersion()) - ) + 'image_cache first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15;sleep 5') - cmd = 'dd if=%s of=/dev/mtdblock%s bs=2048' % (rootfname, mtd) + rc = os.system( + "insmod /lib/modules/" + + getKernelVersion() + + "/kernel/drivers/mtd/nand/nandsim.ko cache_file=" + + getNeoLocation() + + "image_cache first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15;sleep 5" + ) # % getKernelVersion()) + cmd = "dd if=%s of=/dev/mtdblock%s bs=2048" % (rootfname, mtd) rc = os.system(cmd) - cmd = 'ubiattach /dev/ubi_ctrl -m %s -O 2048' % mtd + cmd = "ubiattach /dev/ubi_ctrl -m %s -O 2048" % mtd rc = os.system(cmd) - rc = os.system('mount -t ubifs ubi1_0 ' + getNeoLocation() + 'ubi') - os.chdir('/home/root') - cmd = 'cp -af ' + getNeoLocation() + 'ubi/* ' + getNeoLocation() + \ - 'ImageBoot/' + target + rc = os.system("mount -t ubifs ubi1_0 " + getNeoLocation() + "ubi") + os.chdir("/home/root") + cmd = ( + "cp -af " + + getNeoLocation() + + "ubi/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - rc = os.system('umount ' + getNeoLocation() + 'ubi') - cmd = 'ubidetach -m %s' % mtd + rc = os.system("umount " + getNeoLocation() + "ubi") + cmd = "ubidetach -m %s" % mtd rc = os.system(cmd) - rc = os.system('rmmod nandsim') - rc = os.system('rm ' + getNeoLocation() + 'image_cache') - if os.path.exists('/tmp/dm_image') and os.path.exists('%s/ImageBoot/%s/etc/issue' % (media, target)): - os.system('rm -f /tmp/dm_image') + rc = os.system("rmmod nandsim") + rc = os.system("rm " + getNeoLocation() + "image_cache") + if os.path.exists("/tmp/dm_image") and os.path.exists( + "%s/ImageBoot/%s/etc/issue" % (media, target) + ): + os.system("rm -f /tmp/dm_image") - if '.tar.xz' not in source and not os.path.exists('%s/ImageBoot/%s/etc/issue' % (media, target)): + if ".tar.xz" not in source and not os.path.exists( + "%s/ImageBoot/%s/etc/issue" % (media, target) + ): RemoveUnpackDirs() os.system("echo 3 > /proc/sys/vm/drop_caches") os.system( - 'echo ""; echo "Nie zainstalowano systemu ! Powodem b\xc5\x82\xc4\x99du instalacji mo\xc5\xbce by\xc4\x87 kernel-module-nandsim."') + 'echo ""; echo "Nie zainstalowano systemu ! Powodem b\xc5\x82\xc4\x99du instalacji mo\xc5\xbce by\xc4\x87 kernel-module-nandsim."' + ) os.system( - 'echo "By uzyc innego narzedzia do rozpakowania image, ponow instalacje image jeszcze raz po restarcie tunera."') + 'echo "By uzyc innego narzedzia do rozpakowania image, ponow instalacje image jeszcze raz po restarcie tunera."' + ) os.system('echo "RESTART ZA 15 sekund..."') - os.system('rm -r %s/ImageBoot/%s' % (media, target)) - if os.path.exists('/tmp/dm_image'): - os.system('rm -f /tmp/dm_image') - os.system('sleep 5; init 4; sleep 5; init 3 ') + os.system("rm -r %s/ImageBoot/%s" % (media, target)) + if os.path.exists("/tmp/dm_image"): + os.system("rm -f /tmp/dm_image") + os.system("sleep 5; init 4; sleep 5; init 3 ") - # UBI_READER - elif os.path.exists('' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py') and not os.path.exists('/tmp/root_jffs2'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/venton-hdx'): - os.chdir('venton-hdx') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/hde'): - os.chdir('hde') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/hdx'): - os.chdir('hdx') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/hdp'): - os.chdir('hdp') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox'): - os.chdir('miraclebox') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/mini'): - os.chdir('mini') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/miniplus'): - os.chdir('miniplus') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/minihybrid'): - os.chdir('minihybrid') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/twin'): - os.chdir('twin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/ultra'): - os.chdir('ultra') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/micro'): - os.chdir('micro') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/microv2'): - os.chdir('microv2') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/twinplus'): - os.chdir('twinplus') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/mini4k'): - os.chdir('mini4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/ultra4k'): - os.chdir('ultra4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio'): - os.chdir('atemio') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/5x00'): - os.chdir('5x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/6000'): - os.chdir('6000') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/6100'): - os.chdir('6100') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/6200'): - os.chdir('6200') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/atemio/8x00'): - os.chdir('8x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/xpeedlx'): - os.chdir('xpeedlx') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/xpeedlx3'): - os.chdir('xpeedlx3') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/bwidowx'): - os.chdir('bwidowx') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/bwidowx2'): - os.chdir('bwidowx2') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/beyonwiz'): - os.chdir('beyonwiz') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/beyonwiz/hdx'): - os.chdir('hdx') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/beyonwiz/hdp'): - os.chdir('hdp') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/beyonwiz/hde2'): - os.chdir('hde2') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus'): - os.chdir('vuplus') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo'): - os.chdir('duo') - os.system('mv root_cfe_auto.jffs2 rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solo'): - os.chdir('solo') - os.system('mv -f root_cfe_auto.jffs2 rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solose'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solose/root_cfe_auto.bin'): - os.chdir('solose') - os.system('mv -f root_cfe_auto.bin rootfs.bin') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solose/root_cfe_auto.jffs2'): - os.chdir('solose') - os.system('mv -f root_cfe_auto.jffs2 rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/ultimo'): - os.chdir('ultimo') - os.system('mv -f root_cfe_auto.jffs2 rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/uno'): - os.chdir('uno') - os.system('mv -f root_cfe_auto.jffs2 rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solo2'): - os.chdir('solo2') - os.system('mv -f root_cfe_auto.bin rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo2'): - os.chdir('duo2') - os.system('mv -f root_cfe_auto.bin rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/zero'): - os.chdir('zero') - os.system('mv -f root_cfe_auto.bin rootfs.bin') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solo4k'): - os.chdir('solo4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/uno4k'): - os.chdir('uno4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/ultimo4k'): - os.chdir('ultimo4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo4k'): - os.chdir('duo4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo4kse'): - os.chdir('duo4kse') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/zero4k'): - os.chdir('zero4k') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/uno4kse'): - os.chdir('uno4kse') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et10000'): - os.chdir('et10000') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et9x00'): - os.chdir('et9x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et8500'): - os.chdir('et8500') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et8000'): - os.chdir('et8000') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et7x00'): - os.chdir('et7x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et6x00'): - os.chdir('et6x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et5x00'): - os.chdir('et5x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/et4x00'): - os.chdir('et4x00') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf8'): - os.chdir('sf') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf98'): - os.chdir('sf98') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf108'): - os.chdir('sf108') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf128'): - os.chdir('sf128') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf138'): - os.chdir('sf138') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf208'): - os.chdir('sf208') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf228'): - os.chdir('sf228') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf3038'): - os.chdir('sf3038') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf4008'): - os.chdir('sf4008') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/octagon/sf8008'): - os.chdir('sf8008') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue'): - os.chdir('gigablue') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/quad'): - os.chdir('quad') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/x1'): - os.chdir('x1') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd2400'): - os.chdir('hd2400') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd51'): - os.chdir('hd51') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma'): - os.chdir('zgemma') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h3'): - os.chdir('h3') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h5'): - os.chdir('h5') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h7'): - os.chdir('h7') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm900'): - os.chdir('dm900') - # os_Edision - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmini'): - os.chdir('osmini') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osminiplus'): - os.chdir('osminiplus') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmega'): - os.chdir('osmega') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osnino'): - os.chdir('osnino') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osninoplus'): - os.chdir('osninoplus') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/osninopro'): - os.chdir('osninopro') - # xp1000 - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/xp1000'): - os.chdir('xp1000') + elif os.path.exists( + "" + extensions_path + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) and not os.path.exists("/tmp/root_jffs2"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/venton-hdx"): + os.chdir("venton-hdx") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/hde"): + os.chdir("hde") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/hdx"): + os.chdir("hdx") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/hdp"): + os.chdir("hdp") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/miraclebox"): + os.chdir("miraclebox") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/mini" + ): + os.chdir("mini") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/miniplus" + ): + os.chdir("miniplus") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/miraclebox/minihybrid"): + os.chdir("minihybrid") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/twin" + ): + os.chdir("twin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/ultra" + ): + os.chdir("ultra") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/micro" + ): + os.chdir("micro") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/microv2" + ): + os.chdir("microv2") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/twinplus" + ): + os.chdir("twinplus") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/mini4k" + ): + os.chdir("mini4k") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/miraclebox/ultra4k" + ): + os.chdir("ultra4k") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/atemio"): + os.chdir("atemio") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/5x00"): + os.chdir("5x00") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/6000"): + os.chdir("6000") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/6100"): + os.chdir("6100") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/6200"): + os.chdir("6200") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/atemio/8x00"): + os.chdir("8x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedlx"): + os.chdir("xpeedlx") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/xpeedlx3"): + os.chdir("xpeedlx3") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/bwidowx"): + os.chdir("bwidowx") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/bwidowx2"): + os.chdir("bwidowx2") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/beyonwiz"): + os.chdir("beyonwiz") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/beyonwiz/hdx"): + os.chdir("hdx") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/beyonwiz/hdp"): + os.chdir("hdp") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/beyonwiz/hde2"): + os.chdir("hde2") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus"): + os.chdir("vuplus") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/duo"): + os.chdir("duo") + os.system("mv root_cfe_auto.jffs2 rootfs.bin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/solo"): + os.chdir("solo") + os.system("mv -f root_cfe_auto.jffs2 rootfs.bin") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/solose"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/solose/root_cfe_auto.bin" + ): + os.chdir("solose") + os.system("mv -f root_cfe_auto.bin rootfs.bin") + elif os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/solose/root_cfe_auto.jffs2" + ): + os.chdir("solose") + os.system("mv -f root_cfe_auto.jffs2 rootfs.bin") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/ultimo"): + os.chdir("ultimo") + os.system("mv -f root_cfe_auto.jffs2 rootfs.bin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/uno"): + os.chdir("uno") + os.system("mv -f root_cfe_auto.jffs2 rootfs.bin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/solo2"): + os.chdir("solo2") + os.system("mv -f root_cfe_auto.bin rootfs.bin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/duo2"): + os.chdir("duo2") + os.system("mv -f root_cfe_auto.bin rootfs.bin") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/zero"): + os.chdir("zero") + os.system("mv -f root_cfe_auto.bin rootfs.bin") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/solo4k"): + os.chdir("solo4k") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/uno4k"): + os.chdir("uno4k") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/ultimo4k" + ): + os.chdir("ultimo4k") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/duo4k"): + os.chdir("duo4k") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/duo4kse" + ): + os.chdir("duo4kse") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/vuplus/zero4k"): + os.chdir("zero4k") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/uno4kse" + ): + os.chdir("uno4kse") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et10000"): + os.chdir("et10000") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et9x00"): + os.chdir("et9x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et8500"): + os.chdir("et8500") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et8000"): + os.chdir("et8000") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et7x00"): + os.chdir("et7x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et6x00"): + os.chdir("et6x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et5x00"): + os.chdir("et5x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/et4x00"): + os.chdir("et4x00") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf8"): + os.chdir("sf") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf98"): + os.chdir("sf98") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf108"): + os.chdir("sf108") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf128"): + os.chdir("sf128") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf138"): + os.chdir("sf138") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf208"): + os.chdir("sf208") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf228"): + os.chdir("sf228") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf3038"): + os.chdir("sf3038") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/sf4008"): + os.chdir("sf4008") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/octagon/sf8008"): + os.chdir("sf8008") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue"): + os.chdir("gigablue") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/gigablue/quad"): + os.chdir("quad") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/gigablue/x1"): + os.chdir("x1") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/hd2400"): + os.chdir("hd2400") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/hd51"): + os.chdir("hd51") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/zgemma"): + os.chdir("zgemma") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h3"): + os.chdir("h3") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h5"): + os.chdir("h5") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h7"): + os.chdir("h7") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/dm900"): + os.chdir("dm900") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini"): + os.chdir("osmini") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/osminiplus"): + os.chdir("osminiplus") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/osmega"): + os.chdir("osmega") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/osnino"): + os.chdir("osnino") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/osninoplus"): + os.chdir("osninoplus") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/osninopro"): + os.chdir("osninopro") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/xp1000"): + os.chdir("xp1000") - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler1'): - os.chdir('formuler1') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler2'): - os.chdir('formuler2') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler3'): - os.chdir('formuler3') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/formuler4turbo'): - os.chdir('formuler4turbo') - # AZBOX - Install image VUULTIMO MIPS It works - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/patch.e2'): - os.system('rm -f ' + getNeoLocation() + - 'ImagesUpload/patch.e2 ') + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler1"): + os.chdir("formuler1") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler2"): + os.chdir("formuler2") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler3"): + os.chdir("formuler3") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/formuler4turbo"): + os.chdir("formuler4turbo") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/patch.e2"): + os.system( + "rm -f " + + getNeoLocation() + + "ImagesUpload/patch.e2 ") os.system('echo "____NEOBOOT will not unpack this image.____"') os.system( 'echo "____Try to install the image vuultimo mips____"') - # Vimastec - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vs1000'): - os.chdir('vs1000') - # Dreambox - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm520'): - if os.path.exists('/tmp/dm_image'): - os.system('rm -f /tmp/dm_image') - os.chdir('dm520') + if os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1000"): + os.chdir("vs1000") + if os.path.exists("" + getNeoLocation() + "ImagesUpload/dm520"): + if os.path.exists("/tmp/dm_image"): + os.system("rm -f /tmp/dm_image") + os.chdir("dm520") - # Instalacja image ubi_reader os.system('echo "Instalacja - ubi_reader w toku..."') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/root_cfe_auto.*'): - os.system('mv -f root_cfe_auto.* rootfs.bin') - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/vuplus/root_cfe_auto.*" + ): + os.system("mv -f root_cfe_auto.* rootfs.bin") + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o' + getNeoLocation() + \ - 'ubi' + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o" + + getNeoLocation() + + "ubi" + ) rc = os.system(cmd) - os.chdir('/home/root') - if os.path.exists('' + getNeoLocation() + 'ubi/dreambox-rootfs '): - os.system('mv ' + getNeoLocation() + 'ubi/dreambox-rootfs/* ' + - getNeoLocation() + 'ImageBoot/%s/' % target) + os.chdir("/home/root") + if os.path.exists("" + getNeoLocation() + "ubi/dreambox-rootfs "): + os.system( + "mv " + + getNeoLocation() + + "ubi/dreambox-rootfs/* " + + getNeoLocation() + + "ImageBoot/%s/" % target + ) else: - os.system('mv ' + getNeoLocation() + 'ubi/rootfs/* ' + - getNeoLocation() + 'ImageBoot/%s/' % target) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target + os.system( + "mv " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/%s/" % target + ) + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target rc = os.system(cmd) else: os.system( - 'echo "NeoBoot wykrył błąd !!! Prawdopodobnie brak ubi_reader lub nandsim."') + 'echo "NeoBoot wykrył błąd !!! Prawdopodobnie brak ubi_reader lub nandsim."' + ) -# ARM - elif getCPUtype() == 'ARMv7': - os.chdir('' + getNeoLocation() + 'ImagesUpload') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9/rootfs.ubi') or os.path.exists('' + getNeoLocation() + 'ImagesUpload/h8/rootfs.ubi') or os.path.exists('' + getNeoLocation() + 'ImagesUpload/e2/update/rootfs.ubi'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9/rootfs.ubi'): - os.chdir('h9') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h8/rootfs.ubi'): - os.chdir('h8') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/e2/update/rootfs.ubi'): - os.system('mv -f ' + getNeoLocation() + - 'ImagesUpload/e2/update/rootfs.ubi ' + getNeoLocation() + 'ImagesUpload/e2') - os.chdir('e2') - os.system('mv -f rootfs.ubi rootfs.bin') + elif getCPUtype() == "ARMv7": + os.chdir("" + getNeoLocation() + "ImagesUpload") + if (os.path.exists("" + + getNeoLocation() + + "ImagesUpload/h9/rootfs.ubi") or os.path.exists("" + + getNeoLocation() + + "ImagesUpload/h8/rootfs.ubi") or os.path.exists("" + + getNeoLocation() + + "ImagesUpload/e2/update/rootfs.ubi")): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/h9/rootfs.ubi"): + os.chdir("h9") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h8/rootfs.ubi"): + os.chdir("h8") + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/e2/update/rootfs.ubi" + ): + os.system( + "mv -f " + + getNeoLocation() + + "ImagesUpload/e2/update/rootfs.ubi " + + getNeoLocation() + + "ImagesUpload/e2" + ) + os.chdir("e2") + os.system("mv -f rootfs.ubi rootfs.bin") os.system('echo "Instalacja - ubi_reader w toku..."') print( - "[NeoBoot] Extracting UBIFS image and moving extracted image to our target") - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' + "[NeoBoot] Extracting UBIFS image and moving extracted image to our target" + ) + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi" + ) rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af -p ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target + os.chdir("/home/root") + cmd = ( + "cp -af -p " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' + cmd = "rm -rf " + getNeoLocation() + "ubi" rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/axas/axashistwin'): - os.chdir('axas') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/axas/axashistwin'): - os.chdir('axashistwin') + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/axas/axashistwin"): + os.chdir("axas") + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/axas/axashistwin"): + os.chdir("axashistwin") os.system('echo "Instalacja - ubi_reader w toku..."') print( - "[NeoBoot] Extracting UBIFS image and moving extracted image to our target") - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' + "[NeoBoot] Extracting UBIFS image and moving extracted image to our target" + ) + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi" + ) rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af -p ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target + os.chdir("/home/root") + cmd = ( + "cp -af -p " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' + cmd = "rm -rf " + getNeoLocation() + "ubi" rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/et10000/rootfs.bin'): - os.chdir('et10000') - os.system('mv -f rootfs.bin rootfs.bin') + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et10000/rootfs.bin"): + os.chdir("et10000") + os.system("mv -f rootfs.bin rootfs.bin") os.system('echo "Instalacja - ubi_reader w toku..."') print( - "[NeoBoot] Extracting UBIFS image and moving extracted image to our target") - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' + "[NeoBoot] Extracting UBIFS image and moving extracted image to our target" + ) + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi" + ) rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target + os.chdir("/home/root") + cmd = ( + "cp -af " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' + cmd = "rm -rf " + getNeoLocation() + "ubi" rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/lunix/cfe/oe_rootfs.bin'): - os.chdir('update') - os.system('mv -f ' + getNeoLocation() + 'ImagesUpload/update/lunix/cfe/oe_rootfs.bin ' + - getNeoLocation() + 'ImagesUpload/update/rootfs.bin') - os.system('echo "Instalacja - ubi_reader w toku..."') - print( - "[NeoBoot] Extracting UBIFS image and moving extracted image to our target") - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' - rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' - rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af -p ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target - rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target - rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' - rc = os.system(cmd) - - # vuplus________________________ - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/solo4k'): - os.system('echo "Please wait. System installation VuPlus Solo4K."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/solo4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/solo4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' - rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/uno4k'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/update/lunix/cfe/oe_rootfs.bin" + ): + os.chdir("update") os.system( - 'echo "Please wait. System installation dla modelu VuPlus Uno4K."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/uno4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/uno4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + "mv -f " + + getNeoLocation() + + "ImagesUpload/update/lunix/cfe/oe_rootfs.bin " + + getNeoLocation() + + "ImagesUpload/update/rootfs.bin" + ) + os.system('echo "Instalacja - ubi_reader w toku..."') + print( + "[NeoBoot] Extracting UBIFS image and moving extracted image to our target" + ) + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/uno4kse'): + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi" + ) + rc = os.system(cmd) + os.chdir("/home/root") + cmd = ( + "cp -af -p " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) + rc = os.system(cmd) + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target + rc = os.system(cmd) + cmd = "rm -rf " + getNeoLocation() + "ubi" + rc = os.system(cmd) + + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/solo4k"): + os.system('echo "Please wait. System installation VuPlus Solo4K."') + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/solo4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/solo4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/uno4k"): + os.system( + 'echo "Please wait. System installation dla modelu VuPlus Uno4K."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/uno4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/uno4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/uno4kse"): os.system('echo "Please wait. System installation VuPlus Uno4kse."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/uno4kse/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/uno4kse/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/uno4kse/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/uno4kse/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/zero4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/zero4k"): os.system('echo "Please wait. System installation VuPlus zero4K."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/zero4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/zero4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/zero4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/zero4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/ultimo4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/ultimo4k"): os.system('echo "Please wait. System installation VuPlus Ultimo4K."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/ultimo4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/ultimo4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/ultimo4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/ultimo4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/duo4k"): os.system('echo "Please wait. System installation VuPlus Duo4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/duo4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/duo4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/duo4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/duo4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vuplus/duo4kse'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vuplus/duo4kse"): os.system('echo "Please wait. System installation VuPlus Duo4kse."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vuplus/duo4kse/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vuplus/duo4kse/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vuplus/duo4kse/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vuplus/duo4kse/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - # ________________________________ - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/sf4008'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/sf4008"): os.system('echo "Please wait. System installation Octagon SF4008."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/sf4008/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/sf4008/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/sf4008/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/sf4008/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/octagon/sf8008m'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/octagon/sf8008m"): os.system('echo "Please wait. System installation Octagon SF8008m."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/octagon/sf8008m/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/octagon/sf8008m/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/octagon/sf8008m/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/octagon/sf8008m/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/octagon/sf8008'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/octagon/sf8008"): os.system('echo "Please wait. System installation Octagon SF8008."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/octagon/sf8008/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/octagon/sf8008/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/octagon/sf8008/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/octagon/sf8008/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmio4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmio4k"): os.system('echo "Please wait. System installation EDISION osmio4k"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/osmio4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/osmio4k/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/osmio4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/osmio4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmio4kplus'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmio4kplus"): os.system( 'echo "Please wait. System installation EDISION osmio4kplus"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/osmio4kplus/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/osmio4kplus/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/osmio4kplus/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/osmio4kplus/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/osmini4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/osmini4k"): os.system( 'echo "Please wait. System installation Edision OS mini 4K"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/osmini4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/osmini4k/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/osmini4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/osmini4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm900'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm900"): os.system('echo "Please wait. System installation Dreambox DM900."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dm900/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dm900/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dm900/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dm900/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dm920'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dm920"): os.system('echo "Please wait. System installation Dreambox DM920."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dm920; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dm920/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dm920; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dm920/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dreamtwo'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dreamtwo"): os.system( 'echo "Please wait. System installation Dreambox dreamtwo."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dreamtwo; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dreamtwo/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dreamtwo; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dreamtwo/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd51/rootfs.tar.bz2'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd51/rootfs.tar.bz2"): os.system('echo "Please wait. System installation AX 4K Box HD51 "') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/hd51/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/hd51/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/hd51/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/hd51/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd60'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd60"): os.system('echo "Please wait. System installation AX HD60 4K"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/hd60/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/hd60/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/hd60/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/hd60/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/hd61'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/hd61"): os.system('echo "Please wait. System installation AX HD60 4K"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/hd61/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/hd61/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/hd61/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/hd61/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) -# elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/unpackedzip/hd61'): -# os.system('echo "Please wait. System installation AX 4K HD61"') -# cmd = 'chmod -R 777 ' + getNeoLocation() + 'ImagesUpload/unpackedzip; tar -jxf ' + getNeoLocation() + 'ImagesUpload/unpackedzip/hd61/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' -# rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/multibox'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multibox"): os.system( 'echo "Please wait. System installation AX multi twin or combo"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/multibox/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/multibox/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/multibox/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/multibox/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/multiboxse'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxse"): os.system('echo "Please wait. System installation maxytec"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/multiboxse/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/multiboxse/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/multiboxse/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/multiboxse/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/axas/axasc4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/multiboxpro"): + os.system('echo "Please wait. System installation novaler 4k pro"') + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/multiboxpro/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/multiboxpro/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/axas/axasc4k"): os.system('echo "Please wait. System installation Axas his c4k"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/axas/axasc4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/axas/axasc4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/axas/axasc4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/axas/axasc4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/e4hd'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/e4hd"): os.system( - 'echo "Please wait. System installation Axas E4HD 4K Ultra w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/e4hd/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/e4hd/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + 'echo "Please wait. System installation Axas E4HD 4K Ultra w toku..."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/e4hd/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/e4hd/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/quad4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/quad4k"): os.system('echo "Please wait. System installation GigaBlue quad4k"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/gigablue/quad4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/gigablue/quad4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/gigablue/quad4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/gigablue/quad4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/ue4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/ue4k"): os.system('echo "Please wait. System installation GigaBlue ue4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/gigablue/ue4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/gigablue/ue4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/gigablue/ue4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/gigablue/ue4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/revo4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update/revo4k"): os.system('echo "Please wait. System installation Revo4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/update/revo4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/update/revo4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/update/revo4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/update/revo4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/force3uhd'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update/force3uhd"): os.system('echo "Please wait. System installation force3uhd."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/update/force3uhd/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/update/force3uhd/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/update/force3uhd/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/update/force3uhd/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/galaxy4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update/galaxy4k"): os.system('echo "Please wait. System installation Galaxy4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/update/galaxy4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/update/galaxy4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/update/galaxy4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/update/galaxy4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h7/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h7/rootfs.tar.bz2" + ): os.system('echo "Please wait. System installation Zgemma H7."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/zgemma/h7/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/zgemma/h7/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/zgemma/h7/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/zgemma/h7/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9/rootfs.ubi') or os.path.exists('' + getNeoLocation() + 'ImagesUpload/h8/rootfs.ubi'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9/rootfs.ubi'): - os.chdir('h9') - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h8/rootfs.ubi'): - os.chdir('h8') - os.system('mv -f rootfs.ubi rootfs.bin') + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/h9/rootfs.ubi" + ) or os.path.exists("" + getNeoLocation() + "ImagesUpload/h8/rootfs.ubi"): + if os.path.exists( + "" + + getNeoLocation() + + "ImagesUpload/h9/rootfs.ubi"): + os.chdir("h9") + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h8/rootfs.ubi"): + os.chdir("h8") + os.system("mv -f rootfs.ubi rootfs.bin") os.system('echo "Instalacja - ubi_reader w toku..."') print( - "[NeoBoot] Extracting UBIFS image and moving extracted image to our target") - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' + "[NeoBoot] Extracting UBIFS image and moving extracted image to our target" + ) + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi" + ) rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af -p ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target + os.chdir("/home/root") + cmd = ( + "cp -af -p " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' + cmd = "rm -rf " + getNeoLocation() + "ubi" rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h9/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h9/rootfs.tar.bz2" + ): os.system('echo "Please wait. System installation Zgemma H9S ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/zgemma/h9/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/zgemma/h9/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/zgemma/h9/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/zgemma/h9/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/h9se/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/h9se/rootfs.tar.bz2" + ): os.system('echo "Please wait. System installation Zgemma H9SE ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/zgemma/h9se/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/zgemma/h9se/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/zgemma/h9se/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/zgemma/h9se/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/zgemma/i55plus/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/zgemma/i55plus/rootfs.tar.bz2" + ): os.system('echo "Please wait. System installation Zgemma i55plus ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/zgemma/i55plus/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/zgemma/i55plus/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/zgemma/i55plus/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/zgemma/i55plus/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9combo/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/h9combo/rootfs.tar.bz2" + ): os.system('echo "Please wait. System installation Zgemma h9combo ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/h9combo/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/h9combo/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/h9combo/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/h9combo/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h9combose/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/h9combose/rootfs.tar.bz2" + ): os.system( 'echo "Please wait. System installation Zgemma h9combose ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/h9combose/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/h9combose/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/h9combose/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/h9combose/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h10/rootfs.tar.bz2'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h10/rootfs.tar.bz2"): os.system('echo "Please wait. System installation Zgemma h10 ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/h10/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/h10/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/h10/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/h10/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/h11/rootfs.tar.bz2'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/h11/rootfs.tar.bz2"): os.system('echo "Please wait. System installation Zgemma h11 ."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/h11/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/h11/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/h11/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/h11/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/mini4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/miraclebox/mini4k"): os.system( 'echo "Please wait. System installation Miraclebox mini4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/miraclebox/mini4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/miraclebox/mini4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/miraclebox/mini4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/miraclebox/mini4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/miraclebox/ultra4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/miraclebox/ultra4k"): os.system( 'echo "Please wait. System installation Miraclebox ultra4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/miraclebox/ultra4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/miraclebox/ultra4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/miraclebox/ultra4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/miraclebox/ultra4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/lunix3-4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update/lunix3-4k"): os.system( - 'echo "Please wait. System installation Qviart lunix3-4k w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/update/lunix3-4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/update/lunix3-4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + 'echo "Please wait. System installation Qviart lunix3-4k w toku..."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/update/lunix3-4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/update/lunix3-4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/lunix4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update/lunix4k"): os.system( - 'echo "Please wait. System installation Qviart Lunix 4K w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/update/lunix4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/update/lunix4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + 'echo "Please wait. System installation Qviart Lunix 4K w toku..."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/update/lunix4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/update/lunix4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u5'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u5"): os.system( 'echo "Please wait. System installation dinobot u5 w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/u5; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u5/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/u5; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u5/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u51'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u51"): os.system( 'echo "Please wait. System installation dinobot u51 w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/u51; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u51/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/u51; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u51/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u52'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u52"): os.system( 'echo "Please wait. System installation dinobot u52 w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/u52; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u52/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/u52; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u52/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u53'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u53"): os.system( 'echo "Please wait. System installation dinobot u53 w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/u53; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u53/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/u53; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u53/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u55/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/dinobot/u55/rootfs.tar.bz2" + ): os.system( 'echo "Please wait. System installation dinobot u55 w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/uu55; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u55/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/uu55; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u55/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u55'): - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot'): - os.chdir('dinobot') - if os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u55'): - os.chdir('u55') + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u55"): + if os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot"): + os.chdir("dinobot") + if os.path.exists( + "" + getNeoLocation() + "ImagesUpload/dinobot/u55"): + os.chdir("u55") os.system('echo "Instalacja - ubi_reader w toku..."') os.system('echo "[NeoBoot] Extracting image HITUBE4k"') - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi") rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af -p ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target + os.chdir("/home/root") + cmd = ( + "cp -af -p " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' + cmd = "rm -rf " + getNeoLocation() + "ubi" rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u5pvr'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u5pvr"): os.system( 'echo "Please wait. System installation dinobot u5pvr w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/u5pvr; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u5pvr/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/u5pvr; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u5pvr/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/dinobot/u57'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/dinobot/u57"): os.system( 'echo "Please wait. System installation dinobot u57 w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/dinobot/u57; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/dinobot/u57/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/dinobot/u57; tar -jxf " + + getNeoLocation() + + "ImagesUpload/dinobot/u57/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/uclan/ustym4kpro'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/uclan/ustym4kpro"): os.system( 'echo "Please wait. System installation ustym4kpro w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/uclan/ustym4kpro; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/uclan/ustym4kpro/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/uclan/ustym4kpro; tar -jxf " + + getNeoLocation() + + "ImagesUpload/uclan/ustym4kpro/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/ustym4kpro'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/ustym4kpro"): os.system( 'echo "Please wait. System installation ustym4kpro w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/ustym4kpro; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/ustym4kpro/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/ustym4kpro; tar -jxf " + + getNeoLocation() + + "ImagesUpload/ustym4kpro/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/et1x000'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/et1x000"): os.system( - 'echo "Please wait. System installation GI ET-11000 4K w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/et1x000; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/et1x000/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + 'echo "Please wait. System installation GI ET-11000 4K w toku..."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/et1x000; tar -jxf " + + getNeoLocation() + + "ImagesUpload/et1x000/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/e2/update/rootfs.tar.bz2'): + elif os.path.exists( + "" + getNeoLocation() + "ImagesUpload/e2/update/rootfs.tar.bz2" + ): os.system('echo "Please wait. System installation..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/e2/update; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/e2/update/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/e2/update; tar -jxf " + + getNeoLocation() + + "ImagesUpload/e2/update/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/beyonwiz/v2'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/beyonwiz/v2"): os.system( - 'echo "Please wait. System installation beyonwiz v2 4K w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/beyonwiz/v2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/beyonwiz/v2/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + 'echo "Please wait. System installation beyonwiz v2 4K w toku..."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/beyonwiz/v2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/beyonwiz/v2/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/amiko/viper4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/amiko/viper4k"): os.system( - 'echo "Please wait. System installation Amiko viper4k 4K w toku..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/amiko/viper4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/amiko/viper4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + 'echo "Please wait. System installation Amiko viper4k 4K w toku..."' + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/amiko/viper4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/amiko/viper4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/update/tmtwin4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/update/tmtwin4k"): os.system('echo "Please wait. System installation tmtwin4k."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/update/tmtwin4k/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/update/tmtwin4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/update/tmtwin4k/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/update/tmtwin4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/trio4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/trio4k"): os.system( 'echo "Please wait. System installation trio4k 4K Combo..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/gigablue/trio4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/gigablue/trio4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/gigablue/trio4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/gigablue/trio4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/ip4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/ip4k"): os.system('echo "Please wait. System installation gbip4k 4K..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/gigablue/ip4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/gigablue/ip4k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/gigablue/ip4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/gigablue/ip4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/gigablue/x34k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/gigablue/x34k"): os.system('echo "Please wait. System installation Gigablue X3 4k..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/gigablue/x34k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/gigablue/x34k/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/gigablue/x34k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/gigablue/x34k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/protek4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/protek4k"): os.system('echo "Please wait. System installation protek4k..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/protek4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/protek4k/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/protek4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/protek4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/pulse4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/pulse4k"): os.system( 'echo "Please wait. System installation AB-COM PULSe 4K..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/pulse4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/pulse4k/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/pulse4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/pulse4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/pulse4kmini'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/pulse4kmini"): os.system( 'echo "Please wait. System installation AB-COM PULSe 4K..."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/pulse4kmini; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/pulse4kmini/rootfs.tar.bz2 -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/pulse4kmini; tar -jxf " + + getNeoLocation() + + "ImagesUpload/pulse4kmini/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/bre2ze4k'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/bre2ze4k"): os.system('echo "Please wait. System installation WWIO BRE2ZE 4K."') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/bre2ze4k; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/bre2ze4k/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/bre2ze4k; tar -jxf " + + getNeoLocation() + + "ImagesUpload/bre2ze4k/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - # Vimastec - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/vs1500'): + elif os.path.exists("" + getNeoLocation() + "ImagesUpload/vs1500"): os.system( 'echo "Please wait. System installation VIMASTEC VS1500 4K"') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/vs1500; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/vs1500/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/vs1500; tar -jxf " + + getNeoLocation() + + "ImagesUpload/vs1500/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) else: os.system( - 'echo "NeoBoot wykrył błąd!!! Prawdopodobnie brak pliku instalacyjnego."') + 'echo "NeoBoot wykrył błąd!!! Prawdopodobnie brak pliku instalacyjnego."' + ) - # Instalacja other image: - elif not os.path.exists('/tmp/xz-gz-tar'): - fn = 'NewImage' + elif not os.path.exists("/tmp/xz-gz-tar"): + fn = "NewImage" sourcelist = [] - for fn in os.listdir('%sImagesUpload' % getNeoLocation()): - os.system('touch /tmp/root_jffs2') - if fn.find('.rootfs.tar.xz') != -1: - if not os.path.exists('/tmp/xz-gz-tar'): - os.system('touch /tmp/xz-gz-tar') + if os.path.exists("%sImagesUpload" % getNeoLocation()): + for fn in os.listdir("%sImagesUpload" % getNeoLocation()): + os.system("touch /tmp/root_jffs2") + if fn.find(".rootfs.tar.xz") != -1: + if not os.path.exists("/tmp/xz-gz-tar"): + os.system("touch /tmp/xz-gz-tar") + os.system( + 'echo "Installing the file rootfs.tar.xz in progress..."' + ) + cmd = ( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + source + + ".rootfs.tar.xz " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz > /dev/null 2>&1" + ) + rc = os.system(cmd) + cmd1 = ( + "mv " + + getNeoLocation() + + "ImagesUpload/*rootfs.tar.xz " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz > /dev/null 2>&1" + ) + rc = os.system(cmd1) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz; tar -xf " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + rc = os.system( + "rm -r " + + getNeoLocation() + + "/ImagesUpload/rootfs.tar.xz") + + elif fn.find(".tar.xz") != -1: + if not os.path.exists("/tmp/xz-gz-tar"): + os.system("touch /tmp/xz-gz-tar") + os.system( + 'echo "Installing the file .tar.xz in progress..."') + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + source + + ".tar.xz " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz" + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz; tar -xf " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.xz -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + rc = os.system( + "rm -r " + + getNeoLocation() + + "/ImagesUpload/rootfs.tar.xz") + + elif fn.find(".tar.gz") != -1: + if not os.path.exists("/tmp/xz-gz-tar"): + os.system("touch /tmp/xz-gz-tar") + os.system( + 'echo "Installing the file tar.gz in progress..."') + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + source + + ".tar.gz " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.gz" + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.gz; /bin/tar -xzvf " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.gz -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + rc = os.system( + "rm -r " + + getNeoLocation() + + "/ImagesUpload/rootfs.tar.gz") + + elif fn.find(".tar") != -1: + if not os.path.exists("/tmp/xz-gz-tar"): + os.system("touch /tmp/xz-gz-tar") + os.system( + 'echo "Installing the file tar in progress..."') + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + source + + " " + + getNeoLocation() + + "ImagesUpload/rootfs.tar" + ) + cmd = ( + "/bin/tar -xvf " + + getNeoLocation() + + "ImagesUpload/rootfs.tar -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + rc = os.system( + "rm -r " + + getNeoLocation() + + "/ImagesUpload/rootfs.tar") + + elif fn.find(".tar.bz2") != -1: + if not os.path.exists("/tmp/xz-gz-tar"): + os.system("touch /tmp/xz-gz-tar") + os.system( + 'echo "Installing the file .tar.bz2 in progress..."') + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + source + + ".tar.bz2 " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.bz2" + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.bz2; tar -jxf " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.bz2 -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + rc = os.system( + "rm -r " + + getNeoLocation() + + "/ImagesUpload/rootfs.tar.bz2") + + elif fn.find(".mb") != -1: os.system( - 'echo "Installing the file rootfs.tar.xz in progress..."') - cmd = 'mv ' + getNeoLocation() + 'ImagesUpload/' + source + '.rootfs.tar.xz ' + \ - getNeoLocation() + 'ImagesUpload/rootfs.tar.xz > /dev/null 2>&1' - rc = os.system(cmd) - cmd1 = 'mv ' + getNeoLocation() + 'ImagesUpload/*rootfs.tar.xz ' + \ - getNeoLocation() + 'ImagesUpload/rootfs.tar.xz > /dev/null 2>&1' - rc = os.system(cmd1) - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.xz; tar -xf ' + getNeoLocation() + \ - 'ImagesUpload/rootfs.tar.xz -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' - rc = os.system(cmd) - rc = os.system('rm -r ' + getNeoLocation() + - '/ImagesUpload/rootfs.tar.xz') - - elif fn.find('.tar.xz') != -1: - if not os.path.exists('/tmp/xz-gz-tar'): - os.system('touch /tmp/xz-gz-tar') + 'echo "Please wait. System installation spakowanego w plik .mb w toku..."' + ) os.system( - 'echo "Installing the file .tar.xz in progress..."') - os.system('mv ' + getNeoLocation() + 'ImagesUpload/' + source + - '.tar.xz ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.xz') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.xz; tar -xf ' + getNeoLocation() + \ - 'ImagesUpload/rootfs.tar.xz -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + "cp -af " + + getNeoLocation() + + "ImagesUpload/" + + source + + ".mb " + + getNeoLocation() + + "ImagesUpload/rootfs.tar.gz" + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/*.tar.gz; tar -xzvf " + + getNeoLocation() + + "ImagesUpload/*.tar.gz -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) rc = os.system(cmd) - rc = os.system('rm -r ' + getNeoLocation() + - '/ImagesUpload/rootfs.tar.xz') - elif fn.find('.tar.gz') != -1: - if not os.path.exists('/tmp/xz-gz-tar'): - os.system('touch /tmp/xz-gz-tar') - os.system( - 'echo "Installing the file tar.gz in progress..."') - os.system('mv ' + getNeoLocation() + 'ImagesUpload/' + source + - '.tar.gz ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.gz') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.gz; /bin/tar -xzvf ' + getNeoLocation() + \ - 'ImagesUpload/rootfs.tar.gz -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' + elif ( + os.path.exists("" + getNeoLocation() + "ImagesUpload/rootfs.bin") + or fn.find(".bin") != -1 + ): + os.chdir("ImagesUpload") + os.system("mv -f rootfs.bin rootfs.bin") + os.system('echo "Instalacja - ubi_reader w toku..."') + print( + "[NeoBoot] Extracting UBIFS image and moving extracted image to our target" + ) + cmd = ( + "chmod 777 " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py" + ) + rc = os.system(cmd) + cmd = ( + "python " + + extensions_path + + "NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o " + + getNeoLocation() + + "ubi") + rc = os.system(cmd) + os.chdir("/home/root") + cmd = ( + "cp -af " + + getNeoLocation() + + "ubi/rootfs/* " + + getNeoLocation() + + "ImageBoot/" + + target + ) + rc = os.system(cmd) + cmd = "chmod -R +x " + getNeoLocation() + "ImageBoot/" + target + rc = os.system(cmd) + cmd = "rm -rf " + getNeoLocation() + "ubi" rc = os.system(cmd) - rc = os.system('rm -r ' + getNeoLocation() + - '/ImagesUpload/rootfs.tar.gz') - elif fn.find('.tar') != -1: - if not os.path.exists('/tmp/xz-gz-tar'): - os.system('touch /tmp/xz-gz-tar') - os.system('echo "Installing the file tar in progress..."') - os.system('mv ' + getNeoLocation() + 'ImagesUpload/' + - source + ' ' + getNeoLocation() + 'ImagesUpload/rootfs.tar') - cmd = '/bin/tar -xvf ' + getNeoLocation() + 'ImagesUpload/rootfs.tar -C ' + \ - getNeoLocation() + 'ImageBoot/' + target + ' > /dev/null 2>&1' - rc = os.system(cmd) - rc = os.system('rm -r ' + getNeoLocation() + - '/ImagesUpload/rootfs.tar') - - elif fn.find('.tar.bz2') != -1: - if not os.path.exists('/tmp/xz-gz-tar'): - os.system('touch /tmp/xz-gz-tar') - os.system( - 'echo "Installing the file .tar.bz2 in progress..."') - os.system('mv ' + getNeoLocation() + 'ImagesUpload/' + source + - '.tar.bz2 ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.bz2') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.bz2; tar -jxf ' + getNeoLocation() + \ - 'ImagesUpload/rootfs.tar.bz2 -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' - rc = os.system(cmd) - rc = os.system('rm -r ' + getNeoLocation() + - '/ImagesUpload/rootfs.tar.bz2') - - elif fn.find('.mb') != -1: - os.system( - 'echo "Please wait. System installation spakowanego w plik .mb w toku..."') - os.system('cp -af ' + getNeoLocation() + 'ImagesUpload/' + source + - '.mb ' + getNeoLocation() + 'ImagesUpload/rootfs.tar.gz') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/*.tar.gz; tar -xzvf ' + getNeoLocation() + \ - 'ImagesUpload/*.tar.gz -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' - rc = os.system(cmd) - - elif os.path.exists('' + getNeoLocation() + 'ImagesUpload/rootfs.bin') or fn.find('.bin') != -1: - os.chdir('ImagesUpload') - os.system('mv -f rootfs.bin rootfs.bin') - os.system('echo "Instalacja - ubi_reader w toku..."') - print( - "[NeoBoot] Extracting UBIFS image and moving extracted image to our target") - cmd = 'chmod 777 ' + extensions_path + 'NeoBoot/ubi_reader/ubi_extract_files.py' - rc = os.system(cmd) - cmd = 'python ' + extensions_path + \ - 'NeoBoot/ubi_reader/ubi_extract_files.py rootfs.bin -o ' + getNeoLocation() + \ - 'ubi' - rc = os.system(cmd) - os.chdir('/home/root') - cmd = 'cp -af ' + getNeoLocation() + 'ubi/rootfs/* ' + \ - getNeoLocation() + 'ImageBoot/' + target - rc = os.system(cmd) - cmd = 'chmod -R +x ' + getNeoLocation() + 'ImageBoot/' + target - rc = os.system(cmd) - cmd = 'rm -rf ' + getNeoLocation() + 'ubi' - rc = os.system(cmd) - - elif fn.find('.gz') != -1: - if not os.path.exists('/tmp/xz-gz-tar'): - os.system('touch /tmp/xz-gz-tar') - os.system('echo "Installing the file .gz in progress..."') - os.system('mv ' + getNeoLocation() + 'ImagesUpload/' + source + - '.gz ' + getNeoLocation() + 'ImagesUpload/rootfs.gz') - cmd = 'chmod 777 ' + getNeoLocation() + 'ImagesUpload/rootfs.gz; /bin/tar -xvf ' + getNeoLocation() + \ - 'ImagesUpload/rootfs.gz -C ' + getNeoLocation() + 'ImageBoot/' + \ - target + ' > /dev/null 2>&1' - rc = os.system(cmd) - rc = os.system('rm -r ' + getNeoLocation() + - '/ImagesUpload/rootfs.gz') - cmd = 'rm -rf ' + getNeoLocation() + 'ImagesUpload/' + sourcefile4 + \ - ' ' ' > /dev/null 2>&1' - rc = os.system(cmd) - cmd = 'rm -f ' + getNeoLocation() + 'ImagesUpload/*.jpg ' ' > /dev/null 2>&1' - rc = os.system(cmd) + elif fn.find(".gz") != -1: + if not os.path.exists("/tmp/xz-gz-tar"): + os.system("touch /tmp/xz-gz-tar") + os.system( + 'echo "Installing the file .gz in progress..."') + os.system( + "mv " + + getNeoLocation() + + "ImagesUpload/" + + source + + ".gz " + + getNeoLocation() + + "ImagesUpload/rootfs.gz" + ) + cmd = ( + "chmod 777 " + + getNeoLocation() + + "ImagesUpload/rootfs.gz; /bin/tar -xvf " + + getNeoLocation() + + "ImagesUpload/rootfs.gz -C " + + getNeoLocation() + + "ImageBoot/" + + target + + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + rc = os.system( + "rm -r " + + getNeoLocation() + + "/ImagesUpload/rootfs.gz") + cmd = ( + "rm -rf " + + getNeoLocation() + + "ImagesUpload/" + + sourcefile4 + + " " + " > /dev/null 2>&1" + ) + rc = os.system(cmd) + cmd = ( + "rm -f " + getNeoLocation() + "ImagesUpload/*.jpg " + " > /dev/null 2>&1" + ) + rc = os.system(cmd) else: - os.system('echo "Image %s not installed "' % source) + os.system(f'echo "Image {source} not installed"') return - -# ver. gutosie -# --------------------------------------------- 2023 ---------------------------------------------# -# END diff --git a/NeoBoot/files/Harddisk.py b/NeoBoot/files/Harddisk.py index 55b753f..c8028f5 100644 --- a/NeoBoot/files/Harddisk.py +++ b/NeoBoot/files/Harddisk.py @@ -1,20 +1,19 @@ -# -*- coding: utf-8 -*- - from Plugins.Extensions.NeoBoot.__init__ import _ import os import time +import subprocess from Tools.Directories import fileExists, pathExists from Tools.CList import CList from Components.SystemInfo import SystemInfo from Components.Console import Console -# from Plugins.Extensions.NeoBoot.files import Task -if fileExists('/usr/lib/python2.7'): + +if fileExists("/usr/lib/python2.7"): from Plugins.Extensions.NeoBoot.files import Task else: from Components import Task try: from Plugins.Extensions.NeoBoot.files.Task import LoggingTask -except: +except Exception: from Components.Task import LoggingTask from Screens.Screen import Screen from Components.ActionMap import ActionMap @@ -25,46 +24,55 @@ from Screens.MessageBox import MessageBox def readFile(filename): - file = open(filename) - data = file.read().strip() - file.close() - return data + try: + with open(filename, "r", encoding="utf-8", errors="ignore") as fh: + return fh.read().strip() + except Exception: + return "" def getProcMounts(): + """ + Returns a list of mount entries where each entry is a list of fields from /proc/mounts. + Replaces '\040' with space in mount points as /proc/mounts encodes spaces as '\040'. + """ try: - mounts = open('/proc/mounts', 'r') + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as mounts: + result = [line.strip().split(" ") for line in mounts] except IOError as ex: - print((("[Harddisk] Failed to open /proc/mounts"), ex)) + print("[Harddisk] Failed to open /proc/mounts:", ex) return [] - result = [line.strip().split(' ') for line in mounts] for item in result: - item[1] = item[1].replace('\\040', ' ') - + if len(item) > 1: + item[1] = item[1].replace("\\040", " ") return result def getNonNetworkMediaMounts(): - return [x[1] for x in getProcMounts() if x[1].startswith('/media/') and not x[0].startswith('//')] + return [ + x[1] + for x in getProcMounts() + if x and len(x) > 1 and x[1].startswith("/media/") and not x[0].startswith("//") + ] def isFileSystemSupported(filesystem): try: - for fs in open('/proc/filesystems', 'r'): - if fs.strip().endswith(filesystem): - return True - + with open("/proc/filesystems", "r", encoding="utf-8", errors="ignore") as fh: + for fs in fh: + if fs.strip().endswith(filesystem): + return True return False except Exception as ex: - print((("[Harddisk] Failed to read /proc/filesystems:'"), ex)) + print("[Harddisk] Failed to read /proc/filesystems:", ex) + return False def findMountPoint(path): path = os.path.abspath(path) while not os.path.ismount(path): path = os.path.dirname(path) - return path @@ -72,49 +80,70 @@ DEVTYPE_UDEV = 0 DEVTYPE_DEVFS = 1 -class Harddisk(): +class Harddisk: def __init__(self, device, removable=False): self.device = device - if os.access('/dev/.udev', 0): + if os.path.exists("/dev/.udev"): self.type = DEVTYPE_UDEV - elif os.access('/dev/.devfsd', 0): + elif os.path.exists("/dev/.devfsd"): self.type = DEVTYPE_DEVFS else: print("[Harddisk] Unable to determine structure of /dev") self.type = -1 self.card = False + self.max_idle_time = 0 self.idle_running = False self.last_access = time.time() self.last_stat = 0 self.timer = None self.is_sleeping = False - self.dev_path = '' - self.disk_path = '' + self.dev_path = "" + self.disk_path = "" self.mount_path = None self.mount_device = None - self.phys_path = os.path.realpath(self.sysfsPath('device')) - self.removable = removable - self.internal = 'pci' in self.phys_path or 'ahci' in self.phys_path or 'sata' in self.phys_path try: - data = open('/sys/block/%s/queue/rotational' % - device, 'r').read().strip() + self.phys_path = os.path.realpath(self.sysfsPath("device")) + except Exception: + self.phys_path = "" + self.removable = removable + self.internal = ( + "pci" in self.phys_path + or "ahci" in self.phys_path + or "sata" in self.phys_path + ) + try: + with open( + "/sys/block/%s/queue/rotational" % device, + "r", + encoding="utf-8", + errors="ignore", + ) as f: + data = f.read().strip() self.rotational = int(data) - except: + except Exception: self.rotational = True if self.type == DEVTYPE_UDEV: - self.dev_path = '/dev/' + self.device + self.dev_path = "/dev/" + self.device self.disk_path = self.dev_path - self.card = 'sdhci' in self.phys_path + self.card = "sdhci" in self.phys_path elif self.type == DEVTYPE_DEVFS: - tmp = readFile(self.sysfsPath('dev')).split(':') - s_major = int(tmp[0]) - s_minor = int(tmp[1]) - for disc in os.listdir('/dev/discs'): - dev_path = os.path.realpath('/dev/discs/' + disc) - disk_path = dev_path + '/disc' + tmp = ( + readFile(self.sysfsPath("dev")).split(":") + if readFile(self.sysfsPath("dev")) + else ["0", "0"] + ) + try: + s_major = int(tmp[0]) + s_minor = int(tmp[1]) + except Exception: + s_major = s_minor = 0 + for disc in (os.listdir("/dev/discs") + if os.path.exists("/dev/discs") else []): + dev_path = os.path.realpath("/dev/discs/" + disc) + disk_path = dev_path + "/disc" try: rdev = os.stat(disk_path).st_rdev except OSError: @@ -125,62 +154,79 @@ class Harddisk(): self.disk_path = disk_path break - self.card = self.device[:2] == 'hd' and 'host0' not in self.dev_path - print(("[Harddisk] new device"), self.device, - '->', self.dev_path, '->', self.disk_path) - if not removable and not self.card: - self.startIdle() + self.card = self.device[:2] == "hd" and "host0" not in self.dev_path + print( + "[Harddisk] new device", + self.device, + "->", + self.dev_path, + "->", + self.disk_path, + ) + if not removable and not getattr(self, "card", False): + try: + self.startIdle() + except Exception: + pass return def __lt__(self, ob): return self.device < ob.device def partitionPath(self, n): + n_str = str(n) if self.type == DEVTYPE_UDEV: - if self.dev_path.startswith('/dev/mmcblk0'): - return self.dev_path + 'p' + n + if self.dev_path.startswith("/dev/mmcblk0"): + return self.dev_path + "p" + n_str else: - return self.dev_path + n + return self.dev_path + n_str elif self.type == DEVTYPE_DEVFS: - return self.dev_path + '/part' + n + return self.dev_path + "/part" + n_str def sysfsPath(self, filename): - return os.path.join('/sys/block/', self.device, filename) + return os.path.join("/sys/block/", self.device, filename) def stop(self): if self.timer: - self.timer.stop() - self.timer.callback.remove(self.runIdle) + try: + self.timer.stop() + try: + self.timer.callback.remove(self.runIdle) + except Exception: + pass + except Exception: + pass def bus(self): - ret = _('External') + ret = _("External") + type_name = "" if self.type == DEVTYPE_UDEV: - type_name = ' (SD/MMC)' + type_name = " (SD/MMC)" elif self.type == DEVTYPE_DEVFS: - type_name = ' (CF)' - if self.card: + type_name = " (CF)" + if getattr(self, "card", False): ret += type_name else: if self.internal: - ret = _('Internal') + ret = _("Internal") if not self.rotational: - ret += ' (SSD)' + ret += " (SSD)" return ret def diskSize(self): cap = 0 try: - line = readFile(self.sysfsPath('size')) - cap = int(line) - return cap / 1000 * 512 / 1000 - except: + line = readFile(self.sysfsPath("size")) + cap = int(line) if line else 0 + return (cap * 512) // 1000000 + except Exception: dev = self.findMount() if dev: try: stat = os.statvfs(dev) - cap = int(stat.f_blocks * stat.f_bsize) - return cap / 1000 / 1000 - except: + cap_bytes = int(stat.f_blocks * stat.f_bsize) + return cap_bytes // 1000000 + except Exception: pass return cap @@ -188,42 +234,41 @@ class Harddisk(): def capacity(self): cap = self.diskSize() if cap == 0: - return '' + return "" if cap < 1000: - return _('%03d MB') % cap - return _('%d.%03d GB') % (cap / 1000, cap % 1000) + return _("%03d MB") % cap + return _("%d.%03d GB") % (cap // 1000, cap % 1000) def model(self): try: - if self.device[:2] == 'hd': - return readFile('/proc/ide/' + self.device + '/model') - if self.device[:2] == 'sd': - vendor = readFile(self.sysfsPath('device/vendor')) - model = readFile(self.sysfsPath('device/model')) - return vendor + '(' + model + ')' - if self.device.startswith('mmcblk0'): - return readFile(self.sysfsPath('device/name')) - raise Exception + if self.device[:2] == "hd": + return readFile("/proc/ide/" + self.device + "/model") + if self.device[:2] == "sd": + vendor = readFile(self.sysfsPath("device/vendor")) + model = readFile(self.sysfsPath("device/model")) + return vendor + "(" + model + ")" + if self.device.startswith("mmcblk0"): + return readFile(self.sysfsPath("device/name")) + raise Exception("unknown device type") except Exception as e: - print(("[Harddisk] Failed to get model:"), e) - return '-?-' + print("[Harddisk] Failed to get model:", e) + return "-?-" def free(self): dev = self.findMount() if dev: try: stat = os.statvfs(dev) - return stat.f_bfree / 1000 * (stat.f_bsize / 1024) - except: + return stat.f_bavail * stat.f_bsize + except Exception: pass - return -1 def numPartitions(self): numPart = -1 if self.type == DEVTYPE_UDEV: try: - devdir = os.listdir('/dev') + devdir = os.listdir("/dev") except OSError: return -1 @@ -238,26 +283,34 @@ class Harddisk(): return -1 for filename in idedir: - if filename.startswith('disc'): + if filename.startswith("disc"): numPart += 1 - if filename.startswith('part'): + if filename.startswith("part"): numPart += 1 return numPart def mountDevice(self): for parts in getProcMounts(): - if os.path.realpath(parts[0]).startswith(self.dev_path): - self.mount_device = parts[0] - self.mount_path = parts[1] - return parts[1] - + if not parts: + continue + try: + if os.path.realpath(parts[0]).startswith(self.dev_path): + self.mount_device = parts[0] + self.mount_path = parts[1] + return parts[1] + except Exception: + continue return None def enumMountDevices(self): for parts in getProcMounts(): - if os.path.realpath(parts[0]).startswith(self.dev_path): - yield parts[1] + if parts and len(parts) > 0: + try: + if os.path.realpath(parts[0]).startswith(self.dev_path): + yield parts[1] + except Exception: + continue def findMount(self): if self.mount_path is None: @@ -270,165 +323,162 @@ class Harddisk(): if dev is None: return 0 else: - cmd = 'umount ' + dev - print(("[Harddisk]"), cmd) - res = os.system(cmd) - return res >> 8 + cmd = ["umount", dev] + print("[Harddisk]", " ".join(cmd)) + try: + res = subprocess.run(cmd) + return res.returncode + except Exception: + return -1 def createPartition(self): cmd = 'printf "8,\n;0,0\n;0,0\n;0,0\ny\n" | sfdisk -f -uS ' + self.disk_path - res = os.system(cmd) - return res >> 8 + try: + res = subprocess.run(cmd, shell=True) + return res.returncode + except Exception: + return -1 def mkfs(self): return 1 def mount(self): if self.mount_device is None: - dev = self.partitionPath('1') + dev = self.partitionPath("1") else: dev = self.mount_device try: - fstab = open('/etc/fstab') - lines = fstab.readlines() - fstab.close() + with open("/etc/fstab", "r", encoding="utf-8", errors="ignore") as fstab: + lines = fstab.readlines() except IOError: return -1 for line in lines: - parts = line.strip().split(' ') + parts = line.strip().split() + if not parts: + continue fspath = os.path.realpath(parts[0]) if fspath == dev: - print(("[Harddisk] mounting:"), fspath) - cmd = 'mount -t auto ' + fspath - res = os.system(cmd) - return res >> 8 + print("[Harddisk] mounting:", fspath) + try: + res = subprocess.run(["mount", "-t", "auto", fspath]) + return res.returncode + except Exception: + return -1 res = -1 if self.type == DEVTYPE_UDEV: - res = os.system('hdparm -z ' + self.disk_path) - from time import sleep - sleep(3) - return res >> 8 + try: + subprocess.run(["hdparm", "-z", self.disk_path]) + from time import sleep + + sleep(3) + except Exception: + pass + return res def fsck(self): return 1 def killPartitionTable(self): - zero = 512 * '\x00' - h = open(self.dev_path, 'wb') - for i in range(9): - h.write(zero) - - h.close() + zero = 512 * b"\x00" + try: + with open(self.dev_path, "wb") as h: + for i in range(9): + h.write(zero) + except Exception as ex: + print("[Harddisk] killPartitionTable failed:", ex) def killPartition(self, n): - zero = 512 * '\x00' + zero = 512 * b"\x00" part = self.partitionPath(n) - h = open(part, 'wb') - for i in range(3): - h.write(zero) - - h.close() + try: + with open(part, "wb") as h: + for i in range(3): + h.write(zero) + except Exception as ex: + print("[Harddisk] killPartition failed:", ex) def createInitializeJob(self): - job = Task.Job(_('Initializing storage device...')) + job = Task.Job(_("Initializing storage device...")) size = self.diskSize() - print(("[HD] size: %s MB") % size) + print("[HD] size: %s MB" % size) task = UnmountTask(job, self) - task = Task.PythonTask(job, _('Removing partition table')) + task = Task.PythonTask(job, _("Removing partition table")) task.work = self.killPartitionTable task.weighting = 1 - task = Task.LoggingTask(job, _('Rereading partition table')) + task = Task.LoggingTask(job, _("Rereading partition table")) task.weighting = 1 - task.setTool('hdparm') - task.args.append('-z') + task.setTool("hdparm") + task.args.append("-z") task.args.append(self.disk_path) task = Task.ConditionTask( - job, _('Waiting for partition'), timeoutCount=20) - task.check = lambda: not os.path.exists(self.partitionPath('1')) + job, _("Waiting for partition"), timeoutCount=20) + task.check = lambda: not os.path.exists(self.partitionPath("1")) task.weighting = 1 - if os.path.exists('/usr/sbin/parted'): + if os.path.exists("/usr/sbin/parted"): use_parted = True elif size > 2097151: - addInstallTask(job, 'parted') + addInstallTask(job, "parted") use_parted = True else: use_parted = False - task = Task.LoggingTask(job, _('Creating partition')) + task = Task.LoggingTask(job, _("Creating partition")) task.weighting = 5 if use_parted: - task.setTool('parted') + task.setTool("parted") if size < 1024: - alignment = 'min' + alignment = "min" else: - alignment = 'opt' + alignment = "opt" if size > 2097151: - parttype = 'gpt' + parttype = "gpt" else: - parttype = 'msdos' - task.args += ['-a', - alignment, - '-s', - self.disk_path, - 'mklabel', - parttype, - 'mkpart', - 'primary', - '0%', - '100%'] + parttype = "msdos" + task.args += [ + "-a", + alignment, + "-s", + self.disk_path, + "mklabel", + parttype, + "mkpart", + "primary", + "0%", + "100%", + ] else: - task.setTool('sfdisk') - task.args.append('-f') - task.args.append('-uS') + task.setTool("sfdisk") + task.args.append("-f") + task.args.append("-uS") task.args.append(self.disk_path) if size > 128000: print("[HD] Detected >128GB disk, using 4k alignment") - task.initial_input = '8,,L\n;0,0\n;0,0\n;0,0\ny\n' + task.initial_input = "8,,L\n;0,0\n;0,0\n;0,0\ny\n" else: - task.initial_input = ',,L\n;\n;\n;\ny\n' - task = Task.ConditionTask(job, _('Waiting for partition')) - task.check = lambda: os.path.exists(self.partitionPath('1')) + task.initial_input = ",,L\n;\n;\n;\ny\n" + task = Task.ConditionTask(job, _("Waiting for partition")) + task.check = lambda: os.path.exists(self.partitionPath("1")) task.weighting = 1 - task = MkfsTask(job, _('Creating filesystem')) - big_o_options = ['dir_index'] + task = MkfsTask(job, _("Creating filesystem")) + big_o_options = ["dir_index"] -# __blokada hash dla ext4 >>> -# if isFileSystemSupported('ext4'): -# task.setTool('mkfs.ext4') -# if size > 20000: -# try: -# version = map(int, open('/proc/version', 'r').read().split(' ', 4)[2].split('.', 2)[:2]) -# if version[0] > 3 or version[0] > 2 and version[1] >= 2: -# task.args += ['-C', '262144'] -# big_o_options.append('bigalloc') -# except Exception as ex: -# print 'Failed to detect Linux version:', ex -# else: -# task.setTool('mkfs.ext3') - - task.setTool('mkfs.ext3') + task.setTool("mkfs.ext3") if size > 250000: - task.args += ['-T', - 'largefile', - '-N', - '262144'] - big_o_options.append('sparse_super') + task.args += ["-T", "largefile", "-N", "262144"] + big_o_options.append("sparse_super") elif size > 16384: - task.args += ['-T', 'largefile'] - big_o_options.append('sparse_super') + task.args += ["-T", "largefile"] + big_o_options.append("sparse_super") elif size > 2048: - task.args += ['-T', - 'largefile', - '-N', - str(size * 32)] - task.args += ['-m0', - '-O', - ','.join(big_o_options), - self.partitionPath('1')] + task.args += ["-T", "largefile", "-N", str(size * 32)] + task.args += ["-m0", + "-O", + ",".join(big_o_options), + self.partitionPath("1")] task = MountTask(job, self) task.weighting = 3 - task = Task.ConditionTask(job, _('Waiting for mount'), timeoutCount=20) + task = Task.ConditionTask(job, _("Waiting for mount"), timeoutCount=20) task.check = self.mountDevice task.weighting = 1 return job @@ -440,19 +490,19 @@ class Harddisk(): return -5 def createCheckJob(self): - job = Task.Job(_('Checking filesystem...')) + job = Task.Job(_("Checking filesystem...")) if self.findMount(): UnmountTask(job, self) dev = self.mount_device else: - dev = self.partitionPath('1') - task = Task.LoggingTask(job, 'fsck') - task.setTool('fsck.ext3') - task.args.append('-f') - task.args.append('-p') + dev = self.partitionPath("1") + task = Task.LoggingTask(job, "fsck") + task.setTool("fsck.ext3") + task.args.append("-f") + task.args.append("-p") task.args.append(dev) MountTask(job, self) - task = Task.ConditionTask(job, _('Waiting for mount')) + task = Task.ConditionTask(job, _("Waiting for mount")) task.check = self.mountDevice return job @@ -464,25 +514,34 @@ class Harddisk(): def readStats(self): try: - l = open('/sys/block/%s/stat' % self.device).read() + with open( + "/sys/block/%s/stat" % self.device, + "r", + encoding="utf-8", + errors="ignore", + ) as f: + l = f.read() except IOError: return (-1, -1) data = l.split(None, 5) - return (int(data[0]), int(data[4])) + try: + return (int(data[0]), int(data[4])) + except Exception: + return (-1, -1) def startIdle(self): - from enigma import eTimer - if self.bus() == _('External'): - Console().ePopen(('sdparm', - 'sdparm', - '--set=SCT=0', - self.disk_path)) + try: + from enigma import eTimer + except Exception: + eTimer = None + + if self.bus() == _("External"): + Console().ePopen(("sdparm", "sdparm", "--set=SCT=0", self.disk_path)) else: - Console().ePopen(('hdparm', - 'hdparm', - '-S0', - self.disk_path)) + Console().ePopen(("hdparm", "hdparm", "-S0", self.disk_path)) + if eTimer is None: + return self.timer = eTimer() self.timer.callback.append(self.runIdle) self.idle_running = True @@ -494,7 +553,7 @@ class Harddisk(): t = time.time() idle_time = t - self.last_access stats = self.readStats() - l = sum(stats) + l = sum(stats) if isinstance(stats, (list, tuple)) else 0 if l != self.last_stat and l >= 0: self.last_stat = l self.last_access = t @@ -505,47 +564,63 @@ class Harddisk(): self.is_sleeping = True def setSleep(self): - if self.bus() == _('External'): - Console().ePopen(('sdparm', - 'sdparm', - '--flexible', - '--readonly', - '--command=stop', - self.disk_path)) + if self.bus() == _("External"): + Console().ePopen( + ( + "sdparm", + "sdparm", + "--flexible", + "--readonly", + "--command=stop", + self.disk_path, + ) + ) else: - Console().ePopen(('hdparm', - 'hdparm', - '-y', - self.disk_path)) + Console().ePopen(("hdparm", "hdparm", "-y", self.disk_path)) def setIdleTime(self, idle): self.max_idle_time = idle - if self.idle_running: + if self.idle_running and self.timer: if not idle: - self.timer.stop() + try: + self.timer.stop() + except Exception: + pass else: - self.timer.start(idle * 100, False) + try: + self.timer.start(int(idle * 100), False) + except Exception: + pass def isSleeping(self): return self.is_sleeping -class Partition(): +class Partition: - def __init__(self, mountpoint, device=None, description='', force_mounted=False): + def __init__( + self, + mountpoint, + device=None, + description="", + force_mounted=False): self.mountpoint = mountpoint self.description = description - self.force_mounted = mountpoint and force_mounted + self.force_mounted = bool(mountpoint) and force_mounted self.is_hotplug = force_mounted self.device = device def __str__(self): - return 'Partition(mountpoint=%s,description=%s,device=%s)' % (self.mountpoint, self.description, self.device) + return "Partition(mountpoint=%s,description=%s,device=%s)" % ( + self.mountpoint, + self.description, + self.device, + ) def stat(self): if self.mountpoint: return os.statvfs(self.mountpoint) - raise (OSError, "Device %s is not mounted") % self.device + raise OSError("Device %s is not mounted" % self.device) def free(self): try: @@ -554,8 +629,6 @@ class Partition(): except OSError: return None - return None - def total(self): try: s = self.stat() @@ -563,12 +636,11 @@ class Partition(): except OSError: return None - return None - def tabbedDescription(self): - if self.mountpoint.startswith('/media/net') or self.mountpoint.startswith('/media/autofs'): + if self.mountpoint.startswith( + "/media/net") or self.mountpoint.startswith("/media/autofs"): return self.description - return self.description + '\t' + self.mountpoint + return self.description + "\t" + self.mountpoint def mounted(self, mounts=None): if self.force_mounted: @@ -578,9 +650,12 @@ class Partition(): if mounts is None: mounts = getProcMounts() for parts in mounts: - if self.mountpoint.startswith(parts[1]): + if ( + parts + and len(parts) > 1 + and self.mountpoint.startswith(parts[1]) + ): return True - return False def filesystem(self, mounts=None): @@ -588,90 +663,107 @@ class Partition(): if mounts is None: mounts = getProcMounts() for fields in mounts: - if self.mountpoint.endswith('/') and not self.mountpoint == '/': - if fields[1] + '/' == self.mountpoint: + if len(fields) < 3: + continue + if self.mountpoint.endswith( + "/") and not self.mountpoint == "/": + if fields[1] + "/" == self.mountpoint: return fields[2] elif fields[1] == self.mountpoint: return fields[2] - - return '' + return "" def addInstallTask(job, package): - task = Task.LoggingTask(job, 'update packages') - task.setTool('opkg') - task.args.append('update') - task = Task.LoggingTask(job, 'Install ' + package) - task.setTool('opkg') - task.args.append('install') + task = Task.LoggingTask(job, "update packages") + task.setTool("opkg") + task.args.append("update") + task = Task.LoggingTask(job, "Install " + package) + task.setTool("opkg") + task.args.append("install") task.args.append(package) -class HarddiskManager(): +class HarddiskManager: def __init__(self): self.hdd = [] - self.cd = '' + self.cd = "" self.partitions = [] self.devices_scanned_on_init = [] self.on_partition_list_change = CList() - self.enumerateBlockDevices() - p = (('/media/hdd', _('Hard disk')), - ('/media/card', _('Card')), - ('/media/cf', _('Compact flash')), - ('/media/mmc1', _('MMC card')), - ('/media/net', _('Network mount')), - ('/media/net1', _('Network mount %s') % '1'), - ('/media/net2', _('Network mount %s') % '2'), - ('/media/net3', _('Network mount %s') % '3'), - ('/media/ram', _('Ram disk')), - ('/media/usb', _('USB stick')), - ('/media/usb1', _('USB1 stick')), - ('/media/usb2', _('USB2 stick')), - ('/', _('Internal flash'))) + try: + self.enumerateBlockDevices() + except Exception as ex: + print("[HarddiskManager] enumerateBlockDevices failed:", ex) + p = ( + ("/media/hdd", _("Hard disk")), + ("/media/card", _("Card")), + ("/media/cf", _("Compact flash")), + ("/media/mmc1", _("MMC card")), + ("/media/net", _("Network mount")), + ("/media/net1", _("Network mount %s") % "1"), + ("/media/net2", _("Network mount %s") % "2"), + ("/media/net3", _("Network mount %s") % "3"), + ("/media/ram", _("Ram disk")), + ("/media/usb", _("USB stick")), + ("/media/usb1", _("USB1 stick")), + ("/media/usb2", _("USB2 stick")), + ("/", _("Internal flash")), + ) known = set([os.path.normpath(a.mountpoint) - for a in self.partitions if a.mountpoint]) + for a in self.partitions if a.mountpoint]) for m, d in p: if m not in known and os.path.ismount(m): self.partitions.append(Partition(mountpoint=m, description=d)) def getBlockDevInfo(self, blockdev): - HasMMC = fileExists( - '/proc/cmdline') and 'root=/dev/mmcblk' in open('/proc/cmdline', 'r').read() - devpath = '/sys/block/' + blockdev + HasMMC = False + try: + if fileExists("/proc/cmdline"): + with open( + "/proc/cmdline", "r", encoding="utf-8", errors="ignore" + ) as fh: + HasMMC = "root=/dev/mmcblk" in fh.read() + except Exception: + HasMMC = False + + devpath = "/sys/block/" + blockdev error = False removable = False blacklisted = False is_cdrom = False partitions = [] try: - if os.path.exists(devpath + '/removable'): - removable = bool(int(readFile(devpath + '/removable'))) - if os.path.exists(devpath + '/dev'): - dev = int(readFile(devpath + '/dev').split(':')[0]) + if os.path.exists(devpath + "/removable"): + removable = bool(int(readFile(devpath + "/removable") or 0)) + if os.path.exists(devpath + "/dev"): + dev_raw = readFile(devpath + "/dev") + try: + dev = int(dev_raw.split(":")[0]) + except Exception: + dev = None else: dev = None - blacklisted = dev in [1, - 7, - 31, - 253, - 254] + (['HasMMC'] and [179] or []) - if blockdev[0:2] == 'sr': + blacklist_list = [1, 7, 31, 253, 254] + if HasMMC: + blacklist_list.append(179) + blacklisted = dev in blacklist_list if dev is not None else False + if blockdev.startswith("sr"): is_cdrom = True - if blockdev[0:2] == 'hd': + if blockdev.startswith("hd"): try: - media = readFile('/proc/ide/%s/media' % blockdev) - if 'cdrom' in media: + media = readFile("/proc/ide/%s/media" % blockdev) + if "cdrom" in media: is_cdrom = True except IOError: error = True if not is_cdrom and os.path.exists(devpath): for partition in os.listdir(devpath): - if partition[0:len(blockdev)] != blockdev: + if not partition.startswith(blockdev): continue partitions.append(partition) - else: self.cd = blockdev except IOError: @@ -679,132 +771,162 @@ class HarddiskManager(): medium_found = True try: - open('/dev/' + blockdev).close() + open("/dev/" + blockdev).close() except IOError as err: - if err.errno == 159: - medium_found = False + try: + if hasattr(err, "errno") and err.errno == 159: + medium_found = False + except Exception: + medium_found = True - return (error, - blacklisted, - removable, - is_cdrom, - partitions, - medium_found) + return ( + error, + blacklisted, + removable, + is_cdrom, + partitions, + medium_found) def enumerateBlockDevices(self): print("[Harddisk] enumerating block devices...") - for blockdev in os.listdir('/sys/block'): - error, blacklisted, removable, is_cdrom, partitions, medium_found = self.addHotplugPartition( - blockdev) - if not error and not blacklisted and medium_found: - for part in partitions: - self.addHotplugPartition(part) - - self.devices_scanned_on_init.append((blockdev, - removable, - is_cdrom, - medium_found)) + if not os.path.exists("/sys/block"): + return + for blockdev in os.listdir("/sys/block"): + try: + error, blacklisted, removable, is_cdrom, partitions, medium_found = ( + self.addHotplugPartition(blockdev)) + if not error and not blacklisted and medium_found: + for part in partitions: + self.addHotplugPartition(part) + self.devices_scanned_on_init.append( + (blockdev, removable, is_cdrom, medium_found) + ) + except Exception as ex: + print( + "[Harddisk] enumerateBlockDevices error for", + blockdev, + ex) def getAutofsMountpoint(self, device): r = self.getMountpoint(device) if r is None: - return '/media/' + device + return "/media/" + device else: return r def getMountpoint(self, device): - dev = '/dev/%s' % device + dev = "/dev/%s" % device for item in getProcMounts(): - if item[0] == dev: + if item and item[0] == dev: return item[1] - return None def addHotplugPartition(self, device, physdev=None): if not physdev: dev, part = self.splitDeviceName(device) try: - physdev = os.path.realpath('/sys/block/' + dev + '/device')[4:] + raw = os.path.realpath("/sys/block/" + dev + "/device") + physdev = raw[4:] if len(raw) > 4 else raw except OSError: physdev = dev - print((("couldn't determine blockdev physdev for device"), device)) + print("couldn't determine blockdev physdev for device", device) - error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo( - device) + error, blacklisted, removable, is_cdrom, partitions, medium_found = ( + self.getBlockDevInfo(device) + ) if not blacklisted and medium_found: description = self.getUserfriendlyDeviceName(device, physdev) - p = Partition(mountpoint=self.getMountpoint( - device), description=description, force_mounted=True, device=device) + p = Partition( + mountpoint=self.getMountpoint(device), + description=description, + force_mounted=True, + device=device, + ) self.partitions.append(p) if p.mountpoint: - self.on_partition_list_change('add', p) + self.on_partition_list_change("add", p) l = len(device) - if l and (not device[l - 1].isdigit() or device == 'mmcblk0'): - self.hdd.append(Harddisk(device, removable)) - self.hdd.sort() - SystemInfo['Harddisk'] = True - return (error, - blacklisted, - removable, - is_cdrom, - partitions, - medium_found) + if l and (not device[l - 1].isdigit() or device == "mmcblk0"): + try: + self.hdd.append(Harddisk(device, removable)) + self.hdd.sort() + SystemInfo["Harddisk"] = True + except Exception as ex: + print("[HarddiskManager] adding Harddisk failed:", ex) + return ( + error, + blacklisted, + removable, + is_cdrom, + partitions, + medium_found) def addHotplugAudiocd(self, device, physdev=None): if not physdev: dev, part = self.splitDeviceName(device) try: - physdev = os.path.realpath('/sys/block/' + dev + '/device')[4:] + raw = os.path.realpath("/sys/block/" + dev + "/device") + physdev = raw[4:] if len(raw) > 4 else raw except OSError: physdev = dev - print((("couldn't determine blockdev physdev for device"), device)) + print("couldn't determine blockdev physdev for device", device) - error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo( - device) + error, blacklisted, removable, is_cdrom, partitions, medium_found = ( + self.getBlockDevInfo(device) + ) if not blacklisted and medium_found: description = self.getUserfriendlyDeviceName(device, physdev) - p = Partition(mountpoint='/media/audiocd', - description=description, force_mounted=True, device=device) + p = Partition( + mountpoint="/media/audiocd", + description=description, + force_mounted=True, + device=device, + ) self.partitions.append(p) - self.on_partition_list_change('add', p) - SystemInfo['Harddisk'] = False - return (error, - blacklisted, - removable, - is_cdrom, - partitions, - medium_found) + self.on_partition_list_change("add", p) + SystemInfo["Harddisk"] = False + return ( + error, + blacklisted, + removable, + is_cdrom, + partitions, + medium_found) def removeHotplugPartition(self, device): for x in self.partitions[:]: if x.device == device: self.partitions.remove(x) if x.mountpoint: - self.on_partition_list_change('remove', x) + self.on_partition_list_change("remove", x) l = len(device) if l and not device[l - 1].isdigit(): - for hdd in self.hdd: + for hdd in self.hdd[:]: if hdd.device == device: - hdd.stop() - self.hdd.remove(hdd) + try: + hdd.stop() + except Exception: + pass + try: + self.hdd.remove(hdd) + except ValueError: + pass break - - SystemInfo['Harddisk'] = len(self.hdd) > 0 + SystemInfo["Harddisk"] = len(self.hdd) > 0 def HDDCount(self): return len(self.hdd) def HDDList(self): - list = [] + ret = [] for hd in self.hdd: - hdd = hd.model() + ' - ' + hd.bus() + hddname = hd.model() + " - " + hd.bus() cap = hd.capacity() - if cap != '': - hdd += ' (' + cap + ')' - list.append((hdd, hd)) - - return list + if cap != "": + hddname += " (" + cap + ")" + ret.append((hddname, hd)) + return ret def getCD(self): return self.cd @@ -812,90 +934,101 @@ class HarddiskManager(): def getMountedPartitions(self, onlyhotplug=False, mounts=None): if mounts is None: mounts = getProcMounts() - parts = [x for x in self.partitions if ( - x.is_hotplug or not onlyhotplug) and x.mounted(mounts)] + parts = [ + x + for x in self.partitions + if (x.is_hotplug or not onlyhotplug) and x.mounted(mounts) + ] devs = set([x.device for x in parts]) - for devname in devs.copy(): + for devname in list(devs): if not devname: continue dev, part = self.splitDeviceName(devname) if part and dev in devs: - devs.remove(dev) - + devs.discard(dev) return [x for x in parts if not x.device or x.device in devs] def splitDeviceName(self, devname): - dev = devname[:3] - part = devname[3:] + if len(devname) >= 3: + dev = devname[:3] + part = devname[3:] + else: + dev = devname + part = "" for p in part: if not p.isdigit(): return (devname, 0) - - return (dev, part and int(part) or 0) + return (dev, int(part) if part else 0) def getUserfriendlyDeviceName(self, dev, phys): dev, part = self.splitDeviceName(dev) - description = _('External Storage %s') % dev + description = _("External Storage %s") % dev try: - description = readFile('/sys' + phys + '/model') + description = readFile("/sys" + phys + "/model") or description except IOError as s: - print((("couldn't read model: "), s)) + print("couldn't read model:", s) if part and part != 1: - description += _(' (Partition %d)') % part + description += _(" (Partition %d)") % part return description def addMountedPartition(self, device, desc): for x in self.partitions: if x.mountpoint == device: return - self.partitions.append(Partition(mountpoint=device, description=desc)) def removeMountedPartition(self, mountpoint): for x in self.partitions[:]: if x.mountpoint == mountpoint: self.partitions.remove(x) - self.on_partition_list_change('remove', x) + self.on_partition_list_change("remove", x) def setDVDSpeed(self, device, speed=0): ioctl_flag = int(21282) - if not device.startswith('/'): - device = '/dev/' + device + if not device.startswith("/"): + device = "/dev/" + device try: from fcntl import ioctl - cd = open(device) - ioctl(cd.fileno(), ioctl_flag, speed) - cd.close() + + with open(device, "rb") as cd: + ioctl(cd.fileno(), ioctl_flag, speed) except Exception as ex: - print(("[Harddisk] Failed to set %s speed to %s") % - (device, speed), ex) + print( + "[Harddisk] Failed to set %s speed to %s" % + (device, speed), ex) class UnmountTask(Task.LoggingTask): def __init__(self, job, hdd): - Task.LoggingTask.__init__(self, job, _('Unmount')) + Task.LoggingTask.__init__(self, job, _("Unmount")) self.hdd = hdd self.mountpoints = [] def prepare(self): try: - dev = self.hdd.disk_path.split('/')[-1] - open('/dev/nomount.%s' % dev, 'wb').close() + dev = self.hdd.disk_path.split("/")[-1] + with open( + "/dev/nomount.%s" % dev, "w", encoding="utf-8", errors="ignore" + ) as f: + f.write("") except Exception as e: - print(("ERROR: Failed to create /dev/nomount file:"), e) + print("ERROR: Failed to create /dev/nomount file:", e) - self.setTool('umount') - self.args.append('-f') + self.setTool("umount") + self.args.append("-f") for dev in self.hdd.enumMountDevices(): self.args.append(dev) - self.postconditions.append(Task.ReturncodePostcondition()) + try: + self.postconditions.append(Task.ReturncodePostcondition()) + except Exception: + pass self.mountpoints.append(dev) if not self.mountpoints: print("UnmountTask: No mountpoints found?") - self.cmd = 'true' + self.cmd = "true" self.args = [self.cmd] def afterRun(self): @@ -903,40 +1036,54 @@ class UnmountTask(Task.LoggingTask): try: os.rmdir(path) except Exception as ex: - print(("Failed to remove path '%s':") % path, ex) + print(("Failed to remove path '%s':" % path, ex)) class MountTask(Task.LoggingTask): def __init__(self, job, hdd): - Task.LoggingTask.__init__(self, job, _('Mount')) + Task.LoggingTask.__init__(self, job, _("Mount")) self.hdd = hdd def prepare(self): try: - dev = self.hdd.disk_path.split('/')[-1] - os.unlink('/dev/nomount.%s' % dev) + dev = self.hdd.disk_path.split("/")[-1] + try: + os.unlink("/dev/nomount.%s" % dev) + except Exception: + pass except Exception as e: - print(("ERROR: Failed to remove /dev/nomount file:"), e) + print("ERROR: Failed to remove /dev/nomount file:", e) if self.hdd.mount_device is None: - dev = self.hdd.partitionPath('1') + dev = self.hdd.partitionPath("1") else: dev = self.hdd.mount_device - fstab = open('/etc/fstab') - lines = fstab.readlines() - fstab.close() + try: + with open("/etc/fstab", "r", encoding="utf-8", errors="ignore") as fstab: + lines = fstab.readlines() + except Exception: + lines = [] + for line in lines: - parts = line.strip().split(' ') + parts = line.strip().split() + if not parts: + continue fspath = os.path.realpath(parts[0]) if os.path.realpath(fspath) == dev: - self.setCmdline('mount -t auto ' + fspath) - self.postconditions.append(Task.ReturncodePostcondition()) + self.setCmdline("mount -t auto " + fspath) + try: + self.postconditions.append(Task.ReturncodePostcondition()) + except Exception: + pass return if self.hdd.type == DEVTYPE_UDEV: - self.setCmdline('sleep 2; hdparm -z ' + self.hdd.disk_path) - self.postconditions.append(Task.ReturncodePostcondition()) + self.setCmdline("sleep 2; hdparm -z " + self.hdd.disk_path) + try: + self.postconditions.append(Task.ReturncodePostcondition()) + except Exception: + pass return @@ -947,49 +1094,67 @@ class MkfsTask(Task.LoggingTask): return def processOutput(self, data): - print(("[Mkfs]"), data) - if 'Writing inode tables:' in data: - self.fsck_state = 'inode' - elif 'Creating journal' in data: - self.fsck_state = 'journal' - self.setProgress(80) - elif 'Writing superblocks ' in data: - self.setProgress(95) - elif self.fsck_state == 'inode': - if '/' in data: + print("[Mkfs]", data) + if "Writing inode tables:" in data: + self.fsck_state = "inode" + elif "Creating journal" in data: + self.fsck_state = "journal" + try: + self.setProgress(80) + except Exception: + pass + elif "Writing superblocks " in data: + try: + self.setProgress(95) + except Exception: + pass + elif self.fsck_state == "inode": + if "/" in data: try: - d = data.strip(' \x08\r\n').split('/', 1) - if '\x08' in d[1]: - d[1] = d[1].split('\x08', 1)[0] - self.setProgress(80 * int(d[0]) / int(d[1])) + d = data.strip(" \x08\r\n").split("/", 1) + if len(d) > 1: + left = d[0].strip() + right = d[1].split("\x08", 1)[0].strip() + try: + prog = 80 * (int(left) / int(right)) + self.setProgress(prog) + except Exception: + pass except Exception as e: - print(("[Mkfs] E:"), e) - + print("[Mkfs] E:", e) return - self.log.append(data) + try: + self.log.append(data) + except Exception: + pass -########################### __From HarddiskSetup_################################ class HarddiskSetup(Screen): def __init__(self, session, hdd, action, text, question): Screen.__init__(self, session) self.action = action self.question = question - self.setTitle(_('Setup hard disk')) - self['model'] = Label(_('Model: ') + hdd.model()) - self['capacity'] = Label(_('Capacity: ') + hdd.capacity()) - self['bus'] = Label(_('Bus: ') + hdd.bus()) - self['key_red'] = Label(_('Cancel')) - self['key_green'] = Label(text) - self['actions'] = ActionMap(['OkCancelActions'], {'ok': self.hddQuestion, - 'cancel': self.close}) - self['shortcuts'] = ActionMap(['ShortcutActions'], {'red': self.close, - 'green': self.hddQuestion}) + self.hdd = hdd + self.setTitle(_("Setup hard disk")) + self["model"] = Label(_("Model: ") + hdd.model()) + self["capacity"] = Label(_("Capacity: ") + hdd.capacity()) + self["bus"] = Label(_("Bus: ") + hdd.bus()) + self["key_red"] = Label(_("Cancel")) + self["key_green"] = Label(text) + self["actions"] = ActionMap( + ["OkCancelActions"], {"ok": self.hddQuestion, "cancel": self.close} + ) + self["shortcuts"] = ActionMap( + ["ShortcutActions"], {"red": self.close, "green": self.hddQuestion} + ) def hddQuestion(self): - message = self.question + '\n' + \ - _('You can continue watching TV etc. while this is running.') + message = ( + self.question + + "\n" + + _("You can continue watching TV etc. while this is running.") + ) self.session.openWithCallback(self.hddConfirmed, MessageBox, message) def hddConfirmed(self, confirmed): @@ -997,82 +1162,128 @@ class HarddiskSetup(Screen): return try: from .Task import job_manager - except: + except Exception: from Components.Task import job_manager try: job = self.action() job_manager.AddJob(job, onSuccess=job_manager.popupTaskView) from Screens.TaskView import JobView + self.session.open(JobView, job, afterEventChangeable=False) except Exception as ex: - self.session.open(MessageBox, str( - ex), type=MessageBox.TYPE_ERROR, timeout=10) - + self.session.open( + MessageBox, str(ex), type=MessageBox.TYPE_ERROR, timeout=10 + ) self.close() class HarddiskSelection(Screen): def __init__(self, session): Screen.__init__(self, session) - self.setTitle(_('Select hard disk')) - self.skinName = 'HarddiskSelection' + self.setTitle(_("Select hard disk")) + self.skinName = "HarddiskSelection" if harddiskmanager.HDDCount() == 0: tlist = [] - tlist.append((_('no storage devices found'), 0)) - self['hddlist'] = MenuList(tlist) + tlist.append((_("no storage devices found"), 0)) + self["hddlist"] = MenuList(tlist) else: - self['hddlist'] = MenuList(harddiskmanager.HDDList()) - self['key_red'] = Label(_('Cancel')) - self['key_green'] = Label(_('Select')) - self['actions'] = ActionMap(['OkCancelActions'], {'ok': self.okbuttonClick, - 'cancel': self.close}) - self['shortcuts'] = ActionMap(['ShortcutActions'], {'red': self.close, - 'green': self.okbuttonClick}) + self["hddlist"] = MenuList(harddiskmanager.HDDList()) + self["key_red"] = Label(_("Cancel")) + self["key_green"] = Label(_("Select")) + self["actions"] = ActionMap( + ["OkCancelActions"], { + "ok": self.okbuttonClick, "cancel": self.close}) + self["shortcuts"] = ActionMap( + ["ShortcutActions"], { + "red": self.close, "green": self.okbuttonClick}) def doIt(self, selection): - self.session.openWithCallback(self.close, HarddiskSetup, selection, action=selection.createInitializeJob, text=_( - 'Initialize'), question=_('Do you really want to initialize the device?\nAll data on the disk will be lost!')) + self.session.openWithCallback( + self.close, + HarddiskSetup, + selection, + action=selection.createInitializeJob, + text=_("Initialize"), + question=_( + "Do you really want to initialize the device?\nAll data on the disk will be lost!" + ), + ) def okbuttonClick(self): - selection = self['hddlist'].getCurrent() - if selection[1] != 0: + selection = self["hddlist"].getCurrent() + if selection and selection[1] != 0: self.doIt(selection[1]) class HarddiskFsckSelection(HarddiskSelection): def doIt(self, selection): - self.session.openWithCallback(self.close, HarddiskSetup, selection, action=selection.createCheckJob, text=_( - 'Check'), question=_('Do you really want to check the filesystem?\nThis could take lots of time!')) -########################### __end HarddiskSetup_################################ - - -harddiskmanager = HarddiskManager() + self.session.openWithCallback( + self.close, + HarddiskSetup, + selection, + action=selection.createCheckJob, + text=_("Check"), + question=_( + "Do you really want to check the filesystem?\nThis could take lots of time!" + ), + ) def isSleepStateDevice(device): - ret = os.popen('hdparm -C %s' % device).read() - if 'SG_IO' in ret or 'HDIO_DRIVE_CMD' in ret: + """ + Uses hdparm -C and interprets output. + Returns True for sleeping, False for active, None for unknown/error. + """ + try: + res = subprocess.run( + ["hdparm", "-C", device], capture_output=True, text=True, timeout=5 + ) + ret = res.stdout + res.stderr + except Exception: + try: + ret = os.popen("hdparm -C %s" % device).read() + except Exception: + return None + + if "SG_IO" in ret or "HDIO_DRIVE_CMD" in ret: return None - elif 'drive state is: standby' in ret or 'drive state is: idle' in ret: + if "drive state is: standby" in ret or "drive state is: idle" in ret: return True - elif 'drive state is: active/idle' in ret: + if "drive state is: active/idle" in ret or "drive state is: active/idle" in ret: return False - else: - return None + return None def internalHDDNotSleeping(external=False): state = False if harddiskmanager.HDDCount(): for hdd in harddiskmanager.HDDList(): - if hdd[1].internal or external: - if hdd[1].idle_running and hdd[1].max_idle_time and not hdd[1].isSleeping(): - state = True - + try: + hdobj = hdd[1] + if hdobj.internal or external: + if ( + hdobj.idle_running + and hdobj.max_idle_time + and not hdobj.isSleeping() + ): + state = True + except Exception: + continue return state -harddiskmanager = HarddiskManager() -SystemInfo['ext4'] = isFileSystemSupported( - 'ext4') or isFileSystemSupported('ext3') +try: + harddiskmanager = HarddiskManager() +except Exception as ex: + print("[Harddisk] HarddiskManager initialization failed:", ex) + harddiskmanager = None + +try: + SystemInfo["ext4"] = isFileSystemSupported( + "ext4") or isFileSystemSupported("ext3") +except Exception: + try: + SystemInfo["ext4"] = False + except Exception: + pass diff --git a/NeoBoot/files/Task.py b/NeoBoot/files/Task.py index 229e118..9488e8d 100644 --- a/NeoBoot/files/Task.py +++ b/NeoBoot/files/Task.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from Tools.CList import CList @@ -9,7 +7,7 @@ class Job(object): def __init__(self, name): self.tasks = [] self.resident_tasks = [] - self.workspace = '/tmp' + self.workspace = "/tmp" self.current_task = 0 self.callback = None self.name = name @@ -33,18 +31,20 @@ class Job(object): if self.current_task == len(self.tasks): return self.end t = self.tasks[self.current_task] - jobprogress = t.weighting * t.progress / \ - float(t.end) + \ - sum([task.weighting for task in self.tasks[:self.current_task]]) + jobprogress = t.weighting * t.progress / float(t.end) + sum( + [task.weighting for task in self.tasks[: self.current_task]] + ) return int(jobprogress * self.weightScale) progress = property(getProgress) def getStatustext(self): - return {self.NOT_STARTED: _('Waiting'), - self.IN_PROGRESS: _('In progress'), - self.FINISHED: _('Finished'), - self.FAILED: _('Failed')}[self.status] + return { + self.NOT_STARTED: _("Waiting"), + self.IN_PROGRESS: _("In progress"), + self.FINISHED: _("Finished"), + self.FAILED: _("Failed"), + }[self.status] def task_progress_changed_CB(self): self.state_changed() @@ -73,8 +73,10 @@ class Job(object): self.callback(self, None, []) self.callback = None else: - print(("still waiting for %d resident task(s) %s to finish") % - (len(self.resident_tasks), str(self.resident_tasks))) + print( + ("still waiting for %d resident task(s) %s to finish") + % (len(self.resident_tasks), str(self.resident_tasks)) + ) else: self.tasks[self.current_task].run(self.taskCallback) self.state_changed() @@ -116,7 +118,8 @@ class Job(object): self.abort() def __str__(self): - return 'Components.Task.Job name=%s #tasks=%s' % (self.name, len(self.tasks)) + return "Components.Task.Job name=%s #tasks=%s" % ( + self.name, len(self.tasks)) class Task(object): @@ -133,11 +136,11 @@ class Task(object): self.weighting = 100 self.__progress = 0 self.cmd = None - self.cwd = '/tmp' + self.cwd = "/tmp" self.args = [] self.cmdline = None self.task_progress_changed = None - self.output_line = '' + self.output_line = "" job.addTask(self) self.container = None return @@ -173,6 +176,7 @@ class Task(object): return else: from enigma import eConsoleAppContainer + self.container = eConsoleAppContainer() self.container.appClosed.append(self.processFinished) self.container.stdoutAvail.append(self.processStdout) @@ -180,11 +184,17 @@ class Task(object): if self.cwd is not None: self.container.setCWD(self.cwd) if not self.cmd and self.cmdline: - print(("execute:"), self.container.execute( - self.cmdline), self.cmdline) + print( + ("execute:"), + self.container.execute( + self.cmdline), + self.cmdline) else: - print(("execute:"), self.container.execute( - self.cmd, *self.args), ' '.join(self.args)) + print( + ("execute:"), + self.container.execute(self.cmd, *self.args), + " ".join(self.args), + ) if self.initial_input: self.writeInput(self.initial_input) return @@ -221,10 +231,10 @@ class Task(object): def processOutput(self, data): self.output_line += data while True: - i = self.output_line.find('\n') + i = self.output_line.find("\n") if i == -1: break - self.processOutputLine(self.output_line[:i + 1]) + self.processOutputLine(self.output_line[: i + 1]) self.output_line = self.output_line[i + 1:] def processOutputLine(self, line): @@ -273,7 +283,7 @@ class Task(object): progress = property(getProgress, setProgress) def __str__(self): - return 'Components.Task.Task name=%s' % self.name + return "Components.Task.Task name=%s" % self.name class LoggingTask(Task): @@ -283,7 +293,7 @@ class LoggingTask(Task): self.log = [] def processOutput(self, data): - print(("[%s]") % self.name, data, end=' ') + print(("[%s]") % self.name, data, end=" ") self.log.append(data) @@ -292,6 +302,7 @@ class PythonTask(Task): def _run(self): from twisted.internet import threads from enigma import eTimer + self.aborted = False self.pos = 0 threads.deferToThread(self.work).addBoth(self.onComplete) @@ -329,12 +340,13 @@ class ConditionTask(Task): def prepare(self): from enigma import eTimer + self.timer = eTimer() self.timer.callback.append(self.trigger) self.timer.start(1000) def cleanup(self, failed): - if hasattr(self, 'timer'): + if hasattr(self, "timer"): self.timer.stop() del self.timer @@ -387,13 +399,23 @@ class JobManager: def notifyFailed(self, job, task, problems): from Tools import Notifications from Screens.MessageBox import MessageBox + if problems[0].RECOVERABLE: - Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _( - 'Error: %s\nRetry?') % problems[0].getErrorMessage(task)) + Notifications.AddNotificationWithCallback( + self.errorCB, + MessageBox, + _("Error: %s\nRetry?") % problems[0].getErrorMessage(task), + ) return True else: - Notifications.AddNotification(MessageBox, job.name + '\n' + _( - 'Error') + ': %s' % problems[0].getErrorMessage(task), type=MessageBox.TYPE_ERROR) + Notifications.AddNotification( + MessageBox, + job.name + + "\n" + + _("Error") + + ": %s" % problems[0].getErrorMessage(task), + type=MessageBox.TYPE_ERROR, + ) return False def jobDone(self, job, task, problems): @@ -412,6 +434,7 @@ class JobManager: if not self.visible: from Tools import Notifications from Screens.TaskView import JobView + self.visible = True Notifications.AddNotification(JobView, job) @@ -438,7 +461,10 @@ class Condition: RECOVERABLE = False def getErrorMessage(self, task): - return _('An unknown error occurred!') + ' (%s @ task %s)' % (self.__class__.__name__, task.__class__.__name__) + return _("An unknown error occurred!") + " (%s @ task %s)" % ( + self.__class__.__name__, + task.__class__.__name__, + ) class WorkspaceExistsPrecondition(Condition): @@ -455,6 +481,7 @@ class DiskspacePrecondition(Condition): def check(self, task): import os + try: s = os.statvfs(task.job.workspace) self.diskspace_available = s.f_bsize * s.f_bavail @@ -463,36 +490,50 @@ class DiskspacePrecondition(Condition): return False def getErrorMessage(self, task): - return _('Not enough disk space. Please free up some disk space and try again. (%d MB required, %d MB available)') % (self.diskspace_required / 1024 / 1024, self.diskspace_available / 1024 / 1024) + return _( + "Not enough disk space. Please free up some disk space and try again. (%d MB required, %d MB available)" + ) % ( + self.diskspace_required / 1024 / 1024, + self.diskspace_available / 1024 / 1024, + ) class ToolExistsPrecondition(Condition): def check(self, task): import os - if task.cmd[0] == '/': + + if task.cmd[0] == "/": self.realpath = task.cmd print( - "[Task.py][ToolExistsPrecondition] WARNING: usage of absolute paths for tasks should be avoided!") + "[Task.py][ToolExistsPrecondition] WARNING: usage of absolute paths for tasks should be avoided!" + ) return os.access(self.realpath, os.X_OK) self.realpath = task.cmd - path = os.environ.get('PATH', '').split(os.pathsep) - path.append(task.cwd + '/') - absolutes = [file for file in map(lambda directory, file=task.cmd: os.path.join( - directory, file), path) if os.access(file, os.X_OK)] + path = os.environ.get("PATH", "").split(os.pathsep) + path.append(task.cwd + "/") + absolutes = [ + file for file in map( + lambda directory, + file=task.cmd: os.path.join( + directory, + file), + path) if os.access( + file, + os.X_OK)] if absolutes: self.realpath = absolutes[0] return True return False def getErrorMessage(self, task): - return _('A required tool (%s) was not found.') % self.realpath + return _("A required tool (%s) was not found.") % self.realpath class AbortedPostcondition(Condition): def getErrorMessage(self, task): - return 'Cancelled upon user request' + return "Cancelled upon user request" class ReturncodePostcondition(Condition): @@ -501,13 +542,13 @@ class ReturncodePostcondition(Condition): return task.returncode == 0 def getErrorMessage(self, task): - if hasattr(task, 'log') and task.log: - log = ''.join(task.log).strip() - log = log.split('\n')[-3:] - log = '\n'.join(log) + if hasattr(task, "log") and task.log: + log = "".join(task.log).strip() + log = log.split("\n")[-3:] + log = "\n".join(log) return log else: - return _('Error code') + ': %s' % task.returncode + return _("Error code") + ": %s" % task.returncode class FailedPostcondition(Condition): @@ -517,13 +558,13 @@ class FailedPostcondition(Condition): def getErrorMessage(self, task): if isinstance(self.exception, int): - if hasattr(task, 'log'): - log = ''.join(task.log).strip() - log = log.split('\n')[-4:] - log = '\n'.join(log) + if hasattr(task, "log"): + log = "".join(task.log).strip() + log = log.split("\n")[-4:] + log = "\n".join(log) return log else: - return _('Error code') + ' %s' % self.exception + return _("Error code") + " %s" % self.exception return str(self.exception) def check(self, task): diff --git a/NeoBoot/files/__init__.py b/NeoBoot/files/__init__.py index a76ce93..3d598c1 100644 --- a/NeoBoot/files/__init__.py +++ b/NeoBoot/files/__init__.py @@ -1,27 +1,28 @@ -# -*- coding: utf-8 -*- - - from Components.Language import language from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE import os import gettext -PluginLanguageDomain = 'NeoBoot' -PluginLanguagePath = 'Extensions/NeoBoot/locale' + +PluginLanguageDomain = "NeoBoot" +PluginLanguagePath = "Extensions/NeoBoot/locale" def localeInit(): lang = language.getLanguage()[:2] - os.environ['LANGUAGE'] = lang + os.environ["LANGUAGE"] = lang print("[NeoBoot] set language to "), lang - gettext.bindtextdomain(PluginLanguageDomain, resolveFilename( - SCOPE_PLUGINS, PluginLanguagePath)) + gettext.bindtextdomain( + PluginLanguageDomain, + resolveFilename( + SCOPE_PLUGINS, + PluginLanguagePath)) def _(txt): t = gettext.dgettext(PluginLanguageDomain, txt) if t == txt: print("[NeoBoot] fallback to default translation for"), txt - t = gettext.dgettext('enigma2', txt) + t = gettext.dgettext("enigma2", txt) return t diff --git a/NeoBoot/files/devices.py b/NeoBoot/files/devices.py index bd121f4..9138282 100644 --- a/NeoBoot/files/devices.py +++ b/NeoBoot/files/devices.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from Plugins.Extensions.NeoBoot.__init__ import _ from enigma import getDesktop from Plugins.Plugin import PluginDescriptor @@ -15,7 +13,13 @@ from Components.Label import Label from Components.MenuList import MenuList from Components.Pixmap import Pixmap from Components.ConfigList import ConfigListScreen -from Components.config import getConfigListEntry, config, ConfigSelection, NoSave, configfile +from Components.config import ( + getConfigListEntry, + config, + ConfigSelection, + NoSave, + configfile, +) from Components.Console import Console from Components.Sources.List import List from Components.Sources.StaticText import StaticText @@ -26,12 +30,24 @@ from os import system, rename, path, mkdir, remove, listdir from time import sleep import re import os +import subprocess # Use subprocess for command execution from Screens.VirtualKeyBoard import VirtualKeyBoard import gettext -from Plugins.Extensions.NeoBoot.files.stbbranding import getTunerModel, getCheckExt, getBoxHostName, getMyUUID -import subprocess - -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getTunerModel, + getCheckExt, + getBoxHostName, + getMyUUID, +) + + +def getoutput(cmd): + """Wrapper for subprocess.getoutput (Python 3 equivalent of commands.getoutput)""" + return subprocess.getoutput(cmd) + + +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + class ManagerDevice(Screen): screenwidth = getDesktop(0).size().width() @@ -65,22 +81,27 @@ class ManagerDevice(Screen): def __init__(self, session): Screen.__init__(self, session) - Screen.setTitle(self, _('Mount Manager')) - self['key_red'] = Label(_('Initialize ext3')) - self['key_green'] = Label(_('Mounts UUID')) - self['key_yellow'] = Label(_('Initialize ext4')) - self['key_blue'] = Label(_('Formatting Disk')) - self['lab1'] = Label() + Screen.setTitle(self, _("Mount Manager")) + self["key_red"] = Label(_("Initialize ext3")) + self["key_green"] = Label(_("Mounts UUID")) + self["key_yellow"] = Label(_("Initialize ext4")) + self["key_blue"] = Label(_("Formatting Disk")) + self["lab1"] = Label() self.onChangedEntry = [] self.list = [] - self['list'] = List(self.list) - self['list'].onSelectionChanged.append(self.selectionChanged) - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'MenuActions'], {'back': self.close, - 'red': self.Format_ext3, - 'green': self.SetupMounts, - 'yellow': self.Format_ext4, - 'blue': self.InitializationNeoB, - 'back': self.close}) + self["list"] = List(self.list) + self["list"].onSelectionChanged.append(self.selectionChanged) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions", "MenuActions"], + { + "back": self.close, + "red": self.Format_ext3, + "green": self.SetupMounts, + "yellow": self.Format_ext4, + "blue": self.InitializationNeoB, + "back": self.close, + }, + ) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateList2) self.updateList() @@ -88,27 +109,49 @@ class ManagerDevice(Screen): def Format_ext3(self): try: - if fileExists('/etc/vtiversion.info') or fileExists('/etc/bhversion'): - self.session.open(MessageBox, _("This option is available only from openpli or derivatives."), MessageBox.TYPE_INFO, timeout=10) + if fileExists( + "/etc/vtiversion.info") or fileExists("/etc/bhversion"): + self.session.open( + MessageBox, + _("This option is available only from openpli or derivatives."), + MessageBox.TYPE_INFO, + timeout=10, + ) else: from Harddisk import HarddiskSelection - self.session.openWithCallback(self.updateList, HarddiskSelection) - except: - self.session.open(MessageBox, _("This option is available only from openpli or derivatives."), MessageBox.TYPE_INFO, timeout=10) + + self.session.openWithCallback( + self.updateList, HarddiskSelection) + except BaseException: + self.session.open( + MessageBox, + _("This option is available only from openpli or derivatives."), + MessageBox.TYPE_INFO, + timeout=10, + ) def Format_ext4(self): from Screens.HarddiskSetup import HarddiskSelection + self.session.openWithCallback(self.updateList, HarddiskSelection) def InitializationNeoB(self): - if fileExists('/.multinfo'): - self.session.open(MessageBox, _("This option is available only from Flash"), MessageBox.TYPE_INFO, timeout=10) + if fileExists("/.multinfo"): + self.session.open( + MessageBox, + _("This option is available only from Flash"), + MessageBox.TYPE_INFO, + timeout=10, + ) else: - from Plugins.Extensions.NeoBoot.files.tools import InitializationFormattingDisk - self.session.open(InitializationFormattingDisk) - + from Plugins.Extensions.NeoBoot.files.tools import ( + InitializationFormattingDisk, + ) + + self.session.open(InitializationFormattingDisk) + def setWindowTitle(self): - self.setTitle(_('Mount Manager')) + self.setTitle(_("Mount Manager")) def createSummary(self): return DeviceManagerSummary @@ -116,154 +159,197 @@ class ManagerDevice(Screen): def selectionChanged(self): if len(self.list) == 0: return - self.sel = self['list'].getCurrent() + self.sel = self["list"].getCurrent() seldev = self.sel if self.sel: try: name = str(self.sel[0]) - desc = str(self.sel[1].replace('\t', ' ')) - except: - name = '' - desc = '' + desc = str(self.sel[1].replace("\t", " ")) + except BaseException: + name = "" + desc = "" else: - name = '' - desc = '' + name = "" + desc = "" for cb in self.onChangedEntry: cb(name, desc) def updateList(self, result=None, retval=None, extra_args=None): - scanning = _('Wait please while scanning for devices...') - self['lab1'].setText(scanning) + scanning = _("Wait please while scanning for devices...") + self["lab1"].setText(scanning) self.activityTimer.start(10) def updateList2(self): self.activityTimer.stop() self.list = [] list2 = [] - f = open('/proc/partitions', 'r') - for line in f.readlines(): - parts = line.strip().split() - if not parts: - continue - device = parts[3] - if not re.search('sd[a-z][1-9]', device): - continue - if device in list2: - continue - self.buildMy_rec(device) - list2.append(device) + try: + with open("/proc/partitions", "r") as f: + for line in f.readlines(): + parts = line.strip().split() + if not parts: + continue + device = parts[3] + if not re.search("sd[a-z][1-9]", device): + continue + if device in list2: + continue + self.buildMy_rec(device) + list2.append(device) + except FileNotFoundError: + pass - f.close() - self['list'].list = self.list - self['lab1'].hide() + self["list"].list = self.list + self["lab1"].hide() def buildMy_rec(self, device): mypath = SkinPath() - device2 = re.sub('[0-9]', '', device) - devicetype = path.realpath('/sys/block/' + device2 + '/device') + device2 = re.sub("[0-9]", "", device) + devicetype = path.realpath("/sys/block/" + device2 + "/device") d2 = device - name = _('HARD DISK: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_hdd.png' - model = open('/sys/block/' + device2 + '/device/model').read() - model = str(model).replace('\n', '') - des = '' - if devicetype.find('usb') != -1: - name = _('USB: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' - if devicetype.find('usb1') != -1: - name = _('USB1: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' - if devicetype.find('usb2') != -1: - name = _('USB2: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' - if devicetype.find('card') != -1: - name = _('CARD: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_sd.png' + name = _("HARD DISK: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_hdd.png" + + try: + with open("/sys/block/" + device2 + "/device/model", "r") as f: + model = f.read().strip() + except IOError: + model = "Unknown Model" + + des = "" + if devicetype.find("usb") != -1: + name = _("USB: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_usb.png" + if devicetype.find("usb1") != -1: + name = _("USB1: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_usb.png" + if devicetype.find("usb2") != -1: + name = _("USB2: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_usb.png" + if devicetype.find("card") != -1: + name = _("CARD: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_sd.png" name = name + model self.Console = Console() - self.Console.ePopen("sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp") + self.Console.ePopen( + "sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp" + ) sleep(0.5) - f = open('/tmp/devices.tmp', 'r') - swapdevices = f.read() - f.close() - if path.exists('/tmp/devices.tmp'): - remove('/tmp/devices.tmp') - swapdevices = swapdevices.replace('\n', '') - swapdevices = swapdevices.split('/') - f = open('/proc/mounts', 'r') - for line in f.readlines(): - if line.find(device) != -1: - parts = line.strip().split() - d1 = parts[1] - dtype = parts[2] - rw = parts[3] - break - continue - elif device in swapdevices: - parts = line.strip().split() - d1 = _('None') - dtype = 'swap' - rw = _('None') - break - continue - else: - d1 = _('None') - dtype = _('unavailable') - rw = _('None') - f.close() + swapdevices = "" + if path.exists("/tmp/devices.tmp"): + try: + with open("/tmp/devices.tmp", "r") as f: + swapdevices = f.read() + except IOError: + pass + remove("/tmp/devices.tmp") + + swapdevices = swapdevices.replace("\n", "") + swapdevices = swapdevices.split("/") + + d1 = _("None") + dtype = _("unavailable") + rw = _("None") + + try: + with open("/proc/mounts", "r") as f: + for line in f.readlines(): + if line.find(device) != -1: + parts = line.strip().split() + d1 = parts[1] + dtype = parts[2] + rw = parts[3] + break + elif device in swapdevices: + parts = line.strip().split() + d1 = _("None") + dtype = "swap" + rw = _("None") + break + except FileNotFoundError: + pass + size = Harddisk(device).diskSize() if float(size) / 1024 / 1024 >= 1: - des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') - elif size / 1024 >= 1: - des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB') + des = _("Size: ") + \ + str(round(float(size) / 1024 / 1024, 2)) + _("TB") + elif float(size) / 1024 >= 1: + des = _("Size: ") + str(round(float(size) / 1024, 2)) + _("GB") elif size >= 1: - des = _('Size: ') + str(size) + _('MB') + des = _("Size: ") + str(size) + _("MB") else: - des = _('Size: ') + _('unavailable') - if des != '': - if rw.startswith('rw'): - rw = ' R/W' - elif rw.startswith('ro'): - rw = ' R/O' + des = _("Size: ") + _("unavailable") + if des != "": + if rw.startswith("rw"): + rw = " R/W" + elif rw.startswith("ro"): + rw = " R/O" else: - rw = '' - des += '\t' + _('Mount: ') + d1 + '\n' + _('Device: ') + '/dev/' + device + '\t' + _('Type: ') + dtype + rw + rw = "" + des += ( + "\t" + + _("Mount: ") + + d1 + + "\n" + + _("Device: ") + + "/dev/" + + device + + "\t" + + _("Type: ") + + dtype + + rw + ) png = LoadPixmap(mypixmap) res = (name, des, png) self.list.append(res) def SetupMounts(self): - if getCheckExt() != 'vfat' and getCheckExt() == 'ext3' or getCheckExt() == 'ext4' : + if ( + getCheckExt() != "vfat" + and getCheckExt() == "ext3" + or getCheckExt() == "ext4" + ): self.SetupMountsGo() else: - self.session.open(MessageBox, _('Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot.'), type=MessageBox.TYPE_ERROR) + self.session.open( + MessageBox, + _("Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot."), + type=MessageBox.TYPE_ERROR, + ) def SetupMountsGo(self): - if not fileExists('/etc/fstab.org'): - os.system('cp -f /etc/fstab /etc/fstab.org') - elif fileExists('/etc/fstab.org'): - os.system('rm -f /etc/fstab; cp /etc/fstab.org /etc/fstab; rm /etc/fstab.org') + if not fileExists("/etc/fstab.org"): + os.system("cp -f /etc/fstab /etc/fstab.org") + elif fileExists("/etc/fstab.org"): + os.system( + "rm -f /etc/fstab; cp /etc/fstab.org /etc/fstab; rm /etc/fstab.org" + ) self.session.openWithCallback(self.updateList, DevicesConf) def Unmount(self): - sel = self['list'].getCurrent() + sel = self["list"].getCurrent() if sel: des = sel[1] - des = des.replace('\n', '\t') - parts = des.strip().split('\t') - mountp = parts[1].replace(_('Mount: '), '') - device = parts[2].replace(_('Device: '), '') - system('umount ' + mountp) + des = des.replace("\n", "\t") + parts = des.strip().split("\t") + mountp = parts[1].replace(_("Mount: "), "") + device = parts[2].replace(_("Device: "), "") + system("umount " + mountp) try: - mounts = open('/proc/mounts') + mounts = open("/proc/mounts") mountcheck = mounts.readlines() mounts.close() for line in mountcheck: - parts = line.strip().split(' ') + parts = line.strip().split(" ") if path.realpath(parts[0]).startswith(device): - self.session.open(MessageBox, _("Can't unmount partition, make sure it is not being used for swap or record/timeshift paths"), MessageBox.TYPE_INFO, timeout=10) + self.session.open( + MessageBox, + _("Can't unmount partition, make sure it is not being used for swap or record/timeshift paths"), + MessageBox.TYPE_INFO, + timeout=10, + ) except IOError: return -1 @@ -271,37 +357,64 @@ class ManagerDevice(Screen): self.updateList() def saveMypoints(self): - sel = self['list'].getCurrent() + sel = self["list"].getCurrent() if sel: parts = sel[1].split() self.device = parts[5] self.mountp = parts[3] - self.Console.ePopen('umount ' + self.device) - if self.mountp.find('/media/hdd') < 0: - self.Console.ePopen('umount /media/hdd') - self.Console.ePopen('/sbin/blkid | grep ' + self.device, self.add_fstab, [self.device, self.mountp]) + self.Console.ePopen("umount " + self.device) + if self.mountp.find("/media/hdd") < 0: + self.Console.ePopen("umount /media/hdd") + self.Console.ePopen( + "/sbin/blkid | grep " + self.device, + self.add_fstab, + [self.device, self.mountp], + ) else: - self.session.open(MessageBox, _('This Device is already mounted as HDD.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True) + self.session.open( + MessageBox, + _("This Device is already mounted as HDD."), + MessageBox.TYPE_INFO, + timeout=10, + close_on_any_key=True, + ) def add_fstab(self, result=None, retval=None, extra_args=None): self.device = extra_args[0] self.mountp = extra_args[1] - self.device_uuid = 'UUID=' + result.split('UUID=')[1].split(' ')[0].replace('"', '') + self.device_uuid = "UUID=" + \ + result.split("UUID=")[1].split(" ")[0].replace('"', "") if not path.exists(self.mountp): mkdir(self.mountp, 493) - open('/etc/fstab.tmp', 'w').writelines([l for l in open('/etc/fstab').readlines() if '/media/hdd' not in l]) - rename('/etc/fstab.tmp', '/etc/fstab') - open('/etc/fstab.tmp', 'w').writelines([l for l in open('/etc/fstab').readlines() if self.device not in l]) - rename('/etc/fstab.tmp', '/etc/fstab') - open('/etc/fstab.tmp', 'w').writelines([l for l in open('/etc/fstab').readlines() if self.device_uuid not in l]) - rename('/etc/fstab.tmp', '/etc/fstab') - out = open('/etc/fstab', 'a') - line = self.device_uuid + '\t/media/hdd\tauto\tdefaults\t0 0\n' - out.write(line) - out.close() - self.Console.ePopen('mount -a', self.updateList) - - + + with open("/etc/fstab", "r") as f: + lines = f.readlines() + + with open("/etc/fstab.tmp", "w") as out: + out.writelines([l for l in lines if "/media/hdd" not in l]) + rename("/etc/fstab.tmp", "/etc/fstab") + + with open("/etc/fstab", "r") as f: + lines = f.readlines() + + with open("/etc/fstab.tmp", "w") as out: + out.writelines([l for l in lines if self.device not in l]) + rename("/etc/fstab.tmp", "/etc/fstab") + + with open("/etc/fstab", "r") as f: + lines = f.readlines() + + with open("/etc/fstab.tmp", "w") as out: + out.writelines([l for l in lines if self.device_uuid not in l]) + rename("/etc/fstab.tmp", "/etc/fstab") + + with open("/etc/fstab", "a") as out: + line = self.device_uuid + "\t/media/hdd\tauto\tdefaults\t0 0\n" + out.write(line) + + self.Console.ePopen("mount -a", self.updateList) + + class DevicesConf(Screen, ConfigListScreen): screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth == 1920: @@ -323,197 +436,240 @@ class DevicesConf(Screen, ConfigListScreen): Screen.__init__(self, session) self.list = [] ConfigListScreen.__init__(self, self.list) - Screen.setTitle(self, _('Choose where to mount your devices to:')) - self['key_green'] = Label(_('Save')) - self['key_red'] = Label(_('Cancel')) - self['Linconn'] = Label(_('Wait please while scanning your %s %s devices...n\\ Looking for a disk...')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'green': self.saveMypoints, - 'red': self.close, - 'back': self.close}) + Screen.setTitle(self, _("Choose where to mount your devices to:")) + self["key_green"] = Label(_("Save")) + self["key_red"] = Label(_("Cancel")) + self["Linconn"] = Label( + _("Wait please while scanning your %s %s devices...n\\ Looking for a disk...")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"green": self.saveMypoints, "red": self.close, "back": self.close}, + ) self.updateList() def updateList(self): self.list = [] list2 = [] self.Console = Console() - self.Console.ePopen("sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp") + self.Console.ePopen( + "sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp" + ) sleep(0.5) - f = open('/tmp/devices.tmp', 'r') - swapdevices = f.read() - f.close() - if path.exists('/tmp/devices.tmp'): - remove('/tmp/devices.tmp') - swapdevices = swapdevices.replace('\n', '') - swapdevices = swapdevices.split('/') - f = open('/proc/partitions', 'r') - for line in f.readlines(): - parts = line.strip().split() - if not parts: - continue - device = parts[3] - if not re.search('sd[a-z][1-9]', device): - continue - if device in list2: - continue - if device in swapdevices: - continue - self.buildMy_rec(device) - list2.append(device) - f.close() - self['config'].list = self.list - self['config'].l.setList(self.list) - self['Linconn'].hide() + swapdevices = "" + if path.exists("/tmp/devices.tmp"): + try: + with open("/tmp/devices.tmp", "r") as f: + swapdevices = f.read() + except IOError: + pass + remove("/tmp/devices.tmp") + + swapdevices = swapdevices.replace("\n", "") + swapdevices = swapdevices.split("/") + + try: + with open("/proc/partitions", "r") as f: + for line in f.readlines(): + parts = line.strip().split() + if not parts: + continue + device = parts[3] + if not re.search("sd[a-z][1-9]", device): + continue + if device in list2: + continue + if device in swapdevices: + continue + self.buildMy_rec(device) + list2.append(device) + except FileNotFoundError: + pass + + self["config"].list = self.list + self["config"].l.setList(self.list) + self["Linconn"].hide() def buildMy_rec(self, device): mypath = SkinPath() - device2 = re.sub('[0-9]', '', device) - devicetype = path.realpath('/sys/block/' + device2 + '/device') + device2 = re.sub("[0-9]", "", device) + devicetype = path.realpath("/sys/block/" + device2 + "/device") d2 = device - name = _('HARD DISK: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_hdd.png' - model = open('/sys/block/' + device2 + '/device/model').read() - model = str(model).replace('\n', '') - des = '' - if devicetype.find('usb') != -1: - name = _('USB: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' - if devicetype.find('usb1') != -1: - name = _('USB1: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' - if devicetype.find('usb2') != -1: - name = _('USB2: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' - if devicetype.find('card') != -1: - name = _('CARD: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_sd.png' - if devicetype.find('mmc') != -1: - name = _('MMC: ') - mypixmap = '' + LinkNeoBoot + '/images/dev_sd.png' - + name = _("HARD DISK: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_hdd.png" + + try: + with open("/sys/block/" + device2 + "/device/model", "r") as f: + model = f.read().strip() + except IOError: + model = "Unknown Model" + + des = "" + if devicetype.find("usb") != -1: + name = _("USB: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_usb.png" + if devicetype.find("usb1") != -1: + name = _("USB1: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_usb.png" + if devicetype.find("usb2") != -1: + name = _("USB2: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_usb.png" + if devicetype.find("card") != -1: + name = _("CARD: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_sd.png" + if devicetype.find("mmc") != -1: + name = _("MMC: ") + mypixmap = "" + LinkNeoBoot + "/images/dev_sd.png" name = name + model - f = open('/proc/mounts', 'r') - for line in f.readlines(): - if line.find(device) != -1: - parts = line.strip().split() - d1 = parts[1] - dtype = parts[2] - break - continue - else: - d1 = _('None') - dtype = _('unavailable') + d1 = _("None") + dtype = _("unavailable") + + try: + with open("/proc/mounts", "r") as f: + for line in f.readlines(): + if line.find(device) != -1: + parts = line.strip().split() + d1 = parts[1] + dtype = parts[2] + break + except FileNotFoundError: + pass - f.close() size = Harddisk(device).diskSize() if float(size) / 1024 / 1024 >= 1: - des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') - elif size / 1024 >= 1: - des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB') + des = _("Size: ") + \ + str(round(float(size) / 1024 / 1024, 2)) + _("TB") + elif float(size) / 1024 >= 1: + des = _("Size: ") + str(round(float(size) / 1024, 2)) + _("GB") elif size >= 1: - des = _('Size: ') + str(size) + _('MB') + des = _("Size: ") + str(size) + _("MB") else: - des = _('Size: ') + _('unavailable') - item = NoSave(ConfigSelection(default='/media/' + device, choices=[('/media/' + device, '/media/' + device), - ('/media/hdd', '/media/hdd'), - ('/media/hdd2', '/media/hdd2'), - ('/media/hdd3', '/media/hdd3'), - ('/media/usb', '/media/usb'), - ('/media/usb1', '/media/usb1'), - ('/media/usb2', '/media/usb2'), - ('/media/usb3', '/media/usb3'), - ('/media/usb3', '/media/cf'), - ('/media/usb3', '/media/card'), - ('/media/cf', '/media/cf'), - ('/media/mmc', '/media/mmc'), - ('/media/card', '/media/card')])) - if dtype == 'Linux': - dtype = 'ext2', 'ext3', 'ext4' + des = _("Size: ") + _("unavailable") + item = NoSave( + ConfigSelection( + default="/media/" + device, + choices=[ + ("/media/" + device, "/media/" + device), + ("/media/hdd", "/media/hdd"), + ("/media/hdd2", "/media/hdd2"), + ("/media/hdd3", "/media/hdd3"), + ("/media/usb", "/media/usb"), + ("/media/usb1", "/media/usb1"), + ("/media/usb2", "/media/usb2"), + ("/media/usb3", "/media/usb3"), + ("/media/usb3", "/media/cf"), + ("/media/usb3", "/media/card"), + ("/media/cf", "/media/cf"), + ("/media/mmc", "/media/mmc"), + ("/media/card", "/media/card"), + ], + ) + ) + if dtype == "Linux": + dtype = "ext2", "ext3", "ext4" else: - dtype = 'auto' + dtype = "auto" item.value = d1.strip() - text = name + ' ' + des + ' /dev/' + device + text = name + " " + des + " /dev/" + device res = getConfigListEntry(text, item, device, dtype) - if des != '' and self.list.append(res): + if des != "" and self.list.append(res): pass def saveMypoints(self): self.Console = Console() mycheck = False - for x in self['config'].list: + for x in self["config"].list: self.device = x[2] self.mountp = x[1].value self.type = x[3] - self.Console.ePopen('umount ' + self.device) - self.Console.ePopen('/sbin/blkid | grep ' + self.device + ' && opkg list-installed ntfs-3g', self.add_fstab, [self.device, self.mountp]) + self.Console.ePopen("umount " + self.device) + self.Console.ePopen( + "/sbin/blkid | grep " + self.device + " && opkg list-installed ntfs-3g", + self.add_fstab, + [self.device, self.mountp], + ) - message = _('Continues mounting equipment...') - ybox = self.session.openWithCallback(self.delay, MessageBox, message, type=MessageBox.TYPE_INFO, timeout=5, enable_input=False) - ybox.setTitle(_('Please, wait....')) + message = _("Continues mounting equipment...") + ybox = self.session.openWithCallback( + self.delay, + MessageBox, + message, + type=MessageBox.TYPE_INFO, + timeout=5, + enable_input=False, + ) + ybox.setTitle(_("Please, wait....")) def delay(self, val): - if fileExists('/etc/init.d/volatile-media.sh') and getBoxHostName() == "vusolo2": - system('mv /etc/init.d/volatile-media.sh /etc/init.d/volatile-media.sh.org') - message = _('GUI needs a restart.\nDo you want to Restart the GUI now?') - ybox = self.session.openWithCallback(self.myclose, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('MOUNTING....')) + if ( + fileExists("/etc/init.d/volatile-media.sh") + and getBoxHostName() == "vusolo2" + ): + system("mv /etc/init.d/volatile-media.sh /etc/init.d/volatile-media.sh.org") + message = _("GUI needs a restart.\nDo you want to Restart the GUI now?") + ybox = self.session.openWithCallback( + self.myclose, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("MOUNTING....")) def myclose(self, answer): if answer is True: - os.system('reboot -f') + os.system("reboot -f") else: - self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO) + self.messagebox = self.session.open( + MessageBox, _("Return to installation..."), MessageBox.TYPE_INFO) self.close() def add_fstab(self, result=None, retval=None, extra_args=None): - print("[MountManager] RESULT:"), result + print("[MountManager] RESULT:", result) # Python 3 print function if result: self.device = extra_args[0] self.mountp = extra_args[1] - if fileExists('/usr/lib/python2.7'): - self.device_uuid = 'UUID=' + result.split('UUID=')[1].split(' ')[0].replace('"', '') - self.device_type = result.split('TYPE=')[1].split(' ')[0].replace('"', '') - else: - self.device_uuid = 'UUID=' + getMyUUID() - self.device_type = getCheckExt() - if self.device_type.startswith('ext'): - self.device_type = 'auto' - elif self.device_type.startswith('ntfs') and result.find('ntfs-3g') != -1: - self.device_type = 'ntfs-3g' - elif self.device_type.startswith('ntfs') and result.find('ntfs-3g') == -1: - self.device_type = 'ntfs' + + self.device_uuid = "UUID=" + \ + result.split("UUID=")[1].split(" ")[0].replace('"', "") + self.device_type = result.split("TYPE=")[1].split(" ")[ + 0].replace('"', "") + + if self.device_type.startswith("ext"): + self.device_type = "auto" + elif self.device_type.startswith("ntfs") and result.find("ntfs-3g") != -1: + self.device_type = "ntfs-3g" + elif self.device_type.startswith("ntfs") and result.find("ntfs-3g") == -1: + self.device_type = "ntfs" if not path.exists(self.mountp): mkdir(self.mountp, 493) - open('/etc/fstab.tmp', 'w').writelines([l for l in open('/etc/fstab').readlines() if self.device not in l]) - rename('/etc/fstab.tmp', '/etc/fstab') - open('/etc/fstab.tmp', 'w').writelines([l for l in open('/etc/fstab').readlines() if self.device_uuid not in l]) - rename('/etc/fstab.tmp', '/etc/fstab') - out = open('/etc/fstab', 'a') - if fileExists('/usr/lib/python2.7'): - line = self.device_uuid + '\t' + self.mountp + '\t' + self.device_type + '\tdefaults\t0 0\n' - else: - line = 'UUID=' + getMyUUID() + '\t' + self.mountp + '\t' + self.device_type + '\tdefaults\t0 0\n' - out.write(line) - out.close() - if fileExists('/usr/lib/python2.7'): - self.device_uuid2 = result.split('UUID=')[1].split(' ')[0].replace('"', '') - else: - self.device_uuid = getMyUUID() - -# if fileExists('/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager2'): -# out1 = open('/etc/devicemanager.cfg', 'a') -# line1 = '"' + self.device_uuid2 + '"' + ':' + self.mountp + '\n' -# out1.write(line1) -# out1.close() -# elif fileExists('/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager'): -# out2 = open('/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager/devicemanager.cfg', 'a') -# line2 = '"' + self.device_uuid2 + '"' + ':' + self.mountp + '\n' -# out2.write(line2) -# out2.close() + + with open("/etc/fstab", "r") as f: + lines = f.readlines() + + with open("/etc/fstab.tmp", "w") as out: + out.writelines([l for l in lines if self.device not in l]) + rename("/etc/fstab.tmp", "/etc/fstab") + + with open("/etc/fstab", "r") as f: + lines = f.readlines() + + with open("/etc/fstab.tmp", "w") as out: + out.writelines([l for l in lines if self.device_uuid not in l]) + rename("/etc/fstab.tmp", "/etc/fstab") + + with open("/etc/fstab", "a") as out: + line = ( + self.device_uuid + + "\t" + + self.mountp + + "\t" + + self.device_type + + "\tdefaults\t0 0\n" + ) + out.write(line) + + self.device_uuid2 = result.split("UUID=")[1].split(" ")[ + 0].replace('"', "") -#SetDiskLabel - dziekuje autorowi class SetDiskLabel(Screen): screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth == 1920: @@ -542,7 +698,7 @@ class SetDiskLabel(Screen): - """ % (_('!!!Do not set the label for /dev/mmcblk0p !!!')) + """ % (_("!!!Do not set the label for /dev/mmcblk0p !!!")) else: skin = """ @@ -568,112 +724,146 @@ class SetDiskLabel(Screen): def __init__(self, session): global liczymy Screen.__init__(self, session) - self.labList = ['hdd', 'usb', 'card', 'cf'] + self.labList = ["hdd", "usb", "card", "cf"] self.list = [] self.sprDev() self.devlist = [] self.disklabel = [] - self['devlist'] = MenuList(self.devlist) - self['disklabel'] = Label(self.disklabel) - self['listlabel'] = MenuList(self.labList) + self["devlist"] = MenuList(self.devlist) + self["disklabel"] = Label(self.disklabel) + self["listlabel"] = MenuList(self.labList) liczymy = 0 for x in lista: self.devlist.append(x) liczymy += 1 self.sprLabel() - self['labelname'] = Label(_('Current partition label:')) - self['labeltoset'] = Label(_('Choice label to set:')) - self['infoTXT'] = Label(_('Select partition to set label:')) - self['key_red'] = Button(_('Exit')) - self['key_green'] = Button(_('Set label')) - self['key_yellow'] = Button(_('Add label')) - self['key_blue'] = Button(_('Delete label')) - self['actions'] = ActionMap(['OkCancelActions', 'ColorActions', 'DirectionActions'], {'cancel': self.MyClose, - 'red': self.MyClose, - 'green': self.wlacz, - 'yellow': self.addlabel, - 'blue': self.dellabel, - 'left': self.left, - 'right': self.right, - 'up': self.up, - 'down': self.down}, -2) + self["labelname"] = Label(_("Current partition label:")) + self["labeltoset"] = Label(_("Choice label to set:")) + self["infoTXT"] = Label(_("Select partition to set label:")) + self["key_red"] = Button(_("Exit")) + self["key_green"] = Button(_("Set label")) + self["key_yellow"] = Button(_("Add label")) + self["key_blue"] = Button(_("Delete label")) + self["actions"] = ActionMap( + ["OkCancelActions", "ColorActions", "DirectionActions"], + { + "cancel": self.MyClose, + "red": self.MyClose, + "green": self.wlacz, + "yellow": self.addlabel, + "blue": self.dellabel, + "left": self.left, + "right": self.right, + "up": self.up, + "down": self.down, + }, + -2, + ) def sprDev(self): global lista - lista = [''] - tuner_model = getTunerModel() - blackL = '' - if tuner_model in ('sf8008', 'sf8008s', 'sf8008t'): - blackL = 'mmcblk0' - elif tuner_model in ('h9se'): - blackL = 'mmcblk1' + lista = [""] + blackL = "" + if getTunerModel() in ("sf8008", "sf8008s", "sf8008t"): + blackL = "mmcblk0" + if getTunerModel() in ("h9se"): + blackL = "mmcblk1" else: - try: - blackL_output = subprocess.getoutput('cat /etc/udev/mount-helper.sh | grep "BLACKLISTED="') + blackL_output = getoutput( + 'cat /etc/udev/mount-helper.sh | grep "BLACKLISTED="' + ) + if blackL_output: blackL = blackL_output[13:-1] - except Exception: - blackL = '' - try: - devL_output = subprocess.getoutput('cat /proc/partitions | grep "sd\\|mmc" | awk \'{print $4}\'') - devL = devL_output.split('\n') - except Exception: - devL = [] + devL = getoutput( + "cat /proc/partitions | grep \"sd\\|mmc\" | awk '{print $4}'") + devL = devL.split("\n") ilosc = len(devL) i = 0 while i < ilosc: if len(devL[i]) == 9 or len(devL[i]) == 4: if devL[i][:7] != blackL: - if self.sprLinux(devL[i]) is True: + if self.sprLinux(devL[i]): lista.append(devL[i]) i += 1 - if ilosc > 0 and '' in lista: - lista.remove('') - elif not lista and not ilosc: - lista.append('No Disk') + if ilosc > 0: + lista.remove("") + elif lista[0] == "": + lista.remove("") + lista.insert(0, "No Disk") def cancel(self): self.close() def wlacz(self): - self.session.openWithCallback(self.wlaczyes, MessageBox, _('Set label on %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False) + self.session.openWithCallback( + self.wlaczyes, + MessageBox, + _("Set label on %s?") % str(self["devlist"].getCurrent()), + MessageBox.TYPE_YESNO, + default=False, + ) def wlaczyes(self, w): - if w == True: - os.system('e2label /dev/%s "%s"' % (str(self['devlist'].getCurrent()), self['listlabel'].getCurrent())) - self.session.open(MessageBox, _('Selected label is set'), type=MessageBox.TYPE_INFO, timeout=10) + if w: + os.system( + 'e2label /dev/%s "%s"' % + (str( + self["devlist"].getCurrent()), + self["listlabel"].getCurrent())) + self.session.open( + MessageBox, + _("Selected label is set"), + type=MessageBox.TYPE_INFO, + timeout=10, + ) self.sprLabel() def addlabel(self): - self.session.openWithCallback(self.addlabeltolist, VirtualKeyBoard, title=_('Add new partition label:'), text=self['disklabel'].getText()) + self.session.openWithCallback( + self.addlabeltolist, + VirtualKeyBoard, + title=_("Add new partition label:"), + text=self["disklabel"].getText(), + ) def dellabel(self): - self.session.openWithCallback(self.delabelyes, MessageBox, _('Delete label from %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False) + self.session.openWithCallback( + self.delabelyes, + MessageBox, + _("Delete label from %s?") % str(self["devlist"].getCurrent()), + MessageBox.TYPE_YESNO, + default=False, + ) def delabelyes(self, k): - if k == True: - os.system('e2label /dev/%s ""' % str(self['devlist'].getCurrent())) - self.session.open(MessageBox, _('Label is delete'), type=MessageBox.TYPE_INFO, timeout=10) + if k: + os.system('e2label /dev/%s ""' % str(self["devlist"].getCurrent())) + self.session.open( + MessageBox, + _("Label is delete"), + type=MessageBox.TYPE_INFO, + timeout=10) self.sprLabel() def zamknij(self, data): self.close() def left(self): - self['devlist'].up() + self["devlist"].up() self.sprLabel() def right(self): - self['devlist'].down() + self["devlist"].down() self.sprLabel() def up(self): - self['listlabel'].up() + self["listlabel"].up() def down(self): - self['listlabel'].down() + self["listlabel"].down() def addlabeltolist(self, z): if z is not None: @@ -681,27 +871,21 @@ class SetDiskLabel(Screen): return def sprLabel(self): - current_device = self['devlist'].getCurrent() - if not current_device: - self['disklabel'].setText(_('No device selected')) - return - try: - lab_output = subprocess.getoutput('blkid /dev/' + current_device) - except Exception: - lab_output = '' - if lab_output: - lab1 = lab_output.split(' ') - for item in lab1: - if item.startswith('LABEL='): - label = item.split('"')[1] - self['disklabel'].setText(label) - return - - self['disklabel'].setText(_('No label')) + lab = getoutput("blkid /dev/" + self["devlist"].getCurrent()) + lab1 = lab.split(" ") + licz1 = len(lab1) + i = 0 + while i < licz1: + if lab1[i][:5] == "LABEL": + self["disklabel"].setText(lab1[i][7:-1]) + break + else: + self["disklabel"].setText(_("No label")) + i += 1 def sprLinux(self, dev): - lab = subprocess.getoutput('blkid /dev/' + dev) - lab1 = lab.split(' ') + lab = getoutput("blkid /dev/" + dev) + lab1 = lab.split(" ") licz1 = len(lab1) jest = False j = 0 @@ -711,26 +895,30 @@ class SetDiskLabel(Screen): return jest jest = False j += 1 + return jest - + def MyClose(self): - message = _('GUI needs a restart.\nDo you want to Restart the GUI now?') - ybox = self.session.openWithCallback(self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Label Disc')) + message = _("GUI needs a restart.\nDo you want to Restart the GUI now?") + ybox = self.session.openWithCallback( + self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Label Disc")) def mbdelete(self, answer): if answer is True: - os.system('reboot -f') + os.system("reboot -f") else: - self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO) - self.close() + self.messagebox = self.session.open( + MessageBox, _("Return to installation..."), MessageBox.TYPE_INFO) + self.close() + - class DeviceManagerSummary(Screen): def __init__(self, session, parent): Screen.__init__(self, session, parent=parent) - self['entry'] = StaticText('') - self['desc'] = StaticText('') + self["entry"] = StaticText("") + self["desc"] = StaticText("") self.onShow.append(self.addWatcher) self.onHide.append(self.removeWatcher) @@ -742,12 +930,12 @@ class DeviceManagerSummary(Screen): self.parent.onChangedEntry.remove(self.selectionChanged) def selectionChanged(self, name, desc): - self['entry'].text = name - self['desc'].text = desc + self["entry"].text = name + self["desc"].text = desc def SkinPath(): - myskinpath = resolveFilename(SCOPE_CURRENT_SKIN, '') - if myskinpath == '' + LinkNeoBoot + '/images/': - myskinpath = '' + LinkNeoBoot + '/images/' + myskinpath = resolveFilename(SCOPE_CURRENT_SKIN, "") + if myskinpath == "" + LinkNeoBoot + "/images/": + myskinpath = "" + LinkNeoBoot + "/images/" return myskinpath diff --git a/NeoBoot/files/neoconsole.py b/NeoBoot/files/neoconsole.py index 6ce98bb..f4785f3 100644 --- a/NeoBoot/files/neoconsole.py +++ b/NeoBoot/files/neoconsole.py @@ -1,7 +1,4 @@ -# -*- coding: utf-8 -*- - from Plugins.Extensions.NeoBoot.__init__ import _ -# from __future__ import print_function from enigma import eConsoleAppContainer from Screens.Screen import Screen from Components.ActionMap import ActionMap @@ -16,29 +13,39 @@ class Console(Screen): """ -# def __init__(self, session, title = 'Console', cmdlist = None, finishedCallback = None, closeOnSuccess = False): -# Screen.__init__(self, session) - - def __init__(self, session, title=_('Console'), cmdlist=None, finishedCallback=None, closeOnSuccess=False): + def __init__( + self, + session, + title=_("Console"), + cmdlist=None, + finishedCallback=None, + closeOnSuccess=False, + ): Screen.__init__(self, session) self.finishedCallback = finishedCallback self.closeOnSuccess = closeOnSuccess self.errorOcurred = False - self['key_red'] = Label(_('Stop action')) - self['key_green'] = Label(_('Hide Console')) - self['text'] = ScrollLabel('') - self['summary_description'] = StaticText('') - self['actions'] = ActionMap(['WizardActions', 'DirectionActions', 'ColorActions'], {'ok': self.cancel, - 'back': self.cancel, - 'up': self.key_up, - 'down': self.key_down, - 'green': self.key_green, - 'red': self.key_red}, -1) + self["key_red"] = Label(_("Stop action")) + self["key_green"] = Label(_("Hide Console")) + self["text"] = ScrollLabel("") + self["summary_description"] = StaticText("") + self["actions"] = ActionMap( + ["WizardActions", "DirectionActions", "ColorActions"], + { + "ok": self.cancel, + "back": self.cancel, + "up": self.key_up, + "down": self.key_down, + "green": self.key_green, + "red": self.key_red, + }, + -1, + ) self.cmdlist = cmdlist self.newtitle = title self.screen_hide = False self.cancel_msg = None - self.output_file = '' + self.output_file = "" self.onShown.append(self.updateTitle) self.container = eConsoleAppContainer() self.run = 0 @@ -57,10 +64,14 @@ class Console(Screen): return self.container.execute(cmd) def startRun(self): - self['text'].setText(_('Execution progress:') + '\n\n') - self['summary_description'].setText(_('Execution progress:')) - print(("[Console] executing in run"), self.run, - (" the command:"), self.cmdlist[self.run]) + self["text"].setText(_("Execution progress:") + "\n\n") + self["summary_description"].setText(_("Execution progress:")) + print( + ("[Console] executing in run"), + self.run, + (" the command:"), + self.cmdlist[self.run], + ) if self.doExec(self.cmdlist[self.run]): self.runFinished(-1) @@ -73,21 +84,20 @@ class Console(Screen): if self.doExec(self.cmdlist[self.run]): self.runFinished(-1) else: - # self['key_red'].setText(_('Close')) - # self['key_green'].setText(_('Save')) self.toggleScreenHide(True) if self.cancel_msg: self.cancel_msg.close() from Tools.Directories import fileExists - if not fileExists('/etc/vtiversion.info'): - lastpage = self['text'].isAtLastPage() - self['text'].appendText('\n' + _('Execution finished!!')) - self['summary_description'].setText( - '\n' + _('Execution finished!!')) + + if not fileExists("/etc/vtiversion.info"): + lastpage = self["text"].isAtLastPage() + self["text"].appendText("\n" + _("Execution finished!!")) + self["summary_description"].setText( + "\n" + _("Execution finished!!")) if self.finishedCallback is not None: self.finishedCallback() if not self.errorOcurred and self.closeOnSuccess: - self.output_file = 'end' + self.output_file = "end" self.cancel() return @@ -95,27 +105,26 @@ class Console(Screen): if self.screen_hide: self.toggleScreenHide() return - self['text'].pageUp() + self["text"].pageUp() def key_down(self): if self.screen_hide: self.toggleScreenHide() return - self['text'].pageDown() + self["text"].pageDown() def key_green(self): if self.screen_hide: self.toggleScreenHide() return - if self.output_file == 'end': + if self.output_file == "end": pass - elif self.output_file.startswith('/tmp/'): - self['text'].setText(self.readFile(self.output_file)) - self['key_green'].setText(_(' ')) - self.output_file = 'end' + elif self.output_file.startswith("/tmp/"): + self["text"].setText(self.readFile(self.output_file)) + self["key_green"].setText(_(" ")) + self.output_file = "end" elif self.run == len(self.cmdlist): self.saveOutputText() - # self.toggleScreenHide() else: self.toggleScreenHide() @@ -126,8 +135,13 @@ class Console(Screen): if self.run == len(self.cmdlist): self.cancel() else: - self.cancel_msg = self.session.openWithCallback(self.cancelCB, MessageBox, _( - 'Cancel execution?'), type=MessageBox.TYPE_YESNO, default=False) + self.cancel_msg = self.session.openWithCallback( + self.cancelCB, + MessageBox, + _("Cancel execution?"), + type=MessageBox.TYPE_YESNO, + default=False, + ) def cancelCB(self, ret=None): self.cancel_msg = None @@ -137,11 +151,18 @@ class Console(Screen): def saveOutputText(self): from time import time, localtime + lt = localtime(time()) - self.output_file = '/tmp/%02d%02d%02d_console.txt' % ( + self.output_file = "/tmp/%02d%02d%02d_console.txt" % ( lt[3], lt[4], lt[5]) - self.session.openWithCallback(self.saveOutputTextCB, MessageBox, _( - "Save the commands and the output to a file?\n('%s')") % self.output_file, type=MessageBox.TYPE_YESNO, default=True) + self.session.openWithCallback( + self.saveOutputTextCB, + MessageBox, + _("Save the commands and the output to a file?\n('%s')") % + self.output_file, + type=MessageBox.TYPE_YESNO, + default=True, + ) def formatCmdList(self, source): if isinstance(source, (list, tuple)): @@ -155,44 +176,47 @@ class Console(Screen): def saveOutputTextCB(self, ret=None): if ret: from os import path + failtext = _("Path to save not exist: '/tmp/'") - if path.exists('/tmp/'): - text = 'commands ...\n\n' + if path.exists("/tmp/"): + text = "commands ...\n\n" try: cmdlist = list(self.formatCmdList(self.cmdlist)) - text += 'command line: %s\n\n' % cmdlist[0] - script = '' + text += "command line: %s\n\n" % cmdlist[0] + script = "" for cmd in cmdlist[0].split(): - if '.' in cmd: - if cmd[-3:] in ('.py', '.sh'): + if "." in cmd: + if cmd[-3:] in (".py", ".sh"): script = cmd break if script and path.isfile(script): - text += 'script listing: %s\n\n%s\n\n' % ( - script, self.readFile(script)) + text += "script listing: %s\n\n%s\n\n" % ( + script, + self.readFile(script), + ) if len(cmdlist) > 1: - text += 'next commands:\n\n' + \ - '\n'.join(cmdlist[1:]) + '\n\n' - except: - text += 'error read commands!!!\n\n' + text += "next commands:\n\n" + \ + "\n".join(cmdlist[1:]) + "\n\n" + except BaseException: + text += "error read commands!!!\n\n" - text += '-' * 50 + \ - '\n\noutputs ...\n\n%s' % self['text'].getText() + text += "-" * 50 + \ + "\n\noutputs ...\n\n%s" % self["text"].getText() try: - f = open(self.output_file, 'w') + f = open(self.output_file, "w") f.write(text) f.close() - self['key_green'].setText(_('Load')) + self["key_green"].setText(_("Load")) return - except: + except BaseException: failtext = _("File write error: '%s'") % self.output_file - self.output_file = 'end' - self['key_green'].setText(_(' ')) + self.output_file = "end" + self["key_green"].setText(_(" ")) self.session.open(MessageBox, failtext, type=MessageBox.TYPE_ERROR) else: - self.output_file = '' + self.output_file = "" def toggleScreenHide(self, setshow=False): if self.screen_hide or setshow: @@ -203,12 +227,12 @@ class Console(Screen): def readFile(self, file): try: - with open(file, 'r') as rdfile: + with open(file, "r") as rdfile: rd = rdfile.read() rdfile.close() - except: + except BaseException: if file == self.output_file: - rd = self['text'].getText() + rd = self["text"].getText() else: rd = "File read error: '%s'\n" % file @@ -226,4 +250,4 @@ class Console(Screen): self.container.kill() def dataAvail(self, str): - self['text'].appendText(str) + self["text"].appendText(str) diff --git a/NeoBoot/files/stbbranding.py b/NeoBoot/files/stbbranding.py index 53539af..ce086a3 100644 --- a/NeoBoot/files/stbbranding.py +++ b/NeoBoot/files/stbbranding.py @@ -1,1309 +1,1302 @@ -# -*- coding: utf-8 -*- - -# from Plugins.Extensions.NeoBoot.__init__ import _ import sys import os import time -from Tools.Directories import fileExists, SCOPE_PLUGINS -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +import subprocess +from glob import glob +try: + from Tools.Directories import fileExists, SCOPE_PLUGINS +except Exception: + + def fileExists(path, mode="r"): + return os.path.exists(path) + + +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + +LogFile = "/tmp/NeoBoot.log" LogFileObj = None +try: + _ # noqa: F401 +except NameError: -def Log(param=''): + def _(s): + return s + + +def Log(param=""): + """ + Basic file-backed logger handler. Modes: 'open', 'write', 'append', 'close', 'flush'. + Returns the file object or None. + """ global LogFileObj - # first close object if exists - if param.lower() in ['open', 'write', 'append', 'close']: + p = str(param).lower() + if p in ("open", "write", "append", "close"): if LogFileObj is not None: - LogFileObj.close() - if LogFileObj.closed: - LogFileObj = None - try: - with open('/tmp/NeoBoot.log', 'a') as f: - f.write('LogFile closed properly\n') - f.close() - except Exception: + try: + LogFileObj.close() + except Exception: + pass + try: + if LogFileObj.closed: + LogFileObj = None + try: + with open(LogFile, "a", encoding="utf-8", errors="ignore") as f: + f.write("LogFile closed properly\n") + except Exception: + print("ERROR closing LogFile!!!") + else: print("ERROR closing LogFile!!!") - else: - print("ERROR closing LogFile!!!") - # second create object if does not exist + except Exception: + LogFileObj = None + if LogFileObj is None: - if param.lower() in ['open', 'write']: - LogFileObj = open(LogFile, "w") - elif param.lower() in ['append']: - LogFileObj = open(LogFile, "a") - elif param.lower() in ['close']: + if p in ("open", "write"): + LogFileObj = open(LogFile, "w", encoding="utf-8", errors="ignore") + elif p == "append": + LogFileObj = open(LogFile, "a", encoding="utf-8", errors="ignore") + elif p == "close": pass - elif param.lower() in ['flush']: - LogFileObj.flush() + elif p == "flush": + try: + LogFileObj.flush() + except Exception: + pass + return LogFileObj def clearMemory(): - with open("/proc/sys/vm/drop_caches", "w") as f: - f.write("1\n") - f.close() + try: + with open( + "/proc/sys/vm/drop_caches", "w", encoding="utf-8", errors="ignore" + ) as f: + f.write("1\n") + except Exception: + pass def LogCrashGS(line): - if os.path.isfile('' + getNeoLocation() + 'ImageBoot/neoboot.log'): - os.system(' rm -f ' + getNeoLocation() + 'ImageBoot/neoboot.log;') - log_file = open('%sImageBoot/neoboot.log' % getNeoLocation(), 'a') - log_file.write(line) - log_file.close() + try: + location = getNeoLocation() + target = os.path.join(location, "ImageBoot", "neoboot.log") + if os.path.isfile(target): + try: + os.remove(target) + except Exception: + pass + with open(target, "a", encoding="utf-8", errors="ignore") as log_file: + log_file.write(str(line)) + except Exception: + pass -def fileCheck(f, mode='r'): +def fileCheck(f, mode="r"): return fileExists(f, mode) and f -# if not IsImageName(): -# from Components.PluginComponent import plugins -# plugins.reloadPlugins() - def IsImageName(): - if fileExists("/etc/issue"): - for line in open("/etc/issue"): - if "BlackHole" in line or "vuplus" in line: - return True + try: + if fileExists("/etc/issue"): + with open("/etc/issue", "r", encoding="utf-8", errors="ignore") as fh: + for line in fh: + if "BlackHole" in line or "vuplus" in line: + return True + except Exception: + pass return False def mountp(): pathmp = [] - if os.path.isfile('/proc/mounts'): - for line in open('/proc/mounts'): - if '/dev/sd' in line or '/dev/disk/by-uuid/' in line or '/dev/mmc' in line or '/dev/mtdblock' in line: - pathmp.append(line.split()[1].replace('\\040', ' ') + '/') - pathmp.append('/usr/share/enigma2/') - pathmp.append('/etc/enigma2/') - pathmp.append('/tmp/') + try: + if os.path.isfile("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as fh: + for line in fh: + if ( + "/dev/sd" in line + or "/dev/disk/by-uuid/" in line + or "/dev/mmc" in line + or "/dev/mtdblock" in line + ): + pathmp.append( + line.split()[1].replace( + "\\040", " ") + "/") + except Exception: + pass + + pathmp.append("/usr/share/enigma2/") + pathmp.append("/etc/enigma2/") + pathmp.append("/tmp/") return pathmp def getSupportedTuners(): - supportedT = '' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg', 'r') as f: - lines = f.read() - f.close() - if lines.find("%s" % getBoxHostName()) != -1: - supportedT = '%s' % getBoxHostName() + supportedT = "" + cfg = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg" + try: + if os.path.exists(cfg): + with open(cfg, "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if getBoxHostName() and ("%s" % getBoxHostName()) in lines: + supportedT = "%s" % getBoxHostName() + except Exception: + pass return supportedT def getFreespace(dev): - statdev = os.statvfs(dev) - space = statdev.f_bavail * statdev.f_frsize / 1024 - print(("[NeoBoot] Free space on %s = %i kilobytes") % (dev, space)) - return space - -# check install + try: + statdev = os.statvfs(dev) + space = statdev.f_bavail * statdev.f_frsize // 1024 + print(("[NeoBoot] Free space on %s = %i kilobytes") % (dev, space)) + return space + except Exception: + return 0 def getCheckInstal1(): - neocheckinstal = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install', 'r') as f: - lines1 = f.read() - f.close() - if not lines1.find('/dev/') != -1: - neocheckinstal = '1' + neocheckinstal = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines1 = f.read() + if "/dev/" not in lines1: + neocheckinstal = "1" + except Exception: + pass return neocheckinstal def getCheckInstal2(): - neocheckinstal = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: - lines2 = f.read() - f.close() - if not lines2.find('/media/') != -1: - neocheckinstal = '2' + neocheckinstal = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines2 = f.read() + if "/media/" not in lines2: + neocheckinstal = "2" + except Exception: + pass return neocheckinstal def getCheckInstal3(): - neocheckinstal = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh', 'r') as f: - lines3 = f.read() - f.close() - if not lines3.find('/bin/mount') != -1: - neocheckinstal = '3' - + neocheckinstal = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines3 = f.read() + if "/bin/mount" not in lines3: + neocheckinstal = "3" + except Exception: + pass return neocheckinstal -# check imageATV - def getImageATv(): - atvimage = 'UNKNOWN' - if os.path.exists('/etc/issue.net'): - with open('/etc/issue.net', 'r') as f: - lines = f.read() - f.close() - if lines.find('openatv') != -1: - atvimage = 'okfeedCAMatv' + atvimage = "UNKNOWN" + try: + if os.path.exists("/etc/issue.net"): + with open("/etc/issue.net", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "openatv" in lines: + atvimage = "okfeedCAMatv" + except Exception: + pass return atvimage -# check install - def getNeoLocation(): - locatinoneo = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: - locatino = f.readline().strip() - f.close() - if os.path.exists('/media/hdd/ImageBoot'): - locatinoneo = '/media/hdd/' - elif os.path.exists('/media/usb/ImageBoot'): - locatinoneo = '/media/usb/' - else: - locatinoneo = locatino + locatinoneo = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + locatino = f.readline().strip() + if os.path.exists("/media/hdd/ImageBoot"): + locatinoneo = "/media/hdd/" + elif os.path.exists("/media/usb/ImageBoot"): + locatinoneo = "/media/usb/" + else: + locatinoneo = locatino + except Exception: + pass return locatinoneo -# check ext def getFormat(): - neoformat = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('ext2') != -1: - neoformat = 'ext2' - elif lines.find('ext3') != -1: - neoformat = 'ext3' - elif lines.find('ext4') != -1: - neoformat = 'ext4' - elif lines.find('nfs') != -1: - neoformat = 'nfs' - + neoformat = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "ext2" in lines: + neoformat = "ext2" + elif "ext3" in lines: + neoformat = "ext3" + elif "ext4" in lines: + neoformat = "ext4" + elif "nfs" in lines: + neoformat = "nfs" + except Exception: + pass return neoformat def getNEO_filesystems(): - neo_filesystems = 'UNKNOWN' - if os.path.exists('/tmp/.neo_format'): - with open('/tmp/.neo_format', 'r') as f: - lines = f.read() - f.close() - if lines.find('ext2') != -1: - neo_filesystems = '1' - elif lines.find('ext3') != -1: - neo_filesystems = '1' - elif lines.find('ext4') != -1: - neo_filesystems = '1' - elif lines.find('nfs') != -1: - neo_filesystems = '1' - + neo_filesystems = "UNKNOWN" + try: + if os.path.exists("/tmp/.neo_format"): + with open("/tmp/.neo_format", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if any(x in lines for x in ("ext2", "ext3", "ext4", "nfs")): + neo_filesystems = "1" + except Exception: + pass return neo_filesystems -# typ procesora arm lub mips - def getCPUtype(): - cpu = 'UNKNOWN' - if os.path.exists('/proc/cpuinfo'): - with open('/proc/cpuinfo', 'r') as f: - lines = f.read() - f.close() - if lines.find('ARMv7') != -1: - cpu = 'ARMv7' - elif lines.find('mips') != -1: - cpu = 'MIPS' + cpu = "UNKNOWN" + try: + if os.path.exists("/proc/cpuinfo"): + with open("/proc/cpuinfo", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "ARMv7" in lines: + cpu = "ARMv7" + elif "mips" in lines: + cpu = "MIPS" + except Exception: + pass return cpu -# check install - def getFSTAB(): - install = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid', 'r') as f: - lines = f.read() - f.close() - if lines.find('UUID') != -1: - install = 'UUID' - elif not lines.find('UUID') != -1: - install = 'NOUUID' + install = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "UUID" in lines: + install = "UUID" + else: + install = "NOUUID" + except Exception: + pass return install def getFSTAB2(): - install = 'UNKNOWN' - if os.path.exists('/etc/fstab'): - with open('/etc/fstab', 'r') as f: - lines = f.read() - f.close() - if lines.find('UUID') != -1: - install = 'OKinstall' - elif not lines.find('UUID') != -1: - install = 'NOUUID' + install = "UNKNOWN" + try: + if os.path.exists("/etc/fstab"): + with open("/etc/fstab", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "UUID" in lines: + install = "OKinstall" + else: + install = "NOUUID" + except Exception: + pass return install def getINSTALLNeo(): - neoinstall = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1') != -1: - neoinstall = '/dev/sda1' - elif lines.find('/dev/sda2') != -1: - neoinstall = '/dev/sda2' - elif lines.find('/dev/sdb1') != -1: - neoinstall = '/dev/sdb1' - elif lines.find('/dev/sdb2') != -1: - neoinstall = '/dev/sdb2' - elif lines.find('/dev/sdc1') != -1: - neoinstall = '/dev/sdc1' - elif lines.find('/dev/sdc2') != -1: - neoinstall = '/dev/sdc2' - elif lines.find('/dev/sdd1') != -1: - neoinstall = '/dev/sdd1' - elif lines.find('/dev/sdd2') != -1: - neoinstall = '/dev/sdd2' - elif lines.find('/dev/sde1') != -1: - neoinstall = '/dev/sde1' - elif lines.find('/dev/sde2') != -1: - neoinstall = '/dev/sde2' - elif lines.find('/dev/sdf1') != -1: - neoinstall = '/dev/sdf1' - elif lines.find('/dev/sdf1') != -1: - neoinstall = '/dev/sdf1' - elif lines.find('/dev/sdg1') != -1: - neoinstall = '/dev/sdg1' - elif lines.find('/dev/sdg2') != -1: - neoinstall = '/dev/sdg2' - elif lines.find('/dev/sdh1') != -1: - neoinstall = '/dev/sdh1' - elif lines.find('/dev/sdh2') != -1: - neoinstall = '/dev/sdh2' - + neoinstall = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + for candidate in ( + "/dev/sda1", + "/dev/sda2", + "/dev/sdb1", + "/dev/sdb2", + "/dev/sdc1", + "/dev/sdc2", + "/dev/sdd1", + "/dev/sdd2", + "/dev/sde1", + "/dev/sde2", + "/dev/sdf1", + "/dev/sdg1", + "/dev/sdg2", + "/dev/sdh1", + "/dev/sdh2", + ): + if candidate in lines: + neoinstall = candidate + break + except Exception: + pass return neoinstall def getLocationMultiboot(): - LocationMultiboot = 'UNKNOWN' - if os.path.exists('/media/sda1/ImageBoot'): - LocationMultiboot = '/dev/sda1' - if os.path.exists('/media/sda2/ImageBoot'): - LocationMultiboot = '/dev/sda2' - if os.path.exists('/media/sdb1/ImageBoot'): - LocationMultiboot = '/dev/sdb1' - if os.path.exists('/media/sdb2/ImageBoot'): - LocationMultiboot = '/dev/sdb2' - if os.path.exists('/media/sdc1/ImageBoot'): - LocationMultiboot = '/dev/sdc1' - if os.path.exists('/media/sdc2/ImageBoot'): - LocationMultiboot = '/dev/sdc2' - if os.path.exists('/media/sdd1/ImageBoot'): - LocationMultiboot = '/dev/sdd1' - if os.path.exists('/media/sdd2/ImageBoot'): - LocationMultiboot = '/dev/sdd2' - if os.path.exists('/media/sde1/ImageBoot'): - LocationMultiboot = '/dev/sde1' - if os.path.exists('/media/sde2/ImageBoot'): - LocationMultiboot = '/dev/sde2' - if os.path.exists('/media/sdf1/ImageBoot'): - LocationMultiboot = '/dev/sdf1' - if os.path.exists('/media/sdf2/ImageBoot'): - LocationMultiboot = '/dev/sdf2' - if os.path.exists('/media/sdg1/ImageBoot'): - LocationMultiboot = '/dev/sdg1' - if os.path.exists('/media/sdg2/ImageBoot'): - LocationMultiboot = '/dev/sdg2' - if os.path.exists('/media/sdh1/ImageBoot'): - LocationMultiboot = '/dev/sdh1' - if os.path.exists('/media/sdh2/ImageBoot'): - LocationMultiboot = '/dev/sdh2' - + LocationMultiboot = "UNKNOWN" + try: + for dev in ( + "/media/sda1", + "/media/sda2", + "/media/sdb1", + "/media/sdb2", + "/media/sdc1", + "/media/sdc2", + "/media/sdd1", + "/media/sdd2", + "/media/sde1", + "/media/sde2", + "/media/sdf1", + "/media/sdf2", + "/media/sdg1", + "/media/sdg2", + "/media/sdh1", + "/media/sdh2", + ): + if os.path.exists(os.path.join(dev, "ImageBoot")): + LocationMultiboot = dev.replace("/media/", "/dev/") + break + except Exception: + pass return LocationMultiboot def getLabelDisck(): - label = 'UNKNOWN' - if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid'): - with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid', 'r') as f: - lines = f.read() - f.close() - if lines.find('LABEL=') != -1: - label = 'LABEL=' + label = "UNKNOWN" + path = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid" + try: + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "LABEL=" in lines: + label = "LABEL=" + except Exception: + pass return label -# checking device neo - def getNeoMountDisc(): - lines_mount = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines_mount = f.read() - f.close() - + lines_mount = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines_mount = f.read() + except Exception: + pass return lines_mount def getNeoMount(): - neo = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sda1' - elif lines.find('/dev/sdb1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdb1' - elif lines.find('/dev/sda2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sda2' - elif lines.find('/dev/sdb2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdb2' - elif lines.find('/dev/sdc1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdc1' - elif lines.find('/dev/sdc2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdc2' - elif lines.find('/dev/sdd1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdd1' - elif lines.find('/dev/sdd2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdd2' - elif lines.find('/dev/sde1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sde1' - elif lines.find('/dev/sde2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sde2' - elif lines.find('/dev/sdf1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdf1' - elif lines.find('/dev/sdg1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdg1' - elif lines.find('/dev/sdg2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdg2' - elif lines.find('/dev/sdh1 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdh1' - elif lines.find('/dev/sdh2 /media/hdd') != -1: - neo = 'hdd_install_/dev/sdh2' - + neo = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + mapping = { + "/dev/sda1 /media/hdd": "hdd_install_/dev/sda1", + "/dev/sdb1 /media/hdd": "hdd_install_/dev/sdb1", + "/dev/sda2 /media/hdd": "hdd_install_/dev/sda2", + "/dev/sdb2 /media/hdd": "hdd_install_/dev/sdb2", + "/dev/sdc1 /media/hdd": "hdd_install_/dev/sdc1", + "/dev/sdc2 /media/hdd": "hdd_install_/dev/sdc2", + "/dev/sdd1 /media/hdd": "hdd_install_/dev/sdd1", + "/dev/sdd2 /media/hdd": "hdd_install_/dev/sdd2", + "/dev/sde1 /media/hdd": "hdd_install_/dev/sde1", + "/dev/sde2 /media/hdd": "hdd_install_/dev/sde2", + "/dev/sdf1 /media/hdd": "hdd_install_/dev/sdf1", + "/dev/sdg1 /media/hdd": "hdd_install_/dev/sdg1", + "/dev/sdg2 /media/hdd": "hdd_install_/dev/sdg2", + "/dev/sdh1 /media/hdd": "hdd_install_/dev/sdh1", + "/dev/sdh2 /media/hdd": "hdd_install_/dev/sdh2", + } + for k, v in mapping.items(): + if k in lines: + neo = v + break + except Exception: + pass return neo def getNeoMount2(): - neo = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1 /media/usb') != -1: - neo = 'usb_install_/dev/sda1' - elif lines.find('/dev/sdb1 /media/usb') != -1: - neo = 'usb_install_/dev/sdb1' - elif lines.find('/dev/sdb2 /media/usb') != -1: - neo = 'usb_install_/dev/sdb2' - elif lines.find('/dev/sdc1 /media/usb') != -1: - neo = 'usb_install_/dev/sdc1' - elif lines.find('/dev/sdd1 /media/usb') != -1: - neo = 'usb_install_/dev/sdd1' - elif lines.find('/dev/sde1 /media/usb') != -1: - neo = 'usb_install_/dev/sde1' - elif lines.find('/dev/sdf1 /media/usb') != -1: - neo = 'usb_install_/dev/sdf1' - elif lines.find('/dev/sdg1 /media/usb') != -1: - neo = 'usb_install_/dev/sdg1' - elif lines.find('/dev/sdh1 /media/usb') != -1: - neo = 'usb_install_/dev/sdh1' - elif lines.find('/dev/sda1 /media/usb2') != -1: - neo = 'usb_install_/dev/sda1' - elif lines.find('/dev/sdb1 /media/usb2') != -1: - neo = 'usb_install_/dev/sdb1' - elif lines.find('/dev/sdb2 /media/usb2') != -1: - neo = 'usb_install_/dev/sdb2' - elif lines.find('/dev/sdc1 /media/usb2') != -1: - neo = 'usb_install_/dev/sdc1' - elif lines.find('/dev/sdd1 /media/usb2') != -1: - neo = 'usb_install_/dev/sdd1' - elif lines.find('/dev/sde1 /media/usb2') != -1: - neo = 'usb_install_/dev/sde1' - elif lines.find('/dev/sdf1 /media/usb2') != -1: - neo = 'usb_install_/dev/sdf1' - elif lines.find('/dev/sdg1 /media/usb2') != -1: - neo = 'usb_install_/dev/sdg1' - elif lines.find('/dev/sdh1 /media/usb2') != -1: - neo = 'usb_install_/dev/sdh1' - + neo = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + mapping = { + "/dev/sda1 /media/usb": "usb_install_/dev/sda1", + "/dev/sdb1 /media/usb": "usb_install_/dev/sdb1", + "/dev/sdb2 /media/usb": "usb_install_/dev/sdb2", + "/dev/sdc1 /media/usb": "usb_install_/dev/sdc1", + "/dev/sdd1 /media/usb": "usb_install_/dev/sdd1", + "/dev/sde1 /media/usb": "usb_install_/dev/sde1", + "/dev/sdf1 /media/usb": "usb_install_/dev/sdf1", + "/dev/sdg1 /media/usb": "usb_install_/dev/sdg1", + "/dev/sdh1 /media/usb": "usb_install_/dev/sdh1", + "/dev/sda1 /media/usb2": "usb_install_/dev/sda1", + "/dev/sdb1 /media/usb2": "usb_install_/dev/sdb1", + "/dev/sdb2 /media/usb2": "usb_install_/dev/sdb2", + "/dev/sdc1 /media/usb2": "usb_install_/dev/sdc1", + "/dev/sdd1 /media/usb2": "usb_install_/dev/sdd1", + "/dev/sde1 /media/usb2": "usb_install_/dev/sde1", + "/dev/sdf1 /media/usb2": "usb_install_/dev/sdf1", + "/dev/sdg1 /media/usb2": "usb_install_/dev/sdg1", + "/dev/sdh1 /media/usb2": "usb_install_/dev/sdh1", + } + for k, v in mapping.items(): + if k in lines: + neo = v + break + except Exception: + pass return neo def getNeoMount3(): - neo = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1 /media/cf') != -1: - neo = 'cf_install_/dev/sda1' - elif lines.find('/dev/sdb1 /media/cf') != -1: - neo = 'cf_install_/dev/sdb1' + neo = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "/dev/sda1 /media/cf" in lines: + neo = "cf_install_/dev/sda1" + elif "/dev/sdb1 /media/cf" in lines: + neo = "cf_install_/dev/sdb1" + except Exception: + pass return neo def getNeoMount4(): - neo = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1 /media/card') != -1: - neo = 'card_install_/dev/sda1' - elif lines.find('/dev/sdb1 /media/card') != -1: - neo = 'card_install_/dev/sdb1' + neo = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "/dev/sda1 /media/card" in lines: + neo = "card_install_/dev/sda1" + elif "/dev/sdb1 /media/card" in lines: + neo = "card_install_/dev/sdb1" + except Exception: + pass return neo def getNeoMount5(): - neo = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1 /media/mmc') != -1: - neo = 'mmc_install_/dev/sda1' - elif lines.find('/dev/sdb1 /media/mmc') != -1: - neo = 'mmc_install_/dev/sdb1' + neo = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "/dev/sda1 /media/mmc" in lines: + neo = "mmc_install_/dev/sda1" + elif "/dev/sdb1 /media/mmc" in lines: + neo = "mmc_install_/dev/sdb1" + except Exception: + pass return neo -# zwraca typ chipa prcesora def getCPUSoC(): - chipset = 'UNKNOWN' - if os.path.exists('/proc/stb/info/chipset'): - with open('/proc/stb/info/chipset', 'r') as f: - chipset = f.readline().strip() - f.close() - if chipset == '7405(with 3D)': - chipset = '7405' + chipset = "UNKNOWN" + try: + if os.path.exists("/proc/stb/info/chipset"): + with open( + "/proc/stb/info/chipset", "r", encoding="utf-8", errors="ignore" + ) as f: + chipset = f.readline().strip() + if chipset == "7405(with 3D)": + chipset = "7405" + except Exception: + pass return chipset def getCPUSoCModel(): - devicetree = 'UNKNOWN' - if os.path.exists('/proc/device-tree/model'): - with open('/proc/device-tree/model', 'r') as f: - devicetree = f.readline().strip() - f.close() + devicetree = "UNKNOWN" + try: + if os.path.exists("/proc/device-tree/model"): + with open( + "/proc/device-tree/model", "r", encoding="utf-8", errors="ignore" + ) as f: + devicetree = f.readline().strip() + except Exception: + pass return devicetree -# zwraca wybrane image w neoboot do uruchomienia - def getImageNeoBoot(): - imagefile = 'UNKNOWN' - if os.path.exists('%sImageBoot/.neonextboot' % getNeoLocation()): - with open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') as f: - imagefile = f.readline().strip() - f.close() + imagefile = "UNKNOWN" + try: + location = getNeoLocation() + path = os.path.join(location, "ImageBoot", ".neonextboot") + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + imagefile = f.readline().strip() + except Exception: + pass return imagefile -# zwraca model vuplus - def getBoxVuModel(): - vumodel = 'UNKNOWN' - if fileExists("/proc/stb/info/vumodel") and not fileExists("/proc/stb/info/boxtype"): - with open('/proc/stb/info/vumodel', 'r') as f: - vumodel = f.readline().strip() - f.close() - elif fileExists("/proc/stb/info/boxtype") and not fileExists("/proc/stb/info/vumodel"): - with open('/proc/stb/info/boxtype', 'r') as f: - vumodel = f.readline().strip() - f.close() + vumodel = "UNKNOWN" + try: + if fileExists("/proc/stb/info/vumodel") and not fileExists( + "/proc/stb/info/boxtype" + ): + with open( + "/proc/stb/info/vumodel", "r", encoding="utf-8", errors="ignore" + ) as f: + vumodel = f.readline().strip() + elif fileExists("/proc/stb/info/boxtype") and not fileExists( + "/proc/stb/info/vumodel" + ): + with open( + "/proc/stb/info/boxtype", "r", encoding="utf-8", errors="ignore" + ) as f: + vumodel = f.readline().strip() + except Exception: + pass return vumodel def getVuModel(): - if fileExists("/proc/stb/info/vumodel") and not fileExists("/proc/stb/info/boxtype"): - brand = "Vu+" - f = open("/proc/stb/info/vumodel", 'r') - procmodel = f.readline().strip() - f.close() - model = procmodel.title().replace("olose", "olo SE").replace( - "olo2se", "olo2 SE").replace("2", "²") - return model - -# zwraca nazwe stb z pliku hostname + try: + if fileExists("/proc/stb/info/vumodel") and not fileExists( + "/proc/stb/info/boxtype" + ): + brand = "Vu+" + with open( + "/proc/stb/info/vumodel", "r", encoding="utf-8", errors="ignore" + ) as f: + procmodel = f.readline().strip() + model = ( + procmodel.title() + .replace("olose", "olo SE") + .replace("olo2se", "olo2 SE") + .replace("2", "²") + ) + return model + except Exception: + pass + return "unknown" def getBoxHostName(): - if os.path.exists('/etc/hostname'): - with open('/etc/hostname', 'r') as f: - myboxname = f.readline().strip() - f.close() - return myboxname - -# zwraca vuplus/vumodel + try: + if os.path.exists("/etc/hostname"): + with open("/etc/hostname", "r", encoding="utf-8", errors="ignore") as f: + myboxname = f.readline().strip() + return myboxname + except Exception: + pass + return "unknown" -def getTunerModel(): # < neoboot.py - BOX_NAME = '' - if os.path.isfile('/proc/stb/info/vumodel') and not os.path.isfile("/proc/stb/info/boxtype"): - BOX_NAME = open('/proc/stb/info/vumodel').read().strip() - ImageFolder = 'vuplus/%s' % BOX_NAME - elif os.path.isfile('proc/stb/info/boxtype'): - BOX_NAME = open('/proc/stb/info/boxtype').read().strip() - elif os.path.isfile('proc/stb/info/model') and not os.path.isfile("/proc/stb/info/mid"): - BOX_NAME = open('/proc/stb/info/model').read().strip() +def getTunerModel(): + BOX_NAME = "" + try: + if os.path.isfile("/proc/stb/info/vumodel") and not os.path.isfile( + "/proc/stb/info/boxtype" + ): + BOX_NAME = ( + open( + "/proc/stb/info/vumodel", + "r", + encoding="utf-8", + errors="ignore") .read() .strip()) + elif os.path.isfile("/proc/stb/info/boxtype"): + BOX_NAME = ( + open( + "/proc/stb/info/boxtype", + "r", + encoding="utf-8", + errors="ignore") .read() .strip()) + elif os.path.isfile("/proc/stb/info/model") and not os.path.isfile( + "/proc/stb/info/mid" + ): + BOX_NAME = ( + open( + "/proc/stb/info/model", + "r", + encoding="utf-8", + errors="ignore") .read() .strip()) + except Exception: + pass return BOX_NAME -# zwraca strukture folderu zip - vuplus/vumodel - def getImageFolder(): - if os.path.isfile('/proc/stb/info/vumodel'): - BOX_NAME = getBoxModelVU() - ImageFolder = 'vuplus/' + BOX_NAME + ImageFolder = None + try: + if os.path.isfile("/proc/stb/info/vumodel"): + BOX_NAME = getBoxModelVU() + ImageFolder = "vuplus/" + BOX_NAME + except Exception: + pass return ImageFolder -# zwraca nazwe kernela z /lib/modules - def getKernelVersion(): try: - return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] - except: - return _('unknown') - -# czysci pamiec + with open("/proc/version", "r", encoding="utf-8", errors="ignore") as f: + return f.read().split(" ", 4)[2].split("-", 2)[0] + except Exception: + return _("unknown") def runCMDS(cmdsList): + """ + Run commands. Accepts a string or list/tuple of strings. + Returns the return code (int). + """ clearMemory() if isinstance(cmdsList, (list, tuple)): - myCMD = '\n'.join(cmdsList) # + '\n' - ret = os.system(myCMD) - return rett + myCMD = "\n".join(str(x) for x in cmdsList) + else: + myCMD = str(cmdsList) + try: + result = subprocess.run(myCMD, shell=True) + return result.returncode + except Exception: + return -1 def getImageDistroN(): - image = 'Internal storage' - - if fileExists('/.multinfo') and fileExists('%sImageBoot/.imagedistro' % getNeoLocation()): - with open('%sImageBoot/.imagedistro' % getNeoLocation(), 'r') as f: - image = f.readline().strip() - f.close() - - elif not fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): - f = open("/etc/vtiversion.info", 'r') - imagever = f.readline().strip().replace("Release ", " ") - f.close() - image = imagever - - elif not fileExists('/.multinfo') and fileExists('/etc/bhversion'): - f = open("/etc/bhversion", 'r') - imagever = f.readline().strip() - f.close() - image = imagever - -# elif not fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): -# image = 'VTI Team Image ' - - elif fileExists('/.multinfo') and fileExists('/etc/bhversion'): - image = 'Flash ' + ' ' + getBoxHostName() - - elif fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): - image = 'Flash ' + ' ' + getBoxHostName() - - elif fileExists('/usr/lib/enigma2/python/boxbranding.so') and not fileExists('/.multinfo'): - from boxbranding import getImageDistro - image = getImageDistro() - - elif fileExists('/media/InternalFlash/etc/issue.net') and fileExists('/.multinfo') and not fileExists('%sImageBoot/.imagedistro' % getNeoLocation()): - obraz = open('/media/InternalFlash/etc/issue.net', 'r').readlines() - imagetype = obraz[0][:-3] - image = imagetype - - elif fileExists('/etc/issue.net') and not fileExists('/.multinfo'): - obraz = open('/etc/issue.net', 'r').readlines() - imagetype = obraz[0][:-3] - image = imagetype - - else: - image = 'Inernal Flash ' + ' ' + getBoxHostName() + image = "Internal storage" + try: + if fileExists("/.multinfo") and fileExists( + "%sImageBoot/.imagedistro" % getNeoLocation() + ): + with open( + "%sImageBoot/.imagedistro" % getNeoLocation(), + "r", + encoding="utf-8", + errors="ignore", + ) as f: + image = f.readline().strip() + elif not fileExists("/.multinfo") and fileExists("/etc/vtiversion.info"): + with open( + "/etc/vtiversion.info", "r", encoding="utf-8", errors="ignore" + ) as f: + imagever = f.readline().strip().replace("Release ", " ") + image = imagever + elif not fileExists("/.multinfo") and fileExists("/etc/bhversion"): + with open("/etc/bhversion", "r", encoding="utf-8", errors="ignore") as f: + imagever = f.readline().strip() + image = imagever + elif fileExists("/.multinfo") and fileExists("/etc/bhversion"): + image = "Flash " + " " + getBoxHostName() + elif fileExists("/.multinfo") and fileExists("/etc/vtiversion.info"): + image = "Flash " + " " + getBoxHostName() + elif fileExists("/usr/lib/enigma2/python/boxbranding.so") and not fileExists( + "/.multinfo" + ): + try: + from boxbranding import getImageDistro + image = getImageDistro() + except Exception: + pass + elif ( + fileExists("/media/InternalFlash/etc/issue.net") + and fileExists("/.multinfo") + and not fileExists("%sImageBoot/.imagedistro" % getNeoLocation()) + ): + with open( + "/media/InternalFlash/etc/issue.net", + "r", + encoding="utf-8", + errors="ignore", + ) as f: + obraz = f.readlines() + imagetype = obraz[0][:-3] if obraz else "" + image = imagetype + elif fileExists("/etc/issue.net") and not fileExists("/.multinfo"): + with open("/etc/issue.net", "r", encoding="utf-8", errors="ignore") as f: + obraz = f.readlines() + imagetype = obraz[0][:-3] if obraz else "" + image = imagetype + else: + image = "Inernal Flash " + " " + getBoxHostName() + except Exception: + pass return image def getKernelVersionString(): + """ + Preferred: use uname -r. Fallback to /proc/version parsing. + """ try: - result = open('uname -r', 'r').read().strip('\n').split('-') - kernel_version = result[0] + out = subprocess.check_output(["uname", "-r"]) + kernel_version = out.decode( + "utf-8", errors="ignore").strip().split("-")[0] return kernel_version - except: - pass - - return 'unknown' + except Exception: + try: + with open("/proc/version", "r", encoding="utf-8", errors="ignore") as f: + return f.read().split(" ", 4)[2].split("-", 2)[0] + except Exception: + return "unknown" def getKernelImageVersion(): try: - from glob import glob - lines = open(glob('/var/lib/opkg/info/kernel-*.control') - [0], 'r').readlines() - kernelimage = lines[1][:-1] - except: - kernelimage = getKernelVersionString - - return kernelimage + ctrl_files = glob("/var/lib/opkg/info/kernel-*.control") + if ctrl_files: + lines = open( + ctrl_files[0], "r", encoding="utf-8", errors="ignore" + ).readlines() + if len(lines) > 1: + kernelimage = lines[1].rstrip("\n") + return kernelimage + except Exception: + pass + return getKernelVersionString() def getTypBoxa(): - if not fileExists('/etc/typboxa'): - os.system('touch /etc/typboxa') - f2 = open('/etc/hostname', 'r') - mypath2 = f2.readline().strip() - f2.close() - if mypath2 == 'vuuno': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Uno ') - out.close() - elif mypath2 == 'vuultimo': - out = open('/etc/typboxa', 'w') - out.write('Vu+Ultimo ') - out.close() - elif mypath2 == 'vuduo': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Duo ') - out.close() - elif mypath2 == 'vuduo2': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Duo2 ') - out.close() - elif mypath2 == 'vusolo': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Solo ') - out.close() - elif mypath2 == 'vusolo2': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Solo2 ') - out.close() - elif mypath2 == 'vusolose': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Solo-SE ') - out.close() - elif mypath2 == 'vuvzero': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Zero ') - out.close() - elif mypath2 == 'vuuno4k': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Uno4k ') - out.close() - elif mypath2 == 'vuultimo4k': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Ultimo4k ') - out.close() - elif mypath2 == 'vusolo4k': - out = open('/etc/typboxa ', 'w') - out.write('Vu+Solo4k ') - out.close() - elif mypath2 == 'mbmini': - out = open('/etc/typboxa', 'w') - out.write('Miraclebox-Mini ') - out.close() - elif mypath2 == 'mutant51': - out = open('/etc/typboxa', 'w') - out.write('Mutant 51 ') - out.close() - elif mypath2 == 'sf4008': - out = open('/etc/typboxa', 'w') - out.write('Ocatgon sf4008 ') - out.close() - elif mypath2 == 'ax51': - out = open('/etc/typboxa', 'w') - out.write('ax51 ') - out.close() - try: - lines = open('/etc/typboxa', 'r').readlines() - typboxa = lines[0][:-1] - except: - typboxa = 'not detected' - - return typboxa + if not fileExists("/etc/typboxa"): + with open("/etc/hostname", "r", encoding="utf-8", errors="ignore") as f2: + mypath2 = f2.readline().strip() + mapping = { + "vuuno": "Vu+Uno ", + "vuultimo": "Vu+Ultimo ", + "vuduo": "Vu+Duo ", + "vuduo2": "Vu+Duo2 ", + "vusolo": "Vu+Solo ", + "vusolo2": "Vu+Solo2 ", + "vusolose": "Vu+Solo-SE ", + "vuvzero": "Vu+Zero ", + "vuuno4k": "Vu+Uno4k ", + "vuultimo4k": "Vu+Ultimo4k ", + "vusolo4k": "Vu+Solo4k ", + "mbmini": "Miraclebox-Mini ", + "mutant51": "Mutant 51 ", + "sf4008": "Ocatgon sf4008 ", + "novaler4kpro": "Novaler Multibox Pro ", + "ax51": "ax51 ", + } + val = mapping.get(mypath2, None) + with open("/etc/typboxa", "w", encoding="utf-8", errors="ignore") as out: + if val: + out.write(val) + else: + out.write("unknown") + with open("/etc/typboxa", "r", encoding="utf-8", errors="ignore") as fh: + lines = fh.readlines() + typboxa = lines[0].rstrip("\n") if lines else "not detected" + return typboxa + except Exception: + return "not detected" def getImageVersionString(): try: - if os.path.isfile('/var/lib/opkg/status'): - st = os.stat('/var/lib/opkg/status') - else: - st = os.stat('/usr/lib/ipkg/status') - tm = time.localtime(st.st_mtime) - if tm.tm_year >= 2015: - return time.strftime('%Y-%m-%d %H:%M:%S', tm) - except: + st = None + if os.path.isfile("/var/lib/opkg/status"): + st = os.stat("/var/lib/opkg/status") + elif os.path.isfile("/usr/lib/ipkg/status"): + st = os.stat("/usr/lib/ipkg/status") + if st: + tm = time.localtime(st.st_mtime) + if tm.tm_year >= 2015: + return time.strftime("%Y-%m-%d %H:%M:%S", tm) + except Exception: pass - - return _('unavailable') + return _("unavailable") def getModelString(): try: - file = open('/proc/stb/info/boxtype', 'r') - model = file.readline().strip() - file.close() + with open( + "/proc/stb/info/boxtype", "r", encoding="utf-8", errors="ignore" + ) as file: + model = file.readline().strip() return model - except IOError: - return 'unknown' + except Exception: + return "unknown" def getChipSetString(): try: - f = open('/proc/stb/info/chipset', 'r') - chipset = f.read() - f.close() - return str(chipset.lower().replace('\n', '').replace('bcm', '')) - except IOError: - return 'unavailable' + with open( + "/proc/stb/info/chipset", "r", encoding="utf-8", errors="ignore" + ) as f: + chipset = f.read() + return str(chipset.lower().replace("\n", "").replace("bcm", "")) + except Exception: + return "unavailable" def getCPUString(): try: - file = open('/proc/cpuinfo', 'r') - lines = file.readlines() - for x in lines: - splitted = x.split(': ') - if len(splitted) > 1: - splitted[1] = splitted[1].replace('\n', '') - if splitted[0].startswith('system type'): - system = splitted[1].split(' ')[0] - elif splitted[0].startswith('Processor'): - system = splitted[1].split(' ')[0] - - file.close() + system = "unavailable" + with open("/proc/cpuinfo", "r", encoding="utf-8", errors="ignore") as file: + lines = file.readlines() + for x in lines: + splitted = x.split(": ") + if len(splitted) > 1: + splitted[1] = splitted[1].replace("\n", "") + if splitted[0].startswith("system type"): + system = splitted[1].split(" ")[0] + elif splitted[0].startswith("Processor"): + system = splitted[1].split(" ")[0] return system - except IOError: - return 'unavailable' + except Exception: + return "unavailable" def getCpuCoresString(): try: - file = open('/proc/cpuinfo', 'r') - lines = file.readlines() - for x in lines: - splitted = x.split(': ') - if len(splitted) > 1: - splitted[1] = splitted[1].replace('\n', '') - if splitted[0].startswith('processor'): - if int(splitted[1]) > 0: - cores = 2 - else: - cores = 1 - - file.close() + cores = 1 + with open("/proc/cpuinfo", "r", encoding="utf-8", errors="ignore") as file: + lines = file.readlines() + for x in lines: + splitted = x.split(": ") + if len(splitted) > 1: + splitted[1] = splitted[1].replace("\n", "") + if splitted[0].startswith("processor"): + if int(splitted[1]) > 0: + cores = 2 + else: + cores = 1 return cores - except IOError: - return 'unavailable' + except Exception: + return "unavailable" def getEnigmaVersionString(): - import enigma - enigma_version = enigma.getEnigmaVersionString() - if '-(no branch)' in enigma_version: - enigma_version = enigma_version[:-12] - return enigma_version - - -def getKernelVersionString(): try: - f = open('/proc/version', 'r') - kernelversion = f.read().split(' ', 4)[2].split('-', 2)[0] - f.close() - return kernelversion - except: - return _('unknown') + import enigma + + enigma_version = enigma.getEnigmaVersionString() + if "-(no branch)" in enigma_version: + enigma_version = enigma_version[:-12] + return enigma_version + except Exception: + return _("unavailable") def getHardwareTypeString(): try: - if os.path.isfile('/proc/stb/info/boxtype'): - return open('/proc/stb/info/boxtype').read().strip().upper() + ' (' + open('/proc/stb/info/board_revision').read().strip() + '-' + open('/proc/stb/info/version').read().strip() + ')' - if os.path.isfile('/proc/stb/info/vumodel'): - return 'VU+' + open('/proc/stb/info/vumodel').read().strip().upper() + '(' + open('/proc/stb/info/version').read().strip().upper() + ')' - if os.path.isfile('/proc/stb/info/model'): - return open('/proc/stb/info/model').read().strip().upper() - except: + if os.path.isfile("/proc/stb/info/boxtype"): + boxtype = ( + open( + "/proc/stb/info/boxtype", + "r", + encoding="utf-8", + errors="ignore") .read() .strip()) + board_rev = ( + open( + "/proc/stb/info/board_revision", + "r", + encoding="utf-8", + errors="ignore", + ) + .read() + .strip() + ) + version = ( + open( + "/proc/stb/info/version", + "r", + encoding="utf-8", + errors="ignore") .read() .strip()) + return boxtype.upper() + " (" + board_rev + "-" + version + ")" + if os.path.isfile("/proc/stb/info/vumodel"): + return ( + "VU+" + + open( + "/proc/stb/info/vumodel", + "r", + encoding="utf-8", + errors="ignore") .read() .strip() .upper() + + "(" + + open( + "/proc/stb/info/version", + "r", + encoding="utf-8", + errors="ignore") .read() .strip() .upper() + + ")") + if os.path.isfile("/proc/stb/info/model"): + return ( + open( + "/proc/stb/info/model", + "r", + encoding="utf-8", + errors="ignore") .read() .strip() .upper()) + except Exception: pass - - return _('unavailable') + return _("unavailable") def getImageTypeString(): try: - return open('/etc/issue').readlines()[-2].capitalize().strip()[:-6] - except: + lines = open( + "/etc/issue", + "r", + encoding="utf-8", + errors="ignore").readlines() + if len(lines) >= 2: + return lines[-2].capitalize().strip()[:-6] + except Exception: pass - - return _('undefined') + return _("undefined") def getMachineBuild(): try: - return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] - except: - return 'unknown' + with open("/proc/version", "r", encoding="utf-8", errors="ignore") as f: + return f.read().split(" ", 4)[2].split("-", 2)[0] + except Exception: + return "unknown" def getVuBoxModel(): - if fileExists('/proc/stb/info/vumodel'): - try: - l = open('/proc/stb/info/vumodel') - model = l.read() - l.close() + BOX_MODEL = "not detected" + try: + if fileExists("/proc/stb/info/vumodel"): + with open( + "/proc/stb/info/vumodel", "r", encoding="utf-8", errors="ignore" + ) as l: + model = l.read() BOX_NAME = str(model.lower().strip()) - l.close() - BOX_MODEL = 'vuplus' - except: - BOX_MODEL = 'not detected' - + BOX_MODEL = "vuplus" + except Exception: + BOX_MODEL = "not detected" return BOX_MODEL def getBoxModelVU(): try: - if os.path.isfile('/proc/stb/info/vumodel'): - return open('/proc/stb/info/vumodel').read().strip().upper() - except: + if os.path.isfile("/proc/stb/info/vumodel"): + return ( + open( + "/proc/stb/info/vumodel", + "r", + encoding="utf-8", + errors="ignore") .read() .strip() .upper()) + except Exception: pass - - return _('unavailable') + return _("unavailable") def getMachineProcModel(): - if os.path.isfile('/proc/stb/info/vumodel'): - BOX_NAME = getBoxModelVU() - BOX_MODEL = getVuBoxModel() - if BOX_MODEL == 'vuplus': - if BOX_NAME == 'duo': - GETMACHINEPROCMODEL = 'bcm7335' - elif BOX_NAME == 'solo': - GETMACHINEPROCMODEL = 'bcm7325' - elif BOX_NAME == 'solo2': - GETMACHINEPROCMODEL = 'bcm7346' - elif BOX_NAME == 'solose': - GETMACHINEPROCMODEL = 'bcm7241' - elif BOX_NAME == 'ultimo' or BOX_NAME == 'uno': - GETMACHINEPROCMODEL = 'bcm7413' - elif BOX_NAME == 'zero': - GETMACHINEPROCMODEL = 'bcm7362' - elif BOX_NAME == 'duo2': - GETMACHINEPROCMODEL = 'bcm7425' - elif BOX_NAME == 'ultimo4k': - GETMACHINEPROCMODEL = 'bcm7444S' - elif BOX_NAME == 'uno4k': - GETMACHINEPROCMODEL = 'bcm7252S' - elif BOX_NAME == 'solo4k': - GETMACHINEPROCMODEL = 'bcm7376' - elif BOX_NAME == 'zero4K': - GETMACHINEPROCMODEL = 'bcm72604' - elif BOX_NAME == 'uno4kse': - GETMACHINEPROCMODEL = '' - procmodel = getMachineProcModel() + procmodel = "unknown" + try: + if os.path.isfile("/proc/stb/info/vumodel"): + BOX_NAME = getBoxModelVU().lower() + BOX_MODEL = getVuBoxModel() + if BOX_MODEL == "vuplus": + mapping = { + "duo": "bcm7335", + "solo": "bcm7325", + "solo2": "bcm7346", + "solose": "bcm7241", + "ultimo": "bcm7413", + "uno": "bcm7413", + "zero": "bcm7362", + "duo2": "bcm7425", + "ultimo4k": "bcm7444S", + "uno4k": "bcm7252S", + "solo4k": "bcm7376", + "zero4k": "bcm72604", + "uno4kse": "", + } + procmodel = mapping.get(BOX_NAME, "unknown") + except Exception: + pass return procmodel def getMountPointAll(): - os.system('touch ' + LinkNeoBoot + '/files/mountpoint.sh; echo "#!/bin/sh\n" >> ' + - LinkNeoBoot + '/files/mountpoint.sh; chmod 0755 ' + LinkNeoBoot + '/files/mountpoint.sh') - if getNeoMount() == 'hdd_install_/dev/sda1': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\nmkdir -p /media/sda1\n/bin/mount /dev/sda1 /media/hdd\n/bin/mount /dev/sda1 /media/sda1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount() == 'hdd_install_/dev/sdb1': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\nmkdir -p /media/sdb1\n/bin/mount /dev/sdb1 /media/hdd\n/bin/mount /dev/sdb1 /media/sdb1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount() == 'hdd_install_/dev/sda2': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\nmkdir -p /media/sda2\n/bin/mount /dev/sda2 /media/hdd\n/bin/mount /dev/sda2 /media/sda2" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount() == 'hdd_install_/dev/sdb2': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\nmkdir -p /media/sdb2\n/bin/mount /dev/sdb2 /media/hdd\n/bin/mount /dev/sdb2 /media/sdb2" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - if getNeoMount2() == 'usb_install_/dev/sdb1': - os.system('echo "\numount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdb1\n/bin/mount /dev/sdb1 /media/usb\n/bin/mount /dev/sdb1 /media/sdb1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sda1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sda1\n/bin/mount /dev/sda1 /media/sda1\n/bin/mount /dev/sda1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdb2': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdb2\n/bin/mount /dev/sdb2 /media/sdb2\n/bin/mount /dev/sdb2 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdc1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdc1\n/bin/mount /dev/sdc1 /media/sdb2\n/bin/mount /dev/sdc1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdd1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdd1\n/bin/mount /dev/sdd1 /media/sdd1\n/bin/mount /dev/sdd1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sde1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sde1\n/bin/mount /dev/sde1 /media/sde1\n/bin/mount /dev/sde1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdf1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdf1\n/bin/mount /dev/sdf1 /media/sdf1\n/bin/mount /dev/sdf1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdg1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdg1\n/bin/mount /dev/sdg1 /media/sdg1\n/bin/mount /dev/sdg1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdh1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\nmkdir -p /media/sdh1\n/bin/mount /dev/sdh1 /media/sdh1\n/bin/mount /dev/sdh1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - elif getNeoMount3() == 'cf_install_/dev/sda1': - os.system('echo "umount -l /media/cf\nmkdir -p /media/cf\nmkdir -p /media/sdb1\n/bin/mount /dev/sda1 /media/cf\n/bin/mount /dev/sda1 /media/sda1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount3() == 'cf_install_/dev/sdb1': - os.system('echo "umount -l /media/cf\nmkdir -p /media/cf\nmkdir -p /media/sdb1\n/bin/mount /dev/sdb1 /media/cf\n/bin/mount /dev/sdb1 /media/sdb1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - elif getNeoMount4() == 'card_install_/dev/sda1': - os.system('echo "umount -l /media/card\nmkdir -p /media/card\nmkdir -p /media/sda1\n/bin/mount /dev/sda1 /media/card\n/bin/mount /dev/sda1 /media/sda1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount4() == 'card_install_/dev/sdb1': - os.system('echo "umount -l /media/card\nmkdir -p /media/card\nmkdir -p /media/sdb1\n/bin/mount /dev/sdb1 /media/card\n/bin/mount /dev/sdb1 /media/sdb1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - elif getNeoMount5() == 'mmc_install_/dev/sda1': - os.system('echo "umount -l /media/mmc\nmkdir -p /media/mmc\nmkdir -p /media/sda1\n/bin/mount /dev/sda1 /media/mmc\n/bin/mount /dev/sda1 /media/sda1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount5() == 'mmc_install_/dev/sdb1': - os.system('echo "umount -l /media/mmc\nmkdir -p /media/mmc\nmkdir -p /media/sdb1\n/bin/mount /dev/sdb1 /media/mmc\n/bin/mount /dev/sdb1 /media/sdb1" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - os.system('echo "\n\nexit 0" >> ' + LinkNeoBoot + '/files/mountpoint.sh') + try: + script = os.path.join(LinkNeoBoot, "files", "mountpoint.sh") + os.makedirs(os.path.dirname(script), exist_ok=True) + with open(script, "w", encoding="utf-8", errors="ignore") as f: + f.write("#!/bin/sh\n") + os.chmod(script, 0o755) + + nm = getNeoMount() + if nm.startswith("hdd_install_"): + dev = nm.split("_")[-1] + os.system( + 'echo "umount -l /media/hdd\nmkdir -p /media/hdd\nmkdir -p %s\n/bin/mount %s /media/hdd\n/bin/mount %s %s" >> %s' % + (dev.replace( + "/dev/", + "/media/"), + dev, + dev, + dev.replace( + "/dev/", + "/"), + script, + )) + with open(script, "a", encoding="utf-8", errors="ignore") as f: + f.write("\n\nexit 0\n") + except Exception: + pass def getMountPointNeo(): - os.system('' + LinkNeoBoot + '/files/mountpoint.sh') - os.system('echo ' + getLocationMultiboot() + ' > ' + LinkNeoBoot + - '/bin/install; chmod 0755 ' + LinkNeoBoot + '/bin/install') - if getLocationMultiboot() == '/dev/sda1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sda1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdb1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdb1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sda2': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sda2 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdb2': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdb2 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdc1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdc1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdd1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdd1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sde1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sde1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdf1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdf1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdg1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdg1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - elif getLocationMultiboot() == '/dev/sdh1': - out = open('' + LinkNeoBoot + '/files/neo.sh', 'w') - out.write('#!/bin/sh\n\n/bin/mount /dev/sdh1 ' + - getNeoLocation() + ' \n\nexit 0') - out.close() - - os.system('chmod 755 ' + LinkNeoBoot + '/files/neo.sh') + try: + script = os.path.join(LinkNeoBoot, "files", "mountpoint.sh") + os.system(script) + os.system( + "echo " + + getLocationMultiboot() + + " > " + + os.path.join(LinkNeoBoot, "bin", "install") + + "; chmod 0755 " + + os.path.join(LinkNeoBoot, "bin", "install") + ) + lm = getLocationMultiboot() + if lm and lm != "UNKNOWN": + outpath = os.path.join(LinkNeoBoot, "files", "neo.sh") + dev = lm + with open(outpath, "w", encoding="utf-8", errors="ignore") as out: + out.write( + "#!/bin/sh\n\n/bin/mount %s %s \n\nexit 0" + % (dev, getNeoLocation()) + ) + os.chmod(outpath, 0o755) + except Exception: + pass def getMountPointNeo2(): - # --------------------------------------------- - os.system('touch ' + LinkNeoBoot + '/files/mountpoint.sh; echo "#!/bin/sh" > ' + - LinkNeoBoot + '/files/mountpoint.sh; chmod 0755 ' + LinkNeoBoot + '/files/mountpoint.sh') - if getNeoMount() == 'hdd_install_/dev/sda1': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\n/bin/mount /dev/sda1 /media/hdd" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount() == 'hdd_install_/dev/sdb1': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\n/bin/mount /dev/sdb1 /media/hdd" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount() == 'hdd_install_/dev/sda2': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\n/bin/mount /dev/sda2 /media/hdd" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount() == 'hdd_install_/dev/sdb2': - os.system('echo "umount -l /media/hdd\nmkdir -p /media/hdd\n/bin/mount /dev/sda2 /media/hdd" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - if getNeoMount2() == 'usb_install_/dev/sdb1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdb1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sda1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sda1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdb2': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdb2 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdc1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdc1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdd1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdd1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sde1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sde1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdf1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdf1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdg1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdg1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount2() == 'usb_install_/dev/sdh1': - os.system('echo "umount -l /media/usb\nmkdir -p /media/usb\n/bin/mount /dev/sdh1 /media/usb" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - elif getNeoMount3() == 'cf_install_/dev/sda1': - os.system('echo "umount -l /media/cf\nmkdir -p /media/cf\n/bin/mount /dev/sda1 /media/cf" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount3() == 'cf_install_/dev/sdb1': - os.system('echo "umount -l /media/cf\nmkdir -p /media/cf\n/bin/mount /dev/sdb1 /media/cf" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - elif getNeoMount4() == 'card_install_/dev/sda1': - os.system('echo "umount -l /media/card\nmkdir -p /media/card\n/bin/mount /dev/sda1 /media/card" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount4() == 'card_install_/dev/sdb1': - os.system('echo "umount -l /media/card\nmkdir -p /media/card\n/bin/mount /dev/sdb1 /media/card" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - # --------------------------------------------- - elif getNeoMount5() == 'mmc_install_/dev/sda1': - os.system('echo "umount -l /media/mmc\nmkdir -p /media/mmc\n/bin/mount /dev/sda1 /media/mmc" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - elif getNeoMount5() == 'mmc_install_/dev/sdb1': - os.system('echo "umount -l /media/mmc\nmkdir -p /media/mmc\n/bin/mount /dev/sdb1 /media/mmc" >> ' + - LinkNeoBoot + '/files/mountpoint.sh') - os.system('echo "\n\nexit 0" >> ' + LinkNeoBoot + '/files/mountpoint.sh') + try: + script = os.path.join(LinkNeoBoot, "files", "mountpoint.sh") + with open(script, "w", encoding="utf-8", errors="ignore") as f: + f.write("#!/bin/sh\n") + os.chmod(script, 0o755) + nm = getNeoMount() + if nm != "UNKNOWN": + dev = nm.split("_")[-1] + os.system( + 'echo "umount -l /media/hdd\nmkdir -p /media/hdd\n/bin/mount %s /media/hdd" >> %s' % + (dev, script)) + with open(script, "a", encoding="utf-8", errors="ignore") as f: + f.write("\n\nexit 0\n") + except Exception: + pass def getBoxMacAddres(): - ethernetmac = 'UNKNOWN' - if not fileExists('/etc/.nameneo'): - os.system('%s > /tmp/.mymac' % ("ifconfig -a")) - if os.path.exists('/etc/.nameneo'): - with open('/etc/.nameneo', 'r') as f: - ethernetmac = f.readline().strip() - f.close() - os.system('cp -r /etc/.nameneo /tmp/.mymac') - # return ethernetmac - - elif fileExists('/tmp/.mymac'): - f = open("/tmp/.mymac", 'r') - myboxmac = f.readline().strip().replace( - "eth0 Link encap:Ethernet HWaddr ", "") - f.close() - ethernetmac = myboxmac - writefile = open('/tmp/.mymac', 'w') - writefile.write(myboxmac) - writefile.close() - elif not fileExists('/tmp/.mymac'): - ethernetmac = '12:34:56:78:91:02' + ethernetmac = "UNKNOWN" + try: + if not fileExists("/etc/.nameneo"): + try: + with open("/tmp/.mymac", "w", encoding="utf-8", errors="ignore") as fh: + out = subprocess.check_output( + ["ifconfig", "-a"], stderr=subprocess.DEVNULL + ) + fh.write(out.decode("utf-8", errors="ignore")) + except Exception: + pass + if os.path.exists("/etc/.nameneo"): + with open("/etc/.nameneo", "r", encoding="utf-8", errors="ignore") as f: + ethernetmac = f.readline().strip() + try: + subprocess.run( + ["cp", "-r", "/etc/.nameneo", "/tmp/.mymac"], check=False + ) + except Exception: + pass + elif fileExists("/tmp/.mymac"): + with open("/tmp/.mymac", "r", encoding="utf-8", errors="ignore") as f: + myboxmac = ( + f.readline() + .strip() + .replace("eth0 Link encap:Ethernet HWaddr ", "") + ) + ethernetmac = myboxmac + try: + with open( + "/tmp/.mymac", "w", encoding="utf-8", errors="ignore" + ) as writefile: + writefile.write(myboxmac) + except Exception: + pass + else: + ethernetmac = "12:34:56:78:91:02" + except Exception: + pass return ethernetmac def getCheckActivateVip(): - supportedvip = '' - if os.path.exists('/usr/lib/periodon/.activatedmac'): - with open('/usr/lib/periodon/.activatedmac', 'r') as f: - lines = f.read() - f.close() - if lines.find("%s" % getBoxMacAddres()) != -1: - supportedvip = '%s' % getBoxMacAddres() + supportedvip = "" + try: + path = "/usr/lib/periodon/.activatedmac" + if os.path.exists(path): + with open(path, "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "%s" % getBoxMacAddres() in lines: + supportedvip = "%s" % getBoxMacAddres() + except Exception: + pass return supportedvip def getMountDiskSTB(): - neo_disk = ' ' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/dev/sda1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sda1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdb1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdb1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sda2 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sda2; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdb2 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdb2; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdc1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdc1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdd1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdd1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sde1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sde1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdf1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdf1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdg1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdg1; touch /tmp/disk/#---Select_the_disk_HDD:') - if lines.find('/dev/sdh1 /media/hdd') != -1: - os.system( - 'touch /tmp/disk/sdh1; touch /tmp/disk/#---Select_the_disk_HDD:') - # --------------------------------------------- - if lines.find('/dev/sda1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sda1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdb1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdb1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sda2 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sda2; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdb2 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdb2; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdc1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdc1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdd1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdd1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sde1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sde1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdf1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdf1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdg1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdg1; touch /tmp/disk/#---Select_the_disk_USB:') - if lines.find('/dev/sdh1 /media/usb') != -1: - os.system( - 'touch /tmp/disk/sdh1; touch /tmp/disk/#---Select_the_disk_USB:') - + neo_disk = " " + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + for dev in ( + "sda1", + "sdb1", + "sda2", + "sdb2", + "sdc1", + "sdd1", + "sde1", + "sdf1", + "sdg1", + "sdh1", + ): + if f"/dev/{dev} /media/hdd" in lines: + os.system( + f"touch /tmp/disk/{dev}; touch /tmp/disk/#---Select_the_disk_HDD:") + if f"/dev/{dev} /media/usb" in lines: + os.system( + f"touch /tmp/disk/{dev}; touch /tmp/disk/#---Select_the_disk_USB:") + except Exception: + pass return neo_disk def getCheckExtDisk(): - os.system("cat /proc/mounts | egrep -o '.ext.' | sort | uniq > /tmp/.myext") - if os.path.exists('/tmp/.myext'): - with open('/tmp/.myext', 'r') as f: - myboxEXT = f.readline().strip() - f.close() - return myboxEXT + try: + subprocess.run( + "cat /proc/mounts | egrep -o '.ext.' | sort | uniq > /tmp/.myext", + shell=True, + ) + if os.path.exists("/tmp/.myext"): + with open("/tmp/.myext", "r", encoding="utf-8", errors="ignore") as f: + myboxEXT = f.readline().strip() + return myboxEXT + except Exception: + pass + return "UNKNOWN" def getCheckExt(): - neoExt = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/media/usb vfat') != -1: - neoExt = 'vfat' - elif lines.find('/media/hdd vfat') != -1: - neoExt = 'vfat' - elif lines.find('/media/hdd ext3') != -1: - neoExt = 'ext3' - elif lines.find('/media/hdd ext4') != -1: - neoExt = 'ext4' - elif lines.find('/media/usb ext3') != -1: - neoExt = 'ext3' - elif lines.find('/media/usb ext4') != -1: - neoExt = 'ext4' + neoExt = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if "/media/usb vfat" in lines or "/media/hdd vfat" in lines: + neoExt = "vfat" + elif "/media/hdd ext3" in lines or "/media/usb ext3" in lines: + neoExt = "ext3" + elif "/media/hdd ext4" in lines or "/media/usb ext4" in lines: + neoExt = "ext4" + except Exception: + pass return neoExt def getExtCheckHddUsb(): - neoExt = 'UNKNOWN' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: - lines = f.read() - f.close() - if lines.find('/media/hdd ext4') != -1 or lines.find('/media/hdd type ext4') != -1 and os.path.exists('/media/hdd/ImageBoot'): - neoExt = 'ext4' - if lines.find('/media/usb ext4') != -1 or lines.find('/media/usb type ext4') != -1 and os.path.exists('/media/usb/ImageBoot'): - neoExt = 'ext4' + neoExt = "UNKNOWN" + try: + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as f: + lines = f.read() + if ( + ("/media/hdd ext4" in lines) or ("/media/hdd type ext4" in lines) + ) and os.path.exists("/media/hdd/ImageBoot"): + neoExt = "ext4" + if ( + ("/media/usb ext4" in lines) or ("/media/usb type ext4" in lines) + ) and os.path.exists("/media/usb/ImageBoot"): + neoExt = "ext4" + except Exception: + pass return neoExt def getNandWrite(): - NandWrite = 'NandWrite' - if fileExists('/usr/lib/python2.7'): - if os.path.exists('/usr/sbin/nandwrite'): - with open('/usr/sbin/nandwrite', 'r') as f: - lines = f.read() - f.close() - if lines.find('nandwrite') != -1: - NandWrite = 'nandwrite' - else: - NandWrite = 'no_nandwrite' - + NandWrite = "NandWrite" + try: + if os.path.exists("/usr/sbin/nandwrite"): + try: + with open( + "/usr/sbin/nandwrite", "r", encoding="utf-8", errors="ignore" + ) as f: + lines = f.read() + if "nandwrite" in lines: + NandWrite = "nandwrite" + except Exception: + NandWrite = "nandwrite" + else: + NandWrite = "no_nandwrite" + except Exception: + pass return NandWrite def getMyUUID(): - # os.system("tune2fs -l /dev/sd?? | awk '/UUID/ {print $NF}' > /tmp/.myuuid") - os.system( - "tune2fs -l %s | awk '/UUID/ {print $NF}' > /tmp/.myuuid" % (getLocationMultiboot())) try: - if os.path.isfile('/tmp/.myuuid'): - return open('/tmp/.myuuid').read().strip().upper() - except: + lm = getLocationMultiboot() + if lm and lm != "UNKNOWN": + subprocess.run( + "tune2fs -l %s | awk '/UUID/ {print $NF}' > /tmp/.myuuid" % + (lm,), shell=True, ) + if os.path.isfile("/tmp/.myuuid"): + return ( + open( + "/tmp/.myuuid", + "r", + encoding="utf-8", + errors="ignore") .read() .strip() .upper()) + except Exception: pass - - return _('unavailable') + return _("unavailable") def getImageBootNow(): - imagefile = 'UNKNOWN' - if os.path.exists('/.multinfo'): - with open('/.multinfo', 'r') as f: - imagefile = f.readline().strip() - f.close() + imagefile = "UNKNOWN" + try: + if os.path.exists("/.multinfo"): + with open("/.multinfo", "r", encoding="utf-8", errors="ignore") as f: + imagefile = f.readline().strip() + except Exception: + pass return imagefile def getNeoActivatedtest(): - neoactivated = 'NEOBOOT MULTIBOOT' - if not fileExists('/.multinfo'): - if getCheckActivateVip() != getBoxMacAddres(): - neoactivated = 'Ethernet MAC not found.' - elif not fileExists('/usr/lib/periodon/.kodn'): - neoactivated = 'VIP Pin code missing.' - elif getTestToTest() != UPDATEVERSION: - neoactivated = _('Update %s is available.') % getTestToTest() - else: - if getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn') and getTestToTest() == UPDATEVERSION: - neoactivated = 'NEOBOOT VIP ACTIVATED' - + neoactivated = "NEOBOOT MULTIBOOT" + try: + if not fileExists("/.multinfo"): + if getCheckActivateVip() != getBoxMacAddres(): + neoactivated = "Ethernet MAC not found." + elif not fileExists("/usr/lib/periodon/.kodn"): + neoactivated = "VIP Pin code missing." + else: + try: + if getCheckActivateVip() == getBoxMacAddres( + ) and fileExists("/usr/lib/periodon/.kodn"): + neoactivated = "NEOBOOT VIP ACTIVATED" + except Exception: + neoactivated = "NEOBOOT MULTIBOOT" + except Exception: + pass return neoactivated diff --git a/NeoBoot/files/tools.py b/NeoBoot/files/tools.py index ed1221c..0e609e8 100644 --- a/NeoBoot/files/tools.py +++ b/NeoBoot/files/tools.py @@ -1,8 +1,5 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -# system modules - - +from __future__ import absolute_import +from __future__ import print_function from Plugins.Extensions.NeoBoot.__init__ import _ import codecs from enigma import getDesktop @@ -22,34 +19,84 @@ from Screens.ChoiceBox import ChoiceBox from Components.Sources.List import List from Components.ConfigList import ConfigListScreen from Components.MenuList import MenuList -from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest -from Components.config import getConfigListEntry, config, ConfigYesNo, ConfigText, ConfigSelection, NoSave +from Components.MultiContent import ( + MultiContentEntryText, + MultiContentEntryPixmapAlphaTest, +) +from Components.config import ( + getConfigListEntry, + config, + ConfigYesNo, + ConfigText, + ConfigSelection, + NoSave, +) from Plugins.Extensions.NeoBoot.plugin import Plugins, PLUGINVERSION, UPDATEVERSION from Plugins.Plugin import PluginDescriptor from Screens.Standby import TryQuitMainloop from Screens.MessageBox import MessageBox from Screens.Screen import Screen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_CURRENT_SKIN, fileExists, pathExists, createDir +from Tools.Directories import ( + resolveFilename, + SCOPE_PLUGINS, + SCOPE_SKIN_IMAGE, + SCOPE_CURRENT_SKIN, + fileExists, + pathExists, + createDir, +) from Tools.Testinout import getTestToTest -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen +from os import ( + system, + listdir, + mkdir, + chdir, + getcwd, + rename as os_rename, + remove as os_remove, + popen, +) from os.path import dirname, isdir, isdir as os_isdir from enigma import eTimer -from Plugins.Extensions.NeoBoot.files.stbbranding import fileCheck, getMyUUID, getNeoLocation, getImageNeoBoot, getKernelVersionString, getBoxHostName, getCPUtype, getBoxVuModel, getTunerModel, getCPUSoC, getImageATv, getBoxModelVU, getBoxMacAddres, getMountDiskSTB, getCheckActivateVip, getBoxMacAddres, getChipSetString +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + fileCheck, + getMyUUID, + getNeoLocation, + getImageNeoBoot, + getKernelVersionString, + getBoxHostName, + getCPUtype, + getBoxVuModel, + getTunerModel, + getCPUSoC, + getImageATv, + getBoxModelVU, + getBoxMacAddres, + getMountDiskSTB, + getCheckActivateVip, + getBoxMacAddres, + getChipSetString, +) from Components.Harddisk import harddiskmanager, getProcMounts import os import time import sys import struct import shutil -if not fileExists('/etc/vtiversion.info') and not fileExists('/etc/bhversion') and fileExists('/usr/lib/python2.7'): + +if ( + not fileExists("/etc/vtiversion.info") + and not fileExists("/etc/bhversion") + and fileExists("/usr/lib/python2.7") +): from Plugins.Extensions.NeoBoot.files.neoconsole import Console else: from Screens.Console import Console -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" neoboot = getNeoLocation() media = getNeoLocation() -mediahome = media + '/ImageBoot/' +mediahome = media + "/ImageBoot/" def getDS(): @@ -74,52 +121,59 @@ def isUHD(): def getKernelVersion(): try: - return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] - except: - return _('unknown') + with open("/proc/version", "r") as f: + version_info = f.read() + kernel_version = version_info.split(" ", 4)[2].split("-", 2)[0] + return kernel_version + except BaseException: + return _("unknown") def getCPUtype(): - cpu = 'UNKNOWN' - if os.path.exists('/proc/cpuinfo'): - with open('/proc/cpuinfo', 'r') as f: + cpu = "UNKNOWN" + if os.path.exists("/proc/cpuinfo"): + with open("/proc/cpuinfo", "r") as f: lines = f.read() f.close() - if lines.find('ARMv7') != -1: - cpu = 'ARMv7' - elif lines.find('mips') != -1: - cpu = 'MIPS' + if lines.find("ARMv7") != -1: + cpu = "ARMv7" + elif lines.find("mips") != -1: + cpu = "MIPS" return cpu def getNeoActivatedtest(): - neoactivated = 'NEOBOOT MULTIBOOT' - if not fileExists('/.multinfo'): + neoactivated = "NEOBOOT MULTIBOOT" + if not fileExists("/.multinfo"): if getCheckActivateVip() != getBoxMacAddres(): - neoactivated = 'Ethernet MAC not found.' - elif not fileExists('/usr/lib/periodon/.kodn'): - neoactivated = 'VIP Pin code missing.' + neoactivated = "Ethernet MAC not found." + elif not fileExists("/usr/lib/periodon/.kodn"): + neoactivated = "VIP Pin code missing." elif getTestToTest() != UPDATEVERSION: - neoactivated = _('Update %s is available.') % getTestToTest() + neoactivated = _("Update %s is available.") % getTestToTest() else: - if getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn') and getTestToTest() == UPDATEVERSION: - neoactivated = 'NEOBOOT VIP ACTIVATED' + if ( + getCheckActivateVip() == getBoxMacAddres() + and fileExists("/usr/lib/periodon/.kodn") + and getTestToTest() == UPDATEVERSION + ): + neoactivated = "NEOBOOT VIP ACTIVATED" return neoactivated -if os.path.exists('/etc/hostname'): - with open('/etc/hostname', 'r') as f: +if os.path.exists("/etc/hostname"): + with open("/etc/hostname", "r") as f: myboxname = f.readline().strip() f.close() -if os.path.exists('/proc/stb/info/vumodel'): - with open('/proc/stb/info/vumodel', 'r') as f: +if os.path.exists("/proc/stb/info/vumodel"): + with open("/proc/stb/info/vumodel", "r") as f: vumodel = f.readline().strip() f.close() -if os.path.exists('/proc/stb/info/boxtype'): - with open('/proc/stb/info/boxtype', 'r') as f: +if os.path.exists("/proc/stb/info/boxtype"): + with open("/proc/stb/info/boxtype", "r") as f: boxtype = f.readline().strip() f.close() @@ -156,139 +210,142 @@ class MBTools(Screen): def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['list'] = List(self.list) + self["list"] = List(self.list) self.updateList() - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, - 'back': self.close}) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "ok": self.KeyOk, "back": self.close}) def updateList(self): self.list = [] - mypath = '' + LinkNeoBoot + '' -# if not fileExists('/tmp/.testneo') and getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn'): -# os.system(("mv /tmp/.mymac /usr/lib/periodon/.activatedmac; touch /tmp/.testneo ")) - if not fileExists(mypath + 'icons'): - mypixmap = '' + LinkNeoBoot + '/images/ok.png' + mypath = "" + LinkNeoBoot + "" + if not fileExists(mypath + "icons"): + mypixmap = "" + LinkNeoBoot + "/images/ok.png" png = LoadPixmap(mypixmap) - res = (_('Make a copy of the image from NeoBoot'), png, 0) + res = (_("Make a copy of the image from NeoBoot"), png, 0) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Restore a copy of the image to NeoBoot'), png, 1) + res = (_("Restore a copy of the image to NeoBoot"), png, 1) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Device manager'), png, 2) + res = (_("Device manager"), png, 2) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Set the disk label and uuid'), png, 3) + res = (_("Set the disk label and uuid"), png, 3) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Delete image ZIP from the ImagesUpload directory'), png, 4) + res = (_("Delete image ZIP from the ImagesUpload directory"), png, 4) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('NeoBoot Backup'), png, 5) + res = (_("NeoBoot Backup"), png, 5) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Restore neoboot backup'), png, 6) + res = (_("Restore neoboot backup"), png, 6) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Uninstall NeoBoot'), png, 7) + res = (_("Uninstall NeoBoot"), png, 7) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Update NeoBoot on all images.'), png, 8) + res = (_("Update NeoBoot on all images."), png, 8) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Update TV list on installed image.'), png, 9) + res = (_("Update TV list on installed image."), png, 9) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Update IPTVPlayer on installed image.'), png, 10) + res = (_("Update IPTVPlayer on installed image."), png, 10) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Update FeedExtra on the installed image.'), png, 11) + res = (_("Update FeedExtra on the installed image."), png, 11) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Removing the root password.'), png, 12) + res = (_("Removing the root password."), png, 12) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Check the correctness of neoboot installation'), png, 13) + res = (_("Check the correctness of neoboot installation"), png, 13) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Skin change'), png, 14) + res = (_("Skin change"), png, 14) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Block or unlock skins.'), png, 15) + res = (_("Block or unlock skins."), png, 15) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Mount Internal Flash'), png, 16) + res = (_("Mount Internal Flash"), png, 16) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Deleting languages'), png, 17) + res = (_("Deleting languages"), png, 17) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Updates feed cam OpenATV softcam'), png, 18) + res = (_("Updates feed cam OpenATV softcam"), png, 18) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Create swap- file.'), png, 19) + res = (_("Create swap- file."), png, 19) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Supported sat tuners'), png, 20) + res = (_("Supported sat tuners"), png, 20) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Install IPTVPlayer'), png, 21) + res = (_("Install IPTVPlayer"), png, 21) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Install Multi Stalker'), png, 22) + res = (_("Install Multi Stalker"), png, 22) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Install Multiboot Flash Online'), png, 23) + res = (_("Install Multiboot Flash Online"), png, 23) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Install Dream Sat Panel'), png, 24) + res = (_("Install Dream Sat Panel"), png, 24) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('Initialization - formatting disk for neoboot.'), png, 25) + res = (_("Initialization - formatting disk for neoboot."), png, 25) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - if "vu" + getBoxVuModel() == getBoxHostName() or getBoxHostName() == "et5x00" and getCPUtype() == "MIPS" and not fileExists('/.multinfo'): - res = (_('Boot Managers.'), png, 26) + if ( + "vu" + getBoxVuModel() == getBoxHostName() + or getBoxHostName() == "et5x00" + and getCPUtype() == "MIPS" + and not fileExists("/.multinfo") + ): + res = (_("Boot Managers."), png, 26) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('NeoBoot Information'), png, 27) + res = (_("NeoBoot Information"), png, 27) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list - res = (_('NeoBoot donate'), png, 28) + res = (_("NeoBoot donate"), png, 28) self.list.append(res) - self['list']. list = self.list + self["list"].list = self.list def KeyOk(self): - self.sel = self['list'].getCurrent() + self.sel = self["list"].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0 and self.session.open(MBBackup): @@ -349,8 +406,6 @@ class MBTools(Screen): pass if self.sel == 28 and self.session.open(neoDONATION): pass -# if self.sel == 28and self.session.open(CheckInternet): -# pass class MBBackup(Screen): @@ -378,104 +433,50 @@ class MBBackup(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label('') - self['lab2'] = Label('') - self['lab3'] = Label(_('Choose the image you want to make a copy of')) - self['key_red'] = Label(_('Backup')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'ok': self.backupImage, - 'red': self.backupImage}) - if pathExists('/media/usb/ImageBoot'): - neoboot = 'usb' - elif pathExists('/media/hdd/ImageBoot'): - neoboot = 'hdd' - self.backupdir = '/media/' + neoboot + '/CopyImageNEO' - self.availablespace = '0' + self["lab1"] = Label("") + self["lab2"] = Label("") + self["lab3"] = Label(_("Choose the image you want to make a copy of")) + self["key_red"] = Label(_("Backup")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "ok": self.backupImage, "red": self.backupImage}, + ) + if pathExists("/media/usb/ImageBoot"): + neoboot = "usb" + elif pathExists("/media/hdd/ImageBoot"): + neoboot = "hdd" + self.backupdir = "/media/" + neoboot + "/CopyImageNEO" + self.availablespace = "0" self.onShow.append(self.updateInfo) - # def updateInfo(self): - # if pathExists('/media/usb/ImageBoot'): - # neoboot = 'usb' - # elif pathExists('/media/hdd/ImageBoot'): - # neoboot = 'hdd' - # device = '/media/' + neoboot + '' - # usfree = '0' - # devicelist = ['cf', - # 'hdd', - # 'card', - # 'usb', - # 'usb2'] - # for d in devicelist: - # test = '/media/' + d + '/ImageBoot/.neonextboot' - # if fileExists(test): - # device = '/media/' + d - - # rc = system('df > /tmp/ninfo.tmp') - # f = open('/proc/mounts', 'r') - # for line in f.readlines(): - # if line.find('/hdd') != -1: - # self.backupdir = '/media/' + neoboot + '/CopyImageNEO' - # device = '/media/' + neoboot + '' - - # f.close() - # if pathExists(self.backupdir) == 0 and createDir(self.backupdir): - # pass - # if fileExists('/tmp/ninfo.tmp'): - # f = open('/tmp/ninfo.tmp', 'r') - # for line in f.readlines(): - # line = line.replace('part1', ' ') - # parts = line.strip().split() - # totsp = len(parts) - 1 - # if parts[totsp] == device: - # if totsp == 5: - # usfree = parts[3] - # else: - # usfree = parts[2] - # break - - # f.close() - # os_remove('/tmp/ninfo.tmp') - # self.availablespace = usfree[0:-3] - # strview = _('You have the following images installed') - # self['lab1'].setText(strview) - # strview = _('You still have free: ') + self.availablespace + ' MB' - # self['lab2'].setText(strview) - # imageslist = ['Flash'] - # for fn in listdir('/media/' + neoboot + '/ImageBoot'): - # dirfile = '/media/' + neoboot + '/ImageBoot/' + fn - # if os_isdir(dirfile) and imageslist.append(fn): - # pass - - # self['list'].list = imageslist - def updateInfo(self): - if pathExists('/media/usb/ImageBoot'): - neoboot = 'usb' - elif pathExists('/media/hdd/ImageBoot'): - neoboot = 'hdd' - device = '/media/' + neoboot + '' - usfree = '0' - devicelist = ['cf', 'hdd', 'card', 'usb', 'usb2'] + if pathExists("/media/usb/ImageBoot"): + neoboot = "usb" + elif pathExists("/media/hdd/ImageBoot"): + neoboot = "hdd" + device = "/media/" + neoboot + "" + usfree = "0" + devicelist = ["cf", "hdd", "card", "usb", "usb2"] for d in devicelist: - test = '/media/' + d + '/ImageBoot/.neonextboot' + test = "/media/" + d + "/ImageBoot/.neonextboot" if fileExists(test): - device = '/media/' + d + device = "/media/" + d - rc = system('df > /tmp/ninfo.tmp') - f = open('/proc/mounts', 'r') + rc = system("df > /tmp/ninfo.tmp") + f = open("/proc/mounts", "r") for line in f.readlines(): - if line.find('/hdd') != -1: - self.backupdir = '/media/' + neoboot + '/CopyImageNEO' - device = '/media/' + neoboot + '' + if line.find("/hdd") != -1: + self.backupdir = "/media/" + neoboot + "/CopyImageNEO" + device = "/media/" + neoboot + "" f.close() if pathExists(self.backupdir) == 0 and createDir(self.backupdir): pass - if fileExists('/tmp/ninfo.tmp'): - f = open('/tmp/ninfo.tmp', 'r') + if fileExists("/tmp/ninfo.tmp"): + f = open("/tmp/ninfo.tmp", "r") for line in f.readlines(): - line = line.replace('part1', ' ') + line = line.replace("part1", " ") parts = line.strip().split() totsp = len(parts) - 1 if parts[totsp] == device: @@ -486,66 +487,86 @@ class MBBackup(Screen): break f.close() - os_remove('/tmp/ninfo.tmp') + os_remove("/tmp/ninfo.tmp") self.availablespace = usfree[0:-3] - strview = _('You have the following images installed') - self['lab1'].setText(strview) - strview = _('You still have free: ') + self.availablespace + ' MB' - self['lab2'].setText(strview) + strview = _("You have the following images installed") + self["lab1"].setText(strview) + strview = _("You still have free: ") + self.availablespace + " MB" + self["lab2"].setText(strview) - imageslist = ['Flash'] - for fn in listdir('/media/' + neoboot + '/ImageBoot'): - dirfile = '/media/' + neoboot + '/ImageBoot/' + fn + imageslist = ["Flash"] + for fn in listdir("/media/" + neoboot + "/ImageBoot"): + dirfile = "/media/" + neoboot + "/ImageBoot/" + fn if os_isdir(dirfile): imageslist.append(fn) imageslist[1:] = sorted(imageslist[1:]) - self['list'].list = imageslist + self["list"].list = imageslist def backupImage(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.backupImage2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def backupImage2(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: self.backimage = image.strip() - myerror = '' - if self.backimage == 'Flash': + myerror = "" + if self.backimage == "Flash": myerror = _( - 'Unfortunately you cannot backup from flash with this plugin. \nInstall backupsuite to a copy of the image from flash memory.') + "Unfortunately you cannot backup from flash with this plugin. \nInstall backupsuite to a copy of the image from flash memory." + ) if int(self.availablespace) < 150: myerror = _( - 'There is no space to make a copy of the image. You need 150 Mb of free space for copying the image.') - if myerror == '': - message = (_('Make copies of the image: %s now ?') % image) + "There is no space to make a copy of the image. You need 150 Mb of free space for copying the image." + ) + if myerror == "": + message = _("Make copies of the image: %s now ?") % image ybox = self.session.openWithCallback( self.dobackupImage, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Backup confirmation')) + ybox.setTitle(_("Backup confirmation")) else: self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) def dobackupImage(self, answer): if answer is True: - if pathExists('/media/usb/ImageBoot'): - neoboot = 'usb' - elif pathExists('/media/hdd/ImageBoot'): - neoboot = 'hdd' + if pathExists("/media/usb/ImageBoot"): + neoboot = "usb" + elif pathExists("/media/hdd/ImageBoot"): + neoboot = "hdd" cmd = "echo -e '\n\n%s '" % _( - 'Please wait, NeoBoot is working, the backup may take a few moments, the process is in progress ...') - cmd1 = '/bin/tar -cf ' + self.backupdir + '/' + self.backimage + \ - '.tar /media/' + neoboot + '/ImageBoot/' + self.backimage + ' > /dev/null 2>&1' - cmd2 = 'mv -f ' + self.backupdir + '/' + self.backimage + \ - '.tar ' + self.backupdir + '/' + self.backimage + '.mb' - cmd3 = "echo -e '\n\n%s '" % _('NeoBoot: COMPLETE Backup!') - self.session.open(Console, _('NeoBoot: Image Backup'), [cmd, - cmd1, - cmd2, - cmd3]) + "Please wait, NeoBoot is working, the backup may take a few moments, the process is in progress ..." + ) + cmd1 = ( + "/bin/tar -cf " + + self.backupdir + + "/" + + self.backimage + + ".tar /media/" + + neoboot + + "/ImageBoot/" + + self.backimage + + " > /dev/null 2>&1" + ) + cmd2 = ( + "mv -f " + + self.backupdir + + "/" + + self.backimage + + ".tar " + + self.backupdir + + "/" + + self.backimage + + ".mb" + ) + cmd3 = "echo -e '\n\n%s '" % _("NeoBoot: COMPLETE Backup!") + self.session.open( + Console, _("NeoBoot: Image Backup"), [cmd, cmd1, cmd2, cmd3] + ) self.close() else: self.close() @@ -570,50 +591,56 @@ class MBRestore(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Choose copy you want to restore or delete.')) - self['key_red'] = Label(_('Delete file')) - self['key_green'] = Label(_('Restore')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'ok': self.restoreImage, - 'red': self.deleteback, - 'green': self.restoreImage}) - self.backupdir = '' + getNeoLocation() + 'CopyImageNEO' + self["lab1"] = Label(_("Choose copy you want to restore or delete.")) + self["key_red"] = Label(_("Delete file")) + self["key_green"] = Label(_("Restore")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + { + "back": self.close, + "ok": self.restoreImage, + "red": self.deleteback, + "green": self.restoreImage, + }, + ) + self.backupdir = "" + getNeoLocation() + "CopyImageNEO" self.onShow.append(self.updateInfo) def updateInfo(self): - linesdevice = open('' + LinkNeoBoot + '/.location', 'r').readlines() + linesdevice = open("" + LinkNeoBoot + "/.location", "r").readlines() deviceneo = linesdevice[0][0:-1] device = deviceneo - usfree = '0' - devicelist = ['cf', - 'CF', - 'hdd', - 'card', - 'sd', - 'SD', - 'usb', - 'USB', - 'usb2'] + usfree = "0" + devicelist = [ + "cf", + "CF", + "hdd", + "card", + "sd", + "SD", + "usb", + "USB", + "usb2"] for d in devicelist: - test = '/media/' + d + '/ImageBoot/.neonextboot' + test = "/media/" + d + "/ImageBoot/.neonextboot" if fileExists(test): device = device + d - rc = system('df > /tmp/ninfo.tmp') - f = open('/proc/mounts', 'r') + rc = system("df > /tmp/ninfo.tmp") + f = open("/proc/mounts", "r") for line in f.readlines(): - if line.find('/hdd') != -1: - self.backupdir = '' + getNeoLocation() + 'CopyImageNEO' - elif line.find('/usb') != -1: - self.backupdir = '' + getNeoLocation() + 'CopyImageNEO' + if line.find("/hdd") != -1: + self.backupdir = "" + getNeoLocation() + "CopyImageNEO" + elif line.find("/usb") != -1: + self.backupdir = "" + getNeoLocation() + "CopyImageNEO" f.close() if pathExists(self.backupdir) == 0 and createDir(self.backupdir): pass - if fileExists('/tmp/ninfo.tmp'): - f = open('/tmp/ninfo.tmp', 'r') + if fileExists("/tmp/ninfo.tmp"): + f = open("/tmp/ninfo.tmp", "r") for line in f.readlines(): - line = line.replace('part1', ' ') + line = line.replace("part1", " ") parts = line.strip().split() totsp = len(parts) - 1 if parts[totsp] == device: @@ -624,74 +651,73 @@ class MBRestore(Screen): break f.close() - os_remove('/tmp/ninfo.tmp') + os_remove("/tmp/ninfo.tmp") - # imageslist = [] - # for fn in listdir(self.backupdir): - # imageslist.append(fn) - - # self['list'].list = imageslist imageslist = [] for fn in listdir(self.backupdir): imageslist.append(fn) imageslist.sort() - self['list'].list = imageslist + self["list"].list = imageslist def deleteback(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.deleteback2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def deleteback2(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: self.delimage = image.strip() - message = (_('Software selected: %s remove ?') % image) + message = _("Software selected: %s remove ?") % image ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Confirmation of Deletion...')) + self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Confirmation of Deletion...")) def dodeleteback(self, answer): if answer is True: cmd = "echo -e '\n\n%s '" % _( - 'NeoBoot - deleting backup files .....') - cmd1 = 'rm ' + self.backupdir + '/' + self.delimage - self.session.open(Console, _( - 'NeoBoot: Backup files deleted!'), [cmd, cmd1]) + "NeoBoot - deleting backup files .....") + cmd1 = "rm " + self.backupdir + "/" + self.delimage + self.session.open( + Console, _("NeoBoot: Backup files deleted!"), [ + cmd, cmd1]) self.updateInfo() else: self.close() def restoreImage(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.restoreImage2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def restoreImage2(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: - curimage = 'Flash' - if fileExists('/.neonextboot'): - f = open('/.neonextboot', 'r') + curimage = "Flash" + if fileExists("/.neonextboot"): + f = open("/.neonextboot", "r") curimage = f.readline().strip() f.close() self.backimage = image.strip() imagename = self.backimage[0:-3] - myerror = '' + myerror = "" if curimage == imagename: myerror = _( - 'Sorry you cannot overwrite the image currently booted from. Please, boot from Flash to restore this backup.') - if myerror == '': + "Sorry you cannot overwrite the image currently booted from. Please, boot from Flash to restore this backup." + ) + if myerror == "": message = ( - _('The required space on the device is 300 MB.\nDo you want to take this image: %s \nnow ?') % image) + _("The required space on the device is 300 MB.\nDo you want to take this image: %s \nnow ?") % + image) ybox = self.session.openWithCallback( self.dorestoreImage, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Restore Confirmation')) + ybox.setTitle(_("Restore Confirmation")) else: self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) @@ -699,20 +725,38 @@ class MBRestore(Screen): if answer is True: imagename = self.backimage[0:-3] cmd = "echo -e '\n\n%s '" % _( - 'Wait please, NeoBoot is working: ....Restore in progress....') - cmd1 = 'mv -f ' + self.backupdir + '/' + self.backimage + \ - ' ' + self.backupdir + '/' + imagename + '.tar' - cmd2 = '/bin/tar -xf ' + self.backupdir + '/' + imagename + '.tar -C /' - cmd3 = 'mv -f ' + self.backupdir + '/' + imagename + \ - '.tar ' + self.backupdir + '/' + imagename + '.mb' - cmd4 = 'sync' - cmd5 = "echo -e '\n\n%s '" % _('Neoboot: Restore COMPLETE !') - self.session.open(Console, _('NeoBoot: Restore Image'), [cmd, - cmd1, - cmd2, - cmd3, - cmd4, - cmd5]) + "Wait please, NeoBoot is working: ....Restore in progress...." + ) + cmd1 = ( + "mv -f " + + self.backupdir + + "/" + + self.backimage + + " " + + self.backupdir + + "/" + + imagename + + ".tar" + ) + cmd2 = "/bin/tar -xf " + self.backupdir + "/" + imagename + ".tar -C /" + cmd3 = ( + "mv -f " + + self.backupdir + + "/" + + imagename + + ".tar " + + self.backupdir + + "/" + + imagename + + ".mb" + ) + cmd4 = "sync" + cmd5 = "echo -e '\n\n%s '" % _("Neoboot: Restore COMPLETE !") + self.session.open( + Console, + _("NeoBoot: Restore Image"), + [cmd, cmd1, cmd2, cmd3, cmd4, cmd5], + ) self.close() else: self.close() @@ -732,19 +776,20 @@ class MenagerDevices(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Start the device manager')) - self['key_red'] = Label(_('Run')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.MD}) + self["lab1"] = Label(_("Start the device manager")) + self["key_red"] = Label(_("Run")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.close, "red": self.MD}) def MD(self): try: from Plugins.Extensions.NeoBoot.files.devices import ManagerDevice + self.session.open(ManagerDevice) - except: + except BaseException: self.myClose( - _('Sorry, the operation is not possible from Flash or not supported.')) + _("Sorry, the operation is not possible from Flash or not supported.")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -761,22 +806,24 @@ class SetDiskLabel(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Start the set disk label')) - self['key_red'] = Label(_('Run')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.MD}) + self["lab1"] = Label(_("Start the set disk label")) + self["key_red"] = Label(_("Run")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.close, "red": self.MD}) def MD(self): try: - if fileExists('/usr/lib/python2.7'): + if fileExists("/usr/lib/python2.7"): from Plugins.Extensions.NeoBoot.files.devices import SetDiskLabel + self.session.open(SetDiskLabel) else: from Plugins.Extensions.NeoBoot.files.tools import DiskLabelSet + self.session.open(DiskLabelSet) - except: + except BaseException: self.myClose( - _('Sorry, the operation is not possible from Flash or not supported.')) + _("Sorry, the operation is not possible from Flash or not supported.")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -793,24 +840,26 @@ class MBDeleUpload(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Are you sure you want to delete the image from the ImagesUpload directory\nIf you choose the red button on the remote control then you will delete all zip images from the ImagesUpload directory')) - self['key_red'] = Label(_('Clear')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.usunup}) + self["lab1"] = Label( + _("Are you sure you want to delete the image from the ImagesUpload directory\nIf you choose the red button on the remote control then you will delete all zip images from the ImagesUpload directory")) + self["key_red"] = Label(_("Clear")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.close, "red": self.usunup}) def usunup(self): - message = _('Do you really want to clear') + message = _("Do you really want to clear") ybox = self.session.openWithCallback( - self.pedeleup, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Do you really want to clear')) + self.pedeleup, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Do you really want to clear")) def pedeleup(self, answer): if answer is True: - cmd = "echo -e '\n\n%s '" % _('Wait, deleting .....') - cmd1 = 'rm -r ' + getNeoLocation() + 'ImagesUpload/*.zip' - self.session.open(Console, _( - 'Deleting downloaded image zip files ....'), [cmd, cmd1]) + cmd = "echo -e '\n\n%s '" % _("Wait, deleting .....") + cmd1 = "rm -r " + getNeoLocation() + "ImagesUpload/*.zip" + self.session.open( + Console, _("Deleting downloaded image zip files ...."), [ + cmd, cmd1]) self.close() else: self.close() @@ -834,15 +883,20 @@ class BackupMultiboot(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Make complete copy NeoBoot')) - self['key_red'] = Label(_('Run')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.gobackupneobootplugin}) + self["lab1"] = Label(_("Make complete copy NeoBoot")) + self["key_red"] = Label(_("Run")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.gobackupneobootplugin}, + ) def gobackupneobootplugin(self): - cmd = 'sh ' + LinkNeoBoot + '/files/neobackup.sh -i' - self.session.open(Console, _( - 'The backup will be saved to /media/neoboot. Performing ...'), [cmd]) + cmd = "sh " + LinkNeoBoot + "/files/neobackup.sh -i" + self.session.open( + Console, + _("The backup will be saved to /media/neoboot. Performing ..."), + [cmd], + ) self.close() @@ -856,17 +910,17 @@ class UnistallMultiboot(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Remove the plug')) - self['key_red'] = Label(_('Uninstall')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.checkNeo, - 'red': self.usun}) + self["lab1"] = Label(_("Remove the plug")) + self["key_red"] = Label(_("Uninstall")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.checkNeo, "red": self.usun}) def usun(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.usun2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -874,45 +928,81 @@ class UnistallMultiboot(Screen): def usun2(self): message = _( - 'If you choose Yes, the Multibot image settings will be restored and only uninstalled. You can reinstall it') + "If you choose Yes, the Multibot image settings will be restored and only uninstalled. You can reinstall it" + ) ybox = self.session.openWithCallback( - self.reinstallneoboot, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Delete Confirmation')) + self.reinstallneoboot, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Delete Confirmation")) def reinstallneoboot(self, answer): if answer is True: cmd0 = "echo -e '\nRestoring settings...\n'" - cmd = 'rm -f /etc/neoimage /etc/imageboot /etc/name' - cmd1 = 'rm /sbin/neoinit*; sleep 2' + cmd = "rm -f /etc/neoimage /etc/imageboot /etc/name" + cmd1 = "rm /sbin/neoinit*; sleep 2" cmd1a = "echo -e 'Removing boot manager from NeoBoot....\n'" - cmd2 = 'rm /sbin/init; sleep 2' - cmd3 = 'ln -sfn /sbin/init.sysvinit /sbin/init' - cmd4 = 'chmod 777 /sbin/init; sleep 2' + cmd2 = "rm /sbin/init; sleep 2" + cmd3 = "ln -sfn /sbin/init.sysvinit /sbin/init" + cmd4 = "chmod 777 /sbin/init; sleep 2" cmd4a = "echo -e 'NeoBoot restoring media mounts...\n'" - cmd6 = 'rm -f ' + getNeoLocation() + 'ImageBoot/initneo.log ' + getNeoLocation() + 'ImageBoot/.imagedistro ' + getNeoLocation() + 'ImageBoot/.neonextboot ' + getNeoLocation() + \ - 'ImageBoot/.updateversion ' + getNeoLocation() + 'ImageBoot/.Flash ' + getNeoLocation() + \ - 'ImageBoot/.version ' + getNeoLocation() + 'ImageBoot/NeoInit.log ; sleep 2' - cmd7 = 'rm -f ' + LinkNeoBoot + '/.location ' + LinkNeoBoot + '/bin/install ' + LinkNeoBoot + '/bin/reading_blkid ' + LinkNeoBoot + \ - '/files/mountpoint.sh ' + LinkNeoBoot + '/files/neo.sh ' + \ - LinkNeoBoot + '/files/neom ' + LinkNeoBoot + '/.neo_info ' + cmd6 = ( + "rm -f " + + getNeoLocation() + + "ImageBoot/initneo.log " + + getNeoLocation() + + "ImageBoot/.imagedistro " + + getNeoLocation() + + "ImageBoot/.neonextboot " + + getNeoLocation() + + "ImageBoot/.updateversion " + + getNeoLocation() + + "ImageBoot/.Flash " + + getNeoLocation() + + "ImageBoot/.version " + + getNeoLocation() + + "ImageBoot/NeoInit.log ; sleep 2" + ) + cmd7 = ( + "rm -f " + + LinkNeoBoot + + "/.location " + + LinkNeoBoot + + "/bin/install " + + LinkNeoBoot + + "/bin/reading_blkid " + + LinkNeoBoot + + "/files/mountpoint.sh " + + LinkNeoBoot + + "/files/neo.sh " + + LinkNeoBoot + + "/files/neom " + + LinkNeoBoot + + "/.neo_info " + ) cmd7a = "echo -e '\n\nUninstalling neoboot...\n'" cmd8 = "echo -e '\n\nRestore mount.'" cmd9 = "echo -e '\n\nNeoBoot uninstalled, you can do reinstallation.'" cmd10 = "echo -e '\n\nNEOBoot Exit or Back - RESTART GUI NOW !!!'" - self.session.open(Console, _('NeoBoot is reinstall...'), [cmd0, - cmd, - cmd1, - cmd1a, - cmd2, - cmd3, - cmd4, - cmd4a, - cmd6, - cmd7, - cmd7a, - cmd8, - cmd9, - cmd10]) + self.session.open( + Console, + _("NeoBoot is reinstall..."), + [ + cmd0, + cmd, + cmd1, + cmd1a, + cmd2, + cmd3, + cmd4, + cmd4a, + cmd6, + cmd7, + cmd7a, + cmd8, + cmd9, + cmd10, + ], + ) else: self.close() @@ -921,7 +1011,9 @@ class UnistallMultiboot(Screen): self.close() def checkNeo(self): - if not fileCheck('' + LinkNeoBoot + '/.location') and not fileCheck(' ' + getNeoLocation() + 'ImageBoot/.neonextboot'): + if not fileCheck("" + LinkNeoBoot + "/.location") and not fileCheck( + " " + getNeoLocation() + "ImageBoot/.neonextboot" + ): self.restareE2() else: self.close() @@ -940,10 +1032,12 @@ class ReinstllNeoBoot(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Restore copy NeoBoot')) - self['key_red'] = Label(_('Backup')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.reinstallMB}) + self["lab1"] = Label(_("Restore copy NeoBoot")) + self["key_red"] = Label(_("Backup")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.reinstallMB}, + ) def reinstallMB(self): self.session.open(ReinstllNeoBoot2) @@ -964,19 +1058,24 @@ class ReinstllNeoBoot2(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Choose copy you want to restore or delete.')) - self['key_red'] = Label(_('Delete file')) - self['key_green'] = Label(_('Restore')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'ok': self.restoreImage, - 'green': self.restoreImage, - 'red': self.deleteback}) - self.backupdir = '' + getNeoLocation() + 'CopyNEOBoot' + self["lab1"] = Label(_("Choose copy you want to restore or delete.")) + self["key_red"] = Label(_("Delete file")) + self["key_green"] = Label(_("Restore")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + { + "back": self.close, + "ok": self.restoreImage, + "green": self.restoreImage, + "red": self.deleteback, + }, + ) + self.backupdir = "" + getNeoLocation() + "CopyNEOBoot" self.onShow.append(self.updateInfo) def updateInfo(self): - self.backupdir = '' + getNeoLocation() + 'CopyNEOBoot' + self.backupdir = "" + getNeoLocation() + "CopyNEOBoot" if pathExists(self.backupdir) == 0 and createDir(self.backupdir): pass @@ -984,52 +1083,57 @@ class ReinstllNeoBoot2(Screen): for fn in listdir(self.backupdir): imageslist.append(fn) - self['list'].list = imageslist + self["list"].list = imageslist def deleteback(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: self.delimage = image.strip() - message = (_('Software selected: %s remove ?') % image) + message = _("Software selected: %s remove ?") % image ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Confirmation of Deletion...')) + self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Confirmation of Deletion...")) def dodeleteback(self, answer): if answer is True: cmd = "echo -e '\n\n%s '" % _( - 'NeoBoot - deleting backup files .....') - cmd1 = 'rm ' + self.backupdir + '/' + self.delimage - self.session.open(Console, _( - 'NeoBoot: Backup files deleted!'), [cmd, cmd1]) + "NeoBoot - deleting backup files .....") + cmd1 = "rm " + self.backupdir + "/" + self.delimage + self.session.open( + Console, _("NeoBoot: Backup files deleted!"), [ + cmd, cmd1]) self.updateInfo() else: self.close() def restoreImage(self): - image = self['list'].getCurrent() - myerror = '' - if myerror == '': + image = self["list"].getCurrent() + myerror = "" + if myerror == "": message = ( - _('The required space on the device is 300 MB.\nDo you want to take this image: %s \nnow ?') % image) + _("The required space on the device is 300 MB.\nDo you want to take this image: %s \nnow ?") % + image) ybox = self.session.openWithCallback( - self.dorestoreImage, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Restore Confirmation')) + self.dorestoreImage, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Restore Confirmation")) else: self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) def dorestoreImage(self, answer): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if answer is True: self.backimage = image.strip() imagename = self.backimage[0:-3] cmd = "echo -e '\n\n%s '" % _( - 'Wait please, NeoBoot is working: ....Restore in progress....') - cmd1 = '/bin/tar -xf ' + self.backupdir + '/' + imagename + '.gz -C /' - cmd2 = "echo -e '\n\n%s '" % _('Neoboot: Restore COMPLETE !') - self.session.open(Console, _('NeoBoot: Restore Image'), [cmd, - cmd1, - cmd2]) + "Wait please, NeoBoot is working: ....Restore in progress...." + ) + cmd1 = "/bin/tar -xf " + self.backupdir + "/" + imagename + ".gz -C /" + cmd2 = "echo -e '\n\n%s '" % _("Neoboot: Restore COMPLETE !") + self.session.open( + Console, _("NeoBoot: Restore Image"), [ + cmd, cmd1, cmd2]) self.close() else: self.close() @@ -1045,18 +1149,20 @@ class UpdateNeoBoot(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Install neobot from flash memory to all images')) - self['key_red'] = Label(_('Install')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.mbupload}) + self["lab1"] = Label( + _("Install neobot from flash memory to all images")) + self["key_red"] = Label(_("Install")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.mbupload}, + ) def mbupload(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.session.open(MyUpgrade2) else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1073,8 +1179,8 @@ class MyUpgrade2(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('[NeoBoot]Please wait, updating in progress ...')) + self["lab1"] = Label( + _("[NeoBoot]Please wait, updating in progress ...")) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateInfo) self.onShow.append(self.startShow) @@ -1083,81 +1189,109 @@ class MyUpgrade2(Screen): self.activityTimer.start(10) def updateInfo(self): - if fileExists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh'): - os.system('mv /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/S99neo.local') - periodo = '/usr/lib/periodon' - testinout = '/usr/lib/enigma2/python/Tools/Testinout.p*' - zerotier = '/var/lib/zerotier-one/identity.secret' - S99neo = '/etc/rcS.d/S99neo.local' + if fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh" + ): + os.system( + "mv /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/S99neo.local" + ) + periodo = "/usr/lib/periodon" + testinout = "/usr/lib/enigma2/python/Tools/Testinout.p*" + zerotier = "/var/lib/zerotier-one/identity.secret" + S99neo = "/etc/rcS.d/S99neo.local" self.activityTimer.stop() - f2 = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') + f2 = open("%sImageBoot/.neonextboot" % getNeoLocation(), "r") mypath2 = f2.readline().strip() f2.close() - if mypath2 != 'Flash': + if mypath2 != "Flash": self.myClose( - _('Sorry, NeoBoot can installed or upgraded only when booted from Flash STB')) + _("Sorry, NeoBoot can installed or upgraded only when booted from Flash STB")) self.close() else: - for fn in listdir('%sImageBoot' % getNeoLocation()): - dirfile = '%sImageBoot/' % getNeoLocation() + fn + for fn in listdir("%sImageBoot" % getNeoLocation()): + dirfile = "%sImageBoot/" % getNeoLocation() + fn if isdir(dirfile): - target = dirfile + '' + LinkNeoBoot + '' - target1 = dirfile + '/usr/lib/' - target2 = dirfile + '/usr/lib/enigma2/python/Tools/' - target3 = dirfile + '/var/lib/zerotier-one/' - target4 = dirfile + '/etc/rcS.d/S99neo.local' - target5 = dirfile + '/etc/init.d/rcS.local' - target6 = dirfile + '/etc/init.d/rc.local' + target = dirfile + "" + LinkNeoBoot + "" + target1 = dirfile + "/usr/lib/" + target2 = dirfile + "/usr/lib/enigma2/python/Tools/" + target3 = dirfile + "/var/lib/zerotier-one/" + target4 = dirfile + "/etc/rcS.d/S99neo.local" + target5 = dirfile + "/etc/init.d/rcS.local" + target6 = dirfile + "/etc/init.d/rc.local" - cmd = 'rm -r ' + target + ' > /dev/null 2>&1' + cmd = "rm -r " + target + " > /dev/null 2>&1" system(cmd) - cmd1 = 'cp -af ' + periodo + ' ' + target1 + cmd1 = "cp -af " + periodo + " " + target1 system(cmd1) - cmd2 = 'cp -af ' + testinout + ' ' + target2 + cmd2 = "cp -af " + testinout + " " + target2 system(cmd2) - # cmd3 - if fileExists('%s' % target3): - if fileExists('/var/lib/zerotier-one/identity.secret'): - cmd = 'cp -aRf ' + zerotier + ' ' + target3 + if fileExists("%s" % target3): + if fileExists("/var/lib/zerotier-one/identity.secret"): + cmd = "cp -aRf " + zerotier + " " + target3 system(cmd) - cmd4 = 'cp -aRf ' + S99neo + ' ' + target4 + cmd4 = "cp -aRf " + S99neo + " " + target4 system(cmd4) - if fileExists('%s' % target5): - cmd5 = 'rm -r ' + target5 + ' > /dev/null 2>&1' + if fileExists("%s" % target5): + cmd5 = "rm -r " + target5 + " > /dev/null 2>&1" system(cmd5) - if fileExists('%s' % target6): - cmd6 = 'rm -r ' + target6 + ' > /dev/null 2>&1' + if fileExists("%s" % target6): + cmd6 = "rm -r " + target6 + " > /dev/null 2>&1" system(cmd6) - if fileExists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/S99neo.local'): + if fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/S99neo.local" + ): os.system( - 'mv /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/S99neo.local /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh; sleep 2') + "mv /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/S99neo.local /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh; sleep 2" + ) - # przenoszenie wtyczki neoboot - cmd = 'cp -af ' + LinkNeoBoot + ' ' + target + cmd = "cp -af " + LinkNeoBoot + " " + target system(cmd) - # multiboot_vu+ - if fileExists('/linuxrootfs1'): - cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs1' + LinkNeoBoot + ' ' + if fileExists("/linuxrootfs1"): + cmd = ( + "cp -af " + + LinkNeoBoot + + " /linuxrootfs1" + + LinkNeoBoot + + " " + ) system(cmd) - if fileExists('/linuxrootfs2'): - cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs2' + LinkNeoBoot + ' ' + if fileExists("/linuxrootfs2"): + cmd = ( + "cp -af " + + LinkNeoBoot + + " /linuxrootfs2" + + LinkNeoBoot + + " " + ) system(cmd) - if fileExists('/linuxrootfs3'): - cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs3' + LinkNeoBoot + ' ' + if fileExists("/linuxrootfs3"): + cmd = ( + "cp -af " + + LinkNeoBoot + + " /linuxrootfs3" + + LinkNeoBoot + + " " + ) system(cmd) - if fileExists('/linuxrootfs4'): - cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs4' + LinkNeoBoot + ' ' + if fileExists("/linuxrootfs4"): + cmd = ( + "cp -af " + + LinkNeoBoot + + " /linuxrootfs4" + + LinkNeoBoot + + " " + ) system(cmd) - out = open('%sImageBoot/.version' % getNeoLocation(), 'w') + out = open("%sImageBoot/.version" % getNeoLocation(), "w") out.write(PLUGINVERSION) out.close() self.myClose( - _('NeoBoot successfully updated. You can restart the plugin now.\nHave fun !!')) + _("NeoBoot successfully updated. You can restart the plugin now.\nHave fun !!")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1174,17 +1308,19 @@ class ListTv(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Copy the tv list with flash on all image')) - self['key_red'] = Label(_('Install')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.listupload}) + self["lab1"] = Label(_("Copy the tv list with flash on all image")) + self["key_red"] = Label(_("Install")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.listupload}, + ) def listupload(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.listupload2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def listupload2(self): self.session.open(ListTv2) @@ -1206,8 +1342,8 @@ class ListTv2(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('NeoBoot: Upgrading in progress\nPlease wait...')) + self["lab1"] = Label( + _("NeoBoot: Upgrading in progress\nPlease wait...")) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateInfo) self.onShow.append(self.startShow) @@ -1217,36 +1353,36 @@ class ListTv2(Screen): def updateInfo(self): self.activityTimer.stop() - f2 = open('' + getNeoLocation() + 'ImageBoot/.neonextboot', 'r') + f2 = open("" + getNeoLocation() + "ImageBoot/.neonextboot", "r") mypath2 = f2.readline().strip() f2.close() - if mypath2 != 'Flash': + if mypath2 != "Flash": self.myClose( - _('Sorry, NeoBoot can installed or upgraded only when booted from Flash.')) + _("Sorry, NeoBoot can installed or upgraded only when booted from Flash.")) self.close() else: - os.system('mv /etc/enigma2 /etc/enigma2.tmp') - os.system('mkdir -p /etc/enigma2') - os.system('cp -f /etc/enigma2.tmp/*.tv /etc/enigma2') - os.system('cp -f /etc/enigma2.tmp/*.radio /etc/enigma2') - os.system('cp -f /etc/enigma2.tmp/lamedb /etc/enigma2') - for fn in listdir('' + getNeoLocation() + 'ImageBoot'): - dirfile = '' + getNeoLocation() + 'ImageBoot/' + fn + os.system("mv /etc/enigma2 /etc/enigma2.tmp") + os.system("mkdir -p /etc/enigma2") + os.system("cp -f /etc/enigma2.tmp/*.tv /etc/enigma2") + os.system("cp -f /etc/enigma2.tmp/*.radio /etc/enigma2") + os.system("cp -f /etc/enigma2.tmp/lamedb /etc/enigma2") + for fn in listdir("" + getNeoLocation() + "ImageBoot"): + dirfile = "" + getNeoLocation() + "ImageBoot/" + fn if isdir(dirfile): - target = dirfile + '/etc/' - cmd = 'cp -af /etc/enigma2 ' + target + target = dirfile + "/etc/" + cmd = "cp -af /etc/enigma2 " + target system(cmd) - target1 = dirfile + '/etc/tuxbox' - cmd = 'cp -af /etc/tuxbox/satellites.xml ' + target1 + target1 = dirfile + "/etc/tuxbox" + cmd = "cp -af /etc/tuxbox/satellites.xml " + target1 system(cmd) - target2 = dirfile + '/etc/tuxbox' - cmd = 'cp -af /etc/tuxbox/terrestrial.xml ' + target2 + target2 = dirfile + "/etc/tuxbox" + cmd = "cp -af /etc/tuxbox/terrestrial.xml " + target2 system(cmd) - os.system('rm -f -R /etc/enigma2') - os.system('mv /etc/enigma2.tmp /etc/enigma2/') + os.system("rm -f -R /etc/enigma2") + os.system("mv /etc/enigma2.tmp /etc/enigma2/") self.myClose( - _('NeoBoot successfully updated list tv.\nHave fun !!')) + _("NeoBoot successfully updated list tv.\nHave fun !!")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1263,18 +1399,20 @@ class IPTVPlayer(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Copy the IPTV Player plugin from flash to all images')) - self['key_red'] = Label(_('Install')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.IPTVPlayerUpload}) + self["lab1"] = Label( + _("Copy the IPTV Player plugin from flash to all images")) + self["key_red"] = Label(_("Install")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.IPTVPlayerUpload}, + ) def IPTVPlayerUpload(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.IPTVPlayerUpload2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def IPTVPlayerUpload2(self): self.session.open(IPTVPlayer2) @@ -1296,8 +1434,8 @@ class IPTVPlayer2(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('NeoBoot: Upgrading in progress\nPlease wait...')) + self["lab1"] = Label( + _("NeoBoot: Upgrading in progress\nPlease wait...")) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateInfo) self.onShow.append(self.startShow) @@ -1307,28 +1445,32 @@ class IPTVPlayer2(Screen): def updateInfo(self): self.activityTimer.stop() - f2 = open('' + getNeoLocation() + 'ImageBoot/.neonextboot', 'r') + f2 = open("" + getNeoLocation() + "ImageBoot/.neonextboot", "r") mypath2 = f2.readline().strip() f2.close() - if mypath2 != 'Flash': + if mypath2 != "Flash": self.myClose( - _('Sorry, NeoBoot can installed or upgraded only when booted from Flash.')) + _("Sorry, NeoBoot can installed or upgraded only when booted from Flash.")) self.close() - elif not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer'): - self.myClose(_('Sorry, IPTVPlayer not found.')) + elif not fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer"): + self.myClose(_("Sorry, IPTVPlayer not found.")) self.close() else: - for fn in listdir('' + getNeoLocation() + 'ImageBoot'): - dirfile = '' + getNeoLocation() + 'ImageBoot/' + fn + for fn in listdir("" + getNeoLocation() + "ImageBoot"): + dirfile = "" + getNeoLocation() + "ImageBoot/" + fn if isdir(dirfile): - target = dirfile + '/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer' - cmd = 'rm -r ' + target + ' > /dev/null 2>&1' + target = ( + dirfile + + "/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer") + cmd = "rm -r " + target + " > /dev/null 2>&1" system(cmd) - cmd = 'cp -af /usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer ' + target + cmd = ( + "cp -af /usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer " + + target) system(cmd) self.myClose( - _('NeoBoot successfully updated IPTVPlayer.\nHave fun !!')) + _("NeoBoot successfully updated IPTVPlayer.\nHave fun !!")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1345,18 +1487,21 @@ class FeedExtra(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Copy the FeedExtra Player plugin from flash to all images')) - self['key_red'] = Label(_('Install')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.FeedExtraUpload}) + self["lab1"] = Label( + _("Copy the FeedExtra Player plugin from flash to all images") + ) + self["key_red"] = Label(_("Install")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.FeedExtraUpload}, + ) def FeedExtraUpload(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.FeedExtraUpload2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def FeedExtraUpload2(self): self.session.open(FeedExtra2) @@ -1378,8 +1523,8 @@ class FeedExtra2(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('NeoBoot: Upgrading in progress\nPlease wait...')) + self["lab1"] = Label( + _("NeoBoot: Upgrading in progress\nPlease wait...")) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateInfo) self.onShow.append(self.startShow) @@ -1389,28 +1534,32 @@ class FeedExtra2(Screen): def updateInfo(self): self.activityTimer.stop() - f2 = open('' + getNeoLocation() + 'ImageBoot/.neonextboot', 'r') + f2 = open("" + getNeoLocation() + "ImageBoot/.neonextboot", "r") mypath2 = f2.readline().strip() f2.close() - if mypath2 != 'Flash': + if mypath2 != "Flash": self.myClose( - _('Sorry, NeoBoot can installed or upgraded only when booted from Flash.')) + _("Sorry, NeoBoot can installed or upgraded only when booted from Flash.")) self.close() - elif not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/FeedExtra'): - self.myClose(_('Sorry, FeedExtra not found.')) + elif not fileExists("/usr/lib/enigma2/python/Plugins/Extensions/FeedExtra"): + self.myClose(_("Sorry, FeedExtra not found.")) self.close() else: - for fn in listdir('' + getNeoLocation() + 'ImageBoot'): - dirfile = '' + getNeoLocation() + 'ImageBoot/' + fn + for fn in listdir("" + getNeoLocation() + "ImageBoot"): + dirfile = "" + getNeoLocation() + "ImageBoot/" + fn if isdir(dirfile): - target = dirfile + '/usr/lib/enigma2/python/Plugins/Extensions/FeedExtra' - cmd = 'rm -r ' + target + ' > /dev/null 2>&1' + target = ( + dirfile + + "/usr/lib/enigma2/python/Plugins/Extensions/FeedExtra") + cmd = "rm -r " + target + " > /dev/null 2>&1" system(cmd) - cmd = 'cp -r /usr/lib/enigma2/python/Plugins/Extensions/FeedExtra ' + target + cmd = ( + "cp -r /usr/lib/enigma2/python/Plugins/Extensions/FeedExtra " + + target) system(cmd) self.myClose( - _('NeoBoot successfully updated FeedExtra.\nHave fun !!')) + _("NeoBoot successfully updated FeedExtra.\nHave fun !!")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1427,16 +1576,20 @@ class SetPasswd(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Delete password')) - self['key_red'] = Label(_('Start')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.passwd}) + self["lab1"] = Label(_("Delete password")) + self["key_red"] = Label(_("Start")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.close, "red": self.passwd}) def passwd(self): - os.system('passwd -d root') - restartbox = self.session.openWithCallback(self.restartGUI, MessageBox, _( - 'GUI needs a restart.\nDo you want to Restart the GUI now?'), MessageBox.TYPE_YESNO) - restartbox.setTitle(_('Restart GUI now?')) + os.system("passwd -d root") + restartbox = self.session.openWithCallback( + self.restartGUI, + MessageBox, + _("GUI needs a restart.\nDo you want to Restart the GUI now?"), + MessageBox.TYPE_YESNO, + ) + restartbox.setTitle(_("Restart GUI now?")) def restartGUI(self, answer): if answer is True: @@ -1455,87 +1608,173 @@ class CheckInstall(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Checking filesystem...')) - self['key_red'] = Label(_('Start')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.neocheck}) + self["lab1"] = Label(_("Checking filesystem...")) + self["key_red"] = Label(_("Start")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.neocheck}, + ) def neocheck(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): self.neocheck2() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def neocheck2(self): - os.system(_('rm -f ' + LinkNeoBoot + '/files/modulecheck; echo %s - %s > ' + - LinkNeoBoot + '/files/modulecheck') % (getBoxHostName(), getCPUSoC())) - os.system('echo "Devices:" >> ' + LinkNeoBoot + '/files/modulecheck; cat /sys/block/sd*/device/vendor | sed "s/ *$//" >> ' + - LinkNeoBoot + '/files/modulecheck; cat /sys/block/sd*/device/model | sed "s/ *$//" >> ' + LinkNeoBoot + '/files/modulecheck') - os.system('echo "\n====================================================>\nCheck result:" >> ' + - LinkNeoBoot + '/files/modulecheck') - os.system('echo "* neoboot location:" >> ' + LinkNeoBoot + - '/files/modulecheck; cat "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location" >> ' + LinkNeoBoot + '/files/modulecheck') - os.system('echo "\n* neoboot location install:" >> ' + LinkNeoBoot + - '/files/modulecheck; cat "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install" >> ' + LinkNeoBoot + '/files/modulecheck') - os.system('echo "\n* neoboot location mount:" >> ' + LinkNeoBoot + - '/files/modulecheck; cat "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh" >> ' + LinkNeoBoot + '/files/modulecheck') - if getCPUtype() == 'ARMv7' and getCPUtype() != 'MIPS': - if os.system('opkg update; opkg list-installed | grep python-subprocess') != 0: - os.system('echo "\n* python-subprocess not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep python-argparse') != 0: - os.system('echo "* python-argparse not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep curl') != 0: - os.system('echo "* curl not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') + os.system( + _( + "rm -f " + + LinkNeoBoot + + "/files/modulecheck; echo %s - %s > " + + LinkNeoBoot + + "/files/modulecheck" + ) + % (getBoxHostName(), getCPUSoC()) + ) + os.system( + 'echo "Devices:" >> ' + + LinkNeoBoot + + '/files/modulecheck; cat /sys/block/sd*/device/vendor | sed "s/ *$//" >> ' + + LinkNeoBoot + + '/files/modulecheck; cat /sys/block/sd*/device/model | sed "s/ *$//" >> ' + + LinkNeoBoot + + "/files/modulecheck") + os.system( + 'echo "\n====================================================>\nCheck result:" >> ' + + LinkNeoBoot + + "/files/modulecheck") + os.system( + 'echo "* neoboot location:" >> ' + + LinkNeoBoot + + '/files/modulecheck; cat "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location" >> ' + + LinkNeoBoot + + "/files/modulecheck") + os.system( + 'echo "\n* neoboot location install:" >> ' + + LinkNeoBoot + + '/files/modulecheck; cat "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install" >> ' + + LinkNeoBoot + + "/files/modulecheck") + os.system( + 'echo "\n* neoboot location mount:" >> ' + + LinkNeoBoot + + '/files/modulecheck; cat "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh" >> ' + + LinkNeoBoot + + "/files/modulecheck") + if getCPUtype() == "ARMv7" and getCPUtype() != "MIPS": + if (os.system( + "opkg update; opkg list-installed | grep python-subprocess") != 0): + os.system( + 'echo "\n* python-subprocess not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep python-argparse") != 0: + os.system( + 'echo "* python-argparse not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep curl") != 0: + os.system( + 'echo "* curl not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) else: - os.system('echo "\n* opkg packed everything is OK !" >> ' + - LinkNeoBoot + '/files/modulecheck') - elif getCPUtype() != 'ARMv7' and getCPUtype() == 'MIPS': - if os.system('opkg list-installed | grep kernel-module-nandsim') != 0: - os.system('echo "\n* kernel-module-nandsim not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep mtd-utils-jffs2') != 0: - os.system('echo "* mtd-utils-jffs2 not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep lzo') != 0: - os.system('echo "* lzo not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep python-setuptools') != 0: - os.system('echo "* python-setuptools not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep util-linux-sfdisk') != 0: - os.system('echo "* util-linux-sfdisk not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep packagegroup-base-nfs') != 0: - os.system('echo "* packagegroup-base-nfs not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep ofgwrite') != 0: - os.system('echo "* ofgwrite not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep bzip2') != 0: - os.system('echo "* bzip2 not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep mtd-utils') != 0: - os.system('echo "* mtd-utils not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') - if os.system('opkg list-installed | grep mtd-utils-ubifs') != 0: - os.system('echo "* mtd-utils-ubifs not installed" >> ' + - LinkNeoBoot + '/files/modulecheck') + os.system( + 'echo "\n* opkg packed everything is OK !" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + elif getCPUtype() != "ARMv7" and getCPUtype() == "MIPS": + if os.system( + "opkg list-installed | grep kernel-module-nandsim") != 0: + os.system( + 'echo "\n* kernel-module-nandsim not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep mtd-utils-jffs2") != 0: + os.system( + 'echo "* mtd-utils-jffs2 not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep lzo") != 0: + os.system( + 'echo "* lzo not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep python-setuptools") != 0: + os.system( + 'echo "* python-setuptools not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep util-linux-sfdisk") != 0: + os.system( + 'echo "* util-linux-sfdisk not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system( + "opkg list-installed | grep packagegroup-base-nfs") != 0: + os.system( + 'echo "* packagegroup-base-nfs not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep ofgwrite") != 0: + os.system( + 'echo "* ofgwrite not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep bzip2") != 0: + os.system( + 'echo "* bzip2 not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep mtd-utils") != 0: + os.system( + 'echo "* mtd-utils not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) + if os.system("opkg list-installed | grep mtd-utils-ubifs") != 0: + os.system( + 'echo "* mtd-utils-ubifs not installed" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) else: - os.system('echo "\n* opkg packed everything is OK !" >> ' + - LinkNeoBoot + '/files/modulecheck') + os.system( + 'echo "\n* opkg packed everything is OK !" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) else: - os.system('echo "\n* STB is not ARMv7 or MIPS" >> ' + - LinkNeoBoot + '/files/modulecheck') + os.system( + 'echo "\n* STB is not ARMv7 or MIPS" >> ' + + LinkNeoBoot + + "/files/modulecheck" + ) - cmd = 'echo "\n<====================================================" >> ' + \ - LinkNeoBoot + '/files/modulecheck; cat ' + LinkNeoBoot + '/files/modulecheck' - cmd1 = '' - self.session.openWithCallback(self.close, Console, _('NeoBoot....'), [cmd, - cmd1]) + cmd = ( + 'echo "\n<====================================================" >> ' + + LinkNeoBoot + + "/files/modulecheck; cat " + + LinkNeoBoot + + "/files/modulecheck") + cmd1 = "" + self.session.openWithCallback( + self.close, Console, _("NeoBoot...."), [cmd, cmd1] + ) self.close() def myClose(self, message): @@ -1561,159 +1800,138 @@ class SkinChange(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label('') - self['lab2'] = Label('') - self['lab3'] = Label(_('Choose the skin you want to make.')) - self['key_red'] = Label(_('Change')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.checkimageskin, - 'ok': self.SkinGO, - 'red': self.SkinGO, - '9': self.restareE2}) + self["lab1"] = Label("") + self["lab2"] = Label("") + self["lab3"] = Label(_("Choose the skin you want to make.")) + self["key_red"] = Label(_("Change")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + { + "back": self.checkimageskin, + "ok": self.SkinGO, + "red": self.SkinGO, + "9": self.restareE2, + }, + ) self.onShow.append(self.updateInfo) def updateInfo(self): - self.skindir = '' + LinkNeoBoot + '/neoskins/' + self.skindir = "" + LinkNeoBoot + "/neoskins/" if pathExists(self.skindir) == 0 and createDir(self.skindir): pass - skinlist = ['default'] - for fn in listdir('' + LinkNeoBoot + '/neoskins'): - dirfile = '' + LinkNeoBoot + '/neoskins/' + fn + skinlist = ["default"] + for fn in listdir("" + LinkNeoBoot + "/neoskins"): + dirfile = "" + LinkNeoBoot + "/neoskins/" + fn if os_isdir(dirfile) and skinlist.append(fn): pass - self['list'].list = skinlist + self["list"].list = skinlist def SkinGO(self): - skin = self['list'].getCurrent() + skin = self["list"].getCurrent() if skin: self.selectedskin = skin.strip() - myerror = '' - if self.selectedskin == 'default': + myerror = "" + if self.selectedskin == "default": self.DefaultSkin() - elif myerror == '': - message = (_('Skin Change: %s now ?') % skin) + elif myerror == "": + message = _("Skin Change: %s now ?") % skin ybox = self.session.openWithCallback( self.doSkinChange, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Skin Change confirmation')) + ybox.setTitle(_("Skin Change confirmation")) else: self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) -# ln -sf "neoskins/default.py" "/usr/lib/enigma2/python/Plugins /Extensions/NeoBoot/skin.py" def DefaultSkin(self): cmd = "echo -e '\n\n%s '" % _( - 'Please wait, NeoBot is working, skin change is progress...') - cmd1 = "echo -e '\n\n%s '" % _('NeoBoot: Complete Skin Change!') -# cmd2 = 'cp -af ' +LinkNeoBoot+ '/neoskins/default.py ' +LinkNeoBoot+ '/skin.py' - cmd2 = 'rm -f ' + LinkNeoBoot + '/usedskin.p*; sleep 2' + "Please wait, NeoBot is working, skin change is progress..." + ) + cmd1 = "echo -e '\n\n%s '" % _("NeoBoot: Complete Skin Change!") + cmd2 = "rm -f " + LinkNeoBoot + "/usedskin.p*; sleep 2" cmd3 = 'ln -sf "neoskins/default.py" "' + LinkNeoBoot + '/usedskin.py"' - self.session.open(Console, _('NeoBoot Skin Change'), - [cmd, cmd1, cmd2, cmd3]) + self.session.open( + Console, _("NeoBoot Skin Change"), [ + cmd, cmd1, cmd2, cmd3]) def doSkinChange(self, answer): - if answer is True: - if isFHD(): - if getBoxHostName() == 'vuultimo4k': - system('cp -af ' + LinkNeoBoot + '/images/ultimo4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vusolo4k': - system('cp -af ' + LinkNeoBoot + '/images/solo4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vuduo4k': - system('cp -af ' + LinkNeoBoot + '/images/duo4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vuduo4kse': - system('cp -af ' + LinkNeoBoot + '/images/duo4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vuuno4k': - system('cp -af ' + LinkNeoBoot + '/images/uno4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vuuno4kse': - system('cp -af ' + LinkNeoBoot + '/images/uno4kse.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vuzero4kse': - system('cp -af ' + LinkNeoBoot + '/images/zero4kse.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'sf4008': - system('cp -af ' + LinkNeoBoot + '/images/sf4008.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'ustym4kpro': - system('cp -af ' + LinkNeoBoot + '/images/ustym4kpro.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'vusolo2': - system('cp -af ' + LinkNeoBoot + '/images/solo2.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'bre2ze4k': - system('cp -af ' + LinkNeoBoot + '/images/bre2ze4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'lunix4k': - system('cp -af ' + LinkNeoBoot + '/images/lunix4k.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'zgemmah9s': - system('cp -af ' + LinkNeoBoot + '/images/zgemmah9se.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'h7' or getBoxHostName() == 'zgemmah7': - system('cp -af ' + LinkNeoBoot + '/images/zgmmah7.png ' + - LinkNeoBoot + '/images/box.png') - elif getBoxHostName() == 'zgemmah9combo': - system('cp -af ' + LinkNeoBoot + '/images/zgmmah9twin.png ' + - LinkNeoBoot + '/images/box.png') - else: - system('cp -af ' + LinkNeoBoot + '/images/logo.png ' + - LinkNeoBoot + '/images/box.png') - - cmd = "echo -e '\n\n%s '" % _( - 'Please wait, NeoBot is working, skin change is progress...') - cmd1 = 'rm -f ' + LinkNeoBoot + '/usedskin.p*; sleep 2' - cmd2 = 'sleep 2; cp -af ' + self.skindir + '/' + \ - self.selectedskin + '/*.py ' + LinkNeoBoot + '/usedskin.py' - cmd3 = "echo -e '\n\n%s '" % _( - 'NeoBoot: Complete Skin Change!') - cmd4 = "echo -e '\n\n%s '" % _( - 'To use the new skin please restart enigma2') - self.session.open(Console, _('NeoBoot Skin Change'), [ - cmd, cmd1, cmd2, cmd3, cmd4]) - elif isHD(): - cmd = "echo -e '\n\n%s '" % _( - 'Please wait, NeoBot is working, skin change is progress...') - cmd1 = 'rm -f ' + LinkNeoBoot + '/usedskin.p*; sleep 2' - cmd2 = 'sleep 2; cp -af ' + self.skindir + '/' + \ - self.selectedskin + '/*.py ' + LinkNeoBoot + '/usedskin.py' - cmd3 = "echo -e '\n\n%s '" % _( - 'NeoBoot: Complete Skin Change!') - cmd4 = "echo -e '\n\n%s '" % _( - 'Skin change available only for full hd skin.') - cmd5 = "echo -e '\n\n%s '" % _( - 'Please come back to default skin.') - cmd6 = "echo -e '\n\n%s '" % _( - 'To use the new skin please restart enigma2') - self.session.open(Console, _('NeoBoot Skin Change'), [ - cmd, cmd1, cmd2, cmd3, cmd4, cmd5, cmd6]) - - else: + if not answer: self.close() + return + + base_path = LinkNeoBoot + + cmd_list = [ + f"echo -e '\n\n{_('Please wait, NeoBot is working, skin change is progress...')}'", + f"rm -f {base_path}/usedskin.p*; sleep 2", + f"sleep 2; cp -af {self.skindir}/{self.selectedskin}/*.py {base_path}/usedskin.py", + f"echo -e '\n\n{_('NeoBoot: Complete Skin Change!')}'", + ] + + if isFHD(): + hostname = getBoxHostName() + image_path = f"{base_path}/images" + dest_image = f"{image_path}/box.png" + + box_image_map = { + "vuultimo4k": "ultimo4k.png", + "vusolo4k": "solo4k.png", + "vuduo4k": "duo4k.png", + "vuduo4kse": "duo4k.png", # Uses duo4k.png + "vuuno4k": "uno4k.png", + "vuuno4kse": "uno4kse.png", + "vuzero4kse": "zero4kse.png", + "sf4008": "sf4008.png", + "ustym4kpro": "ustym4kpro.png", + "vusolo2": "solo2.png", + "bre2ze4k": "bre2ze4k.png", + "lunix4k": "lunix4k.png", + "zgemmah9s": "zgemmah9se.png", # Uses zgemmah9se.png + "h7": "zgmmah7.png", + "zgemmah7": "zgmmah7.png", + "zgemmah9combo": "zgmmah9twin.png", + "novaler4kpro": "novaler4kpro.png", + } + + source_image_name = box_image_map.get(hostname, "logo.png") + source_image = f"{image_path}/{source_image_name}" + + system(f"cp -af {source_image} {dest_image}") + + cmd_list.append( + f"echo -e '\n\n{_('To use the new skin please restart enigma2')}'" + ) + + self.session.open(Console, _("NeoBoot Skin Change"), cmd_list) + + elif isHD(): + cmd_list.extend( + [ + f"echo -e '\n\n{_('Skin change available only for full hd skin.')}'", + f"echo -e '\n\n{_('Please come back to default skin.')}'", + f"echo -e '\n\n{_('To use the new skin please restart enigma2')}'", + ] + ) + + self.session.open(Console, _("NeoBoot Skin Change"), cmd_list) def checkimageskin(self): - if fileCheck('/etc/vtiversion.info'): - # fail = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/usedskin.py' - # f = open(fail, 'r') - # content = f.read() - # f.close() - # localfile2 = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/usedskin.py' - # temp_file2 = open(localfile2, 'w') - # temp_file2.write(content.replace('selektor.png', 'slekvti.png')) - # temp_file2.close() + if fileCheck("/etc/vtiversion.info"): self.restareE2() else: self.restareE2() def restareE2(self): - restartbox = self.session.openWithCallback(self.restartGUI, MessageBox, _( - 'GUI needs a restart.\nDo you want to Restart the GUI now?'), MessageBox.TYPE_YESNO) - restartbox.setTitle(_('Restart GUI now?')) + restartbox = self.session.openWithCallback( + self.restartGUI, + MessageBox, + _("GUI needs a restart.\nDo you want to Restart the GUI now?"), + MessageBox.TYPE_YESNO, + ) + restartbox.setTitle(_("Restart GUI now?")) def restartGUI(self, answer): if answer is True: @@ -1735,17 +1953,20 @@ class BlocUnblockImageSkin(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Block or unblock the neoboot skin display in the system skin.')) - self['key_red'] = Label(_('Block or unlock skins.')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.restareE2, - 'red': self.deleteback}) - self.backupdir = '/usr/share/enigma2' + self["lab1"] = Label( + _("Block or unblock the neoboot skin display in the system skin.") + ) + self["key_red"] = Label(_("Block or unlock skins.")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.restareE2, "red": self.deleteback}, + ) + self.backupdir = "/usr/share/enigma2" self.onShow.append(self.updateInfo) def updateInfo(self): - self.backupdir = '/usr/share/enigma2' + self.backupdir = "/usr/share/enigma2" if pathExists(self.backupdir) == 0 and createDir(self.backupdir): pass @@ -1753,52 +1974,58 @@ class BlocUnblockImageSkin(Screen): for fn in listdir(self.backupdir): imageslist.append(fn) - self['list'].list = imageslist + self["list"].list = imageslist def deleteback(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() self.delimage = image.strip() - if fileExists(self.backupdir + '/' + self.delimage + '/skin.xml'): + if fileExists(self.backupdir + "/" + self.delimage + "/skin.xml"): self.deleteback2() else: - self.myClose(_('Sorry, not find skin neoboot.')) + self.myClose(_("Sorry, not find skin neoboot.")) def deleteback2(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: self.delimage = image.strip() - message = ( - _('Select Yes to lock or No to unlock.\n %s ?') % image) + message = _( + "Select Yes to lock or No to unlock.\n %s ?") % image ybox = self.session.openWithCallback( self.Block_Unlock_Skin, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Confirmation...')) + ybox.setTitle(_("Confirmation...")) def Block_Unlock_Skin(self, answer): if answer is True: - fail = self.backupdir + '/' + self.delimage + '/skin.xml' - f = open(fail, 'r') + fail = self.backupdir + "/" + self.delimage + "/skin.xml" + f = open(fail, "r") content = f.read() f.close() - localfile2 = self.backupdir + '/' + self.delimage + '/skin.xml' - temp_file2 = open(localfile2, 'w') - temp_file2.write(content.replace( - 'NeoBootImageChoose', 'neoBootImageChoose')) + localfile2 = self.backupdir + "/" + self.delimage + "/skin.xml" + temp_file2 = open(localfile2, "w") + temp_file2.write( + content.replace("NeoBootImageChoose", "neoBootImageChoose") + ) temp_file2.close() else: - fail = self.backupdir + '/' + self.delimage + '/skin.xml' - f = open(fail, 'r') + fail = self.backupdir + "/" + self.delimage + "/skin.xml" + f = open(fail, "r") content = f.read() f.close() - localfile2 = self.backupdir + '/' + self.delimage + '/skin.xml' - temp_file2 = open(localfile2, 'w') - temp_file2.write(content.replace( - 'neoBootImageChoose', 'NeoBootImageChoose')) + localfile2 = self.backupdir + "/" + self.delimage + "/skin.xml" + temp_file2 = open(localfile2, "w") + temp_file2.write( + content.replace("neoBootImageChoose", "NeoBootImageChoose") + ) temp_file2.close() def restareE2(self): - restartbox = self.session.openWithCallback(self.restartGUI, MessageBox, _( - 'GUI needs a restart.\nDo you want to Restart the GUI now?'), MessageBox.TYPE_YESNO) - restartbox.setTitle(_('Restart GUI now?')) + restartbox = self.session.openWithCallback( + self.restartGUI, + MessageBox, + _("GUI needs a restart.\nDo you want to Restart the GUI now?"), + MessageBox.TYPE_YESNO, + ) + restartbox.setTitle(_("Restart GUI now?")) def restartGUI(self, answer): if answer is True: @@ -1821,99 +2048,115 @@ class InternalFlash(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Install software internal flash memory in media')) - self['key_red'] = Label(_('Start - Red')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.mountIF}) + self["lab1"] = Label( + _("Install software internal flash memory in media")) + self["key_red"] = Label(_("Start - Red")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.close, "red": self.mountIF}) def mountIF(self): - if fileExists('/.multinfo') and getCPUtype() != 'MIPS': + if fileExists("/.multinfo") and getCPUtype() != "MIPS": self.mountinternalflash() else: self.myClose( - _('Sorry, the operation is not possible from Flash or not supported.')) + _("Sorry, the operation is not possible from Flash or not supported.")) self.close() def mountinternalflash(self): - if fileExists('/.multinfo') and getCPUtype() == 'ARMv7': - if os.path.exists('/proc/stb/info/boxtype'): - if getBoxHostName == 'sf4008': # getCPUSoC() == 'bcm7251' + if fileExists("/.multinfo") and getCPUtype() == "ARMv7": + if os.path.exists("/proc/stb/info/boxtype"): + if getBoxHostName == "sf4008": # getCPUSoC() == 'bcm7251' os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash" + ) - if os.path.exists('/proc/stb/info/boxtype'): - if getBoxHostName == 'et1x000': # getCPUSoC() == 'bcm7251' or + if os.path.exists("/proc/stb/info/boxtype"): + if getBoxHostName == "et1x000": # getCPUSoC() == 'bcm7251' or os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash" + ) - if os.path.exists('/proc/stb/info/boxtype'): - if getBoxHostName == 'ax51': # getCPUSoC() == 'bcm7251s' or + if os.path.exists("/proc/stb/info/boxtype"): + if getBoxHostName == "ax51": # getCPUSoC() == 'bcm7251s' or os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash" + ) - if os.path.exists('/proc/stb/info/boxtype'): - if getCPUSoC() == 'bcm7251s' or getBoxHostName() == 'h7' or getBoxHostName() == 'zgemmah7': + if os.path.exists("/proc/stb/info/boxtype"): + if ( + getCPUSoC() == "bcm7251s" + or getBoxHostName() == "h7" + or getBoxHostName() == "zgemmah7" + ): os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p3 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p3 /media/InternalFlash" + ) - if os.path.exists('/proc/stb/info/boxtype'): - if getBoxHostName() == 'zgemmah9s': + if os.path.exists("/proc/stb/info/boxtype"): + if getBoxHostName() == "zgemmah9s": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash" + ) -# if os.path.exists('/proc/stb/info/boxtype'): -# if getBoxHostName() == 'zgemmah9combo': -# os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') - - if getBoxHostName == 'sf8008': + if getBoxHostName == "sf8008": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p13 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p13 /media/InternalFlash" + ) - if getBoxHostName == 'ax60': + if getBoxHostName == "ax60": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p21 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p21 /media/InternalFlash" + ) - if getBoxHostName() == 'ustym4kpro' or getTunerModel() == 'ustym4kpro': + if getBoxHostName() == "ustym4kpro" or getTunerModel() == "ustym4kpro": os.system( - ' ' + LinkNeoBoot + '/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash') - # os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p13 /media/InternalFlash') + " " + + LinkNeoBoot + + "/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash") - if os.path.exists('/proc/stb/info/model'): - if getTunerModel() == 'dm900' or getCPUSoC() == 'BCM97252SSFF': + if os.path.exists("/proc/stb/info/model"): + if getTunerModel() == "dm900" or getCPUSoC() == "BCM97252SSFF": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p2 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p2 /media/InternalFlash" + ) - if getBoxVuModel() == 'uno4kse' or getBoxVuModel() == 'uno4k' or getBoxVuModel() == 'ultimo4k' or getBoxVuModel() == 'solo4k': + if ( + getBoxVuModel() == "uno4kse" + or getBoxVuModel() == "uno4k" + or getBoxVuModel() == "ultimo4k" + or getBoxVuModel() == "solo4k" + ): os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash" + ) - if getBoxVuModel() == 'zero4k': + if getBoxVuModel() == "zero4k": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash" + ) - if getBoxVuModel() == 'duo4k': + if getBoxVuModel() == "duo4k": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash" + ) - if getBoxVuModel() == 'duo4kse': + if getBoxVuModel() == "duo4kse": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash" + ) - if getCPUSoC() == 'bcm7252s' or getBoxHostName() == 'gbquad4k': + if getCPUSoC() == "bcm7252s" or getBoxHostName() == "gbquad4k": os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash') - - # if getBoxHostName == 'osmio4k': - # os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash') + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash" + ) else: - self.myClose(_('Your image flash cannot be mounted.')) + self.myClose(_("Your image flash cannot be mounted.")) - if fileExists('/media/InternalFlash/etc/init.d/neobootmount.sh'): - os.system('rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;') + if fileExists("/media/InternalFlash/etc/init.d/neobootmount.sh"): + os.system("rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;") - self.myClose(_('Your image flash is mounted in the media location')) + self.myClose(_("Your image flash is mounted in the media location")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1933,17 +2176,18 @@ class DeletingLanguages(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Select to delete.')) - self['key_red'] = Label(_('Delete file')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'ok': self.deleteback, - 'red': self.deleteback}) - self.backupdir = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/locale' + self["lab1"] = Label(_("Select to delete.")) + self["key_red"] = Label(_("Delete file")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "ok": self.deleteback, "red": self.deleteback}, + ) + self.backupdir = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/locale" self.onShow.append(self.updateInfo) def updateInfo(self): - self.backupdir = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/locale' + self.backupdir = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/locale" if pathExists(self.backupdir) == 0 and createDir(self.backupdir): pass @@ -1951,24 +2195,26 @@ class DeletingLanguages(Screen): for fn in listdir(self.backupdir): imageslist.append(fn) - self['list'].list = imageslist + self["list"].list = imageslist def deleteback(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: self.delimage = image.strip() - message = (_('File: %s remove ?') % image) + message = _("File: %s remove ?") % image ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Confirmation of Deletion...')) + self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Confirmation of Deletion...")) def dodeleteback(self, answer): if answer is True: cmd = "echo -e '\n\n%s '" % _( - 'NeoBoot - deleting backup files .....') - cmd1 = 'rm -fR ' + self.backupdir + '/' + self.delimage - self.session.open(Console, _( - 'NeoBoot: Backup files deleted!'), [cmd, cmd1]) + "NeoBoot - deleting backup files .....") + cmd1 = "rm -fR " + self.backupdir + "/" + self.delimage + self.session.open( + Console, _("NeoBoot: Backup files deleted!"), [ + cmd, cmd1]) self.updateInfo() else: self.close() @@ -1984,20 +2230,23 @@ class ATVcamfeed(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Add softcam download from feed.')) - self['key_red'] = Label(_('Start')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.addcamatv}) + self["lab1"] = Label(_("Add softcam download from feed.")) + self["key_red"] = Label(_("Start")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.addcamatv}, + ) def addcamatv(self): - if getImageATv() == 'okfeedCAMatv': - cmd = "echo -e '\n\n%s '" % _('NeoBoot - ATV add cam feed ...') - cmd1 = 'wget -O - -q http://updates.mynonpublic.com/oea/feed | bash' - self.session.open(Console, _( - 'NeoBoot: Cams feed add...'), [cmd, cmd1]) + if getImageATv() == "okfeedCAMatv": + cmd = "echo -e '\n\n%s '" % _("NeoBoot - ATV add cam feed ...") + cmd1 = "wget -O - -q http://updates.mynonpublic.com/oea/feed | bash" + self.session.open( + Console, _("NeoBoot: Cams feed add..."), [ + cmd, cmd1]) - elif getImageATv() != 'okfeedCAMatv': - self.myClose(_('Sorry, is not image Open ATV !!!')) + elif getImageATv() != "okfeedCAMatv": + self.myClose(_("Sorry, is not image Open ATV !!!")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -2014,20 +2263,21 @@ class TunerInfo(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('List of supported stb.')) - self['key_red'] = Label(_('Start - Red')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.iNFO}) + self["lab1"] = Label(_("List of supported stb.")) + self["key_red"] = Label(_("Start - Red")) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "back": self.close, "red": self.iNFO}) def iNFO(self): try: - cmd = ' cat ' + LinkNeoBoot + '/stbinfo.cfg' - cmd1 = '' - self.session.openWithCallback(self.close, Console, _('NeoBoot....'), [cmd, - cmd1]) + cmd = " cat " + LinkNeoBoot + "/stbinfo.cfg" + cmd1 = "" + self.session.openWithCallback( + self.close, Console, _("NeoBoot...."), [cmd, cmd1] + ) self.close() - except: + except BaseException: False @@ -2036,26 +2286,31 @@ class CreateSwap(Screen): skin = """ - + """ def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Create swap-file.')) - self['key_red'] = Label(_('Remove file swap.')) - self['key_green'] = Label(_('Start create file swap.')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.RemoveSwap, - 'green': self.CreateSwap}) + self["lab1"] = Label(_("Create swap-file.")) + self["key_red"] = Label(_("Remove file swap.")) + self["key_green"] = Label(_("Start create file swap.")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.RemoveSwap, "green": self.CreateSwap}, + ) def CreateSwap(self): - if not os.path.exists('/media/hdd/swapfile') and not os.path.exists('/media/usb/swapfile') and not os.path.exists('/swapfile'): + if ( + not os.path.exists("/media/hdd/swapfile") + and not os.path.exists("/media/usb/swapfile") + and not os.path.exists("/swapfile") + ): self.goCreateSwap() else: - self.myClose(_('The file swapfile already exists.')) + self.myClose(_("The file swapfile already exists.")) def goCreateSwap(self): - supported_filesystems = frozenset(('ext4', 'ext3', 'ext2', 'vfat')) + supported_filesystems = frozenset(("ext4", "ext3", "ext2", "vfat")) candidates = [] mounts = getProcMounts() for partition in harddiskmanager.getMountedPartitions(False, mounts): @@ -2063,106 +2318,141 @@ class CreateSwap(Screen): candidates.append( (partition.description, partition.mountpoint)) if len(candidates): - self.session.openWithCallback(self.doCSplace, ChoiceBox, title=_( - 'Please select device to use as swapfile location'), list=candidates) + self.session.openWithCallback( + self.doCSplace, + ChoiceBox, + title=_("Please select device to use as swapfile location"), + list=candidates, + ) else: - self.session.open(MessageBox, _( - "Sorry, no physical devices that supports SWAP attached. Can't create Swapfile on network or fat32 filesystems"), MessageBox.TYPE_INFO, timeout=10) + self.session.open( + MessageBox, + _("Sorry, no physical devices that supports SWAP attached. Can't create Swapfile on network or fat32 filesystems"), + MessageBox.TYPE_INFO, + timeout=10, + ) def doCSplace(self, name): if name: self.new_place = name[1] - myoptions = [[_('8 MB'), '8192'], - [_('16 MB'), '16384'], - [_('32 MB'), '32768'], - [_('64 MB'), '65536'], - [_('96 MB'), '98304'], - [_('128 MB'), '131072'], - [_('256 MB'), '262144'], - [_('512 MB'), '524288'], - [_('1024 MB'), '1048576']] - self.session.openWithCallback(self.doChoiceSize, ChoiceBox, title=_( - 'Select the Swap File Size:'), list=myoptions) + myoptions = [ + [_("8 MB"), "8192"], + [_("16 MB"), "16384"], + [_("32 MB"), "32768"], + [_("64 MB"), "65536"], + [_("96 MB"), "98304"], + [_("128 MB"), "131072"], + [_("256 MB"), "262144"], + [_("512 MB"), "524288"], + [_("1024 MB"), "1048576"], + ] + self.session.openWithCallback( + self.doChoiceSize, + ChoiceBox, + title=_("Select the Swap File Size:"), + list=myoptions, + ) def doChoiceSize(self, swapsize): if swapsize: - self['actions'].setEnabled(False) + self["actions"].setEnabled(False) swapsize = swapsize[1] - myfile = self.new_place + '/swapfile' - cmd0 = "echo -e '\n\n%s '" % _('Creation swap ' + - myfile + ', please wait...') - cmd1 = 'dd if=/dev/zero of=' + myfile + \ - ' bs=1024 count=' + swapsize + ' 2>/dev/null' - cmd2 = 'mkswap ' + myfile + myfile = self.new_place + "/swapfile" + cmd0 = "echo -e '\n\n%s '" % _( + "Creation swap " + myfile + ", please wait..." + ) + cmd1 = ( + "dd if=/dev/zero of=" + + myfile + + " bs=1024 count=" + + swapsize + + " 2>/dev/null" + ) + cmd2 = "mkswap " + myfile cmd3 = 'echo "' + myfile + ' swap swap defaults 0 0" >> /etc/fstab' - cmd4 = 'chmod 755 ' + myfile + '; /sbin/swapon ' + myfile + '' + cmd4 = "chmod 755 " + myfile + "; /sbin/swapon " + myfile + "" cmd5 = "echo -e '\n\n%s '" % _( - 'Creation complete swap ' + swapsize + '') - self.session.open(Console, _('NeoBoot....'), [cmd0, - cmd1, - cmd2, - cmd3, - cmd4, - cmd5]) + "Creation complete swap " + swapsize + "") + self.session.open( + Console, _("NeoBoot...."), [cmd0, cmd1, cmd2, cmd3, cmd4, cmd5] + ) self.close() def RemoveSwap(self): - if os.path.exists('/media/hdd/swapfile') or os.path.exists('/media/usb/swapfile') or os.path.exists('/swapfile'): - cmd0 = "echo -e '\n%s '" % _('Remove swap, please wait...') - if os.path.exists('/media/hdd/swapfile'): + if ( + os.path.exists("/media/hdd/swapfile") + or os.path.exists("/media/usb/swapfile") + or os.path.exists("/swapfile") + ): + cmd0 = "echo -e '\n%s '" % _("Remove swap, please wait...") + if os.path.exists("/media/hdd/swapfile"): system( - '/sbin/swapoff -a; sleep 2; rm -rf /media/hdd/swapfile; sleep 2') - if os.path.exists('/media/usb/swapfile'): + "/sbin/swapoff -a; sleep 2; rm -rf /media/hdd/swapfile; sleep 2") + if os.path.exists("/media/usb/swapfile"): system( - '/sbin/swapoff -a; sleep 2; rm -rf /media/usb/swapfile; sleep 2') - if os.path.exists('/swapfile'): - system('/sbin/swapoff -a; sleep 2; rm -rf /swapfile; sleep 2') + "/sbin/swapoff -a; sleep 2; rm -rf /media/usb/swapfile; sleep 2") + if os.path.exists("/swapfile"): + system("/sbin/swapoff -a; sleep 2; rm -rf /swapfile; sleep 2") - swapfileinstall = ' ' - if os.path.exists('/etc/fstab'): - with open('/etc/fstab', 'r') as f: + swapfileinstall = " " + if os.path.exists("/etc/fstab"): + with open("/etc/fstab", "r") as f: lines = f.read() f.close() - if lines.find('swapfile') != -1: - swapfileinstall = 'swapfileyes' + if lines.find("swapfile") != -1: + swapfileinstall = "swapfileyes" - if swapfileinstall == 'swapfileyes': - with open('/etc/fstab', 'r') as f: + if swapfileinstall == "swapfileyes": + with open("/etc/fstab", "r") as f: lines = f.read() f.close() - fail = '/etc/fstab' - f = open(fail, 'r') + fail = "/etc/fstab" + f = open(fail, "r") content = f.read() f.close() - localfile2 = '/etc/fstab' - temp_file2 = open(localfile2, 'w') + localfile2 = "/etc/fstab" + temp_file2 = open(localfile2, "w") - if lines.find('/media/hdd/swapfile swap swap defaults 0 0') != -1: - temp_file2.write(content.replace( - "/media/hdd/swapfile swap swap defaults 0 0", "")) - elif lines.find('/media/hdd//swapfile swap swap defaults 0 0') != -1: - temp_file2.write(content.replace( - "/media/hdd//swapfile swap swap defaults 0 0", "")) - elif lines.find('/media/usb/swapfile swap swap defaults 0 0') != -1: - temp_file2.write(content.replace( - "/media/usb/swapfile swap swap defaults 0 0", "")) - elif lines.find('/media/usb//swapfile swap swap defaults 0 0') != -1: - temp_file2.write(content.replace( - "/media/usb//swapfile swap swap defaults 0 0", "")) - elif lines.find('//swapfile swap swap defaults 0 0') != -1: - temp_file2.write(content.replace( - "/swapfile swap swap defaults 0 0", "")) - elif lines.find('/swapfile swap swap defaults 0 0') != -1: - temp_file2.write(content.replace( - "/swapfile swap swap defaults 0 0", "")) + if lines.find( + "/media/hdd/swapfile swap swap defaults 0 0") != -1: + temp_file2.write( + content.replace( + "/media/hdd/swapfile swap swap defaults 0 0", "" + ) + ) + elif lines.find("/media/hdd//swapfile swap swap defaults 0 0") != -1: + temp_file2.write( + content.replace( + "/media/hdd//swapfile swap swap defaults 0 0", "" + ) + ) + elif lines.find("/media/usb/swapfile swap swap defaults 0 0") != -1: + temp_file2.write( + content.replace( + "/media/usb/swapfile swap swap defaults 0 0", "" + ) + ) + elif lines.find("/media/usb//swapfile swap swap defaults 0 0") != -1: + temp_file2.write( + content.replace( + "/media/usb//swapfile swap swap defaults 0 0", "" + ) + ) + elif lines.find("//swapfile swap swap defaults 0 0") != -1: + temp_file2.write( + content.replace("/swapfile swap swap defaults 0 0", "") + ) + elif lines.find("/swapfile swap swap defaults 0 0") != -1: + temp_file2.write( + content.replace("/swapfile swap swap defaults 0 0", "") + ) temp_file2.close() - cmd1 = "echo -e '\n\n%s '" % _('Swap file has been deleted.') - self.session.open(Console, _('NeoBoot....'), [cmd0, - cmd1]) + cmd1 = "echo -e '\n\n%s '" % _("Swap file has been deleted.") + self.session.open(Console, _("NeoBoot...."), [cmd0, cmd1]) self.close() else: - self.myClose(_('The swap not exists.')) + self.myClose(_("The swap not exists.")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -2180,23 +2470,35 @@ class IPTVPlayerInstall(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Re-installing IPTVPlayer. \n\nPress red, install and please wait...')) - self['key_red'] = Label(_('Installation')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.panel_update}) + self["lab1"] = Label( + _("Re-installing IPTVPlayer. \n\nPress red, install and please wait...")) + self["key_red"] = Label(_("Installation")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.panel_update}, + ) def panel_update(self): - os.system('cd /tmp; curl -O --ftp-ssl https://gitlab.com/zadmario/e2iplayer/-/archive/master/e2iplayer-master.tar.gz; sleep 2;') - if fileExists('/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer'): + os.system( + "cd /tmp; curl -O --ftp-ssl https://gitlab.com/zadmario/e2iplayer/-/archive/master/e2iplayer-master.tar.gz; sleep 2;" + ) + if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer"): os.system( - 'rm -rf /usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer') - os.system('tar -xzf /tmp/e2iplayer-master.zip -C /tmp; sleep 2; tar -xzf /tmp/e2iplayer-master.tar.gz -C /tmp; sleep 2; mv -f /tmp/e2iplayer-master/IPTVPlayer /usr/lib/enigma2/python/Plugins/Extensions/') - os.system('opkg update > /dev/null 2>&1 ; opkg install python-html > /dev/null 2>&1 ;opkg install python-json > /dev/null 2>&1 && opkg install python-simplejson > /dev/null 2>&1; opkg install python-compression > /dev/null 2>&1; opkg install openssl-bin > /dev/null 2>&1;opkg install duktape > /dev/null 2>&1;opkg install python3-pycurl > /dev/null 2>&1;opkg install python3-e2icjson > /dev/null 2>&1;opkg install python-e2icjson > /dev/null 2>&1;opkg install cmdwrap > /dev/null 2>&1;opkg install exteplayer3 > /dev/null 2>&1;opkg install gstplayer > /dev/null 2>&1') + "rm -rf /usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer") + os.system( + "tar -xzf /tmp/e2iplayer-master.zip -C /tmp; sleep 2; tar -xzf /tmp/e2iplayer-master.tar.gz -C /tmp; sleep 2; mv -f /tmp/e2iplayer-master/IPTVPlayer /usr/lib/enigma2/python/Plugins/Extensions/" + ) + os.system( + "opkg update > /dev/null 2>&1 ; opkg install python-html > /dev/null 2>&1 ;opkg install python-json > /dev/null 2>&1 && opkg install python-simplejson > /dev/null 2>&1; opkg install python-compression > /dev/null 2>&1; opkg install openssl-bin > /dev/null 2>&1;opkg install duktape > /dev/null 2>&1;opkg install python3-pycurl > /dev/null 2>&1;opkg install python3-e2icjson > /dev/null 2>&1;opkg install python-e2icjson > /dev/null 2>&1;opkg install cmdwrap > /dev/null 2>&1;opkg install exteplayer3 > /dev/null 2>&1;opkg install gstplayer > /dev/null 2>&1" + ) - if fileExists('/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer'): - self.session.open(MessageBox, _( - 'The plugin IPTVPlayer installed.'), MessageBox.TYPE_INFO, 10) + if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer"): + self.session.open( + MessageBox, + _("The plugin IPTVPlayer installed."), + MessageBox.TYPE_INFO, + 10, + ) self.close() @@ -2211,15 +2513,17 @@ class MultiStalker(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Re-installing Multi-Stalker. \n\nInstall?')) - self['key_red'] = Label(_('Installation')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.MultiStalker_update}) + self["lab1"] = Label(_("Re-installing Multi-Stalker. \n\nInstall?")) + self["key_red"] = Label(_("Installation")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.MultiStalker_update}, + ) def MultiStalker_update(self): - os.system('rm -f /tmp/*.ipk') + os.system("rm -f /tmp/*.ipk") cmd1 = 'wget -q "--no-check-certificate" https://raw.githubusercontent.com/ziko-ZR1/Multi-Stalker-install/main/Downloads/installer.sh -O - | /bin/sh' - self.session.open(Console, _('Enigma2 restarting..'), [cmd1]) + self.session.open(Console, _("Enigma2 restarting.."), [cmd1]) self.close() @@ -2234,31 +2538,47 @@ class MultibootFlashonline(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label( - _('Re-installing MultibootFlashonline. \n\nInstall?')) - self['key_red'] = Label(_('Installation')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.MultibootFlashonline_update}) + self["lab1"] = Label( + _("Re-installing MultibootFlashonline. \n\nInstall?")) + self["key_red"] = Label(_("Installation")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.MultibootFlashonline_update}, + ) def MultibootFlashonline_update(self): - os.system('rm -f /tmp/*.ipk') - os.system('rm -f /tmp/*.ipk') - if fileExists('/usr/bin/curl'): - os.system('cd /tmp; curl -O --ftp-ssl http://178.63.156.75/paneladdons/Pluginsoe20/multiboot/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk') - if not fileExists('/tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk'): - if fileExists('/usr/bin/fullwget'): - cmd1 = 'cd /tmp; fullwget --no-check-certificate http://178.63.156.75/paneladdons/Pluginsoe20/multiboot/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk' + os.system("rm -f /tmp/*.ipk") + os.system("rm -f /tmp/*.ipk") + if fileExists("/usr/bin/curl"): + os.system( + "cd /tmp; curl -O --ftp-ssl http://178.63.156.75/paneladdons/Pluginsoe20/multiboot/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" + ) + if not fileExists( + "/tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" + ): + if fileExists("/usr/bin/fullwget"): + cmd1 = "cd /tmp; fullwget --no-check-certificate http://178.63.156.75/paneladdons/Pluginsoe20/multiboot/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" system(cmd1) - if not fileExists('/tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk'): - if fileExists('/usr/bin/wget'): - os.system('cd /tmp; wget --no-check-certificate http://178.63.156.75/paneladdons/Pluginsoe20/multiboot/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk') - if fileExists('/tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk'): - cmd2 = 'opkg install --force-overwrite --force-reinstall --force-downgrade /tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk' - self.session.open(Console, _('Enigma2 restarting..'), [cmd2]) + if not fileExists( + "/tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" + ): + if fileExists("/usr/bin/wget"): + os.system( + "cd /tmp; wget --no-check-certificate http://178.63.156.75/paneladdons/Pluginsoe20/multiboot/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" + ) + if fileExists( + "/tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" + ): + cmd2 = "opkg install --force-overwrite --force-reinstall --force-downgrade /tmp/enigma2-plugin-extensions-multiboot-flashonline_6.2_all.ipk" + self.session.open(Console, _("Enigma2 restarting.."), [cmd2]) self.close() else: - self.session.open(MessageBox, _( - 'The plugin not installed.\nAccess Fails with Error code error-panel_install.'), MessageBox.TYPE_INFO, 10) + self.session.open( + MessageBox, + _("The plugin not installed.\nAccess Fails with Error code error-panel_install."), + MessageBox.TYPE_INFO, + 10, + ) self.close() @@ -2273,15 +2593,17 @@ class DreamSatPanel(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Re-installing DreamSatPanel \n\nInstall?')) - self['key_red'] = Label(_('Installation')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.MultiStalker_update}) + self["lab1"] = Label(_("Re-installing DreamSatPanel \n\nInstall?")) + self["key_red"] = Label(_("Installation")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.MultiStalker_update}, + ) def MultiStalker_update(self): - os.system('rm -f /tmp/*.ipk') + os.system("rm -f /tmp/*.ipk") cmd1 = 'wget -q "--no-check-certificate" http://ipkinstall.ath.cx/ipk-install/DreamSatPanel/installer.sh -O - | /bin/sh' - self.session.open(Console, _('Enigma2 restarting..'), [cmd1]) + self.session.open(Console, _("Enigma2 restarting.."), [cmd1]) self.close() @@ -2299,19 +2621,20 @@ class InitializationFormattingDisk(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Select disk.')) - self['key_red'] = Label(_('Formatting')) - self['list'] = List([]) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.myClose, - 'ok': self.deleteback, - 'red': self.deleteback}) - self.backupdir = '/tmp/disk' + self["lab1"] = Label(_("Select disk.")) + self["key_red"] = Label(_("Formatting")) + self["list"] = List([]) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.myClose, "ok": self.deleteback, "red": self.deleteback}, + ) + self.backupdir = "/tmp/disk" self.onShow.append(self.updateInfo) def updateInfo(self): - os.system(' mkdir -p /tmp/disk ') + os.system(" mkdir -p /tmp/disk ") getMountDiskSTB() - self.backupdir = '/tmp/disk' + self.backupdir = "/tmp/disk" if pathExists(self.backupdir) == 0 and createDir(self.backupdir): pass @@ -2319,34 +2642,43 @@ class InitializationFormattingDisk(Screen): for fn in listdir(self.backupdir): imageslist.append(fn) - self['list'].list = imageslist + self["list"].list = imageslist def deleteback(self): - image = self['list'].getCurrent() + image = self["list"].getCurrent() if image: self.diskNeoFormatting = image.strip() message = ( - _('Hard disk: %s Formatting ? Attention! All data will be lost !!!') % image) + _("Hard disk: %s Formatting ? Attention! All data will be lost !!!") % + image) ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Format the disk ???')) + self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Format the disk ???")) def dodeleteback(self, answer): if answer is True: - cmd = "echo -e '\n\n%s '" % _('NeoBoot - Formatting disk .....') + cmd = "echo -e '\n\n%s '" % _("NeoBoot - Formatting disk .....") cmd1 = "echo -e '\n\n%s '" % _( - 'Please wait and dont disconnect the power !!! ....') - cmd2 = 'umount -f -l /dev/' + self.diskNeoFormatting - cmd3 = 'sleep 2; mkfs.ext3 -i 8400 /dev/' + self.diskNeoFormatting - if not fileExists('/etc/vtiversion.info'): - cmd4 = 'sleep 2; tune2fs -O extents,uninit_bg,dir_index /dev/' + self.diskNeoFormatting - elif fileExists('/etc/vtiversion.info'): - cmd4 = 'sleep 5' + "Please wait and dont disconnect the power !!! ...." + ) + cmd2 = "umount -f -l /dev/" + self.diskNeoFormatting + cmd3 = "sleep 2; mkfs.ext3 -i 8400 /dev/" + self.diskNeoFormatting + if not fileExists("/etc/vtiversion.info"): + cmd4 = ( + "sleep 2; tune2fs -O extents,uninit_bg,dir_index /dev/" + + self.diskNeoFormatting + ) + elif fileExists("/etc/vtiversion.info"): + cmd4 = "sleep 5" cmd5 = "echo -e '\n\n%s '" % _( - 'Receiver reboot in 5 seconds... !!!') - cmd6 = 'rm -r /tmp/disk ;sync; sync; sleep 5; /etc/init.d/reboot' - self.session.open(Console, _('Disk Formatting...!'), [ - cmd, cmd1, cmd2, cmd3, cmd4, cmd5, cmd6]) + "Receiver reboot in 5 seconds... !!!") + cmd6 = "rm -r /tmp/disk ;sync; sync; sleep 5; /etc/init.d/reboot" + self.session.open( + Console, + _("Disk Formatting...!"), + [cmd, cmd1, cmd2, cmd3, cmd4, cmd5, cmd6], + ) self.updateInfo() else: self.close() @@ -2359,54 +2691,60 @@ class BootManagers(Screen): __module__ = __name__ skin = """ - + """ def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Test the Boot Manager.')) - self['key_red'] = Label(_('Do not use Boot Manager.')) - self['key_green'] = Label(_('Use Boot Manager.')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.RemoveBootManagers, - 'green': self.CreateBootManagers}) + self["lab1"] = Label(_("Test the Boot Manager.")) + self["key_red"] = Label(_("Do not use Boot Manager.")) + self["key_green"] = Label(_("Use Boot Manager.")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + { + "back": self.close, + "red": self.RemoveBootManagers, + "green": self.CreateBootManagers, + }, + ) def CreateBootManagers(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): cmd0 = "echo -e '\n\n%s '" % _( - 'Creation Boot Manager , please wait...') + "Creation Boot Manager , please wait...") if getBoxHostName() == "et5x00": - cmd1 = 'cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmips' + cmd1 = "cp -af " + LinkNeoBoot + "/bin/neoinitmips /sbin/neoinitmips" else: - cmd1 = 'cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmipsvu' + cmd1 = "cp -af " + LinkNeoBoot + "/bin/neoinitmips /sbin/neoinitmipsvu" cmd2 = "echo -e '\n\n%s '" % _( - 'Creation Boot Manager complete\nThe boot manager has been activated ! ') - self.session.open(Console, _('NeoBoot....'), [cmd0, - cmd1, - cmd2]) + "Creation Boot Manager complete\nThe boot manager has been activated ! " + ) + self.session.open(Console, _("NeoBoot...."), [cmd0, cmd1, cmd2]) self.close() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def RemoveBootManagers(self): - if not fileExists('/.multinfo'): + if not fileExists("/.multinfo"): cmd0 = "echo -e '\n\n%s '" % _( - 'Creation Boot Manager , please wait...') + "Creation Boot Manager , please wait...") if getBoxHostName() == "et5x00": - cmd1 = 'cp -af ' + LinkNeoBoot + '/bin/neoinitmipsvu /sbin/neoinitmips' + cmd1 = "cp -af " + LinkNeoBoot + "/bin/neoinitmipsvu /sbin/neoinitmips" else: - cmd1 = 'cp -af ' + LinkNeoBoot + '/bin/neoinitmipsvu /sbin/neoinitmipsvu' + cmd1 = ( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitmipsvu /sbin/neoinitmipsvu") cmd2 = "echo -e '\n\n%s '" % _( - 'Creation Boot Manager complete\nBoot manager has been hidden !') - self.session.open(Console, _('NeoBoot....'), [cmd0, - cmd1, - cmd2]) + "Creation Boot Manager complete\nBoot manager has been hidden !" + ) + self.session.open(Console, _("NeoBoot...."), [cmd0, cmd1, cmd2]) self.close() else: self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -2424,72 +2762,79 @@ class DiskLabelSet(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Label')) - self['key_red'] = Label(_('Set Label')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.SetLabelDisk}) + self["lab1"] = Label(_("Label")) + self["key_red"] = Label(_("Set Label")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.SetLabelDisk}, + ) def SetLabelDisk(self): - # os.system("tune2fs -l /dev/sd?? | awk '/UUID/ {print $NF}' > /tmp/.myuuid") - # os.system("tune2fs -l %s | awk '/UUID/ {print $NF}' > /tmp/.myuuid" % (getLocationMultiboot())) - if os.path.exists('/media/hdd/ImageBoot'): - locatin_neo = '/media/hdd' - elif os.path.exists('/media/usb/ImageBoot'): - locatin_neo = '/media/usb' - if os.path.exists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: + if os.path.exists("/media/hdd/ImageBoot"): + locatin_neo = "/media/hdd" + elif os.path.exists("/media/usb/ImageBoot"): + locatin_neo = "/media/usb" + if os.path.exists("/proc/mounts"): + with open("/proc/mounts", "r") as f: lines = f.read() f.close() - cmd = "echo -e '\n\n%s '" % _('NeoBoot - Label disk .....') - cmd1 = "echo -e '\n\n%s'" % _('Please wait') - if lines.find('/dev/sda1 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sda1') - if lines.find('/dev/sdb1 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sdb1') - if lines.find('/dev/sda2 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sda2') - if lines.find('/dev/sdb2 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sdb2') - if lines.find('/dev/sdc1 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sdc1') - if lines.find('/dev/sdd1 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sdd1') - if lines.find('/dev/sde1 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sde1') - if lines.find('/dev/sdf1 /media/hdd') != -1: - os.system('tune2fs -L hdd /dev/sdf1') - if lines.find('/dev/sda1 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sda1') - if lines.find('/dev/sdb1 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sdb1') - if lines.find('/dev/sda2 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sda2') - if lines.find('/dev/sdb2 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sdb2') - if lines.find('/dev/sdc1 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sdc1') - if lines.find('/dev/sdd1 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sdd1') - if lines.find('/dev/sde1 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sde1') - if lines.find('/dev/sdf1 /media/usb') != -1: - os.system('tune2fs -L usb /dev/sdf1') - cmd2 = "echo -e '\n\n%s '" % _('Label set OK') + cmd = "echo -e '\n\n%s '" % _("NeoBoot - Label disk .....") + cmd1 = "echo -e '\n\n%s'" % _("Please wait") + if lines.find("/dev/sda1 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sda1") + if lines.find("/dev/sdb1 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sdb1") + if lines.find("/dev/sda2 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sda2") + if lines.find("/dev/sdb2 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sdb2") + if lines.find("/dev/sdc1 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sdc1") + if lines.find("/dev/sdd1 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sdd1") + if lines.find("/dev/sde1 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sde1") + if lines.find("/dev/sdf1 /media/hdd") != -1: + os.system("tune2fs -L hdd /dev/sdf1") + if lines.find("/dev/sda1 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sda1") + if lines.find("/dev/sdb1 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sdb1") + if lines.find("/dev/sda2 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sda2") + if lines.find("/dev/sdb2 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sdb2") + if lines.find("/dev/sdc1 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sdc1") + if lines.find("/dev/sdd1 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sdd1") + if lines.find("/dev/sde1 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sde1") + if lines.find("/dev/sdf1 /media/usb") != -1: + os.system("tune2fs -L usb /dev/sdf1") + cmd2 = "echo -e '\n\n%s '" % _("Label set OK") - with open('/etc/fstab', 'r') as f: + with open("/etc/fstab", "r") as f: flines = f.read() f.close() - if flines.find('' + getMyUUID() + '') != -1: + if flines.find("" + getMyUUID() + "") != -1: cmd3 = "echo -e '\n%s '" % _( - 'UUID exists or neoboot not installed yet\nAfter installing the plugin, give uuid\n\nReboot...') + "UUID exists or neoboot not installed yet\nAfter installing the plugin, give uuid\n\nReboot..." + ) else: - os.system('echo UUID=' + getMyUUID() + ' ' + - locatin_neo + ' auto defaults 0 0 >> /etc/fstab') - cmd3 = "echo -e '\n%s '" % _('UUID set OK\n\nReboot...') - cmd4 = 'sleep 10; reboot -f' - self.session.open(Console, _('Disk Label...!'), - [cmd, cmd1, cmd2, cmd3, cmd4]) + os.system( + "echo UUID=" + + getMyUUID() + + " " + + locatin_neo + + " auto defaults 0 0 >> /etc/fstab" + ) + cmd3 = "echo -e '\n%s '" % _("UUID set OK\n\nReboot...") + cmd4 = "sleep 10; reboot -f" + self.session.open( + Console, _("Disk Label...!"), [cmd, cmd1, cmd2, cmd3, cmd4] + ) class MultiBootMyHelp(Screen): @@ -2504,32 +2849,39 @@ class MultiBootMyHelp(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = ScrollLabel('') - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, - 'ok': self.close, - 'up': self['lab1'].pageUp, - 'left': self['lab1'].pageUp, - 'down': self['lab1'].pageDown, - 'right': self['lab1'].pageDown}) - self['lab1'].hide() + self["lab1"] = ScrollLabel("") + self["actions"] = ActionMap( + ["WizardActions", "ColorActions", "DirectionActions"], + { + "back": self.close, + "ok": self.close, + "up": self["lab1"].pageUp, + "left": self["lab1"].pageUp, + "down": self["lab1"].pageDown, + "right": self["lab1"].pageDown, + }, + ) + self["lab1"].hide() self.updatetext() def updatetext(self): - message = '' - message += 'NeoBoot Version ' + PLUGINVERSION + ' Enigma2\n\n' - message += 'NeoBoot is based on EGAMIBoot < mod by gutosie >\n\n' - message += 'EGAMIBoot author allowed neoboot development and editing - Thanks\n\n' - message += 'nfidump by gutemine - Thanks\n\n' - message += 'ubi_reader by Jason Pruitt - Thanks\n\n' - message += 'Translation by gutosie and other people!\n\n' - message += _('Thank you to everyone not here for helping to improve NeoBoot \n\n') - message += _('Successful fun :)\n\n') - self['lab1'].show() - self['lab1'].setText(message) + message = "" + message += "NeoBoot Version " + PLUGINVERSION + " Enigma2\n\n" + message += "NeoBoot is based on EGAMIBoot < mod by gutosie >\n\n" + message += ( + "EGAMIBoot author allowed neoboot development and editing - Thanks\n\n" + ) + message += "nfidump by gutemine - Thanks\n\n" + message += "ubi_reader by Jason Pruitt - Thanks\n\n" + message += "Translation by gutosie and other people!\n\n" + message += _( + "Thank you to everyone not here for helping to improve NeoBoot \n\n" + ) + message += _("Successful fun :)\n\n") + self["lab1"].show() + self["lab1"].setText(message) -### ______\\\\\\----for plugin----////_____### - class MyHelpNeo(Screen): if isFHD(): skin = """ @@ -2544,33 +2896,51 @@ class MyHelpNeo(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = ScrollLabel('') - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, - 'ok': self.close, - 'up': self['lab1'].pageUp, - 'left': self['lab1'].pageUp, - 'down': self['lab1'].pageDown, - 'right': self['lab1'].pageDown}) - self['lab1'].hide() + self["lab1"] = ScrollLabel("") + self["actions"] = ActionMap( + ["WizardActions", "ColorActions", "DirectionActions"], + { + "back": self.close, + "ok": self.close, + "up": self["lab1"].pageUp, + "left": self["lab1"].pageUp, + "down": self["lab1"].pageDown, + "right": self["lab1"].pageDown, + }, + ) + self["lab1"].hide() self.updatetext() def updatetext(self): - message = _('NeoBoot Ver. ' + PLUGINVERSION + - ' Enigma2\n\nDuring the entire installation process does not restart the receiver !!!\n\n') - message += _('NeoBoot Ver. updates ' + UPDATEVERSION + ' \n\n') - message += _('NeoBoot Ver. updates ' + UPDATEVERSION + ' \n\n') message = _( - 'For proper operation NeoBota type device is required USB stick or HDD, formatted on your system files Linux ext3 or ext4..\n\n') - message += _('1. If you do not have a media formatted with the ext3 or ext4 is open to the Device Manager , select the drive and format it.\n\n') - message += _('2. Go to the device manager and install correctly hdd and usb ...\n\n') - message += _('3. Install NeoBota on the selected device.\n\n') - message += _('4. Install the needed packages...\n\n') - message += _('5. For proper installation NenoBota receiver must be connected to the Internet.\n\n') - message += _('6. In the event of a problem with the installation cancel and inform the author of the plug of a problem.\n\n') - message += _('Buy a satellite tuner in the store: http://www.expert-tvsat.com/\n') - message += _('Have fun !!!') - self['lab1'].show() - self['lab1'].setText(message) + "NeoBoot Ver. " + + PLUGINVERSION + + " Enigma2\n\nDuring the entire installation process does not restart the receiver !!!\n\n") + message += _("NeoBoot Ver. updates " + UPDATEVERSION + " \n\n") + message += _("NeoBoot Ver. updates " + UPDATEVERSION + " \n\n") + message = _( + "For proper operation NeoBota type device is required USB stick or HDD, formatted on your system files Linux ext3 or ext4..\n\n" + ) + message += _( + "1. If you do not have a media formatted with the ext3 or ext4 is open to the Device Manager , select the drive and format it.\n\n" + ) + message += _( + "2. Go to the device manager and install correctly hdd and usb ...\n\n" + ) + message += _("3. Install NeoBota on the selected device.\n\n") + message += _("4. Install the needed packages...\n\n") + message += _( + "5. For proper installation NenoBota receiver must be connected to the Internet.\n\n" + ) + message += _( + "6. In the event of a problem with the installation cancel and inform the author of the plug of a problem.\n\n" + ) + message += _( + "Buy a satellite tuner in the store: http://www.expert-tvsat.com/\n" + ) + message += _("Have fun !!!") + self["lab1"].show() + self["lab1"].setText(message) class Opis(Screen): @@ -2587,7 +2957,7 @@ class Opis(Screen): - + """ else: skin = """ @@ -2602,87 +2972,117 @@ class Opis(Screen): - + """ __module__ = __name__ def __init__(self, session): Screen.__init__(self, session) - self['key_red'] = Label(_('Remove NeoBoot of STB')) - self['key_green'] = Label(_('Install NeoBOOT from github')) - self['lab1'] = ScrollLabel('') - self['lab2'] = Label(_('' + getNeoActivatedtest() + '')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, - 'red': self.delete, - 'green': self.neoinstallgithub, - 'ok': self.close, - 'up': self['lab1'].pageUp, - 'left': self['lab1'].pageUp, - 'down': self['lab1'].pageDown, - 'right': self['lab1'].pageDown}) - self['lab1'].hide() + self["key_red"] = Label(_("Remove NeoBoot of STB")) + self["key_green"] = Label(_("Install NeoBOOT from github")) + self["lab1"] = ScrollLabel("") + self["lab2"] = Label(_("" + getNeoActivatedtest() + "")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions", "DirectionActions"], + { + "back": self.close, + "red": self.delete, + "green": self.neoinstallgithub, + "ok": self.close, + "up": self["lab1"].pageUp, + "left": self["lab1"].pageUp, + "down": self["lab1"].pageDown, + "right": self["lab1"].pageDown, + }, + ) + self["lab1"].hide() self.updatetext() def updatetext(self): - message = _('\\ NeoBoot Ver. ' + PLUGINVERSION + - ' - NeoBoot Ver. updates ' + UPDATEVERSION + '//\n\n') - message += _('\\----------NEOBOOT - VIP FULL VERSION----------/\\n') - message += _('Get the full version of the multiboot plugin.\n') - message += _('Send an e-mail request for the neoboot vip version.\n') - message += _('e-mail: krzysztofgutosie@gmail.com\n\n') - message += _(' ' + getBoxHostName() + - ' Ethernet MAC: ' + getBoxMacAddres() + '\n') - message += _('----------------Free donate----------------\n') - message += _('Spendenbetrag\nDonaco\nDarowizna\nПожертвование\n') - message += _('Donate to the project\n') - message += _('- Access to the latest version\n') - message += _('- Online support\n') - message += _('- Full version\n') - message += _('- More information email\n') - message += _('We thank you for any help\n') - message += _('If you want to support the neoboot project, you can do so by contacting us by e-mail:\n') - message += _(' krzysztofgutosie@gmail.com\n\n') - message += _(' PayPal adress: krzysztofgutosie@gmail.com\n') - message += _('---------------- ¯\\_(ツ)_/¯ ----------------\\n\\n') - message += _('1. Requirements: For proper operation of the device NeoBota are required USB stick or HDD.\n\n') - message += _('2. NeoBot is fully automated\n\n') - message += _('3. To install the new software in multiboot, you must send the software file compressed in zip format via ftp to the ImagesUpload directory, or download from the network.\n\n') - message += _('4. For proper installation and operation of additional image multiboot, use only the image intended for your receiver. !!!\n\n') - message += _('5. By installing the multiboot images of a different type than for your model STB DOING THIS AT YOUR OWN RISK !!!\n\n') - message += _('6. The installed to multiboot images, it is not indicated update to a newer version.\n\n') - message += _('The authors plug NeoBot not liable for damage a receiver, NeoBoota incorrect use or installation of unauthorized additions or images.!!!\n\n') - message += _('\nCompletely uninstall NeoBota: \nIf you think NeoBot not you need it, you can uninstall it.\nTo uninstall now press the red button on the remote control.\n\n') - message += _('Have fun !!!') - self['lab1'].show() - self['lab1'].setText(message) + message = _( + "\\ NeoBoot Ver. " + + PLUGINVERSION + + " - NeoBoot Ver. updates " + + UPDATEVERSION + + "//\n\n" + ) + message += _("\\----------NEOBOOT - VIP FULL VERSION----------/\\n") + message += _("Get the full version of the multiboot plugin.\n") + message += _("Send an e-mail request for the neoboot vip version.\n") + message += _("e-mail: krzysztofgutosie@gmail.com\n\n") + message += _(" " + + getBoxHostName() + + " Ethernet MAC: " + + getBoxMacAddres() + + "\n") + message += _("----------------Free donate----------------\n") + message += _("Spendenbetrag\nDonaco\nDarowizna\nПожертвование\n") + message += _("Donate to the project\n") + message += _("- Access to the latest version\n") + message += _("- Online support\n") + message += _("- Full version\n") + message += _("- More information email\n") + message += _("We thank you for any help\n") + message += _( + "If you want to support the neoboot project, you can do so by contacting us by e-mail:\n" + ) + message += _(" krzysztofgutosie@gmail.com\n\n") + message += _(" PayPal adress: krzysztofgutosie@gmail.com\n") + message += _("---------------- ¯\\_(ツ)_/¯ ----------------\\n\\n") + message += _( + "1. Requirements: For proper operation of the device NeoBota are required USB stick or HDD.\n\n" + ) + message += _("2. NeoBot is fully automated\n\n") + message += _( + "3. To install the new software in multiboot, you must send the software file compressed in zip format via ftp to the ImagesUpload directory, or download from the network.\n\n" + ) + message += _( + "4. For proper installation and operation of additional image multiboot, use only the image intended for your receiver. !!!\n\n" + ) + message += _( + "5. By installing the multiboot images of a different type than for your model STB DOING THIS AT YOUR OWN RISK !!!\n\n" + ) + message += _( + "6. The installed to multiboot images, it is not indicated update to a newer version.\n\n" + ) + message += _( + "The authors plug NeoBot not liable for damage a receiver, NeoBoota incorrect use or installation of unauthorized additions or images.!!!\n\n" + ) + message += _( + "\nCompletely uninstall NeoBota: \nIf you think NeoBot not you need it, you can uninstall it.\nTo uninstall now press the red button on the remote control.\n\n" + ) + message += _("Have fun !!!") + self["lab1"].show() + self["lab1"].setText(message) def neoinstallgithub(self): - message = _('Are you sure you want to reinstall neoboot from github.') + message = _("Are you sure you want to reinstall neoboot from github.") ybox = self.session.openWithCallback( - self.neogithub, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Install.')) + self.neogithub, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Install.")) def neogithub(self, answer): - if fileExists('/.multinfo'): + if fileExists("/.multinfo"): self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) self.close() else: if answer is True: - os.system('touch /tmp/.upneo; rm -r /tmp/.*') - if fileExists('' + LinkNeoBoot + '/.location'): - system('rm -f ' + LinkNeoBoot + '/.location') - if fileExists('/usr/bin/curl'): - cmd1 = 'rm -f /usr/lib/periodon/.kodn; curl -kLs https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh|sh' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + os.system("touch /tmp/.upneo; rm -r /tmp/.*") + if fileExists("" + LinkNeoBoot + "/.location"): + system("rm -f " + LinkNeoBoot + "/.location") + if fileExists("/usr/bin/curl"): + cmd1 = "rm -f /usr/lib/periodon/.kodn; curl -kLs https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh|sh" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() - elif fileExists('/usr/bin/wget'): - cmd1 = 'rm -f /usr/lib/periodon/.kodn; cd /tmp; rm ./*.sh; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + elif fileExists("/usr/bin/wget"): + cmd1 = "rm -f /usr/lib/periodon/.kodn; cd /tmp; rm ./*.sh; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() - elif fileExists('/usr/bin/fullwget'): - cmd1 = 'rm -f /usr/lib/periodon/.kodn; cd /tmp; rm ./*.sh; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + elif fileExists("/usr/bin/fullwget"): + cmd1 = "rm -f /usr/lib/periodon/.kodn; cd /tmp; rm ./*.sh; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() else: pass @@ -2690,47 +3090,58 @@ class Opis(Screen): self.close() def delete(self): - message = _('Are you sure you want to completely remove NeoBoota of your image?\n\nIf you choose so all directories NeoBoota will be removed.\nA restore the original image settings Flash.') + message = _( + "Are you sure you want to completely remove NeoBoota of your image?\n\nIf you choose so all directories NeoBoota will be removed.\nA restore the original image settings Flash." + ) ybox = self.session.openWithCallback( - self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Removed successfully.')) + self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Removed successfully.")) def mbdelete(self, answer): if answer is True: for line in open("/etc/hostname"): - if "dm500hd" not in line or "dm800" not in line or "dm800se" not in line or "dm8000" not in line: - os.system('touch /tmp/.upneo') - if fileExists('/usr/lib/periodon/.activatedmac'): + if ( + "dm500hd" not in line + or "dm800" not in line + or "dm800se" not in line + or "dm8000" not in line + ): + os.system("touch /tmp/.upneo") + if fileExists("/usr/lib/periodon/.activatedmac"): os.system(("rm -r /usr/lib/periodon ")) - if fileExists('/etc/rcS.d/S99neo.local'): - system('rm -r /etc/rcS.d/S99neo.local') - if fileExists('/etc/name'): - system('rm -r /etc/name') - if fileExists('/usr/lib/libpngneo'): - system('rm -r /usr/lib/libpngneo') - if fileExists('/etc/fstab.org'): - system('rm -r /etc/fstab; mv /etc/fstab.org /etc/fstab') - if fileExists('/etc/init.d/volatile-media.sh.org'): - system(' mv /etc/init.d/volatile-media.sh.org /etc/init.d/volatile-media.sh; rm -r /etc/init.d/volatile-media.sh.org; chmod 755 /etc/init.d/volatile-media.sh ') - if os.path.isfile('%sImageBoot/.neonextboot' % getNeoLocation()): - os.system('rm -f /etc/neoimage; rm -f /etc/imageboot; rm -f %sImageBoot/.neonextboot; rm -f %sImageBoot/.version; rm -f %sImageBoot/.Flash; ' % - (getNeoLocation(), getNeoLocation(), getNeoLocation())) - if os.path.isfile('%sImagesUpload/.kernel ' % getNeoLocation()): - os.system('rm -r %sImagesUpload/.kernel' % getNeoLocation()) - cmd = "echo -e '\n\n%s '" % _('Recovering setting....\n') - cmd1 = 'rm -R ' + LinkNeoBoot + '' - cmd2 = 'rm -R /sbin/neoinit*' - cmd3 = 'ln -sfn /sbin/init.sysvinit /sbin/init' - cmd4 = 'rm -rf /usr/lib/enigma2/python/Tools/Testinout.p*' - cmd5 = 'rm -rf /usr/lib/periodon' + if fileExists("/etc/rcS.d/S99neo.local"): + system("rm -r /etc/rcS.d/S99neo.local") + if fileExists("/etc/name"): + system("rm -r /etc/name") + if fileExists("/usr/lib/libpngneo"): + system("rm -r /usr/lib/libpngneo") + if fileExists("/etc/fstab.org"): + system("rm -r /etc/fstab; mv /etc/fstab.org /etc/fstab") + if fileExists("/etc/init.d/volatile-media.sh.org"): + system( + " mv /etc/init.d/volatile-media.sh.org /etc/init.d/volatile-media.sh; rm -r /etc/init.d/volatile-media.sh.org; chmod 755 /etc/init.d/volatile-media.sh " + ) + if os.path.isfile("%sImageBoot/.neonextboot" % getNeoLocation()): + os.system( + "rm -f /etc/neoimage; rm -f /etc/imageboot; rm -f %sImageBoot/.neonextboot; rm -f %sImageBoot/.version; rm -f %sImageBoot/.Flash; " % + (getNeoLocation(), getNeoLocation(), getNeoLocation())) + if os.path.isfile("%sImagesUpload/.kernel " % getNeoLocation()): + os.system("rm -r %sImagesUpload/.kernel" % getNeoLocation()) + cmd = "echo -e '\n\n%s '" % _("Recovering setting....\n") + cmd1 = "rm -R " + LinkNeoBoot + "" + cmd2 = "rm -R /sbin/neoinit*" + cmd3 = "ln -sfn /sbin/init.sysvinit /sbin/init" + cmd4 = "rm -rf /usr/lib/enigma2/python/Tools/Testinout.p*" + cmd5 = "rm -rf /usr/lib/periodon" cmd6 = 'opkg install --force-maintainer --force-reinstall --force-overwrite --force-downgrade volatile-media; sleep 10; PATH=/sbin:/bin:/usr/sbin:/usr/bin; echo -n "Rebooting... "; reboot -d -f' - self.session.open(Console, _('NeoBot was removed !!! \nThe changes will be visible only after complete restart of the receiver.'), [cmd, - cmd1, - cmd2, - cmd3, - cmd4, - cmd5, - cmd6]) + self.session.open( + Console, + _( + "NeoBot was removed !!! \nThe changes will be visible only after complete restart of the receiver." + ), + [cmd, cmd1, cmd2, cmd3, cmd4, cmd5, cmd6], + ) self.close() else: self.close() @@ -2751,23 +3162,25 @@ class ReinstallKernel(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = Label(_('Re-installing the kernel. \n\nInstall?')) - self['key_red'] = Label(_('Installation')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, - 'red': self.InfoCheck}) + self["lab1"] = Label(_("Re-installing the kernel. \n\nInstall?")) + self["key_red"] = Label(_("Installation")) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"back": self.close, "red": self.InfoCheck}, + ) def InfoCheck(self): - if fileExists('/.multinfo'): - if getCPUtype() == 'MIPS': - if not fileExists('/boot/' + getBoxHostName() + '.vmlinux.gz'): - mess = _('Update available only from the image Flash.') + if fileExists("/.multinfo"): + if getCPUtype() == "MIPS": + if not fileExists("/boot/" + getBoxHostName() + ".vmlinux.gz"): + mess = _("Update available only from the image Flash.") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: self.kernel_update() - elif getCPUtype() == 'ARMv7': - if not fileExists('/boot/zImage.' + getBoxHostName() + ''): - mess = _('Update available only from the image Flash.') + elif getCPUtype() == "ARMv7": + if not fileExists("/boot/zImage." + getBoxHostName() + ""): + mess = _("Update available only from the image Flash.") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: self.kernel_update() @@ -2776,17 +3189,22 @@ class ReinstallKernel(Screen): self.kernel_update() def kernel_update(self): - if not fileCheck('' + LinkNeoBoot + '/.location'): + if not fileCheck("" + LinkNeoBoot + "/.location"): pass else: - os.system('echo "Flash " > ' + getNeoLocation() + - 'ImageBoot/.neonextboot') - out = open('' + getNeoLocation() + - 'ImagesUpload/.kernel/used_flash_kernel', 'w') - out.write('Used Kernel: Flash') + os.system( + 'echo "Flash " > ' + + getNeoLocation() + + "ImageBoot/.neonextboot") + out = open( + "" + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel", + "w") + out.write("Used Kernel: Flash") out.close() - cmd1 = 'rm -f /home/root/*.ipk; opkg download kernel-image; sleep 2; opkg install --force-maintainer --force-reinstall --force-overwrite --force-downgrade /home/root/*.ipk; opkg configure update-modules; rm -f /home/root/*.ipk' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + cmd1 = "rm -f /home/root/*.ipk; opkg download kernel-image; sleep 2; opkg install --force-maintainer --force-reinstall --force-overwrite --force-downgrade /home/root/*.ipk; opkg configure update-modules; rm -f /home/root/*.ipk" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() @@ -2804,35 +3222,45 @@ class neoDONATION(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = ScrollLabel('') - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, - 'ok': self.close, - 'up': self['lab1'].pageUp, - 'left': self['lab1'].pageUp, - 'down': self['lab1'].pageDown, - 'right': self['lab1'].pageDown}) - self['lab1'].hide() + self["lab1"] = ScrollLabel("") + self["actions"] = ActionMap( + ["WizardActions", "ColorActions", "DirectionActions"], + { + "back": self.close, + "ok": self.close, + "up": self["lab1"].pageUp, + "left": self["lab1"].pageUp, + "down": self["lab1"].pageDown, + "right": self["lab1"].pageDown, + }, + ) + self["lab1"].hide() self.updatetext() def updatetext(self): - message = _('NeoBoot Ver. ' + PLUGINVERSION + ' Enigma2\n') - message += _('NeoBoot Ver. updates ' + UPDATEVERSION + ' \n\n') - message += _('If you want to support the neoboot project, you can do so by contacting us by e-mail:\n') - message += _(' krzysztofgutosie@gmail.com\n\n') - message += _(' PayPal adress: krzysztofgutosie@gmail.com\n') - message += _(' ' + getBoxHostName() + - ' Ethernet MAC: ' + getBoxMacAddres() + '\n') - message += _('----------------Free donate----------------\n') - message += _('Spendenbetrag\nDonaco\nDarowizna\nПожертвование\n') - message += _('Donate to the project\n') - message += _('- Access to the latest version\n') - message += _('- Online support\n') - message += _('- More information email\n') - message += _('We thank you for any help\n') - message += _('----------------Free donate----------------\n') - message += _('¯\\_(ツ)_/¯ Have fun !!!') - self['lab1'].show() - self['lab1'].setText(message) + message = _("NeoBoot Ver. " + PLUGINVERSION + " Enigma2\n") + message += _("NeoBoot Ver. updates " + UPDATEVERSION + " \n\n") + message += _( + "If you want to support the neoboot project, you can do so by contacting us by e-mail:\n" + ) + message += _(" krzysztofgutosie@gmail.com\n\n") + message += _(" PayPal adress: krzysztofgutosie@gmail.com\n") + message += _(" " + + getBoxHostName() + + " Ethernet MAC: " + + getBoxMacAddres() + + "\n") + message += _("----------------Free donate----------------\n") + message += _("Spendenbetrag\nDonaco\nDarowizna\nПожертвование\n") + message += _("Donate to the project\n") + message += _("- Access to the latest version\n") + message += _("- Online support\n") + message += _("- More information email\n") + message += _("We thank you for any help\n") + message += _("----------------Free donate----------------\n") + message += _("¯\\_(ツ)_/¯ Have fun !!!") + self["lab1"].show() + self["lab1"].setText(message) def myboot(session, **kwargs): @@ -2842,4 +3270,10 @@ def myboot(session, **kwargs): def Plugins(path, **kwargs): global pluginpath pluginpath = path - return PluginDescriptor(name='NeoBoot', description='MENU NeoBoot', icon=None, where=PluginDescriptor.WHERE_PLUGINMENU, fnc=myboot) + return PluginDescriptor( + name="NeoBoot", + description="MENU NeoBoot", + icon=None, + where=PluginDescriptor.WHERE_PLUGINMENU, + fnc=myboot, + ) diff --git a/NeoBoot/images/novaler4kpro.png b/NeoBoot/images/novaler4kpro.png new file mode 100755 index 0000000..af9a088 Binary files /dev/null and b/NeoBoot/images/novaler4kpro.png differ diff --git a/NeoBoot/neoskins/biko/skin_biko73.py b/NeoBoot/neoskins/biko/skin_biko73.py index a3f2635..04b58de 100644 --- a/NeoBoot/neoskins/biko/skin_biko73.py +++ b/NeoBoot/neoskins/biko/skin_biko73.py @@ -1,22 +1,19 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# biko73 = ./neoskins/biko/skin_biko73.py -# ImageChooseFULLHD - biko73 ImageChooseFULLHD = """ - - + + - - + + - + Format:%A, %d %B %Y @@ -26,46 +23,46 @@ ImageChooseFULLHD = """ Format::%S - + - - - - - - - - + + + + + + + + - - + + - - - - - + + + + + - - - + + + - + - + - + - + - + @@ -73,5 +70,3 @@ ImageChooseFULLHD = """ """ - -### diff --git a/NeoBoot/neoskins/biko2/skin_biko73.py b/NeoBoot/neoskins/biko2/skin_biko73.py index ff66049..c46a2ea 100644 --- a/NeoBoot/neoskins/biko2/skin_biko73.py +++ b/NeoBoot/neoskins/biko2/skin_biko73.py @@ -1,10 +1,7 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# biko73 = ./neoskins/biko/skin_biko73.py -# ImageChooseFULLHD - biko73 ImageChooseFULLHD = """ @@ -32,8 +29,8 @@ ImageChooseFULLHD = """ - - + + @@ -46,7 +43,7 @@ ImageChooseFULLHD = """ - + @@ -72,5 +69,3 @@ ImageChooseFULLHD = """ """ - -### diff --git a/NeoBoot/neoskins/cobaltfhd/skin_cobaltfhd.py b/NeoBoot/neoskins/cobaltfhd/skin_cobaltfhd.py index 9f8733c..efff15f 100644 --- a/NeoBoot/neoskins/cobaltfhd/skin_cobaltfhd.py +++ b/NeoBoot/neoskins/cobaltfhd/skin_cobaltfhd.py @@ -1,32 +1,29 @@ -# skin = ./neoskins/cobaltfhd_skin - mod. gutosie - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# ImageChooseFULLHD ImageChooseFULLHD = """ - - - + + + Format:%A %e %B %Y - - + + Format:%H:%M:%S - - + + - - - Name - - - Name - - Progress + + + Name + + + Name + + Progress - + StartTime Format:%H:%M @@ -34,41 +31,40 @@ ImageChooseFULLHD = """ EndTime Format:%H:%M - + - + - - - - + + + + - - - + + + - + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + """ -### diff --git a/NeoBoot/neoskins/darog69/skin_darog69.py b/NeoBoot/neoskins/darog69/skin_darog69.py index 95773f3..f120bbd 100644 --- a/NeoBoot/neoskins/darog69/skin_darog69.py +++ b/NeoBoot/neoskins/darog69/skin_darog69.py @@ -1,10 +1,7 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# darog69 = ./neoskins/darog69/skin_darog69.py -# ImageChooseFULLHD - darog69 ImageChooseFULLHD = """ @@ -55,5 +52,3 @@ ImageChooseFULLHD = """ """ - -### diff --git a/NeoBoot/neoskins/darog69_Ustym4kpro/skin_darog69_Ustym4kpro.py b/NeoBoot/neoskins/darog69_Ustym4kpro/skin_darog69_Ustym4kpro.py index a72919b..dc6f999 100644 --- a/NeoBoot/neoskins/darog69_Ustym4kpro/skin_darog69_Ustym4kpro.py +++ b/NeoBoot/neoskins/darog69_Ustym4kpro/skin_darog69_Ustym4kpro.py @@ -1,10 +1,7 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# darog69 = ./neoskins/darog69_Ustym4kpro/skin_darog69_Ustym4kpro.py -# ImageChooseFULLHD - darog69_Ustym4kpro ImageChooseFULLHD = """ @@ -55,5 +52,3 @@ ImageChooseFULLHD = """ """ - -### diff --git a/NeoBoot/neoskins/default.py b/NeoBoot/neoskins/default.py index e84661c..8b59351 100644 --- a/NeoBoot/neoskins/default.py +++ b/NeoBoot/neoskins/default.py @@ -1,36 +1,8 @@ -# skin = ./meoskins/defaul_skin - gutosie - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# Colors (#AARRGGBB) -# ____Recommended colors - Zalecane kolory : -# color name="white" value="#ffffff" -# color name="darkwhite" value="#00dddddd" -# color name="red" value="#f23d21" -# color name="green" value="#389416" -# color name="blue" value="#0064c7" -# color name="yellow" value="#bab329" -# color name="orange" value="#00ffa500" -# color name="gray" value="#808080" -# color name="lightgrey" value="#009b9b9b" -# green = '#00389416' lub #00389416 -# red = '#00ff2525' -# yellow = '#00ffe875' -# orange = '#00ff7f50' -# seledynowy = #00FF00 -# jasny-blue = #99FFFF -# Zamiast font=Regular ktory nie rozpoznaje polskich znakow np. na VTi, mozesz zmienic na ponizsze font="*: -# font - genel -# font - baslk -# font - tasat -# font - dugme - -# - -# ____ Skin Ultra HD - ImageChooseFULLHD ___ mod. gutosie___ ImageChooseFULLHD = """ @@ -88,7 +60,6 @@ ImageChooseFULLHD = """ """ -# ____ Skin Ultra HD - ImageChooseULTRAHD ___ mod. gutosie___ ImageChooseULTRAHD = """ @@ -137,7 +108,6 @@ ImageChooseULTRAHD = """ """ -# ____ Skin HD - ImageChoose ___mod. gutosie ___ ImageChooseHD = """ \n \n @@ -189,7 +159,6 @@ ImageChooseHD = """ """ -# ____ Skin FULLHD - MyUpgradeFULLHD ___mod. gutosie ___ MyUpgradeFULLHD = """ @@ -208,7 +177,6 @@ MyUpgradeFULLHD = """ """ -# ____ Skin UltraHD - MyUpgradeUltraHD ___mod. gutosie ___ MyUpgradeUltraHD = """ @@ -225,7 +193,6 @@ MyUpgradeUltraHD = """ """ -# ____ Skin MyUpgradeHD - MyUpgradeHD ___mod. gutosie ___ MyUpgradeHD = """ @@ -244,7 +211,6 @@ MyUpgradeHD = """ """ -# ____ Skin NeoBootInstallationFULLHD - NeoBootInstallationFULLHD ___mod. gutosie ___ NeoBootInstallationFULLHD = """ @@ -269,7 +235,6 @@ NeoBootInstallationFULLHD = """ """ -# ____ Skin NeoBootInstallationUltraHD - NeoBootInstallationUltraHD ___mod. gutosie ___ NeoBootInstallationUltraHD = """ @@ -278,7 +243,7 @@ NeoBootInstallationUltraHD = """ - + @@ -305,7 +270,6 @@ NeoBootInstallationUltraHD = """ """ -# ____ Skin NeoBootInstallationHD - NeoBootInstallationHD ___mod. gutosie ___ NeoBootInstallationHD = """ @@ -323,5 +287,5 @@ NeoBootInstallationHD = """ - + """ diff --git a/NeoBoot/neoskins/mercus/mercus_skin.py b/NeoBoot/neoskins/mercus/mercus_skin.py index e4ad692..98ede98 100644 --- a/NeoBoot/neoskins/mercus/mercus_skin.py +++ b/NeoBoot/neoskins/mercus/mercus_skin.py @@ -1,11 +1,8 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# mercus = /neoskins/mercus/mercus_skin.py -# ImageChooseFULLHD - mercus ImageChooseFULLHD = """ diff --git a/NeoBoot/neoskins/metrix/metrix_skin.py b/NeoBoot/neoskins/metrix/metrix_skin.py index a11ea23..32b0cd2 100644 --- a/NeoBoot/neoskins/metrix/metrix_skin.py +++ b/NeoBoot/neoskins/metrix/metrix_skin.py @@ -1,11 +1,8 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# skin /neoskins/matrix/matrix_skin.py - mod.gutosie -# ImageChooseFULLHD ImageChooseFULLHD = """ diff --git a/NeoBoot/neoskins/neo/neo_skin.py b/NeoBoot/neoskins/neo/neo_skin.py index b3c6f22..80595be 100644 --- a/NeoBoot/neoskins/neo/neo_skin.py +++ b/NeoBoot/neoskins/neo/neo_skin.py @@ -1,31 +1,8 @@ -# neo = /neoskins/neo/neo_skin.py - gutosie - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# Colors (#AARRGGBB) -# ____Recommended colors - Zalecane kolory : -# color name="white" value="#ffffff" -# color name="darkwhite" value="#00dddddd" -# color name="red" value="#f23d21" -# color name="green" value="#389416" -# color name="blue" value="#0064c7" -# color name="yellow" value="#bab329" -# color name="orange" value="#00ffa500" -# color name="gray" value="#808080" -# color name="lightgrey" value="#009b9b9b" - -# font genel -# font baslk -# font tasat -# font dugme - -# jak by chcial ktos wlasny selektor, to przyklad: -# - -# ImageChooseFULLHD ImageChooseFULLHD = """ @@ -55,18 +32,14 @@ ImageChooseFULLHD = """ -#Window image selection - Okno wyboru image -#Used Kernel: -#More options - Menu -#key 1> 2> 3> @@ -74,51 +47,34 @@ ImageChooseFULLHD = """ -#Please choose an image to boot -#NeoBoot is running from: -#NeoBoot is running image: -#Memory disc: - Pamiec dysku -#Number of images installed: -#Version update: -#UPDATEVERSION -#NeoBoot version: -#PLUGINVERSION -#Kernel Version -#KERNELVERSION -#hostname -#Memory - Used: Available: -#VIP """ - - -# ImageChoose-HD diff --git a/NeoBoot/neoskins/nitro/nitro_skin.py b/NeoBoot/neoskins/nitro/nitro_skin.py index 6d9c257..ef13531 100644 --- a/NeoBoot/neoskins/nitro/nitro_skin.py +++ b/NeoBoot/neoskins/nitro/nitro_skin.py @@ -1,10 +1,7 @@ -# skin = ./neoskins/nitro_skin - mod. gutosie - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# ImageChooseFULLHD ImageChooseFULLHD = """ @@ -20,7 +17,7 @@ ImageChooseFULLHD = """ - + @@ -30,7 +27,7 @@ ImageChooseFULLHD = """ - + diff --git a/NeoBoot/neoskins/oldhd/hd_skin.py b/NeoBoot/neoskins/oldhd/hd_skin.py index 9734c91..57baee8 100644 --- a/NeoBoot/neoskins/oldhd/hd_skin.py +++ b/NeoBoot/neoskins/oldhd/hd_skin.py @@ -1,10 +1,8 @@ - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# ____ Skin HD - ImageChoose ___mod. gutosie ___ ImageChooseHD = """ diff --git a/NeoBoot/plugin.py b/NeoBoot/plugin.py index 18ff1f2..bdf9f92 100644 --- a/NeoBoot/plugin.py +++ b/NeoBoot/plugin.py @@ -1,25 +1,40 @@ -# -*- coding: utf-8 -*- -# -------------------------------------- _q(-_-)p_ gutosie _q(-_-)p_ --------------------------------------# -# --------------------------------------------- -#[NEOBOOT]#- ---------------------------------------------# -# Copyright (c) , gutosie license -# EN: - -# Redistribution of the program version and making modifications IS PROHIBITED. -# The author assumes NO responsibility for the consequences of using this program or for the use that may be made of the information contained therein. -# Creating an ipk package and placing it in the official repository of ANY software is forbidden without my permission. -# Please respect the work. Never remove anyone from the authors list. -# PL: -# Redystrybucja wersji programu i dokonywania modyfikacji JEST ZABRONIONE. -# Autor NIE ponosi JAKIEJKOLWIEK odpowiedzialnoĹ›ci za skutki uĹĽtkowania tego programu oraz za wykorzystanie zawartych tu informacji. -# Tworzenie paczki ipk i umieszczanie jej w oficjalnym repozytorium DOWOLNEGO softu jest zabronione bez mojej zgody. -# Prosze uszanuj prace. Nigdy nie usuwaj nikogo z listy autorow. -# --------------------------------------------- -#[NEOBOOT]#- ---------------------------------------------# -# neoboot modules - - +from __future__ import absolute_import +from __future__ import print_function from Plugins.Plugin import PluginDescriptor from . import _ -from Plugins.Extensions.NeoBoot.files.stbbranding import LogCrashGS, getSupportedTuners, getLabelDisck, getINSTALLNeo, getNeoLocation, getLocationMultiboot, getNeoMount, getNeoMount2, getNeoMount3, getNeoMount4, getNeoMount5, getFSTAB, getFSTAB2, getKernelVersionString, getKernelImageVersion, getChipSetString, getCPUtype, getCPUSoC, getImageNeoBoot, getBoxVuModel, getBoxHostName, getTunerModel, getImageDistroN, getFormat, getNEO_filesystems, getBoxModelVU, getMountPointAll, getMountPointNeo, getCheckActivateVip, getBoxMacAddres, getCheckExt +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + LogCrashGS, + getSupportedTuners, + getLabelDisck, + getINSTALLNeo, + getNeoLocation, + getLocationMultiboot, + getNeoMount, + getNeoMount2, + getNeoMount3, + getNeoMount4, + getNeoMount5, + getFSTAB, + getFSTAB2, + getKernelVersionString, + getKernelImageVersion, + getChipSetString, + getCPUtype, + getCPUSoC, + getImageNeoBoot, + getBoxVuModel, + getBoxHostName, + getTunerModel, + getImageDistroN, + getFormat, + getNEO_filesystems, + getBoxModelVU, + getMountPointAll, + getMountPointNeo, + getCheckActivateVip, + getBoxMacAddres, + getCheckExt, +) from Plugins.Extensions.NeoBoot.files import Harddisk from Components.About import about from enigma import getDesktop, eTimer @@ -42,14 +57,43 @@ from Components.Pixmap import Pixmap, MultiPixmap from Components.config import * from Components.ConfigList import ConfigListScreen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import fileExists, pathExists, createDir, resolveFilename, SCOPE_PLUGINS -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen +from Tools.Directories import ( + fileExists, + pathExists, + createDir, + resolveFilename, + SCOPE_PLUGINS, +) +from os import ( + system, + listdir, + mkdir, + chdir, + getcwd, + rename as os_rename, + remove as os_remove, + popen, +) from os.path import dirname, isdir, isdir as os_isdir import os import time from time import gmtime, strftime -from Tools.Testinout import getTestIn, getTestOut, getTestInTime, getTestOutTime, getAccessN, getAccesDate, getButtonPin, getTestToTest -if not fileExists('/etc/vtiversion.info') and not fileExists('/etc/bhversion') and fileExists('/usr/lib/python2.7'): +from Tools.Testinout import ( + getTestIn, + getTestOut, + getTestInTime, + getTestOutTime, + getAccessN, + getAccesDate, + getButtonPin, + getTestToTest, +) + +if ( + not fileExists("/etc/vtiversion.info") + and not fileExists("/etc/bhversion") + and fileExists("/usr/lib/python2.7") +): from Plugins.Extensions.NeoBoot.files.neoconsole import Console else: from Screens.Console import Console @@ -57,29 +101,30 @@ loggscrash = time.localtime(time.time()) PLUGINVERSION = '9.81' UPDATEVERSION = '9.81' UPDATEDATE = '"+%Y13%d"' -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" try: from enigma import addFont - font_osans = LinkNeoBoot + '/neoskins/osans.ttf' - font_sagoe = LinkNeoBoot + '/neoskins/sagoe.ttf' - addFont(font_osans, 'genel', 100, True) - addFont(font_sagoe, 'baslk', 100, True) - addFont(font_sagoe, 'tasat', 100, True) - addFont(font_sagoe, 'dugme', 90, True) -except: + + font_osans = LinkNeoBoot + "/neoskins/osans.ttf" + font_sagoe = LinkNeoBoot + "/neoskins/sagoe.ttf" + addFont(font_osans, "genel", 100, True) + addFont(font_sagoe, "baslk", 100, True) + addFont(font_sagoe, "tasat", 100, True) + addFont(font_sagoe, "dugme", 90, True) +except BaseException: print("ERROR INSERTING FONT") def neoTranslator(): - neolang = '' - usedlang = open('/etc/enigma2/settings', 'r') - lang = 'config.osd.language=pl_PL' + neolang = "" + usedlang = open("/etc/enigma2/settings", "r") + lang = "config.osd.language=pl_PL" local = usedlang.read().find(lang) if local != -1: - neolang = 'islangPL' + neolang = "islangPL" else: - neolang = 'isnotlangPL' + neolang = "isnotlangPL" return neolang @@ -106,12 +151,15 @@ def isUHD(): class MyUpgrade(Screen): if isFHD(): from Plugins.Extensions.NeoBoot.neoskins.default import MyUpgradeFULLHD + skin = MyUpgradeFULLHD elif isUHD(): from Plugins.Extensions.NeoBoot.neoskins.default import MyUpgradeUltraHD + skin = MyUpgradeUltraHD else: from Plugins.Extensions.NeoBoot.neoskins.default import MyUpgradeHD + skin = MyUpgradeHD __module__ = __name__ @@ -119,36 +167,44 @@ class MyUpgrade(Screen): def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['list'] = List(self.list) + self["list"] = List(self.list) self.wybierz() - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, - 'back': self.changever}) + self["actions"] = ActionMap( + ["WizardActions", "ColorActions"], + {"ok": self.KeyOk, "back": self.changever}, + ) def changever(self): ImageChoose = self.session.open(NeoBootImageChoose) - if fileExists('' + LinkNeoBoot + '/.location'): - out = open('%sImageBoot/.version' % getNeoLocation(), 'w') + if fileExists("" + LinkNeoBoot + "/.location"): + out = open("%sImageBoot/.version" % getNeoLocation(), "w") out.write(PLUGINVERSION) out.close() self.close() else: - self.close(self.session.open(MessageBox, _( - 'No file location NeoBot, do re-install the plugin.'), MessageBox.TYPE_INFO, 10)) + self.close( + self.session.open( + MessageBox, + _("No file location NeoBot, do re-install the plugin."), + MessageBox.TYPE_INFO, + 10, + ) + ) self.close() return ImageChoose def wybierz(self): self.list = [] - mypath = '' + LinkNeoBoot + '' - if not fileExists(mypath + 'icons'): - mypixmap = '' + LinkNeoBoot + '/images/ok.png' + mypath = "" + LinkNeoBoot + "" + if not fileExists(mypath + "icons"): + mypixmap = "" + LinkNeoBoot + "/images/ok.png" png = LoadPixmap(mypixmap) - res = (_('Update neoboot in all images ?'), png, 0) + res = (_("Update neoboot in all images ?"), png, 0) self.list.append(res) - self['list'].list = self.list + self["list"].list = self.list def KeyOk(self): - self.sel = self['list'].getCurrent() + self.sel = self["list"].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0 and self.goKeyOk(): @@ -158,204 +214,309 @@ class MyUpgrade(Screen): def goKeyOk(self): try: from Plugins.Extensions.NeoBoot.files.tools import UpdateNeoBoot + self.session.open(UpdateNeoBoot) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def CRASHlogNeo(self): - showlog = 'echo "\nCRARSH LOG-neoboot startup error!" >> ' + getNeoLocation() + \ - 'ImageBoot/neoboot.log; cat ' + getNeoLocation() + 'ImageBoot/neoboot.log' + showlog = ( + 'echo "\nCRARSH LOG-neoboot startup error!" >> ' + + getNeoLocation() + + "ImageBoot/neoboot.log; cat " + + getNeoLocation() + + "ImageBoot/neoboot.log" + ) self.session.openWithCallback( - self.close, Console, _('NeoBoot ERROR !!!'), [showlog]) + self.close, Console, _("NeoBoot ERROR !!!"), [showlog] + ) class NeoBootInstallation(Screen): if isFHD(): - from Plugins.Extensions.NeoBoot.neoskins.default import NeoBootInstallationFULLHD + from Plugins.Extensions.NeoBoot.neoskins.default import ( + NeoBootInstallationFULLHD, + ) + skin = NeoBootInstallationFULLHD elif isUHD(): - from Plugins.Extensions.NeoBoot.neoskins.default import NeoBootInstallationUltraHD + from Plugins.Extensions.NeoBoot.neoskins.default import ( + NeoBootInstallationUltraHD, + ) + skin = NeoBootInstallationUltraHD else: from Plugins.Extensions.NeoBoot.neoskins.default import NeoBootInstallationHD + skin = NeoBootInstallationHD def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['config'] = MenuList(self.list) - self['key_red'] = Label(_('Instruction')) - self['key_green'] = Label(_('Installation')) - self['key_yellow'] = Label(_('Set UUID Label')) - self['key_blue'] = Label(_('Device Manager')) - self['label1'] = Label( - _('Welcome to NeoBoot %s Plugin installation.') % PLUGINVERSION) - self['label2'] = Label( - _('Here is the list of mounted devices in Your STB\nPlease choose a device where You would like to install NeoBoot')) - self['label3'] = Label( - _('It is recommended to give a label to the disk.')) - self['label4'] = Label(_('Press MENU - Backup')) - self['label5'] = Label(_('Press 1 - Mounting')) - self['label6'] = Label(_('Press 2 - Delete NeoBoot')) - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'MenuActions', 'NumberActionMap', 'SetupActions', 'number' 'DirectionActions'], {'red': self.Instrukcja, - 'green': self.checkinstall, - 'ok': self.checkinstall, - '0': self.checkinstall, - 'menu': self.helpneo, - '1': self.datadrive, - '2': self.deleteneo, - 'yellow': self.SetDiskLabel, - 'blue': self.devices, - 'back': self.close}) + self["config"] = MenuList(self.list) + self["key_red"] = Label(_("Instruction")) + self["key_green"] = Label(_("Installation")) + self["key_yellow"] = Label(_("Set UUID Label")) + self["key_blue"] = Label(_("Device Manager")) + self["label1"] = Label( + _("Welcome to NeoBoot %s Plugin installation.") % PLUGINVERSION + ) + self["label2"] = Label( + _("Here is the list of mounted devices in Your STB\nPlease choose a device where You would like to install NeoBoot")) + self["label3"] = Label( + _("It is recommended to give a label to the disk.")) + self["label4"] = Label(_("Press MENU - Backup")) + self["label5"] = Label(_("Press 1 - Mounting")) + self["label6"] = Label(_("Press 2 - Delete NeoBoot")) + self["actions"] = ActionMap( + [ + "WizardActions", + "ColorActions", + "MenuActions", + "NumberActionMap", + "SetupActions", + "number" "DirectionActions", + ], + { + "red": self.Instrukcja, + "green": self.checkinstall, + "ok": self.checkinstall, + "0": self.checkinstall, + "menu": self.helpneo, + "1": self.datadrive, + "2": self.deleteneo, + "yellow": self.SetDiskLabel, + "blue": self.devices, + "back": self.close, + }, + ) self.updateList() - if fileExists('/etc/fstab'): + if fileExists("/etc/fstab"): neoformat = getFormat() - writefile = open('/tmp/.neo_format', 'w') + writefile = open("/tmp/.neo_format", "w") writefile.write(neoformat) writefile.close() def SetDiskLabel(self): - # if fileExists('/usr/lib/python3.8') or fileExists('/usr/lib/python3.9') or fileExists('/tmp/.upneo') : - # self.session.open(MessageBox, _('Skip this step and install neoboot.\nThis option is available in the neoboot menu.'), type=MessageBox.TYPE_INFO) - if getCheckExt() != 'vfat' and getCheckExt() == 'ext3' or getCheckExt() == 'ext4': + if ( + getCheckExt() != "vfat" + and getCheckExt() == "ext3" + or getCheckExt() == "ext4" + ): try: - if fileExists('/usr/lib/python2.7'): + if fileExists("/usr/lib/python2.7"): from Plugins.Extensions.NeoBoot.files.devices import SetDiskLabel + self.session.open(SetDiskLabel) else: from Plugins.Extensions.NeoBoot.files.tools import DiskLabelSet + self.session.open(DiskLabelSet) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() else: - self.session.open(MessageBox, _( - 'Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot.'), type=MessageBox.TYPE_ERROR) + self.session.open( + MessageBox, + _("Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot."), + type=MessageBox.TYPE_ERROR, + ) def Instrukcja(self): try: from Plugins.Extensions.NeoBoot.files.tools import MyHelpNeo + self.session.open(MyHelpNeo) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def datadrive(self): try: message = "echo -e '\n" - message += _('NeoBot checks the connected media.\nWAIT ...\n\nDISCS:') + message += _("NeoBot checks the connected media.\nWAIT ...\n\nDISCS:") message += "'" os.system(" 'mount | sed '/sd/!d' | cut -d" " -f1,2,3,4,5' ") - cmd = '/sbin/blkid ' + cmd = "/sbin/blkid " system(cmd) - print("[MULTI-BOOT]: "), cmd - self.session.open(Console, _( - ' NeoBot - Available media:'), [message, cmd]) + print("[MULTI-BOOT]: %s" % cmd) + self.session.open( + Console, _(" NeoBot - Available media:"), [message, cmd] + ) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) pass def helpneo(self): - if fileExists('/media/hdd/CopyNEOBoot') or fileExists('/media/usb/CopyNEOBoot'): + if fileExists( + "/media/hdd/CopyNEOBoot") or fileExists("/media/usb/CopyNEOBoot"): try: from Plugins.Extensions.NeoBoot.files.tools import ReinstllNeoBoot + self.session.open(ReinstllNeoBoot) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) pass else: - self.session.open(MessageBox, _( - 'Neoboot backup not found.'), type=MessageBox.TYPE_INFO) + self.session.open( + MessageBox, + _("Neoboot backup not found."), + type=MessageBox.TYPE_INFO) def deleteneo(self): - message = _('Are you sure you want to completely remove NeoBoota of your image?\n\nIf you choose so all directories NeoBoota will be removed.\nA restore the original image settings Flash.') + message = _( + "Are you sure you want to completely remove NeoBoota of your image?\n\nIf you choose so all directories NeoBoota will be removed.\nA restore the original image settings Flash." + ) ybox = self.session.openWithCallback( - self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Removed successfully.')) + self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Removed successfully.")) def mbdelete(self, answer): if answer is True: - if fileExists('/etc/fstab.org'): - system('rm -r /etc/fstab; mv /etc/fstab.org /etc/fstab') - if fileExists('/etc/rcS.d/S99neo.local'): - system('rm -r /etc/rcS.d/S99neo.local') - if fileExists('/etc/name'): - system('rm -r /etc/name') - if fileExists('/etc/init.d/volatile-media.sh.org'): - system(' mv /etc/init.d/volatile-media.sh.org /etc/init.d/volatile-media.sh; rm -r /etc/init.d/volatile-media.sh.org; chmod 755 /etc/init.d/volatile-media.sh ') - if os.path.isfile('%sImageBoot/.neonextboot' % getNeoLocation()): - os.system('rm -f /etc/neoimage; rm -f /etc/imageboot; rm -f %sImageBoot/.neonextboot; rm -f %sImageBoot/.Flash; ' % - (getNeoLocation(), getNeoLocation(), getNeoLocation())) - if os.path.isfile('%sImagesUpload/.kernel ' % getNeoLocation()): - os.system('rm -r %sImagesUpload/.kernel' % getNeoLocation()) - cmd = "echo -e '\n\n%s '" % _('Recovering setting....\n') - cmd1 = 'rm -R ' + LinkNeoBoot + '' - cmd2 = 'rm -R /sbin/neoinit*' - cmd3 = 'ln -sfn /sbin/init.sysvinit /sbin/init' - cmd4 = 'rm -rf /usr/lib/enigma2/python/Tools/Testinout.p*' - cmd5 = 'rm -rf /usr/lib/periodon' + if fileExists("/etc/fstab.org"): + system("rm -r /etc/fstab; mv /etc/fstab.org /etc/fstab") + if fileExists("/etc/rcS.d/S99neo.local"): + system("rm -r /etc/rcS.d/S99neo.local") + if fileExists("/etc/name"): + system("rm -r /etc/name") + if fileExists("/etc/init.d/volatile-media.sh.org"): + system( + " mv /etc/init.d/volatile-media.sh.org /etc/init.d/volatile-media.sh; rm -r /etc/init.d/volatile-media.sh.org; chmod 755 /etc/init.d/volatile-media.sh " + ) + if os.path.isfile("%sImageBoot/.neonextboot" % getNeoLocation()): + os.system( + "rm -f /etc/neoimage; rm -f /etc/imageboot; rm -f %sImageBoot/.neonextboot; rm -f %sImageBoot/.Flash; " % + (getNeoLocation(), getNeoLocation(), getNeoLocation())) + if os.path.isfile("%sImagesUpload/.kernel " % getNeoLocation()): + os.system("rm -r %sImagesUpload/.kernel" % getNeoLocation()) + cmd = "echo -e '\n\n%s '" % _("Recovering setting....\n") + cmd1 = "rm -R " + LinkNeoBoot + "" + cmd2 = "rm -R /sbin/neoinit*" + cmd3 = "ln -sfn /sbin/init.sysvinit /sbin/init" + cmd4 = "rm -rf /usr/lib/enigma2/python/Tools/Testinout.p*" + cmd5 = "rm -rf /usr/lib/periodon" cmd6 = 'opkg install --force-maintainer --force-reinstall --force-overwrite --force-downgrade volatile-media; sleep 10; PATH=/sbin:/bin:/usr/sbin:/usr/bin; echo -n "Rebooting... "; reboot -d -f' - self.session.open(Console, _('NeoBot was removed !!! \nThe changes will be visible only after complete restart of the receiver.'), [cmd, - cmd1, - cmd2, - cmd3, - cmd4, - cmd5, - cmd6]) + self.session.open( + Console, + _( + "NeoBot was removed !!! \nThe changes will be visible only after complete restart of the receiver." + ), + [cmd, cmd1, cmd2, cmd3, cmd4, cmd5, cmd6], + ) self.close() else: self.close() def updateList(self): mycf, mymmc, myusb, myusb2, myusb3, mysd, mycard, myhdd, myssd = ( - '', '', '', '', '', '', '', '', '') + "", + "", + "", + "", + "", + "", + "", + "", + "", + ) myoptions = [] - if fileExists('/proc/mounts'): - fileExists('/proc/mounts') - f = open('/proc/mounts', 'r') + if fileExists("/proc/mounts"): + fileExists("/proc/mounts") + f = open("/proc/mounts", "r") for line in f.readlines(): - if line.find('/media/cf') != -1: - mycf = '/media/cf/' + if line.find("/media/cf") != -1: + mycf = "/media/cf/" continue - if line.find('/media/mmc') != -1: - mymmc = '/media/mmc/' + if line.find("/media/mmc") != -1: + mymmc = "/media/mmc/" continue - if line.find('/media/usb') != -1: - myusb = '/media/usb/' + if line.find("/media/usb") != -1: + myusb = "/media/usb/" continue - if line.find('/media/usb2') != -1: - myusb2 = '/media/usb2/' + if line.find("/media/usb2") != -1: + myusb2 = "/media/usb2/" continue - if line.find('/media/usb3') != -1: - myusb3 = '/media/usb3/' + if line.find("/media/usb3") != -1: + myusb3 = "/media/usb3/" continue - if line.find('/media/card') != -1: - mysd = '/media/card/' + if line.find("/media/card") != -1: + mysd = "/media/card/" continue - if line.find('/hdd') != -1: - myhdd = '/media/hdd/' + if line.find("/hdd") != -1: + myhdd = "/media/hdd/" continue - if line.find('/ssd') != -1: - myhdd = '/media/ssd/' + if line.find("/ssd") != -1: + myhdd = "/media/ssd/" continue f.close() else: - self['label2'].setText( - _('Sorry it seems that there are not Linux formatted devices mounted on your STB. To install NeoBoot you need a Linux formatted part1 device. Click on the blue button to open Devices Panel')) - fileExists('/proc/mounts') + self["label2"].setText( + _("Sorry it seems that there are not Linux formatted devices mounted on your STB. To install NeoBoot you need a Linux formatted part1 device. Click on the blue button to open Devices Panel")) + fileExists("/proc/mounts") if mycf: self.list.append(mycf) else: @@ -397,14 +558,15 @@ class NeoBootInstallation(Screen): else: myssd - self['config'].setList(self.list) + self["config"].setList(self.list) def checkReadWriteDir(self, configele): - supported_filesystems = frozenset(('ext4', 'ext3', 'ext2', 'nfs')) + supported_filesystems = frozenset(("ext4", "ext3", "ext2", "nfs")) candidates = [] mounts = Harddisk.getProcMounts() - for partition in Harddisk.harddiskmanager.getMountedPartitions(False, mounts): + for partition in Harddisk.harddiskmanager.getMountedPartitions( + False, mounts): if partition.filesystem(mounts) in supported_filesystems: candidates.append( (partition.description, partition.mountpoint)) @@ -414,76 +576,125 @@ class NeoBootInstallation(Screen): for validdevice in candidates: locations.append(validdevice[1]) - if Harddisk.findMountPoint(os.path.realpath(configele)) + '/' in locations or Harddisk.findMountPoint(os.path.realpath(configele)) in locations: - if fileExists(configele, 'w'): + if ( + Harddisk.findMountPoint(os.path.realpath(configele)) + "/" in locations + or Harddisk.findMountPoint(os.path.realpath(configele)) in locations + ): + if fileExists(configele, "w"): return True else: dir = configele - self.session.open(MessageBox, _( - 'The directory %s is not a ext2, ext3, ext4 or nfs partition.\nMake sure you select a valid partition type to install.') % dir, type=MessageBox.TYPE_ERROR) + self.session.open( + MessageBox, + _("The directory %s is not a ext2, ext3, ext4 or nfs partition.\nMake sure you select a valid partition type to install.") % + dir, + type=MessageBox.TYPE_ERROR, + ) return False - elif getFormat() == 'ext4' or getFormat() == 'ext3' or getFormat() == 'ext2' or getFormat() == 'nfs': + elif ( + getFormat() == "ext4" + or getFormat() == "ext3" + or getFormat() == "ext2" + or getFormat() == "nfs" + ): return True else: dir = configele - self.session.open(MessageBox, _( - 'The directory %s is not a EXT2, EXT3, EXT4 or NFS partition.\nMake sure you select a valid partition type.') % dir, type=MessageBox.TYPE_ERROR) + self.session.open( + MessageBox, + _("The directory %s is not a EXT2, EXT3, EXT4 or NFS partition.\nMake sure you select a valid partition type.") % + dir, + type=MessageBox.TYPE_ERROR, + ) return False else: dir = configele - self.session.open(MessageBox, _( - 'The directory %s is not a EXT2, EXT3, EXT4 or NFS partition.\nMake sure you select a valid partition type.\nIt may be helpful to restart the stb device completely.') % dir, type=MessageBox.TYPE_ERROR) + self.session.open( + MessageBox, + _("The directory %s is not a EXT2, EXT3, EXT4 or NFS partition.\nMake sure you select a valid partition type.\nIt may be helpful to restart the stb device completely.") % + dir, + type=MessageBox.TYPE_ERROR, + ) return False def devices(self): check = False - if not fileExists('/usr/lib/python2.7') or fileExists('/usr/lib/python3.8') or fileExists('/usr/lib/python3.9') or fileExists('/tmp/.upneo'): - # self.session.open(MessageBox, _('Skip this step and install neoboot.\nThis option is available in the neoboot menu.'), type=MessageBox.TYPE_INFO) - if fileExists('/.multinfo'): - self.session.open(MessageBox, _( - "This option is available only from Flash"), MessageBox.TYPE_INFO, timeout=10) + if ( + not fileExists("/usr/lib/python2.7") + or fileExists("/usr/lib/python3.8") + or fileExists("/usr/lib/python3.9") + or fileExists("/usr/lib/python3.10") + or fileExists("/usr/lib/python3.11") + or fileExists("/usr/lib/python3.12") + or fileExists("/usr/lib/python3.13") + or fileExists("/tmp/.upneo") + ): + if fileExists("/.multinfo"): + self.session.open( + MessageBox, + _("This option is available only from Flash"), + MessageBox.TYPE_INFO, + timeout=10, + ) else: - from Plugins.Extensions.NeoBoot.files.tools import InitializationFormattingDisk + from Plugins.Extensions.NeoBoot.files.tools import ( + InitializationFormattingDisk, + ) + self.session.open(InitializationFormattingDisk) elif check == False: message = _( - 'After selecting OK start Mounting Manager, option Mount - green\n') - message += _('Do you want to run the manager to mount the drives correctly ?\n') + "After selecting OK start Mounting Manager, option Mount - green\n" + ) + message += _( + "Do you want to run the manager to mount the drives correctly ?\n" + ) ybox = self.session.openWithCallback( - self.device2, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Device Manager')) + self.device2, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Device Manager")) def device2(self, yesno): if yesno: from Plugins.Extensions.NeoBoot.files.devices import ManagerDevice + self.session.open(ManagerDevice) else: self.close() def checkinstall(self): - if fileExists('/.multinfo'): + if fileExists("/.multinfo"): mess = _( - 'Sorry, Neoboot can be installed or upgraded only when booted from Flash') + "Sorry, Neoboot can be installed or upgraded only when booted from Flash" + ) self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) - elif getCheckExt() != 'vfat' and getCheckExt() == 'ext3' or getCheckExt() == 'ext4': + elif ( + getCheckExt() != "vfat" + and getCheckExt() == "ext3" + or getCheckExt() == "ext4" + ): self.checkinstall2() else: - self['label2'].setText( - _('Sorry it seems that there are not Linux formatted devices mounted on your STB. To install NeoBoot you need a Linux formatted part1 device. Click on the blue button to open Devices Panel.')) - self.session.open(MessageBox, _( - 'Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot.'), type=MessageBox.TYPE_ERROR) + self["label2"].setText( + _("Sorry it seems that there are not Linux formatted devices mounted on your STB. To install NeoBoot you need a Linux formatted part1 device. Click on the blue button to open Devices Panel.")) + self.session.open( + MessageBox, + _("Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot."), + type=MessageBox.TYPE_ERROR, + ) def checkinstall2(self): - if fileExists('/media/usb/ImageBoot/') and fileExists('/media/hdd/ImageBoot/'): - os.system('umount -l /media/usb; sleep 2') - if fileExists('/media/usb'): - if len(os.listdir('/media/usb')) == 0: - # print("Directory is empty") - os.system('rm -r /media/usb') + if fileExists( + "/media/usb/ImageBoot/") and fileExists("/media/hdd/ImageBoot/"): + os.system("umount -l /media/usb; sleep 2") + if fileExists("/media/usb"): + if len(os.listdir("/media/usb")) == 0: + os.system("rm -r /media/usb") mess = _( - 'An error was encountered, you have neoboot installed on usb and hdd.\nUninstall one directories from one drive.') + "An error was encountered, you have neoboot installed on usb and hdd.\nUninstall one directories from one drive." + ) self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: self.checkinstall3() @@ -492,27 +703,36 @@ class NeoBootInstallation(Screen): if checkInternet(): self.check_LabelDisck() else: - mess = _('Geen internet') + mess = _("Geen internet") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) def check_LabelDisck(self): - system('blkid -c /dev/null /dev/sd* > ' + LinkNeoBoot + - '/bin/reading_blkid; chmod 755 ' + LinkNeoBoot + '/bin/reading_blkid ') - if getLabelDisck() != 'LABEL=': + system( + "blkid -c /dev/null /dev/sd* > " + + LinkNeoBoot + + "/bin/reading_blkid; chmod 755 " + + LinkNeoBoot + + "/bin/reading_blkid " + ) + if getLabelDisck() != "LABEL=": message = _( - 'NeoBot - First use yellow button and Set Disk Label!\nWithout labeling disc neoboot may not work properly') + "NeoBot - First use yellow button and Set Disk Label!\nWithout labeling disc neoboot may not work properly" + ) ybox = self.session.openWithCallback( - self.goSetDiskLabel, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Install Confirmation')) + self.goSetDiskLabel, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Install Confirmation")) else: self.check_fstabUUID() def check_fstabUUID(self): - if getFSTAB2() != 'OKinstall': - message = (_('Disk UUID not found\n - Universally unique identifier (UUID) is not required.\nYou can proceed with further installation or give an ID to your disk.\nTo continue the installation neoboo, press OK or No to abort.')) + if getFSTAB2() != "OKinstall": + message = _( + "Disk UUID not found\n - Universally unique identifier (UUID) is not required.\nYou can proceed with further installation or give an ID to your disk.\nTo continue the installation neoboo, press OK or No to abort." + ) ybox = self.session.openWithCallback( self.SetMountPointFSTAB, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Install Confirmation')) + ybox.setTitle(_("Install Confirmation")) else: self.first_installation() @@ -520,21 +740,25 @@ class NeoBootInstallation(Screen): def goSetDiskLabel(self, yesno): if yesno: from Plugins.Extensions.NeoBoot.files.devices import SetDiskLabel + self.session.open(SetDiskLabel) else: message = _( - 'NeoBot - choose what you want to do, install or not !!!') + "NeoBot - choose what you want to do, install or not !!!") ybox = self.session.openWithCallback( - self.goInstall, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Install Confirmation')) + self.goInstall, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Install Confirmation")) def SetMountPointFSTAB(self, yesno): if yesno: message = _( - 'Proceed with further installation without providing a unique identifier for the disks ?') + "Proceed with further installation without providing a unique identifier for the disks ?" + ) ybox = self.session.openWithCallback( - self.goInstall, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Install Confirmation')) + self.goInstall, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Install Confirmation")) else: self.devices() @@ -542,323 +766,636 @@ class NeoBootInstallation(Screen): if yesno: self.first_installation() else: - self.myclose2(_('NeoBoot has not been installed ! :(')) + self.myclose2(_("NeoBoot has not been installed ! :(")) def first_installation(self): check = False - if fileExists('/proc/mounts'): - with open('/proc/mounts', 'r') as f: + if fileExists("/proc/mounts"): + with open("/proc/mounts", "r") as f: for line in f.readlines(): - if line.find(' ext') and line.find('/media/hdd') or line.find('/media/usb') == -1 and (line.find('ext4') != -1 or line.find('ext3') != -1 or line.find('ext2') != -1): + if ( + line.find(" ext") + and line.find("/media/hdd") + or line.find("/media/usb") == -1 + and ( + line.find("ext4") != -1 + or line.find("ext3") != -1 + or line.find("ext2") != -1 + ) + ): check = True break - if check == False: - self.session.open(MessageBox, _( - 'Sorry, there is not any connected devices in your STB.\nPlease connect HDD or USB to install NeoBoot!'), MessageBox.TYPE_INFO) + if not check: + self.session.open( + MessageBox, + _("Sorry, there is not any connected devices in your STB.\nPlease connect HDD or USB to install NeoBoot!"), + MessageBox.TYPE_INFO, + ) else: - self.mysel = self['config'].getCurrent() + self.mysel = self["config"].getCurrent() if self.checkReadWriteDir(self.mysel): - message = _( - 'Do You really want to install NeoBoot in:\n ') + self.mysel + ' ?' + message = ( + _("Do You really want to install NeoBoot in:\n ") + + self.mysel + + " ?" + ) ybox = self.session.openWithCallback( - self.install2, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Install Confirmation')) + self.install2, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Install Confirmation")) else: self.close() def install2(self, yesno): - print("yesno:"), yesno + print("yesno: %s" % yesno) if yesno: self.first_installationNeoBoot() else: - self.myclose2(_('NeoBoot has not been installed ! :(')) + self.myclose2(_("NeoBoot has not been installed ! :(")) def first_installationNeoBoot(self): - self.mysel = self['config'].getCurrent() - os.system('cd ' + LinkNeoBoot + - '/; chmod 0755 ./bin/neoini*; chmod 0755 ./ex_init.py; chmod 0755 ./files/userscript.sh') - cmd1 = 'mkdir ' + self.mysel + 'ImageBoot;mkdir ' + self.mysel + 'ImagesUpload' + self.mysel = self["config"].getCurrent() + os.system( + "cd " + + LinkNeoBoot + + "/; chmod 0755 ./bin/neoini*; chmod 0755 ./ex_init.py; chmod 0755 ./files/userscript.sh") + cmd1 = "mkdir " + self.mysel + "ImageBoot;mkdir " + self.mysel + "ImagesUpload" system(cmd1) - cmd2 = 'mkdir ' + self.mysel + 'ImageBoot;mkdir ' + \ - self.mysel + 'ImagesUpload/.kernel' + cmd2 = ( + "mkdir " + + self.mysel + + "ImageBoot;mkdir " + + self.mysel + + "ImagesUpload/.kernel" + ) system(cmd2) - if os.path.isfile('' + LinkNeoBoot + '/.location'): - os.system('rm -f ' + LinkNeoBoot + '/.location') + if os.path.isfile("" + LinkNeoBoot + "/.location"): + os.system("rm -f " + LinkNeoBoot + "/.location") out = open( - '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'w') + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location", + "w") out.write(self.mysel) out.close() - if os.path.isfile('%sImageBoot/.neonextboot' % getNeoLocation()): - os.system('rm -f /etc/neoimage; rm -f /etc/imageboot; rm -f %sImageBoot/.neonextboot; rm -f %sImageBoot/.Flash; rm -f %sImageBoot/.imagedistro; rm -f %sImageBoot/.initneo.log; rm -f %sImageBoot/.updateversion' % - (getNeoLocation(), getNeoLocation(), getNeoLocation(), getNeoLocation(), getNeoLocation())) + if os.path.isfile("%sImageBoot/.neonextboot" % getNeoLocation()): + os.system( + "rm -f /etc/neoimage; rm -f /etc/imageboot; rm -f %sImageBoot/.neonextboot; rm -f %sImageBoot/.Flash; rm -f %sImageBoot/.imagedistro; rm -f %sImageBoot/.initneo.log; rm -f %sImageBoot/.updateversion" % + (getNeoLocation(), + getNeoLocation(), + getNeoLocation(), + getNeoLocation(), + getNeoLocation(), + )) - if os.path.isfile('%sImagesUpload/.kernel/zImage*.ipk or %sImagesUpload/.kernel/zImage*.bin' % (getNeoLocation(), getNeoLocation())): - os.system('rm -f %sImagesUpload/.kernel/zImage*.ipk; rm -f %sImagesUpload/.kernel/zImage*.bin' % - (getNeoLocation(), getNeoLocation())) + if os.path.isfile( + "%sImagesUpload/.kernel/zImage*.ipk or %sImagesUpload/.kernel/zImage*.bin" % + (getNeoLocation(), getNeoLocation())): + os.system( + "rm -f %sImagesUpload/.kernel/zImage*.ipk; rm -f %sImagesUpload/.kernel/zImage*.bin" % + (getNeoLocation(), getNeoLocation())) - if fileExists('/etc/issue.net'): + if fileExists("/etc/issue.net"): try: - lines = open('/etc/hostname', 'r').readlines() + lines = open("/etc/hostname", "r").readlines() imagename = lines[0][:-1] image = imagename - open('%sImageBoot/.Flash' % getNeoLocation(), 'w').write(image) - except: + open("%sImageBoot/.Flash" % getNeoLocation(), "w").write(image) + except BaseException: False - if not fileExists('/usr/lib/periodon/.accessdate'): - os.system('date %s > /usr/lib/periodon/.accessdate' % UPDATEDATE) - if not fileExists('/usr/lib/periodon/.accessdate') or not fileExists('/etc/name'): - out1 = open('%sImageBoot/.version' % getNeoLocation(), 'w') + if not fileExists("/usr/lib/periodon/.accessdate"): + os.system("date %s > /usr/lib/periodon/.accessdate" % UPDATEDATE) + if not fileExists("/usr/lib/periodon/.accessdate") or not fileExists( + "/etc/name" + ): + out1 = open("%sImageBoot/.version" % getNeoLocation(), "w") out1.write(PLUGINVERSION) out1.close() - out2 = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w') - out2.write('Flash ') + out2 = open("%sImageBoot/.neonextboot" % getNeoLocation(), "w") + out2.write("Flash ") out2.close() - if not fileExists('/usr/lib/python3.12'): - out3 = open('' + LinkNeoBoot + '/.neo_info', 'w') - out3.write('Kernel\n') - out3.write('Kernel-Version: ' + - about.getKernelVersionString() + '\n') - out3.write('NeoBoot\n') - out3.write('NeoBoot-Version: ' + PLUGINVERSION + '\n') + if not (fileExists("/usr/lib/python3.12") + or fileExists("/usr/lib/python3.13")): + out3 = open("" + LinkNeoBoot + "/.neo_info", "w") + out3.write("Kernel\n") + out3.write( + "Kernel-Version: " + + about.getKernelVersionString() + + "\n") + out3.write("NeoBoot\n") + out3.write("NeoBoot-Version: " + PLUGINVERSION + "\n") out3.close() - out = open('%sImageBoot/.updateversion' % getNeoLocation(), 'w') + out = open("%sImageBoot/.updateversion" % getNeoLocation(), "w") out.write(UPDATEVERSION) out.close() - if fileExists('/usr/lib/enigma2/python/boxbranding.so'): + if fileExists("/usr/lib/enigma2/python/boxbranding.so"): from boxbranding import getImageDistro + imagedistro = getImageDistro() - writefile = open('%sImageBoot/.imagedistro' % - getNeoLocation(), 'w') + writefile = open( + "%sImageBoot/.imagedistro" % + getNeoLocation(), "w") writefile.write(imagedistro) writefile.close() - elif fileExists('/usr/lib/enigma2/python/Plugins/PLi'): - obraz = open('/etc/issue.net', 'r').readlines() + elif fileExists("/usr/lib/enigma2/python/Plugins/PLi"): + obraz = open("/etc/issue.net", "r").readlines() imagetype = obraz[0][:-3] image = imagetype - writefile = open('%sImageBoot/.imagedistro' % - getNeoLocation(), 'w') + writefile = open( + "%sImageBoot/.imagedistro" % + getNeoLocation(), "w") writefile.write(imagetype) writefile.close() - elif fileExists('/etc/vtiversion.info'): - f = open("/etc/vtiversion.info", 'r') + elif fileExists("/etc/vtiversion.info"): + f = open("/etc/vtiversion.info", "r") imagever = f.readline().strip().replace("Release ", " ") f.close() image = imagever - writefile = open('%sImageBoot/.imagedistro' % - getNeoLocation(), 'w') + writefile = open( + "%sImageBoot/.imagedistro" % + getNeoLocation(), "w") writefile.write(imagever) writefile.close() - elif fileExists('/etc/bhversion'): - f = open("/etc/bhversion", 'r') + elif fileExists("/etc/bhversion"): + f = open("/etc/bhversion", "r") imagever = f.readline().strip() f.close() image = imagever - writefile = open('%sImageBoot/.imagedistro' % - getNeoLocation(), 'w') + writefile = open( + "%sImageBoot/.imagedistro" % + getNeoLocation(), "w") writefile.write(imagever) writefile.close() - if not os.path.isfile('/etc/name'): - if getBoxHostName() == "dm500hd" or getBoxHostName() == "dm520" or getBoxHostName() == "dm525" or getBoxHostName() == "dm800" or getBoxHostName() == "dm800se" or getBoxHostName() == "dm8000": - system('chmod 755 ' + LinkNeoBoot + '/bin/dminit') + if not os.path.isfile("/etc/name"): + if ( + getBoxHostName() == "dm500hd" + or getBoxHostName() == "dm520" + or getBoxHostName() == "dm525" + or getBoxHostName() == "dm800" + or getBoxHostName() == "dm800se" + or getBoxHostName() == "dm8000" + ): + system("chmod 755 " + LinkNeoBoot + "/bin/dminit") else: - system('opkg update') + system("opkg update") os.system( - 'opkg install --force-overwrite --force-reinstall python-subprocess') + "opkg install --force-overwrite --force-reinstall python-subprocess" + ) os.system( - 'opkg install --force-overwrite --force-reinstall python-argparse') - os.system('opkg install liblzo2-2') - os.system('opkg install curl') - if getCPUtype() == 'MIPS': + "opkg install --force-overwrite --force-reinstall python-argparse" + ) + os.system("opkg install liblzo2-2") + os.system("opkg install curl") + if getCPUtype() == "MIPS": os.system( - 'opkg install --force-overwrite --force-reinstall kernel-module-nandsim') + "opkg install --force-overwrite --force-reinstall kernel-module-nandsim" + ) os.system( - 'opkg install --force-overwrite --force-reinstall mtd-utils-jffs2') + "opkg install --force-overwrite --force-reinstall mtd-utils-jffs2" + ) os.system( - 'opkg install --force-overwrite --force-reinstall lzo') + "opkg install --force-overwrite --force-reinstall lzo") os.system( - 'opkg install --force-overwrite --force-reinstall python-setuptools') + "opkg install --force-overwrite --force-reinstall python-setuptools" + ) os.system( - 'opkg install --force-overwrite --force-reinstall util-linux-sfdisk') + "opkg install --force-overwrite --force-reinstall util-linux-sfdisk" + ) os.system( - 'opkg install --force-overwrite --force-reinstall packagegroup-base-nfs') + "opkg install --force-overwrite --force-reinstall packagegroup-base-nfs" + ) os.system( - 'opkg install --force-overwrite --force-reinstall ofgwrite') + "opkg install --force-overwrite --force-reinstall ofgwrite" + ) os.system( - 'opkg install --force-overwrite --force-reinstall bzip2') + "opkg install --force-overwrite --force-reinstall bzip2") os.system( - 'opkg install --force-overwrite --force-reinstall mtd-utils') + "opkg install --force-overwrite --force-reinstall mtd-utils" + ) os.system( - 'opkg install --force-overwrite --force-reinstall mtd-utils-ubifs') - # STB ARM + "opkg install --force-overwrite --force-reinstall mtd-utils-ubifs" + ) if getCPUtype() == "ARMv7": if getBoxHostName() == "vuduo4k" and getBoxHostName() != "ustym4kpro": - os.system('cd ' + LinkNeoBoot + '/') - os.system('cp -Rf ' + LinkNeoBoot + '/bin/neoinitarm /sbin/neoinitarm; cp -Rf ' + LinkNeoBoot + - '/bin/neoinitarmvuDuo4k /sbin/neoinitarmvu; mv ' + LinkNeoBoot + '/tmpfiles/vu4k_run.py ' + LinkNeoBoot + '/run.py; cd') + os.system("cd " + LinkNeoBoot + "/") os.system( - 'chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu') - os.system('dd if=/dev/mmcblk0p6 of=%sImagesUpload/.kernel/flash-kernel-%s.bin' % - (getNeoLocation(), getBoxHostName())) + "cp -Rf " + + LinkNeoBoot + + "/bin/neoinitarm /sbin/neoinitarm; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k /sbin/neoinitarmvu; mv " + + LinkNeoBoot + + "/tmpfiles/vu4k_run.py " + + LinkNeoBoot + + "/run.py; cd" + ) + os.system( + "chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu") + os.system( + "dd if=/dev/mmcblk0p6 of=%sImagesUpload/.kernel/flash-kernel-%s.bin" % + (getNeoLocation(), getBoxHostName())) - elif getBoxHostName() == "vuduo4kse" and getBoxHostName() != "vuultimo4k" and getBoxHostName() != "ustym4kpro": - os.system('cd ' + LinkNeoBoot + '/') - os.system('cp -Rf ' + LinkNeoBoot + '/bin/neoinitarm /sbin/neoinitarm; cp -Rf ' + LinkNeoBoot + - '/bin/neoinitarmvuDuo4k /sbin/neoinitarmvu; mv ' + LinkNeoBoot + '/tmpfiles/vu4k_run.py ' + LinkNeoBoot + '/run.py; cd') + elif ( + getBoxHostName() == "vuduo4kse" + and getBoxHostName() != "vuultimo4k" + and getBoxHostName() != "ustym4kpro" + ): + os.system("cd " + LinkNeoBoot + "/") os.system( - 'chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu') - os.system('dd if=/dev/mmcblk0p6 of=%sImagesUpload/.kernel/flash-kernel-%s.bin' % - (getNeoLocation(), getBoxHostName())) + "cp -Rf " + + LinkNeoBoot + + "/bin/neoinitarm /sbin/neoinitarm; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k /sbin/neoinitarmvu; mv " + + LinkNeoBoot + + "/tmpfiles/vu4k_run.py " + + LinkNeoBoot + + "/run.py; cd" + ) + os.system( + "chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu") + os.system( + "dd if=/dev/mmcblk0p6 of=%sImagesUpload/.kernel/flash-kernel-%s.bin" % + (getNeoLocation(), getBoxHostName())) elif getBoxHostName() == "vuzero4k" and getBoxHostName() != "ustym4kpro": - os.system('cd ' + LinkNeoBoot + '/') - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitarm /sbin/neoinitarm; cp -Rf ' + - LinkNeoBoot + '/bin/neoinitarmvu /sbin/neoinitarmvu; cd') + os.system("cd " + LinkNeoBoot + "/") os.system( - 'chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu') - os.system('dd if=/dev/mmcblk0p4 of=%sImagesUpload/.kernel/flash-kernel-%s.bin' % - (getNeoLocation(), getBoxHostName())) - os.system('mv ' + LinkNeoBoot + '/tmpfiles/vu4k_run.py ' + LinkNeoBoot + - '/run.py; rm -f ' + LinkNeoBoot + '/bin/neoinitarmvuDuo4k; cd') - - elif getBoxHostName() == "vuultimo4k" or getBoxHostName() == "vusolo4k" or getBoxHostName() == "vuuno4k" or getBoxHostName() == "vuuno4kse" and getBoxHostName() != "ustym4kpro": - os.system('cd ' + LinkNeoBoot + '/') - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitarm /sbin/neoinitarm; cp -Rf ' + - LinkNeoBoot + '/bin/neoinitarmvu /sbin/neoinitarmvu; cd') + "cp -af " + + LinkNeoBoot + + "/bin/neoinitarm /sbin/neoinitarm; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitarmvu /sbin/neoinitarmvu; cd" + ) os.system( - 'chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu') - os.system('dd if=/dev/mmcblk0p1 of=%sImagesUpload/.kernel/flash-kernel-%s.bin' % - (getNeoLocation(), getBoxHostName())) - os.system('mv ' + LinkNeoBoot + '/tmpfiles/vu4k_run.py ' + LinkNeoBoot + - '/run.py; rm -f; rm -f ' + LinkNeoBoot + '/bin/neoinitarmvuDuo4k; cd') + "chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu") + os.system( + "dd if=/dev/mmcblk0p4 of=%sImagesUpload/.kernel/flash-kernel-%s.bin" % + (getNeoLocation(), getBoxHostName())) + os.system( + "mv " + + LinkNeoBoot + + "/tmpfiles/vu4k_run.py " + + LinkNeoBoot + + "/run.py; rm -f " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k; cd" + ) - elif getBoxHostName() == "lunix4k" and getCPUSoC() == "72604" and getBoxHostName() != "vuzero4k": - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitarmvu /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv ' + - LinkNeoBoot + '/tmpfiles/arm_run.py ' + LinkNeoBoot + '/run.py; rm -f ' + LinkNeoBoot + '/bin/neoinitarmvuDuo4k; cd') + elif ( + getBoxHostName() == "vuultimo4k" + or getBoxHostName() == "vusolo4k" + or getBoxHostName() == "vuuno4k" + or getBoxHostName() == "vuuno4kse" + and getBoxHostName() != "ustym4kpro" + ): + os.system("cd " + LinkNeoBoot + "/") + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitarm /sbin/neoinitarm; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitarmvu /sbin/neoinitarmvu; cd" + ) + os.system( + "chmod 755 /sbin/neoinitarm; chmod 755 /sbin/neoinitarmvu") + os.system( + "dd if=/dev/mmcblk0p1 of=%sImagesUpload/.kernel/flash-kernel-%s.bin" % + (getNeoLocation(), getBoxHostName())) + os.system( + "mv " + + LinkNeoBoot + + "/tmpfiles/vu4k_run.py " + + LinkNeoBoot + + "/run.py; rm -f; rm -f " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k; cd" + ) - elif getBoxHostName() == "revo4k" and getCPUSoC() == "7252S" and getBoxHostName() != "vuuno4k": - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitarmvu /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv ' + - LinkNeoBoot + '/tmpfiles/arm_run.py ' + LinkNeoBoot + '/run.py; rm -f ' + LinkNeoBoot + '/bin/neoinitarmvuDuo4k; cd') + elif ( + getBoxHostName() == "lunix4k" + and getCPUSoC() == "72604" + and getBoxHostName() != "vuzero4k" + ): + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitarmvu /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv " + + LinkNeoBoot + + "/tmpfiles/arm_run.py " + + LinkNeoBoot + + "/run.py; rm -f " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k; cd") - elif getBoxHostName() == "osmio4k" or getBoxHostName() == "osmio4kplus" or getBoxHostName() == "osmini4k": - os.system('mv ' + LinkNeoBoot + '/bin/neoinitmips ' + LinkNeoBoot + '/bin/neoinitosmi4k; cp -af ' + LinkNeoBoot + '/bin/neoinitosmi4k /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv ' + - LinkNeoBoot + '/tmpfiles/arm_run.py ' + LinkNeoBoot + '/run.py; rm -f ' + LinkNeoBoot + '/bin/neoinitarmvuDuo4k; cd') + elif ( + getBoxHostName() == "revo4k" + and getCPUSoC() == "7252S" + and getBoxHostName() != "vuuno4k" + ): + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitarmvu /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv " + + LinkNeoBoot + + "/tmpfiles/arm_run.py " + + LinkNeoBoot + + "/run.py; rm -f " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k; cd") + + elif ( + getBoxHostName() == "osmio4k" + or getBoxHostName() == "osmio4kplus" + or getBoxHostName() == "osmini4k" + ): + os.system( + "mv " + + LinkNeoBoot + + "/bin/neoinitmips " + + LinkNeoBoot + + "/bin/neoinitosmi4k; cp -af " + + LinkNeoBoot + + "/bin/neoinitosmi4k /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv " + + LinkNeoBoot + + "/tmpfiles/arm_run.py " + + LinkNeoBoot + + "/run.py; rm -f " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k; cd") else: - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitarm /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv ' + - LinkNeoBoot + '/tmpfiles/arm_run.py ' + LinkNeoBoot + '/run.py; rm -f ' + LinkNeoBoot + '/bin/neoinitarmvuDuo4k; cd') + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitarm /sbin/neoinitarm; chmod 0755 /sbin/neoinitarm; ln -sfn /sbin/neoinitarm /sbin/init; mv " + + LinkNeoBoot + + "/tmpfiles/arm_run.py " + + LinkNeoBoot + + "/run.py; rm -f " + + LinkNeoBoot + + "/bin/neoinitarmvuDuo4k; cd") - # STB MIPS - elif getCPUtype() == 'MIPS': - os.system('chmod 755 ' + LinkNeoBoot + '/bin/nfidump; chmod 0755 ' + - LinkNeoBoot + '/bin/nanddump_mips; cd /') - if fileExists('' + getNeoLocation() + 'ImagesUpload/.kernel/' + getBoxHostName() + '.vmlinux.gz') and not os.path.isfile('/etc/name'): - os.system('rm -r ' + getNeoLocation() + - 'ImagesUpload/.kernel/' + getBoxHostName() + '.vmlinux.gz') - # vuplus stb mtd1 - if getBoxHostName() == 'bm750' or getBoxHostName() == 'vuduo' or getBoxHostName() == 'vusolo' or getBoxHostName() == 'vuuno' or getBoxHostName() == 'vuultimo': - if fileExists('/usr/sbin/nanddump'): - os.system('cd ' + getNeoLocation() + - 'ImagesUpload/.kernel/; /usr/sbin/nanddump -f vmlinux.gz /dev/mtd1; mv ./vmlinux.gz ./' + getBoxHostName() + '.vmlinux.gz') - elif not fileExists('/usr/sbin/nanddump'): - os.system('cd ' + getNeoLocation() + 'ImagesUpload/.kernel/; ' + LinkNeoBoot + - '/bin/nanddump_mips -f vmlinux.gz /dev/mtd1; mv ./vmlinux.gz ./' + getBoxHostName() + '.vmlinux.gz') - os.system('cd ' + LinkNeoBoot + '/; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo;mv ' + - LinkNeoBoot + '/tmpfiles/vu_run.py ' + LinkNeoBoot + '/run.py; cd') - # os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmipsvu') #test nowe pli - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmips; cp -Rf ' + - LinkNeoBoot + '/bin/neoinitmipsvu /sbin/neoinitmipsvu') + elif getCPUtype() == "MIPS": + os.system( + "chmod 755 " + + LinkNeoBoot + + "/bin/nfidump; chmod 0755 " + + LinkNeoBoot + + "/bin/nanddump_mips; cd /" + ) + if fileExists( + "" + + getNeoLocation() + + "ImagesUpload/.kernel/" + + getBoxHostName() + + ".vmlinux.gz" + ) and not os.path.isfile("/etc/name"): + os.system( + "rm -r " + + getNeoLocation() + + "ImagesUpload/.kernel/" + + getBoxHostName() + + ".vmlinux.gz" + ) + if ( + getBoxHostName() == "bm750" + or getBoxHostName() == "vuduo" + or getBoxHostName() == "vusolo" + or getBoxHostName() == "vuuno" + or getBoxHostName() == "vuultimo" + ): + if fileExists("/usr/sbin/nanddump"): + os.system( + "cd " + + getNeoLocation() + + "ImagesUpload/.kernel/; /usr/sbin/nanddump -f vmlinux.gz /dev/mtd1; mv ./vmlinux.gz ./" + + getBoxHostName() + + ".vmlinux.gz") + elif not fileExists("/usr/sbin/nanddump"): + os.system( + "cd " + + getNeoLocation() + + "ImagesUpload/.kernel/; " + + LinkNeoBoot + + "/bin/nanddump_mips -f vmlinux.gz /dev/mtd1; mv ./vmlinux.gz ./" + + getBoxHostName() + + ".vmlinux.gz") + os.system( + "cd " + + LinkNeoBoot + + "/; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo;mv " + + LinkNeoBoot + + "/tmpfiles/vu_run.py " + + LinkNeoBoot + + "/run.py; cd" + ) + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitmips /sbin/neoinitmips; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitmipsvu /sbin/neoinitmipsvu" + ) - # vuplus stb mtd2 - elif getBoxHostName() == 'vuduo2' or getBoxHostName() == 'vusolose' or getBoxHostName() == 'vuzero': - if fileExists('/usr/sbin/nanddump'): - os.system('cd ' + getNeoLocation() + - 'ImagesUpload/.kernel/; /usr/sbin/nanddump /dev/mtd2 -f vmlinux.gz; mv ./vmlinux.gz ./' + getBoxHostName() + '.vmlinux.gz') - elif not fileExists('/usr/sbin/nanddump'): - os.system('cd ' + getNeoLocation() + 'ImagesUpload/.kernel/; ' + LinkNeoBoot + - '/bin/nanddump_mips -f vmlinux.gz /dev/mtd2; mv ./vmlinux.gz ./' + getBoxHostName() + '.vmlinux.gz') - os.system('cd ' + LinkNeoBoot + '/; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo; mv ' + - LinkNeoBoot + '/tmpfiles/vu_run.py ' + LinkNeoBoot + '/run.py; cd') - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmips; cp -Rf ' + - LinkNeoBoot + '/bin/neoinitmips_vu /sbin/neoinitmipsvu') + elif ( + getBoxHostName() == "vuduo2" + or getBoxHostName() == "vusolose" + or getBoxHostName() == "vuzero" + ): + if fileExists("/usr/sbin/nanddump"): + os.system( + "cd " + + getNeoLocation() + + "ImagesUpload/.kernel/; /usr/sbin/nanddump /dev/mtd2 -f vmlinux.gz; mv ./vmlinux.gz ./" + + getBoxHostName() + + ".vmlinux.gz") + elif not fileExists("/usr/sbin/nanddump"): + os.system( + "cd " + + getNeoLocation() + + "ImagesUpload/.kernel/; " + + LinkNeoBoot + + "/bin/nanddump_mips -f vmlinux.gz /dev/mtd2; mv ./vmlinux.gz ./" + + getBoxHostName() + + ".vmlinux.gz") + os.system( + "cd " + + LinkNeoBoot + + "/; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo; mv " + + LinkNeoBoot + + "/tmpfiles/vu_run.py " + + LinkNeoBoot + + "/run.py; cd" + ) + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitmips /sbin/neoinitmips; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitmips_vu /sbin/neoinitmipsvu" + ) - elif getBoxHostName() == 'vusolo2': - if fileExists('/usr/sbin/nanddump'): - os.system('cd ' + getNeoLocation() + - 'ImagesUpload/.kernel/; /usr/sbin/nanddump /dev/mtd2 -f vmlinux.gz; mv ./vmlinux.gz ./' + getBoxHostName() + '.vmlinux.gz') - elif not fileExists('/usr/sbin/nanddump'): - os.system('cd ' + getNeoLocation() + 'ImagesUpload/.kernel/; ' + LinkNeoBoot + - '/bin/nanddump_mips -o -b vmlinux.gz /dev/mtd2; mv ./vmlinux.gz ./' + getBoxHostName() + '.vmlinux.gz') - os.system('cd ' + LinkNeoBoot + '/; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo; mv ' + - LinkNeoBoot + '/tmpfiles/vu_run.py ' + LinkNeoBoot + '/run.py; cd') - os.system('cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmips; cp -Rf ' + - LinkNeoBoot + '/bin/neoinitmipsvu /sbin/neoinitmipsvu') + elif getBoxHostName() == "vusolo2": + if fileExists("/usr/sbin/nanddump"): + os.system( + "cd " + + getNeoLocation() + + "ImagesUpload/.kernel/; /usr/sbin/nanddump /dev/mtd2 -f vmlinux.gz; mv ./vmlinux.gz ./" + + getBoxHostName() + + ".vmlinux.gz") + elif not fileExists("/usr/sbin/nanddump"): + os.system( + "cd " + + getNeoLocation() + + "ImagesUpload/.kernel/; " + + LinkNeoBoot + + "/bin/nanddump_mips -o -b vmlinux.gz /dev/mtd2; mv ./vmlinux.gz ./" + + getBoxHostName() + + ".vmlinux.gz") + os.system( + "cd " + + LinkNeoBoot + + "/; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo; mv " + + LinkNeoBoot + + "/tmpfiles/vu_run.py " + + LinkNeoBoot + + "/run.py; cd" + ) + os.system( + "cp -af " + + LinkNeoBoot + + "/bin/neoinitmips /sbin/neoinitmips; cp -Rf " + + LinkNeoBoot + + "/bin/neoinitmipsvu /sbin/neoinitmipsvu" + ) os.system( - 'opkg install --force-maintainer --force-reinstall --force-overwrite --force-downgrade kernel-image') - if fileExists('/home/root/*.ipk'): - os.system('rm -Rf /home/root/*.ipk') - os.system('opkg download kernel-image; sleep 2; mv /home/root/*.ipk ' + - getNeoLocation() + 'ImagesUpload/.kernel/zImage.%s.ipk' % getBoxVuModel()) + "opkg install --force-maintainer --force-reinstall --force-overwrite --force-downgrade kernel-image" + ) + if fileExists("/home/root/*.ipk"): + os.system("rm -Rf /home/root/*.ipk") + os.system( + "opkg download kernel-image; sleep 2; mv /home/root/*.ipk " + + getNeoLocation() + + "ImagesUpload/.kernel/zImage.%s.ipk" % getBoxVuModel() + ) - # Other stb MIPS else: - os.system('cd ' + LinkNeoBoot + '/; chmod 755 ./bin/nandwrite; mv ./bin/fontforneoboot.ttf /usr/share/fonts; mv ./bin/libpngneo /usr/lib; cp -f ./bin/neoinitmips /sbin/neoinitmips; cp -f ./bin/neoinitmipsvu /sbin/neoinitmipsvu; chmod 0755 /sbin/neoinit*; mv ./bin/neobmmips ./bin/neobm; chmod 0755 ./bin/neobm; chmod 0755 /usr/lib/libpngneo; cd; chmod 0755 /sbin/neoinitmips; ln -sf /media/neoboot/ImageBoot/.neonextboot /etc/neoimage; mv ' + LinkNeoBoot + '/tmpfiles/mips_run.py ' + LinkNeoBoot + '/run.py; cd') + os.system( + "cd " + + LinkNeoBoot + + "/; chmod 755 ./bin/nandwrite; mv ./bin/fontforneoboot.ttf /usr/share/fonts; mv ./bin/libpngneo /usr/lib; cp -f ./bin/neoinitmips /sbin/neoinitmips; cp -f ./bin/neoinitmipsvu /sbin/neoinitmipsvu; chmod 0755 /sbin/neoinit*; mv ./bin/neobmmips ./bin/neobm; chmod 0755 ./bin/neobm; chmod 0755 /usr/lib/libpngneo; cd; chmod 0755 /sbin/neoinitmips; ln -sf /media/neoboot/ImageBoot/.neonextboot /etc/neoimage; mv " + + LinkNeoBoot + + "/tmpfiles/mips_run.py " + + LinkNeoBoot + + "/run.py; cd") if getBoxHostName() == "et5x00": - os.system('cd ' + LinkNeoBoot + '/; cp -af ./bin/neoinitarmvuDuo4k /sbin/neoinitmips; cp -af ./bin/neoinitmips ./bin/neoinitmipsvu; cp -af ./bin/neoinitarmvuDuo4k ./bin/neoinitmips; cd') - if getBoxHostName() == 'dm500hd' or getBoxHostName() == 'dm800se' or getBoxHostName() == 'dm800' or getBoxHostName() == 'dm8000': - os.system('cd ' + LinkNeoBoot + - '/; cp -af ./bin/dminit /sbin/neoinitmips; cp -af ./bin/neoinitmipsvu ./bin/neoinitmipsvu; rm -r ./ubi_reade*; cd') - os.system('chmod 755 ' + LinkNeoBoot + '/bin/nfidump; chmod 0755 ' + LinkNeoBoot + - '/bin/nanddump_mips; rm -r ' + LinkNeoBoot + '/bin/neoinitar*; cd /') - if fileExists('' + LinkNeoBoot + '/bin/fontforneoboot.ttf'): - ('cd ' + LinkNeoBoot + - '/;mv ./bin/fontforneoboot.ttf /usr/share/fonts; cd /') - if fileExists('' + LinkNeoBoot + '/bin/libpngneo'): - ('cd ' + LinkNeoBoot + - '/;mv ./bin/libpngneo /usr/lib; chmod 0755 /usr/lib/libpngneo; cd /') - if fileExists('' + LinkNeoBoot + '/bin/neobm'): - ('cd ' + LinkNeoBoot + '/;chmod 0755 ./bin/neobm; cd /') + os.system( + "cd " + + LinkNeoBoot + + "/; cp -af ./bin/neoinitarmvuDuo4k /sbin/neoinitmips; cp -af ./bin/neoinitmips ./bin/neoinitmipsvu; cp -af ./bin/neoinitarmvuDuo4k ./bin/neoinitmips; cd") + if ( + getBoxHostName() == "dm500hd" + or getBoxHostName() == "dm800se" + or getBoxHostName() == "dm800" + or getBoxHostName() == "dm8000" + ): + os.system( + "cd " + + LinkNeoBoot + + "/; cp -af ./bin/dminit /sbin/neoinitmips; cp -af ./bin/neoinitmipsvu ./bin/neoinitmipsvu; rm -r ./ubi_reade*; cd") + os.system( + "chmod 755 " + + LinkNeoBoot + + "/bin/nfidump; chmod 0755 " + + LinkNeoBoot + + "/bin/nanddump_mips; rm -r " + + LinkNeoBoot + + "/bin/neoinitar*; cd /" + ) + if fileExists("" + LinkNeoBoot + "/bin/fontforneoboot.ttf"): + ( + "cd " + + LinkNeoBoot + + "/;mv ./bin/fontforneoboot.ttf /usr/share/fonts; cd /" + ) + if fileExists("" + LinkNeoBoot + "/bin/libpngneo"): + ("cd " + LinkNeoBoot + + "/;mv ./bin/libpngneo /usr/lib; chmod 0755 /usr/lib/libpngneo; cd /") + if fileExists("" + LinkNeoBoot + "/bin/neobm"): + ("cd " + LinkNeoBoot + "/;chmod 0755 ./bin/neobm; cd /") else: - self.messagebox = self.session.open(MessageBox, _( - 'The tuner is not supported by NeoBoot.\nContact the author.\nNo proper STB for installation !!!!'), type=MessageBox.TYPE_ERROR) + self.messagebox = self.session.open( + MessageBox, + _("The tuner is not supported by NeoBoot.\nContact the author.\nNo proper STB for installation !!!!"), + type=MessageBox.TYPE_ERROR, + ) - if fileExists('/home/root/vmlinux.gz'): - os.system('mv -f /home/root/vmlinux.gz %sImagesUpload/.kernel/%s.vmlinux.gz' % - (getNeoLocation(), getBoxHostName())) + if fileExists("/home/root/vmlinux.gz"): + os.system( + "mv -f /home/root/vmlinux.gz %sImagesUpload/.kernel/%s.vmlinux.gz" % + (getNeoLocation(), getBoxHostName())) - if fileExists('' + LinkNeoBoot + '/ubi_reader_mips') or fileExists('' + LinkNeoBoot + '/ubi_reader_arm') and fileExists('' + LinkNeoBoot + '/ubi_reader'): - os.system('rm -r ' + LinkNeoBoot + '/ubi_reader ') + if ( + fileExists("" + LinkNeoBoot + "/ubi_reader_mips") + or fileExists("" + LinkNeoBoot + "/ubi_reader_arm") + and fileExists("" + LinkNeoBoot + "/ubi_reader") + ): + os.system("rm -r " + LinkNeoBoot + "/ubi_reader ") - if getCPUtype() == 'ARMv7': - os.system('cd ' + LinkNeoBoot + '/;chmod 755 ./files/findsk.sh; mv ./bin/fbcleararm ./bin/fbclear; chmod 755 ./bin/fbclear; rm -f ./bin/nandwrite; rm -f ./bin/fbclearmips; mv ./ubi_reader_arm ./ubi_reader; rm -r ./ubi_reader_mips; rm ./bin/neoinitmips; rm ./bin/neoinitmipsvu; rm -r ./bin/nanddump_mips; rm ./bin/nfidump; rm ./bin/neobmmips; mv ./bin/neobmarm ./bin/neobm; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo; rm ./bin/dminit; cd') - elif getCPUtype() == 'MIPS': - os.system('cd ' + LinkNeoBoot + '/;rm -f ./files/findsk.sh; mv ./bin/fbclearmips ./bin/fbclear; chmod 755 ./bin/fbclear; rm -f ./bin/fbcleararm; mv ./ubi_reader_mips ./ubi_reader; rm -r ./ubi_reader_arm; rm -f /bin/neoinitarm; rm -f /bin/neoinitarmvu; rm -r ./bin/nanddump_arm; rm -f /bin/neoinitarmvuDuo4k; rm -f ./bin/neobmarm') + if getCPUtype() == "ARMv7": + os.system( + "cd " + + LinkNeoBoot + + "/;chmod 755 ./files/findsk.sh; mv ./bin/fbcleararm ./bin/fbclear; chmod 755 ./bin/fbclear; rm -f ./bin/nandwrite; rm -f ./bin/fbclearmips; mv ./ubi_reader_arm ./ubi_reader; rm -r ./ubi_reader_mips; rm ./bin/neoinitmips; rm ./bin/neoinitmipsvu; rm -r ./bin/nanddump_mips; rm ./bin/nfidump; rm ./bin/neobmmips; mv ./bin/neobmarm ./bin/neobm; rm ./bin/fontforneoboot.ttf; rm ./bin/libpngneo; rm ./bin/dminit; cd" + ) + elif getCPUtype() == "MIPS": + os.system( + "cd " + + LinkNeoBoot + + "/;rm -f ./files/findsk.sh; mv ./bin/fbclearmips ./bin/fbclear; chmod 755 ./bin/fbclear; rm -f ./bin/fbcleararm; mv ./ubi_reader_mips ./ubi_reader; rm -r ./ubi_reader_arm; rm -f /bin/neoinitarm; rm -f /bin/neoinitarmvu; rm -r ./bin/nanddump_arm; rm -f /bin/neoinitarmvuDuo4k; rm -f ./bin/neobmarm" + ) - os.system(' ln -sfn ' + LinkNeoBoot + '/files/userscript.sh /etc/rcS.d/S99neo.local; ln -sfn ' + getNeoLocation() + 'ImageBoot/.neonextboot /etc/neoimage; chmod 644 ' + getNeoLocation() + - 'ImagesUpload/.kernel/*; ln -sfn ' + getNeoLocation() + 'ImageBoot /etc/imageboot; rm -r ' + LinkNeoBoot + '/tmpfiles; chmod 0755 ' + LinkNeoBoot + '/files/kernel.sh') + os.system( + " ln -sfn " + + LinkNeoBoot + + "/files/userscript.sh /etc/rcS.d/S99neo.local; ln -sfn " + + getNeoLocation() + + "ImageBoot/.neonextboot /etc/neoimage; chmod 644 " + + getNeoLocation() + + "ImagesUpload/.kernel/*; ln -sfn " + + getNeoLocation() + + "ImageBoot /etc/imageboot; rm -r " + + LinkNeoBoot + + "/tmpfiles; chmod 0755 " + + LinkNeoBoot + + "/files/kernel.sh" + ) - if os.path.isfile('' + LinkNeoBoot + '/.location'): - if getLabelDisck() != 'LABEL=': - cmd = "echo -e '\n%s '" % _('NeoBoot has been installed succesfully!\nNeoBoot has detected that the disks do not have a label.\nFor correct neo boot operation, please give the disks the name LABEL\nRecommended total restart of the tuner.\n') - elif getLabelDisck() == 'LABEL=': + if os.path.isfile("" + LinkNeoBoot + "/.location"): + if getLabelDisck() != "LABEL=": cmd = "echo -e '\n%s '" % _( - 'Installed succesfully NEOBOOT!\nNeoBoot has detected that the disks have been marked.\nRecommended total restart of the tuner\n') + "NeoBoot has been installed succesfully!\nNeoBoot has detected that the disks do not have a label.\nFor correct neo boot operation, please give the disks the name LABEL\nRecommended total restart of the tuner.\n" + ) + elif getLabelDisck() == "LABEL=": + cmd = "echo -e '\n%s '" % _( + "Installed succesfully NEOBOOT!\nNeoBoot has detected that the disks have been marked.\nRecommended total restart of the tuner\n" + ) else: - self.myclose2(_('NeoBoot has not been installed ! :(')) + self.myclose2(_("NeoBoot has not been installed ! :(")) - if os.path.isfile('/etc/name'): - self.myclose2(_('The plug-in has been successfully installed.')) + if os.path.isfile("/etc/name"): + self.myclose2(_("The plug-in has been successfully installed.")) self.close() else: - if not fileExists('/etc/name'): - os.system('touch /etc/name') + if not fileExists("/etc/name"): + os.system("touch /etc/name") closereboot = self.rebootSTBE2() - self.session.open(Console, _('NeoBoot Install....'), [cmd]) + self.session.open(Console, _("NeoBoot Install...."), [cmd]) self.close(closereboot) def myclose2(self, message): @@ -866,14 +1403,16 @@ class NeoBootInstallation(Screen): def rebootSTBE2(self): restartbox = self.session.openWithCallback( - self.RebootSTB, MessageBox, _('Reboot stb now ?'), MessageBox.TYPE_YESNO) - restartbox.setTitle(_('Reboot')) + self.RebootSTB, + MessageBox, + _("Reboot stb now ?"), + MessageBox.TYPE_YESNO) + restartbox.setTitle(_("Reboot")) def RebootSTB(self, answer): if answer is True: - cmd = 'echo 3 > /proc/sys/vm/drop_caches; shutdown -r now ;sleep 1; reboot -d -f &' + cmd = "echo 3 > /proc/sys/vm/drop_caches; shutdown -r now ;sleep 1; reboot -d -f &" rc = os.system(cmd) - # os.system('sync && echo 3 > /proc/sys/vm/drop_caches; reboot -d -f') else: self.close() @@ -882,394 +1421,507 @@ class NeoBootImageChoose(Screen): if isFHD(): try: from Plugins.Extensions.NeoBoot.usedskin import ImageChooseFULLHD + skin = ImageChooseFULLHD - except: + except BaseException: from Plugins.Extensions.NeoBoot.neoskins.default import ImageChooseFULLHD + skin = ImageChooseFULLHD elif isUHD(): from Plugins.Extensions.NeoBoot.neoskins.default import ImageChooseULTRAHD + skin = ImageChooseULTRAHD else: try: from Plugins.Extensions.NeoBoot.usedskin import ImageChooseHD + skin = ImageChooseHD - except: + except BaseException: from Plugins.Extensions.NeoBoot.neoskins.default import ImageChooseHD + skin = ImageChooseHD def __init__(self, session): Screen.__init__(self, session) self.list = [] - self.setTitle(' NeoBoot %s - Menu' % PLUGINVERSION + - ' ' + 'Ver. update: %s' % UPDATEVERSION) - self['device_icon'] = Pixmap() - self['progreso'] = ProgressBar() - self['linea'] = ProgressBar() - self['config'] = MenuList(self.list) - self['key_red'] = Label(_('Download Image')) - self['key_green'] = Label(_('Installation')) - self['key_yellow'] = Label(_('Remove Image ')) - self['key_blue'] = Label(_('Info')) - self['key_menu'] = Label(_('More options')) - self['key_1'] = Label(_('Update NeoBot')) - self['key_2'] = Label(_('Reinstall NeoBoot')) - self['key_3'] = Label(_('Reinstall kernel')) - self['label1'] = Label(_('Please choose an image to boot')) - self['label2'] = Label(_('NeoBoot is running from:')) - self['label3'] = Label('') - self['label4'] = Label(_('NeoBoot is running image:')) - self['label5'] = Label('') - self['label6'] = Label('') - self['label7'] = Label('') - self['label8'] = Label(_('Number of images installed:')) - self['label9'] = Label('') - self['label10'] = Label('') - self['label11'] = Label('') - self['label12'] = Label('') - self['label13'] = Label(_('Version update: ')) - if fileExists('/.multinfo') and getImageNeoBoot() != "Flash": - self['label14'] = Label(_('VIP-on NeoBoot: ')) - elif getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn'): - self['label14'] = Label(_('VIP-on NeoBoot: ')) + self.setTitle( + " NeoBoot %s - Menu" % PLUGINVERSION + + " " + + "Ver. update: %s" % UPDATEVERSION + ) + self["device_icon"] = Pixmap() + self["progreso"] = ProgressBar() + self["linea"] = ProgressBar() + self["config"] = MenuList(self.list) + self["key_red"] = Label(_("Download Image")) + self["key_green"] = Label(_("Installation")) + self["key_yellow"] = Label(_("Remove Image ")) + self["key_blue"] = Label(_("Info")) + self["key_menu"] = Label(_("More options")) + self["key_1"] = Label(_("Update NeoBot")) + self["key_2"] = Label(_("Reinstall NeoBoot")) + self["key_3"] = Label(_("Reinstall kernel")) + self["label1"] = Label(_("Please choose an image to boot")) + self["label2"] = Label(_("NeoBoot is running from:")) + self["label3"] = Label("") + self["label4"] = Label(_("NeoBoot is running image:")) + self["label5"] = Label("") + self["label6"] = Label("") + self["label7"] = Label("") + self["label8"] = Label(_("Number of images installed:")) + self["label9"] = Label("") + self["label10"] = Label("") + self["label11"] = Label("") + self["label12"] = Label("") + self["label13"] = Label(_("Version update: ")) + if fileExists("/.multinfo") and getImageNeoBoot() != "Flash": + self["label14"] = Label(_("VIP-on NeoBoot: ")) + elif getCheckActivateVip() == getBoxMacAddres() and fileExists( + "/usr/lib/periodon/.kodn" + ): + self["label14"] = Label(_("VIP-on NeoBoot: ")) else: - self['label14'] = Label(_('VIP-off NeoBoot: ')) - self['label15'] = Label(_('Memory disc:')) - self['label16'] = Label(_('Kernel')) - self['label17'] = Label('') - self['label18'] = Label('') - self['label19'] = Label('') - self['label20'] = Label('') - if fileExists('/.multinfo') and getImageNeoBoot() != "Flash": - self['label21'] = Label('VIP-OK!') - elif getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn'): - self['label21'] = Label('VIP-OK!') + self["label14"] = Label(_("VIP-off NeoBoot: ")) + self["label15"] = Label(_("Memory disc:")) + self["label16"] = Label(_("Kernel")) + self["label17"] = Label("") + self["label18"] = Label("") + self["label19"] = Label("") + self["label20"] = Label("") + if fileExists("/.multinfo") and getImageNeoBoot() != "Flash": + self["label21"] = Label("VIP-OK!") + elif getCheckActivateVip() == getBoxMacAddres() and fileExists( + "/usr/lib/periodon/.kodn" + ): + self["label21"] = Label("VIP-OK!") else: - self['label21'] = Label('Enter pin code') - self['actions'] = ActionMap(['WizardActions', - 'ColorActions', - 'MenuActions', - 'NumberActionMap', - 'SetupActions', - 'number'], {'ok': self.bootIMG, - 'red': self.DownloadImageOnline, - 'green': self.ImageInstall, - 'yellow': self.removeIMG, - 'blue': self.pomoc, - 'menu': self.mytools, - '1': self.neoboot_update, - '2': self.ReinstallNeoBoot, - '3': self.ReinstallKernel, - '4': self.touch4, # hidden option - '5': self.touch5, # hidden option - '6': self.touch6, # hidden option - '7': self.touch7, # hidden option - '8': self.touch8, # hidden option - '9': self.touch9, # hidden option - '0': self.touch0, # hidden option - 'back': self.close_exit}) + self["label21"] = Label("Enter pin code") + self["actions"] = ActionMap( + [ + "WizardActions", + "ColorActions", + "MenuActions", + "NumberActionMap", + "SetupActions", + "number", + ], + { + "ok": self.bootIMG, + "red": self.DownloadImageOnline, + "green": self.ImageInstall, + "yellow": self.removeIMG, + "blue": self.pomoc, + "menu": self.mytools, + "1": self.neoboot_update, + "2": self.ReinstallNeoBoot, + "3": self.ReinstallKernel, + "4": self.touch4, # hidden option + "5": self.touch5, # hidden option + "6": self.touch6, # hidden option + "7": self.touch7, # hidden option + "8": self.touch8, # hidden option + "9": self.touch9, # hidden option + "0": self.touch0, # hidden option + "back": self.close_exit, + }, + ) self.availablespace = 0 self.onShow.append(self.updateList) - if not fileExists('' + LinkNeoBoot + '/files/mountpoint.sh'): + if not fileExists("" + LinkNeoBoot + "/files/mountpoint.sh"): getMountPointAll() - if not fileExists('' + LinkNeoBoot + '/files/neo.sh'): + if not fileExists("" + LinkNeoBoot + "/files/neo.sh"): getMountPointNeo() - if os.path.exists('/media/hdd/swapfile') or os.path.exists('/media/usb/swapfile') or os.path.exists('/swapfile'): - system('swapon -a') + if ( + os.path.exists("/media/hdd/swapfile") + or os.path.exists("/media/usb/swapfile") + or os.path.exists("/swapfile") + ): + system("swapon -a") - if fileExists('/tmp/.init_reboot'): - system('rm /tmp/.init_reboot') + if fileExists("/tmp/.init_reboot"): + system("rm /tmp/.init_reboot") - if fileExists('/media/sda1'): - if len(os.listdir('/media/sda1')) == 0: - os.system('rm -r /media/sda1') - # print("Directory sda1 is empty") + if fileExists("/media/sda1"): + if len(os.listdir("/media/sda1")) == 0: + os.system("rm -r /media/sda1") - if fileExists('/media/sdb1'): - if len(os.listdir('/media/sdb1')) == 0: - os.system('rm -r /media/sdb1') - # print("Directory sdb1 is empty") + if fileExists("/media/sdb1"): + if len(os.listdir("/media/sdb1")) == 0: + os.system("rm -r /media/sdb1") - if fileExists('/.multinfo'): - if not fileExists('/.control_ok'): - if fileExists('/.control_boot_new_image'): + if fileExists("/.multinfo"): + if not fileExists("/.control_ok"): + if fileExists("/.control_boot_new_image"): os.system( - 'rm -f /.control_boot_new_image; echo "Image uruchomione OK\nNie kasuj tego pliku. \n\nImage started OK\nDo not delete this file." > /.control_ok ') - if not fileExists('/.control_boot_new_image'): + 'rm -f /.control_boot_new_image; echo "Image uruchomione OK\nNie kasuj tego pliku. \n\nImage started OK\nDo not delete this file." > /.control_ok ' + ) + if not fileExists("/.control_boot_new_image"): os.system( - 'echo "Image uruchomione OK\nNie kasuj tego pliku. \n\nImage started OK\nDo not delete this file." > /.control_ok') + 'echo "Image uruchomione OK\nNie kasuj tego pliku. \n\nImage started OK\nDo not delete this file." > /.control_ok' + ) def DownloadImageOnline(self): - if not fileExists('/usr/lib/python2.7'): + if not fileExists("/usr/lib/python2.7"): mess = _( - 'Plug installation lost.The plugin doesnt work on python 3 yet. Please try again later.') + "Plug installation lost.The plugin doesnt work on python 3 yet. Please try again later." + ) self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) - elif not os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/download.py'): + elif not os.path.exists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/download.py" + ): message = _( - 'Plugin ImageDownloader not installed!\nInstall plugin to download new image? \and---Continue ?---') + "Plugin ImageDownloader not installed!\nInstall plugin to download new image? \and---Continue ?---" + ) ybox = self.session.openWithCallback( self.InstallImageDownloader, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Installation')) + ybox.setTitle(_("Installation")) else: try: from Plugins.Extensions.ImageDownloader.main import STBmodelsScreen + self.session.open(STBmodelsScreen) except Exception as e: - system('rm -f ' + getNeoLocation() + 'ImageBoot/neoboot.log') + system("rm -f " + getNeoLocation() + "ImageBoot/neoboot.log") loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def InstallImageDownloader(self, yesno): if yesno: if checkInternet(): - cmd = 'mkdir /tmp/install; touch /tmp/install/plugin.txt; rm -rf /tmp/*.ipk' + cmd = "mkdir /tmp/install; touch /tmp/install/plugin.txt; rm -rf /tmp/*.ipk" system(cmd) - if fileExists('/usr/bin/curl'): + if fileExists("/usr/bin/curl"): os.system( - 'cd /tmp; curl -O --ftp-ssl -k http://read.cba.pl/box/skrypt/img.sh') - if not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader'): - if fileExists('/usr/bin/fullwget'): - cmd1 = 'cd /tmp; fullwget --no-check-certificate http://read.cba.pl/box/skrypt/img.sh' + "cd /tmp; curl -O --ftp-ssl -k http://read.cba.pl/box/skrypt/img.sh" + ) + if not fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader" + ): + if fileExists("/usr/bin/fullwget"): + cmd1 = "cd /tmp; fullwget --no-check-certificate http://read.cba.pl/box/skrypt/img.sh" system(cmd1) - if not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader'): - if fileExists('/usr/bin/wget'): + if not fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader" + ): + if fileExists("/usr/bin/wget"): os.system( - 'cd /tmp; wget --no-check-certificate http://read.cba.pl/box/skrypt/img.sh') - if fileExists('/tmp/img.sh'): - cmd2 = 'chmod -R +x /tmp/img.sh; /tmp/img.sh; sleep 2; rm /tmp/img.sh' + "cd /tmp; wget --no-check-certificate http://read.cba.pl/box/skrypt/img.sh" + ) + if fileExists("/tmp/img.sh"): + cmd2 = ( + "chmod -R +x /tmp/img.sh; /tmp/img.sh; sleep 2; rm /tmp/img.sh" + ) system(cmd2) - if not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py') and fileExists('/usr/bin/curl'): + if not fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py" + ) and fileExists("/usr/bin/curl"): os.system( - 'cd /tmp; curl -O --ftp-ssl -k http://read.cba.pl/box/plugin/enigma2-plugin-extensions-imagedownloader_all.ipk') - if fileExists('/tmp/enigma2-plugin-extensions-imagedownloader_all.ipk'): - cmd2 = 'opkg install --force-overwrite --force-reinstall --force-downgrade /tmp/enigma2-plugin-extensions-imagedownloader_all.ipk; rm /tmp/enigma2-plugin-extensions-imagedownloader_all.ipk' + "cd /tmp; curl -O --ftp-ssl -k http://read.cba.pl/box/plugin/enigma2-plugin-extensions-imagedownloader_all.ipk" + ) + if fileExists( + "/tmp/enigma2-plugin-extensions-imagedownloader_all.ipk" + ): + cmd2 = "opkg install --force-overwrite --force-reinstall --force-downgrade /tmp/enigma2-plugin-extensions-imagedownloader_all.ipk; rm /tmp/enigma2-plugin-extensions-imagedownloader_all.ipk" system(cmd2) - if not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py') and fileExists('/usr/bin/curl'): + if not fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py" + ) and fileExists("/usr/bin/curl"): os.system( - 'cd /tmp; curl -O --ftp-ssl -k http://read.cba.pl/box/plugin/enigma2-plugin-extensions-imagedownloader_all.ipk') - cmd3 = 'cd /tmp; ar x enigma2-plugin-extensions-imagedownloader_all.ipk; rm -rf control.tar.gz; rm -rf *.ipk; rm -rf debian-binary; /bin/tar -xzvf /tmp/*.tar.gz -C /; rm -fr /tmp/*.tar.gz' + "cd /tmp; curl -O --ftp-ssl -k http://read.cba.pl/box/plugin/enigma2-plugin-extensions-imagedownloader_all.ipk" + ) + cmd3 = "cd /tmp; ar x enigma2-plugin-extensions-imagedownloader_all.ipk; rm -rf control.tar.gz; rm -rf *.ipk; rm -rf debian-binary; /bin/tar -xzvf /tmp/*.tar.gz -C /; rm -fr /tmp/*.tar.gz" system(cmd3) - if fileExists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py'): - self.session.open(MessageBox, _( - 'The plug-in has been successfully installed.'), MessageBox.TYPE_INFO, 5) + if fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py" + ): + self.session.open( + MessageBox, + _("The plug-in has been successfully installed."), + MessageBox.TYPE_INFO, + 5, + ) self.close() else: - if not fileExists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py'): - self.session.open(MessageBox, _( - 'The plugin not installed.\nAccess Fails with Error code 0x04.'), MessageBox.TYPE_INFO, 10) + if not fileExists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/plugin.py" + ): + self.session.open( + MessageBox, + _("The plugin not installed.\nAccess Fails with Error code 0x04."), + MessageBox.TYPE_INFO, + 10, + ) self.close() else: - mess = _('Geen internet') + mess = _("Geen internet") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: mess = _( - 'Upload image files in zip formats to the ImagesUpload location.') + "Upload image files in zip formats to the ImagesUpload location.") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) def chackkernel(self): message = _( - 'NeoBoot detected a kernel mismatch in flash, \nInstall a kernel for flash image??') + "NeoBoot detected a kernel mismatch in flash, \nInstall a kernel for flash image??" + ) ybox = self.session.openWithCallback( - self.updatekernel, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Updating ... ')) + self.updatekernel, MessageBox, message, MessageBox.TYPE_YESNO + ) + ybox.setTitle(_("Updating ... ")) def pomoc(self): try: from Plugins.Extensions.NeoBoot.files.tools import Opis + self.session.open(Opis) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def ReinstallNeoBoot(self): - INSTALLbox = self.session.openWithCallback(self.reinstallboot, MessageBox, _( - 'Select Yes to reinstall the neoboot.\n NEOBOOT.'), MessageBox.TYPE_YESNO) - INSTALLbox.setTitle(_('Reinstall neoboot')) + INSTALLbox = self.session.openWithCallback( + self.reinstallboot, + MessageBox, + _("Select Yes to reinstall the neoboot.\n NEOBOOT."), + MessageBox.TYPE_YESNO, + ) + INSTALLbox.setTitle(_("Reinstall neoboot")) def reinstallboot(self, answer): if answer is True: try: cmd = "echo -e '\n\n%s '" % _( - 'NEOBOOT - Please reinstall NeoBoot....\nPlease wait, done...\nrestart systemu...') - cmd1 = 'cd ' + LinkNeoBoot + '/; rm ./bin/install; rm ./.location; rm ./files/mountpoint.sh; rm ./files/neo.sh; sleep 5; PATH=/sbin:/bin:/usr/sbin:/usr/bin; echo -n "Restarting E2... "; init 4; sleep 1; init 3 ' - except: + "NEOBOOT - Please reinstall NeoBoot....\nPlease wait, done...\nrestart systemu..." + ) + cmd1 = ( + "cd " + + LinkNeoBoot + + '/; rm ./bin/install; rm ./.location; rm ./files/mountpoint.sh; rm ./files/neo.sh; sleep 5; PATH=/sbin:/bin:/usr/sbin:/usr/bin; echo -n "Restarting E2... "; init 4; sleep 1; init 3 ') + except BaseException: False - self.session.open(Console, _('NeoBoot ARM....'), [cmd, cmd1]) + self.session.open(Console, _("NeoBoot ARM...."), [cmd, cmd1]) self.close() else: try: - self.session.open(MessageBox, _( - 'Resignation.'), MessageBox.TYPE_INFO, 4) + self.session.open( + MessageBox, _("Resignation."), MessageBox.TYPE_INFO, 4 + ) self.close() - except: + except BaseException: False def close_exit(self): try: self.close_exit2() - except: - system('touch /tmp/.init_reboot') + except BaseException: + system("touch /tmp/.init_reboot") self.close() - # if fileExists('/usr/lib/python2.7'): - # self.close_exit2() - # else: - # system('touch /tmp/.init_reboot') - # self.close() - def close_exit2(self): - system('touch /tmp/.init_reboot') - if fileExists('/tmp/error_neo'): + system("touch /tmp/.init_reboot") + if fileExists("/tmp/error_neo"): try: - cmd = 'cat /tmp/error_neo' - cmd1 = '' - self.session.openWithCallback(self.close, Console, _('NeoBoot....'), [cmd, - cmd1]) + cmd = "cat /tmp/error_neo" + cmd1 = "" + self.session.openWithCallback( + self.close, Console, _("NeoBoot...."), [cmd, cmd1] + ) self.close() - except: + except BaseException: self.close() - if not fileExists('/tmp/.finishdate') or not fileExists('/tmp/.nkod') or fileExists('/.multinfo'): + if ( + not fileExists("/tmp/.finishdate") + or not fileExists("/tmp/.nkod") + or fileExists("/.multinfo") + ): if checkInternet(): pass else: system( - '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh') - mess = _('Geen internet') + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/userscript.sh" + ) + mess = _("Geen internet") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) - if not fileExists('/.multinfo'): - system('ln -sfn /sbin/init.sysvinit /sbin/init') - os.system('echo "Flash" > %sImageBoot/.neonextboot' % - getNeoLocation()) - # out = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w') - # out.write('Flash') - # out.close() - # self.close() + if not fileExists("/.multinfo"): + system("ln -sfn /sbin/init.sysvinit /sbin/init") + os.system( + 'echo "Flash" > %sImageBoot/.neonextboot' % + getNeoLocation()) - elif fileExists('/.multinfo'): - with open('/.multinfo', 'r') as f: + elif fileExists("/.multinfo"): + with open("/.multinfo", "r") as f: imagefile = f.readline().strip() f.close() - out = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w') + out = open("%sImageBoot/.neonextboot" % getNeoLocation(), "w") out.write(imagefile) out.close() else: - system('touch /tmp/.init_reboot') - out = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w') - out.write('Flash') + system("touch /tmp/.init_reboot") + out = open("%sImageBoot/.neonextboot" % getNeoLocation(), "w") + out.write("Flash") out.close() self.close() def ReinstallKernel(self): try: from Plugins.Extensions.NeoBoot.files.tools import ReinstallKernel + self.session.open(ReinstallKernel) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def touch5(self): - if fileExists('/tmp/.testneo'): - os.system('rm -f /tmp/.testneo') - if fileExists('/usr/lib/periodon/.kodn'): + if fileExists("/tmp/.testneo"): + os.system("rm -f /tmp/.testneo") + if fileExists("/usr/lib/periodon/.kodn"): if getTestIn() == getTestOut(): pass else: - system('touch /tmp/guto') + system("touch /tmp/guto") else: - system('touch /tmp/guto') + system("touch /tmp/guto") def touch7(self): - if fileExists('/usr/lib/periodon/.kodn'): + if fileExists("/usr/lib/periodon/.kodn"): pass else: - if not fileExists('/tmp/guto'): + if not fileExists("/tmp/guto"): pass else: - system('touch /tmp/gutos') + system("touch /tmp/gutos") def touch6(self): - if fileExists('/usr/lib/periodon/.kodn'): + if fileExists("/usr/lib/periodon/.kodn"): pass else: - if not fileExists('/tmp/gutos'): + if not fileExists("/tmp/gutos"): pass else: - system('touch /tmp/gutosi') + system("touch /tmp/gutosi") def touch4(self): - if fileExists('/usr/lib/periodon/.kodn'): + if fileExists("/usr/lib/periodon/.kodn"): pass else: - if not fileExists('/tmp/gutosi'): + if not fileExists("/tmp/gutosi"): pass else: - if not fileExists('/usr/lib/periodon'): - system('mkdir /usr/lib/periodon') + if not fileExists("/usr/lib/periodon"): + system("mkdir /usr/lib/periodon") else: - if getButtonPin() == 'pinok': + if getButtonPin() == "pinok": os.system( - 'sleep 2; rm -f /tmp/gut*; date %s > /usr/lib/periodon/.accessdate' % UPDATEDATE) - if fileExists('/usr/lib/periodon/.accessdate') and fileExists('/usr/lib/periodon/.kodn'): - restartbox = self.session.openWithCallback(self.GUIRestart, MessageBox, _( - 'Bravo! Neoboot vip full version activated OK!\nPlease restart your system E2.'), MessageBox.TYPE_YESNO, 10) - restartbox.setTitle(_('Restart GUI now !!')) - elif not fileExists('/usr/lib/periodon/.accessdate'): + "sleep 2; rm -f /tmp/gut*; date %s > /usr/lib/periodon/.accessdate" % + UPDATEDATE) + if fileExists("/usr/lib/periodon/.accessdate") and fileExists( + "/usr/lib/periodon/.kodn" + ): + restartbox = self.session.openWithCallback( + self.GUIRestart, + MessageBox, + _("Bravo! Neoboot vip full version activated OK!\nPlease restart your system E2."), + MessageBox.TYPE_YESNO, + 10, + ) + restartbox.setTitle(_("Restart GUI now !!")) + elif not fileExists("/usr/lib/periodon/.accessdate"): mess = _( - 'VIP Access Activation Fails with Error code 0x10.') + "VIP Access Activation Fails with Error code 0x10." + ) self.session.open( MessageBox, mess, MessageBox.TYPE_INFO) - elif not fileExists('/usr/lib/periodon/.kodn'): + elif not fileExists("/usr/lib/periodon/.kodn"): mess = _( - 'VIP Access Activation Fails with Error code 0x20.') + "VIP Access Activation Fails with Error code 0x20." + ) self.session.open( MessageBox, mess, MessageBox.TYPE_INFO) def touch9(self): - if fileExists('/usr/lib/periodon/.kodn'): - system('touch /tmp/gut1') + if fileExists("/usr/lib/periodon/.kodn"): + system("touch /tmp/gut1") else: - if not fileExists('/tmp/gutosie'): + if not fileExists("/tmp/gutosie"): pass else: - system('touch /tmp/gutosiep') + system("touch /tmp/gutosiep") def touch8(self): - if fileExists('/usr/lib/periodon/.kodn'): - system('touch /tmp/gut2') + if fileExists("/usr/lib/periodon/.kodn"): + system("touch /tmp/gut2") else: - if not fileExists('/tmp/gutosiep'): + if not fileExists("/tmp/gutosiep"): pass else: - system('touch /tmp/gutosiepi') + system("touch /tmp/gutosiepi") def touch0(self): - if fileExists('/usr/lib/periodon/.kodn'): - if not fileExists('/tmp/gut3'): - system('touch /tmp/gut3') - elif fileExists('/tmp/gut3'): - system('rm -f /tmp/gut*; rm -f /usr/lib/periodon/.kodn; rm -f /usr/lib/periodon/.accessdate; rm -f /tmp/.finishdate; rm -f /tmp/.nkod') - restartbox = self.session.openWithCallback(self.GUIRestart, MessageBox, _( - 'Bravo - pin code removed!\nPlease re-enter your pin code.'), MessageBox.TYPE_YESNO, 10) - restartbox.setTitle(_('Restart GUI now !!')) + if fileExists("/usr/lib/periodon/.kodn"): + if not fileExists("/tmp/gut3"): + system("touch /tmp/gut3") + elif fileExists("/tmp/gut3"): + system( + "rm -f /tmp/gut*; rm -f /usr/lib/periodon/.kodn; rm -f /usr/lib/periodon/.accessdate; rm -f /tmp/.finishdate; rm -f /tmp/.nkod" + ) + restartbox = self.session.openWithCallback( + self.GUIRestart, + MessageBox, + _("Bravo - pin code removed!\nPlease re-enter your pin code."), + MessageBox.TYPE_YESNO, + 10, + ) + restartbox.setTitle(_("Restart GUI now !!")) else: pass else: - if not fileExists('/tmp/gutosiepi'): + if not fileExists("/tmp/gutosiepi"): pass else: - system('touch /tmp/gutosiepin') + system("touch /tmp/gutosiepin") def GUIRestart(self, answer): if answer is True: @@ -1277,39 +1929,33 @@ class NeoBootImageChoose(Screen): else: self.close() -# def neoboot_update(self): -# mess = _('Updated unnecessary, you have the latest version. Please try again later.') -# self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) - - # Zablokowanie aktualizacji przez zmiane nazwy neoboot_update na neoboot_update2 i likwidacja 3 lini hastagu wyzej - def neoboot_update(self): if checkInternet(): - # if getTestInTime() == getTestOutTime() or getTestIn() != getTestOut(): - # myerror = _('Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button.') - # self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) - # else: - if fileExists('/.multinfo'): - mess = _('Downloading available only from the image Flash.') + if fileExists("/.multinfo"): + mess = _("Downloading available only from the image Flash.") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: - out = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w') - out.write('Flash') + out = open("%sImageBoot/.neonextboot" % getNeoLocation(), "w") + out.write("Flash") out.close() - message = _('\n\n\n') - message += _('WARNING !: The update brings with it the risk of errors.\n') - message += _('Before upgrading it is recommended that you make a backup NeoBoot.\n') - message += _('Do you want to run the update now ?\n') - message += _('\n') - message += _('Select Yes to do update\n') - message += _('\n') - message += _('Select No to do backup\n') - message += _('\n') + message = _("\n\n\n") + message += _( + "WARNING !: The update brings with it the risk of errors.\n" + ) + message += _( + "Before upgrading it is recommended that you make a backup NeoBoot.\n" + ) + message += _("Do you want to run the update now ?\n") + message += _("\n") + message += _("Select Yes to do update\n") + message += _("\n") + message += _("Select No to do backup\n") + message += _("\n") ybox = self.session.openWithCallback( self.chackupdate2, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('The download neoboot update.')) + ybox.setTitle(_("The download neoboot update.")) else: - mess = _('Geen internet') + mess = _("Geen internet") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) def chackupdate2(self, yesno): @@ -1317,125 +1963,172 @@ class NeoBootImageChoose(Screen): self.chackupdate3() else: from Plugins.Extensions.NeoBoot.files.tools import BackupMultiboot + self.session.open(BackupMultiboot) - # self.session.open(MessageBox, _('Canceled update.'), MessageBox.TYPE_INFO, 7) def chackupdate3(self): - if fileExists('/usr/bin/curl'): - os.system('cd ' + LinkNeoBoot + - ';curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt;sleep 3;cd /') - if not fileExists('' + LinkNeoBoot + '/ver.txt'): - if fileExists('/usr/bin/wget'): - os.system('cd ' + LinkNeoBoot + - ';wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; sleep 3;cd /') - if not fileExists('' + LinkNeoBoot + '/ver.txt'): - if fileExists('/usr/bin/fullwget'): - os.system('cd ' + LinkNeoBoot + - ';fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; sleep 3;cd /') - if fileExists('' + LinkNeoBoot + '/ver.txt'): - mypath = '' - version = open('' + LinkNeoBoot + '/ver.txt', 'r') + if fileExists("/usr/bin/curl"): + os.system( + "cd " + + LinkNeoBoot + + ";curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt;sleep 3;cd /") + if not fileExists("" + LinkNeoBoot + "/ver.txt"): + if fileExists("/usr/bin/wget"): + os.system( + "cd " + + LinkNeoBoot + + ";wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; sleep 3;cd /") + if not fileExists("" + LinkNeoBoot + "/ver.txt"): + if fileExists("/usr/bin/fullwget"): + os.system( + "cd " + + LinkNeoBoot + + ";fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; sleep 3;cd /") + if fileExists("" + LinkNeoBoot + "/ver.txt"): + mypath = "" + version = open("" + LinkNeoBoot + "/ver.txt", "r") mypath = float(version.read().strip()) version.close() if float(UPDATEVERSION) != mypath: message = _( - 'NeoBoot has detected update.\nDo you want to update NeoBoota now ?') + "NeoBoot has detected update.\nDo you want to update NeoBoota now ?" + ) ybox = self.session.openWithCallback( self.aktualizacjamboot, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Updating ... ')) - elif fileExists('' + LinkNeoBoot + '/ver.txt'): - os.system('rm ' + LinkNeoBoot + '/ver.txt') - if fileExists('' + LinkNeoBoot + '/wget-log'): - os.system('rm ' + LinkNeoBoot + '/wget-log') - self.session.open(MessageBox, _( - 'Updated unnecessary, you have the latest version. Please try again later.'), MessageBox.TYPE_INFO) + ybox.setTitle(_("Updating ... ")) + elif fileExists("" + LinkNeoBoot + "/ver.txt"): + os.system("rm " + LinkNeoBoot + "/ver.txt") + if fileExists("" + LinkNeoBoot + "/wget-log"): + os.system("rm " + LinkNeoBoot + "/wget-log") + self.session.open( + MessageBox, + _("Updated unnecessary, you have the latest version. Please try again later."), + MessageBox.TYPE_INFO, + ) else: - self.session.open(MessageBox, _( - 'Unfortunately, at the moment not found an update, try again later.'), MessageBox.TYPE_INFO, 10) + self.session.open( + MessageBox, + _("Unfortunately, at the moment not found an update, try again later."), + MessageBox.TYPE_INFO, + 10, + ) else: - if not fileExists('' + LinkNeoBoot + '/ver.txt'): - self.session.open(MessageBox, _( - 'Unfortunately, at the moment not found an update, try again later.'), MessageBox.TYPE_INFO, 10) + if not fileExists("" + LinkNeoBoot + "/ver.txt"): + self.session.open( + MessageBox, + _("Unfortunately, at the moment not found an update, try again later."), + MessageBox.TYPE_INFO, + 10, + ) def aktualizacjamboot(self, yesno): if yesno: - if fileExists('/.multinfo'): + if fileExists("/.multinfo"): self.myClose( - _('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) self.close() else: - os.system('touch /tmp/.upneo; rm -r /tmp/.*') - if fileExists('/usr/bin/curl'): - cmd1 = 'curl -kLs -k https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh|sh' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + os.system("touch /tmp/.upneo; rm -r /tmp/.*") + if fileExists("/usr/bin/curl"): + cmd1 = "curl -kLs -k https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh|sh" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() - elif fileExists('/usr/bin/wget'): - cmd1 = 'cd /tmp; rm ./*.sh; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + elif fileExists("/usr/bin/wget"): + cmd1 = "cd /tmp; rm ./*.sh; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() - elif fileExists('/usr/bin/fullwget'): - cmd1 = 'cd /tmp; rm ./*.sh; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /' - self.session.open(Console, _('NeoBoot....'), [cmd1]) + elif fileExists("/usr/bin/fullwget"): + cmd1 = "cd /tmp; rm ./*.sh; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/iNB.sh;chmod 755 ./iNB.sh;sh ./iNB.sh; rm ./iNB.sh; cd /" + self.session.open(Console, _("NeoBoot...."), [cmd1]) self.close() else: - self.session.open(MessageBox, _( - 'Unfortunately, at the moment not found an update, try again later.'), MessageBox.TYPE_INFO, 10) + self.session.open( + MessageBox, + _("Unfortunately, at the moment not found an update, try again later."), + MessageBox.TYPE_INFO, + 10, + ) else: - os.system('rm -f ' + LinkNeoBoot + '/ver.txt') - self.session.open(MessageBox, _( - 'The update has been canceled.'), MessageBox.TYPE_INFO, 8) + os.system("rm -f " + LinkNeoBoot + "/ver.txt") + self.session.open( + MessageBox, + _("The update has been canceled."), + MessageBox.TYPE_INFO, + 8) def MBBackup(self): try: from Plugins.Extensions.NeoBoot.files.tools import MBBackup + self.session.open(MBBackup) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def MBRestore(self): try: from Plugins.Extensions.NeoBoot.files.tools import MBRestore + self.session.open(MBRestore) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def updateList(self): self.list = [] - pluginpath = '' + LinkNeoBoot + '' - f = open(pluginpath + '/.location', 'r') + pluginpath = "" + LinkNeoBoot + "" + f = open(pluginpath + "/.location", "r") mypath = f.readline().strip() f.close() - icon = 'dev_usb.png' - if 'card' in mypath or 'sd' in mypath: - icon = 'dev_sd.png' - elif 'ntfs' in mypath: - icon = 'dev_sd.png' - elif 'hdd' in mypath: - icon = 'dev_hdd.png' - elif 'cf' in mypath: - icon = 'dev_cf.png' - elif 'ssd' in mypath: - icon = 'dev_ssd.png' + icon = "dev_usb.png" + if "card" in mypath or "sd" in mypath: + icon = "dev_sd.png" + elif "ntfs" in mypath: + icon = "dev_sd.png" + elif "hdd" in mypath: + icon = "dev_hdd.png" + elif "cf" in mypath: + icon = "dev_cf.png" + elif "ssd" in mypath: + icon = "dev_ssd.png" - icon = pluginpath + '/images/' + icon + icon = pluginpath + "/images/" + icon png = LoadPixmap(icon) - self['device_icon'].instance.setPixmap(png) - linesdevice = open('' + LinkNeoBoot + '/.location', 'r').readlines() + self["device_icon"].instance.setPixmap(png) + linesdevice = open("" + LinkNeoBoot + "/.location", "r").readlines() deviceneo = linesdevice[0][0:-1] device = deviceneo - ustot = usfree = usperc = '' - rc = system('df > /tmp/memoryinfo.tmp') - if fileExists('/tmp/memoryinfo.tmp'): - f = open('/tmp/memoryinfo.tmp', 'r') + ustot = usfree = usperc = "" + rc = system("df > /tmp/memoryinfo.tmp") + if fileExists("/tmp/memoryinfo.tmp"): + f = open("/tmp/memoryinfo.tmp", "r") for line in f.readlines(): - line = line.replace('part1', ' ') + line = line.replace("part1", " ") parts = line.strip().split() totsp = len(parts) - 1 if parts[totsp] == device: @@ -1444,23 +2137,23 @@ class NeoBootImageChoose(Screen): usfree = parts[3] usperc = parts[4] else: - ustot = 'N/A ' + ustot = "N/A " usfree = parts[2] usperc = parts[3] break f.close() - os.remove('/tmp/memoryinfo.tmp') + os.remove("/tmp/memoryinfo.tmp") try: perc = int(usperc[0:-1]) - except: + except BaseException: perc = int() # jak czasami robi error to odhaszowac i zahaszowac wyzej - self['progreso'].setValue(perc) - green = '#00389416' - red = '#00ff2525' - yellow = '#00ffe875' - orange = '#00ff7f50' + self["progreso"].setValue(perc) + green = "#00389416" + red = "#00ff2525" + yellow = "#00ffe875" + orange = "#00ff7f50" if perc < 30: color = green elif perc < 60: @@ -1471,173 +2164,226 @@ class NeoBootImageChoose(Screen): color = red try: from skin import parseColor - self['label13'].instance.setForegroundColor(parseColor(color)) - self['label15'].instance.setForegroundColor(parseColor(color)) - self['progreso'].instance.setForegroundColor(parseColor(color)) - except: + + self["label13"].instance.setForegroundColor(parseColor(color)) + self["label15"].instance.setForegroundColor(parseColor(color)) + self["progreso"].instance.setForegroundColor(parseColor(color)) + except BaseException: pass self.availablespace = usfree[0:-3] - strview = _('Used: ') + usperc + \ - _(' \n Available: ') + usfree[0:-3] + ' MB' - self['label3'].setText(strview) + strview = _("Used: ") + usperc + \ + _(" \n Available: ") + usfree[0:-3] + " MB" + self["label3"].setText(strview) - strview2 = _('Free Space : ') + usfree[0:-3] + ' MB' - self['label11'].setText(strview2) + strview2 = _("Free Space : ") + usfree[0:-3] + " MB" + self["label11"].setText(strview2) - strview1 = _('Capacity : ') + usperc + _(' Full') - self['label18'].setText(strview1) + strview1 = _("Capacity : ") + usperc + _(" Full") + self["label18"].setText(strview1) try: - f2 = open('%sImageBoot/.neonextboot', 'r' % getNeoLocation()) + f2 = open("%sImageBoot/.neonextboot" % getNeoLocation(), "r") mypath2 = f2.readline().strip() f2.close() - except: - mypath2 = 'Flash' + except BaseException: + mypath2 = "Flash" - if mypath2 == 'Flash': + if mypath2 == "Flash": image = getImageDistroN() - writefile = open('%sImageBoot/.Flash' % getNeoLocation(), 'w') + writefile = open("%sImageBoot/.Flash" % getNeoLocation(), "w") writefile.write(image) writefile.close() - image = ' [' + image + ']' - self.list.append('Flash' + image) + image = " [" + image + "]" + self.list.append("Flash" + image) - elif fileExists('%sImageBoot/.Flash' % getNeoLocation()): - f = open('%sImageBoot/.Flash', 'r' % getNeoLocation()) + elif fileExists("%sImageBoot/.Flash" % getNeoLocation()): + f = open("%sImageBoot/.Flash" % getNeoLocation(), "r") image = f.readline().strip() f.close() - image = ' [' + image + ']' - self.list.append('Flash' + image) - self['label5'].setText(mypath) + image = " [" + image + "]" + self.list.append("Flash" + image) + self["label5"].setText(mypath) - if fileExists('/.multinfo'): - f2 = open('/.multinfo', 'r') + if fileExists("/.multinfo"): + f2 = open("/.multinfo", "r") mypath3 = f2.readline().strip() f2.close() - self['label6'].setText(mypath3) + self["label6"].setText(mypath3) else: - f2 = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') + f2 = open("%sImageBoot/.neonextboot" % getNeoLocation(), "r") mypath3 = f2.readline().strip() f2.close() - self['label6'].setText(mypath3) + self["label6"].setText(mypath3) - # Retrieve the list of images and ignore the "Flash" image - mypath = ('%sImageBoot' % getNeoLocation()) + mypath = "%sImageBoot" % getNeoLocation() myimages = listdir(mypath) - self.list = [fil for fil in myimages if os.path.isdir(os.path.join( - mypath, fil)) and fil != 'Flash'] # Ignore the "Flash" image + self.list = [ + fil + for fil in myimages + if os.path.isdir(os.path.join(mypath, fil)) and fil != "Flash" + ] # Ignore the "Flash" image - # Sort the list before setting it to config (case-insensitive) self.list = sorted(self.list, key=lambda x: x.lower()) - # Add the "Flash [egami]" image to the list - if fileExists('%sImageBoot/.Flash' % getNeoLocation()): - f = open('%sImageBoot/.Flash' % getNeoLocation(), 'r') + if fileExists("%sImageBoot/.Flash" % getNeoLocation()): + f = open("%sImageBoot/.Flash" % getNeoLocation(), "r") image = f.readline().strip() f.close() - image = ' [' + image + ']' - # Insert the "Flash" image at the beginning of the list - self.list.insert(0, 'Flash' + image) + image = " [" + image + "]" + self.list.insert(0, "Flash" + image) - self['config'].setList(self.list) + self["config"].setList(self.list) - self['label7'].setText(str(len(self.list) - 1)) - self['config'].setList(self.list) + self["label7"].setText(str(len(self.list) - 1)) + self["config"].setList(self.list) strview = PLUGINVERSION - self['label9'].setText(strview) + self["label9"].setText(strview) KERNELVERSION = getKernelImageVersion() strview = KERNELVERSION - self['label20'].setText(strview) + self["label20"].setText(strview) - self['label17'].setText(readline('/etc/hostname')) - self['label19'].setText( - readline('%sImagesUpload/.kernel/used_flash_kernel' % getNeoLocation())) + self["label17"].setText(readline("/etc/hostname")) + self["label19"].setText( + readline( + "%sImagesUpload/.kernel/used_flash_kernel" % + getNeoLocation())) strview = UPDATEVERSION - self['label10'].setText(strview) + self["label10"].setText(strview) def mytools(self): - if getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn'): + if getCheckActivateVip() == getBoxMacAddres() and fileExists( + "/usr/lib/periodon/.kodn" + ): try: from Plugins.Extensions.NeoBoot.files.tools import MBTools + self.session.open(MBTools) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() - elif not fileExists('/.multinfo'): + elif not fileExists("/.multinfo"): if getTestIn() == getTestOut(): - if ('1234%s' % getTestToTest()) == getAccessN(): + if ("1234%s" % getTestToTest()) == getAccessN(): if (getSupportedTuners()) == (getBoxHostName()): try: from Plugins.Extensions.NeoBoot.files.tools import MBTools + self.session.open(MBTools) - # except: except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() else: - mess = _('Sorry cannot open neo menu. Open Error Menu.') - self.session.open(MessageBox, mess, - MessageBox.TYPE_INFO) + mess = _("Sorry cannot open neo menu. Open Error Menu.") + self.session.open( + MessageBox, mess, MessageBox.TYPE_INFO) else: myerror = _( - 'Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button.') - self.session.open(MessageBox, myerror, - MessageBox.TYPE_INFO) + "Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button." + ) + self.session.open( + MessageBox, myerror, MessageBox.TYPE_INFO) else: myerror = _( - 'Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button or try to update.') - myerror += _('\nVIP - Try entering the pin code again.') + "Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button or try to update." + ) + myerror += _("\nVIP - Try entering the pin code again.") self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) else: try: from Plugins.Extensions.NeoBoot.files.tools import MBTools + self.session.open(MBTools) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def removeIMG(self): - self.mysel = self['config'].getCurrent() - if 'Flash' in self.mysel: - self.mysel = 'Flash' + self.mysel = self["config"].getCurrent() + if "Flash" in self.mysel: + self.mysel = "Flash" if self.mysel: - f = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') + f = open("%sImageBoot/.neonextboot" % getNeoLocation(), "r") mypath = f.readline().strip() f.close() try: - if fileExists('/.multinfo'): - self.session.open(MessageBox, _( - 'Sorry you can delete only from the image Flash.'), MessageBox.TYPE_INFO, 5) - elif self.mysel == 'Flash': - self.session.open(MessageBox, _( - 'Sorry you cannot delete Flash image'), MessageBox.TYPE_INFO, 5) + if fileExists("/.multinfo"): + self.session.open( + MessageBox, + _("Sorry you can delete only from the image Flash."), + MessageBox.TYPE_INFO, + 5, + ) + elif self.mysel == "Flash": + self.session.open( + MessageBox, + _("Sorry you cannot delete Flash image"), + MessageBox.TYPE_INFO, + 5, + ) elif mypath == self.mysel: - self.session.open(MessageBox, _( - 'Sorry you cannot delete the image currently booted from.'), MessageBox.TYPE_INFO, 5) + self.session.open( + MessageBox, + _("Sorry you cannot delete the image currently booted from."), + MessageBox.TYPE_INFO, + 5, + ) else: - out = open('%sImageBoot/.neonextboot' % - getNeoLocation(), 'w') - out.write('Flash') + out = open( + "%sImageBoot/.neonextboot" % + getNeoLocation(), "w") + out.write("Flash") out.close() - message = _('Delete the selected image - ') + \ - self.mysel + _('\nDelete ?') + message = ( + _("Delete the selected image - ") + + self.mysel + + _("\nDelete ?")) ybox = self.session.openWithCallback( self.RemoveIMAGE, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Delete Confirmation')) - except: + ybox.setTitle(_("Delete Confirmation")) + except BaseException: print("no image to remove") else: @@ -1645,75 +2391,115 @@ class NeoBootImageChoose(Screen): def up(self): self.list = [] - self['config'].setList(self.list) + self["config"].setList(self.list) self.updateList() def up2(self): try: self.list = [] - self['config'].setList(self.list) + self["config"].setList(self.list) self.updateList() - except: + except BaseException: print(" ") def RemoveIMAGE(self, yesno): if yesno: cmd = _("echo -e 'Deleting in progress...\n'") - cmd1 = 'chattr -i %sImageBoot/' % getNeoLocation() + self.mysel - if fileExists('%sImageBoot/' % getNeoLocation() + self.mysel + '/usr/lib/periodon/.activatedmac'): - cmd2 = 'chattr -i %sImageBoot/' % getNeoLocation() + self.mysel + \ - '/usr/lib/periodon/.activatedmac' - if fileExists('%sImageBoot/' % getNeoLocation() + self.mysel + '' + LinkNeoBoot + '/plugin.py'): - cmd3 = 'chattr -i %sImageBoot/ ' % getNeoLocation() + self.mysel + '' + \ - LinkNeoBoot + '/plugin.py' - if fileExists('%sImageBoot/' % getNeoLocation() + self.mysel + '' + LinkNeoBoot + '/plugin.pyo'): - cmd4 = 'chattr -i %sImageBoot > /dev/null 2>&1/' % getNeoLocation() + self.mysel + \ - '' + LinkNeoBoot + '/plugin.pyo' - cmd5 = 'rm -r %sImageBoot/' % getNeoLocation() + self.mysel + cmd1 = "chattr -i %sImageBoot/" % getNeoLocation() + self.mysel + if fileExists( + "%sImageBoot/" % getNeoLocation() + + self.mysel + + "/usr/lib/periodon/.activatedmac" + ): + cmd2 = ( + "chattr -i %sImageBoot/" % getNeoLocation() + + self.mysel + + "/usr/lib/periodon/.activatedmac" + ) + if fileExists( + "%sImageBoot/" % getNeoLocation() + + self.mysel + + "" + + LinkNeoBoot + + "/plugin.py" + ): + cmd3 = ( + "chattr -i %sImageBoot/ " % getNeoLocation() + + self.mysel + + "" + + LinkNeoBoot + + "/plugin.py" + ) + if fileExists( + "%sImageBoot/" % getNeoLocation() + + self.mysel + + "" + + LinkNeoBoot + + "/plugin.pyo" + ): + cmd4 = ( + "chattr -i %sImageBoot > /dev/null 2>&1/" % + getNeoLocation() + + self.mysel + + "" + + LinkNeoBoot + + "/plugin.pyo") + cmd5 = "rm -r %sImageBoot/" % getNeoLocation() + self.mysel self.session.openWithCallback(self.up, Console, _( - 'NeoBoot: Deleting Image'), [cmd, cmd1, cmd5]) + "NeoBoot: Deleting Image"), [cmd, cmd1, cmd5]) else: - self.session.open(MessageBox, _( - 'Removing canceled!'), MessageBox.TYPE_INFO) + self.session.open( + MessageBox, + _("Removing canceled!"), + MessageBox.TYPE_INFO) def ImageInstall(self): - if getCheckActivateVip() == getBoxMacAddres() and fileExists('/usr/lib/periodon/.kodn'): + if getCheckActivateVip() == getBoxMacAddres() and fileExists( + "/usr/lib/periodon/.kodn" + ): self.ImageInstallTestOK() - elif not fileExists('/.multinfo'): - if ('1234%s' % getTestToTest()) != getAccessN(): + elif not fileExists("/.multinfo"): + if ("1234%s" % getTestToTest()) != getAccessN(): count = 0 - for fn in listdir('' + getNeoLocation() + '/ImageBoot'): - dirfile = '' + getNeoLocation() + '/ImageBoot/' + fn + for fn in listdir("" + getNeoLocation() + "/ImageBoot"): + dirfile = "" + getNeoLocation() + "/ImageBoot/" + fn if os_isdir(dirfile): count = count + 1 if count > 1: myerror = _( - 'Sorry, you can install up to 2 images, this is not neoboot vip version.\nGet unlimited image installations in VIP version') - self.session.open(MessageBox, myerror, - MessageBox.TYPE_INFO) + "Sorry, you can install up to 2 images, this is not neoboot vip version.\nGet unlimited image installations in VIP version" + ) + self.session.open( + MessageBox, myerror, MessageBox.TYPE_INFO) elif int(self.availablespace) < 500: myerror = _( - 'Not enough free space on /media/ !!\nYou need at least 500Mb free space.\n\nExit plugin.') - self.session.open(MessageBox, myerror, - MessageBox.TYPE_INFO) + "Not enough free space on /media/ !!\nYou need at least 500Mb free space.\n\nExit plugin." + ) + self.session.open( + MessageBox, myerror, MessageBox.TYPE_INFO) else: self.ImageInstallTestOK() else: - if getTestIn() == getTestOut() and getCheckActivateVip() == getBoxMacAddres(): + if ( + getTestIn() == getTestOut() + and getCheckActivateVip() == getBoxMacAddres() + ): self.ImageInstallTestOK() else: myerror = _( - 'Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button or try to update.') - self.session.open(MessageBox, myerror, - MessageBox.TYPE_INFO) + "Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button or try to update." + ) + self.session.open( + MessageBox, myerror, MessageBox.TYPE_INFO) else: self.ImageInstallTestOK() def ImageInstallTestOK(self): if int(self.availablespace) < 500: myerror = _( - 'Not enough free space on /media/ !!\nYou need at least 500Mb free space.\n\nExit plugin.') + "Not enough free space on /media/ !!\nYou need at least 500Mb free space.\n\nExit plugin." + ) self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) else: if (getSupportedTuners()) == (getBoxHostName()): @@ -1721,53 +2507,69 @@ class NeoBootImageChoose(Screen): self.GOImageInstall() except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() else: mess = _( - 'Your receiver is not on the list of supported tuners.\nAccess stb error.') + "Your receiver is not on the list of supported tuners.\nAccess stb error." + ) self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) def GOImageInstall(self): - if fileExists('/.multinfo'): + if fileExists("/.multinfo"): message = _( - 'Installing new neoboot software, only recommended from Flash!!!\n---Continue ?---') + "Installing new neoboot software, only recommended from Flash!!!\n---Continue ?---" + ) ybox = self.session.openWithCallback( self.installation_image, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Installation')) + ybox.setTitle(_("Installation")) else: - message = _('Installation from Flash!!!\n---Continue ?---') + message = _("Installation from Flash!!!\n---Continue ?---") ybox = self.session.openWithCallback( self.installation_image, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Installation new image. ')) + ybox.setTitle(_("Installation new image. ")) def installation_image(self, yesno): if yesno: self.extractImage() else: - self.messagebox = self.session.open(MessageBox, _( - 'It is recommended to install new software only from a flash system.\n---NEOBOOT EXIT---'), MessageBox.TYPE_INFO, 10) + self.messagebox = self.session.open( + MessageBox, + _("It is recommended to install new software only from a flash system.\n---NEOBOOT EXIT---"), + MessageBox.TYPE_INFO, + 10, + ) self.close() def extractImage(self): - if fileExists('%sImageBoot/.without_copying' % getNeoLocation()): - system('rm -f %sImageBoot/.without_copying' % getNeoLocation()) + if fileExists("%sImageBoot/.without_copying" % getNeoLocation()): + system("rm -f %sImageBoot/.without_copying" % getNeoLocation()) - if not os.path.exists('%sImagesUpload' % getNeoLocation()): - system('mkdir %sImagesUpload' % getNeoLocation()) + if not os.path.exists("%sImagesUpload" % getNeoLocation()): + system("mkdir %sImagesUpload" % getNeoLocation()) images = False - myimages = listdir('%sImagesUpload' % getNeoLocation()) + myimages = listdir("%sImagesUpload" % getNeoLocation()) print(myimages) for fil in myimages: if fil.endswith(".zip"): images = True break - if os.path.exists('%sImagesUpload/*zip' % getNeoLocation()): + if os.path.exists("%sImagesUpload/*zip" % getNeoLocation()): images = True break - if os.path.exists('%sImagesUpload/*.tar.bz2' % getNeoLocation()): + if os.path.exists("%sImagesUpload/*.tar.bz2" % getNeoLocation()): images = True break if fil.endswith(".tar.xz"): @@ -1792,130 +2594,202 @@ class NeoBootImageChoose(Screen): def ImageTrue(self): try: from Plugins.Extensions.NeoBoot.unpack import InstallImage + self.session.open(InstallImage) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) - os.system('echo "Cannot open command, error in line ^:" >> ' + - getNeoLocation() + 'ImageBoot/neoboot.log') - showlog = 'cat ' + getNeoLocation() + 'ImageBoot/neoboot.log' + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) + os.system( + 'echo "Cannot open command, error in line ^:" >> ' + + getNeoLocation() + + "ImageBoot/neoboot.log" + ) + showlog = "cat " + getNeoLocation() + "ImageBoot/neoboot.log" self.session.openWithCallback( - self.close, Console, _('NeoBoot ERROR !!!'), [showlog]) + self.close, Console, _("NeoBoot ERROR !!!"), [showlog] + ) def DownloaderImage(self): - if not os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/download.py'): + if not os.path.exists( + "/usr/lib/enigma2/python/Plugins/Extensions/ImageDownloader/download.py" + ): message = ( - _('The %sImagesUpload directory is EMPTY!!!\nInstall the plugin to download new image online ?\n --- Continue? ---') % getNeoLocation()) + _("The %sImagesUpload directory is EMPTY!!!\nInstall the plugin to download new image online ?\n --- Continue? ---") % + getNeoLocation()) ybox = self.session.openWithCallback( self.ImageDownloader, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('Installation')) - elif not fileExists('/usr/lib/python2.7') and fileExists('/.multinfo'): - self.session.open(MessageBox, _( - 'Sorry, cannot open neo menu install image.'), type=MessageBox.TYPE_ERROR) + ybox.setTitle(_("Installation")) + elif not fileExists("/usr/lib/python2.7") and fileExists("/.multinfo"): + self.session.open( + MessageBox, + _("Sorry, cannot open neo menu install image."), + type=MessageBox.TYPE_ERROR, + ) else: message = ( - _('Catalog %sImagesUpload directory is empty\nPlease upload the image files in zip or nfi formats to install') % getNeoLocation()) + _("Catalog %sImagesUpload directory is empty\nPlease upload the image files in zip or nfi formats to install") % + getNeoLocation()) self.session.open(MessageBox, message, MessageBox.TYPE_INFO) def ImageDownloader(self, yesno): if checkInternet(): if yesno: - cmd = 'mkdir /tmp/install; touch /tmp/install/plugin.txt; rm -rf /tmp/*.ipk' + cmd = "mkdir /tmp/install; touch /tmp/install/plugin.txt; rm -rf /tmp/*.ipk" system(cmd) - if fileExists('/usr/bin/fullwget'): + if fileExists("/usr/bin/fullwget"): os.system( - 'cd /tmp; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ImageDownloader.tar.gz') - if not fileExists('/tmp/ImageDownloader.tar.gz'): - if fileExists('/usr/bin/curl'): + "cd /tmp; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ImageDownloader.tar.gz" + ) + if not fileExists("/tmp/ImageDownloader.tar.gz"): + if fileExists("/usr/bin/curl"): os.system( - 'sync; cd /tmp; curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoboot/master/ImageDownloader.tar.gz') - if not fileExists('/tmp/ImageDownloader.tar.gz'): - if fileExists('/usr/bin/wget'): + "sync; cd /tmp; curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoboot/master/ImageDownloader.tar.gz" + ) + if not fileExists("/tmp/ImageDownloader.tar.gz"): + if fileExists("/usr/bin/wget"): os.system( - 'cd /tmp;rm ./*.zip; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ImageDownloader.tar.gz') - if not fileExists('/tmp/ImageDownloader.tar.gz'): - self.session.open(MessageBox, _( - 'Unfortunately, at the moment not found an update, try again later.'), MessageBox.TYPE_INFO, 10) + "cd /tmp;rm ./*.zip; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ImageDownloader.tar.gz" + ) + if not fileExists("/tmp/ImageDownloader.tar.gz"): + self.session.open( + MessageBox, + _("Unfortunately, at the moment not found an update, try again later."), + MessageBox.TYPE_INFO, + 10, + ) else: - cmd2 = '/bin/tar -xzvf /tmp/ImageDownloader.tar.gz -C /' + cmd2 = "/bin/tar -xzvf /tmp/ImageDownloader.tar.gz -C /" system(cmd2) - self.session.open(MessageBox, _( - 'The plug-in has been successfully installed.'), MessageBox.TYPE_INFO, 5) + self.session.open( + MessageBox, + _("The plug-in has been successfully installed."), + MessageBox.TYPE_INFO, + 5, + ) self.close() else: mess = ( - _('Directory %sImagesUpload is empty\nPlease upload the image files in zip or nfi formats to install') % getNeoLocation()) + _("Directory %sImagesUpload is empty\nPlease upload the image files in zip or nfi formats to install") % + getNeoLocation()) self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: - mess = _('Geen internet') + mess = _("Geen internet") self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) def bootIMG(self): if getCheckActivateVip() == getBoxMacAddres(): self.bootIMG2() - elif not fileExists('/.multinfo'): - if ('1234%s' % getTestToTest()) == getAccessN(): + elif not fileExists("/.multinfo"): + if ("1234%s" % getTestToTest()) == getAccessN(): self.bootIMG2() else: count = 0 - for fn in listdir('' + getNeoLocation() + '/ImageBoot'): - dirfile = '' + getNeoLocation() + '/ImageBoot/' + fn + for fn in listdir("" + getNeoLocation() + "/ImageBoot"): + dirfile = "" + getNeoLocation() + "/ImageBoot/" + fn if os_isdir(dirfile): count = count + 1 if count > 1: myerror = _( - 'Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button.') - self.session.open(MessageBox, myerror, - MessageBox.TYPE_INFO) + "Sorry, this is not neoboot vip version.\nGet NEO-VIP version, more info press blue button." + ) + self.session.open( + MessageBox, myerror, MessageBox.TYPE_INFO) else: self.bootIMG2() else: self.bootIMG2() def bootIMG2(self): - self.mysel = self['config'].getCurrent() - if 'Flash' in self.mysel: - self.mysel = 'Flash' + self.mysel = self["config"].getCurrent() + if "Flash" in self.mysel: + self.mysel = "Flash" if self.mysel: - out = open('' + getNeoLocation() + 'ImageBoot/.neonextboot', 'w') + out = open("" + getNeoLocation() + "ImageBoot/.neonextboot", "w") out.write(self.mysel) out.close() if getImageNeoBoot() != "Flash": - if not fileExists('%sImageBoot/%s/.control_ok' % (getNeoLocation(), getImageNeoBoot())): - message = _('After successful launch of the selected software\nyou must run the neoboot plugin\nif the software does not start or neoboot is not confirmed\nthe system will return to the internal flash memory\n\nPress OK or exit on the remote control to continue...') + if not fileExists( + "%sImageBoot/%s/.control_ok" % + (getNeoLocation(), getImageNeoBoot())): + message = _( + "After successful launch of the selected software\nyou must run the neoboot plugin\nif the software does not start or neoboot is not confirmed\nthe system will return to the internal flash memory\n\nPress OK or exit on the remote control to continue..." + ) ybox = self.session.openWithCallback( self.StartReboot, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_('First start of software')) + ybox.setTitle(_("First start of software")) else: try: from Plugins.Extensions.NeoBoot.run import StartImage + self.session.open(StartImage) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() else: try: from Plugins.Extensions.NeoBoot.run import StartImage + self.session.open(StartImage) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() def StartReboot(self, yesno): if yesno: try: from Plugins.Extensions.NeoBoot.run import StartImage + self.session.open(StartImage) except Exception as e: loggscrash = time.localtime(time.time()) - LogCrashGS('%02d:%02d:%d %02d:%02d:%02d - %s\r\n' % (loggscrash.tm_mday, loggscrash.tm_mon, - loggscrash.tm_year, loggscrash.tm_hour, loggscrash.tm_min, loggscrash.tm_sec, str(e))) + LogCrashGS( + "%02d:%02d:%d %02d:%02d:%02d - %s\r\n" + % ( + loggscrash.tm_mday, + loggscrash.tm_mon, + loggscrash.tm_year, + loggscrash.tm_hour, + loggscrash.tm_min, + loggscrash.tm_sec, + str(e), + ) + ) self.CRASHlogNeo() else: self.close() @@ -1925,14 +2799,20 @@ class NeoBootImageChoose(Screen): self.close() def CRASHlogNeo(self): - showlog = 'echo "\nCRARSH LOG-neoboot startup error!" >> ' + getNeoLocation() + \ - 'ImageBoot/neoboot.log; cat ' + getNeoLocation() + 'ImageBoot/neoboot.log' + showlog = ( + 'echo "\nCRARSH LOG-neoboot startup error!" >> ' + + getNeoLocation() + + "ImageBoot/neoboot.log; cat " + + getNeoLocation() + + "ImageBoot/neoboot.log" + ) self.session.openWithCallback( - self.close, Console, _('NeoBoot ERROR !!!'), [showlog]) + self.close, Console, _("NeoBoot ERROR !!!"), [showlog] + ) -def readline(filename, iferror=''): - if iferror[:3] == 'or:': +def readline(filename, iferror=""): + if iferror[:3] == "or:": data = iferror[3:] else: data = iferror @@ -1947,29 +2827,37 @@ def readline(filename, iferror=''): def checkInternet(): - if fileExists('/usr/lib/python2.7'): - import urllib.request - import urllib.error - import urllib.parse - import urllib.request - import urllib.parse - import urllib.error + if fileExists("/usr/lib/python2.7"): + import urllib2 + import urllib + try: - response = urllib.request.urlopen("http://google.com", None, 5) + response = urllib2.urlopen("http://google.com", None, 5) response.close() - except urllib.error.HTTPError: + except urllib2.HTTPError: return False - except urllib.error.URLError: + except urllib2.URLError: return False else: return True else: - return True + try: + import urllib.request + + urllib.request.urlopen("http://google.com", timeout=5) + return True + except BaseException: + return False def checkimage(): mycheck = False - if not fileExists('/proc/stb/info') or not fileExists('' + LinkNeoBoot + '/neoskins/neo/neo_skin.py') or not fileExists('' + LinkNeoBoot + '/bin/utilsbh') or not fileExists('' + LinkNeoBoot + '/stbinfo.cfg'): + if ( + not fileExists("/proc/stb/info") + or not fileExists("" + LinkNeoBoot + "/neoskins/neo/neo_skin.py") + or not fileExists("" + LinkNeoBoot + "/bin/utilsbh") + or not fileExists("" + LinkNeoBoot + "/stbinfo.cfg") + ): mycheck = False else: mycheck = True @@ -1979,99 +2867,160 @@ def checkimage(): def main(session, **kwargs): vip = checkimage() if vip == 1: - if not fileExists('' + LinkNeoBoot + '/.location'): + if not fileExists("" + LinkNeoBoot + "/.location"): pass else: - if not fileExists('%sImageBoot/.version' % getNeoLocation()): - if fileExists('' + LinkNeoBoot + '/files/neo.sh'): - os.system('chmod 0755 ' + LinkNeoBoot + - '/files/neo.sh; ' + LinkNeoBoot + '/files/neo.sh') - if not fileExists('%sImageBoot/.version' % getNeoLocation()): - os.system('chmod 0755 ' + LinkNeoBoot + - '/files/mountpoint.sh; ' + LinkNeoBoot + '/files/mountpoint.sh') + if not fileExists("%sImageBoot/.version" % getNeoLocation()): + if fileExists("" + LinkNeoBoot + "/files/neo.sh"): + os.system( + "chmod 0755 " + + LinkNeoBoot + + "/files/neo.sh; " + + LinkNeoBoot + + "/files/neo.sh" + ) + if not fileExists( + "%sImageBoot/.version" % + getNeoLocation()): + os.system( + "chmod 0755 " + + LinkNeoBoot + + "/files/mountpoint.sh; " + + LinkNeoBoot + + "/files/mountpoint.sh" + ) - if not fileExists('/.multinfo') and fileExists('' + LinkNeoBoot + '/.location'): + if not fileExists("/.multinfo") and fileExists("" + + LinkNeoBoot + "/.location"): if checkInternet(): - if not os.path.exists('/tmp/.finishdate'): + if not os.path.exists("/tmp/.finishdate"): os.system('date "+%Y%m%d" > /tmp/.finishdate') - if fileExists('/tmp/.nkod'): + if fileExists("/tmp/.nkod"): pass else: - if not fileExists('/tmp/ver.txt'): - if fileExists('/usr/bin/curl'): + if not fileExists("/tmp/ver.txt"): + if fileExists("/usr/bin/curl"): os.system( - 'cd /tmp; curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoscript/master/.neouser; cd /') - if not fileExists('/tmp/ver.txt'): - if fileExists('/usr/bin/wget'): - os.system('cd /tmp; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoscript/master/.neouser; cd /') - if not fileExists('/tmp/ver.txt'): - if fileExists('/usr/bin/fullwget'): - os.system('cd /tmp; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoscript/master/.neouser; cd /') - if fileExists('/tmp/ver.txt'): + "cd /tmp; curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; curl -O --ftp-ssl -k https://raw.githubusercontent.com/gutosie/neoscript/master/.neouser; cd /" + ) + if not fileExists("/tmp/ver.txt"): + if fileExists("/usr/bin/wget"): + os.system( + "cd /tmp; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; wget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoscript/master/.neouser; cd /" + ) + if not fileExists("/tmp/ver.txt"): + if fileExists("/usr/bin/fullwget"): + os.system( + "cd /tmp; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoboot/master/ver.txt; fullwget --no-check-certificate https://raw.githubusercontent.com/gutosie/neoscript/master/.neouser; cd /" + ) + if fileExists("/tmp/ver.txt"): os.system( - 'mv /tmp/ver.txt /tmp/.nkod; mv /tmp/.neouser /usr/lib/periodon/.activatedmac; cd /') + "mv /tmp/ver.txt /tmp/.nkod; mv /tmp/.neouser /usr/lib/periodon/.activatedmac; cd /" + ) else: - os.system(_('echo %s > /tmp/.nkod') % UPDATEVERSION) - from Plugins.Extensions.NeoBoot.files.stbbranding import getCheckInstal1, getCheckInstal2, getCheckInstal3 - if fileExists('/tmp/error_neo'): - if fileExists('/tmp/error_neo'): - os.system('rm -f /tmp/error_neo') - if getCheckInstal1() == '1': + os.system(_("echo %s > /tmp/.nkod") % UPDATEVERSION) + from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getCheckInstal1, + getCheckInstal2, + getCheckInstal3, + ) + + if fileExists("/tmp/error_neo"): + if fileExists("/tmp/error_neo"): + os.system("rm -f /tmp/error_neo") + if getCheckInstal1() == "1": os.system( - 'echo "\nNeoboot installation errors 1:\nfile install is error - 1\n" >> /tmp/error_neo') - session.open(MessageBox, _( - 'Neoboot plugin installed with ERRORS! Not work properly! The error number is 1'), type=MessageBox.TYPE_ERROR) - if getCheckInstal2() == '2': + 'echo "\nNeoboot installation errors 1:\nfile install is error - 1\n" >> /tmp/error_neo' + ) + session.open( + MessageBox, + _("Neoboot plugin installed with ERRORS! Not work properly! The error number is 1"), + type=MessageBox.TYPE_ERROR, + ) + if getCheckInstal2() == "2": os.system( - 'echo "\nNeoboot installation errors 2:\nfile .location is error - 2\n" >> /tmp/error_neo') - session.open(MessageBox, _( - 'Neoboot plugin installed with ERRORS! Not work properly! The error number is 2'), type=MessageBox.TYPE_ERROR) - if getCheckInstal3() == '3': + 'echo "\nNeoboot installation errors 2:\nfile .location is error - 2\n" >> /tmp/error_neo' + ) + session.open( + MessageBox, + _("Neoboot plugin installed with ERRORS! Not work properly! The error number is 2"), + type=MessageBox.TYPE_ERROR, + ) + if getCheckInstal3() == "3": os.system( - 'echo "\nNeoboot installation errors 3:\nfile neo.sh is error - 3\n" >> /tmp/error_neo') - session.open(MessageBox, _( - 'Neoboot plugin installed with ERRORS! Not work properly! The error number is 3'), type=MessageBox.TYPE_ERROR) + 'echo "\nNeoboot installation errors 3:\nfile neo.sh is error - 3\n" >> /tmp/error_neo' + ) + session.open( + MessageBox, + _("Neoboot plugin installed with ERRORS! Not work properly! The error number is 3"), + type=MessageBox.TYPE_ERROR, + ) if getCheckActivateVip() == getBoxMacAddres(): if checkInternet(): if getTestToTest() != UPDATEVERSION: - session.open(MessageBox, _( - 'New version update neoboot is available!\nPlease upgrade your flash plugin.'), type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + _("New version update neoboot is available!\nPlease upgrade your flash plugin."), + type=MessageBox.TYPE_ERROR, + ) else: - session.open(MessageBox, _('Geen internet'), - type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + _("Geen internet"), + type=MessageBox.TYPE_ERROR) else: - if not fileExists('/usr/lib/periodon/.kodn'): - session.open(MessageBox, _( - 'Get a free test to the full vip version.'), type=MessageBox.TYPE_ERROR) - elif fileExists('/usr/lib/periodon/.kodn') and fileExists('/tmp/.nkod'): + if not fileExists("/usr/lib/periodon/.kodn"): + session.open( + MessageBox, + _("Get a free test to the full vip version."), + type=MessageBox.TYPE_ERROR, + ) + elif fileExists("/usr/lib/periodon/.kodn") and fileExists("/tmp/.nkod"): if checkInternet(): if getTestToTest() != UPDATEVERSION: - session.open(MessageBox, _( - 'New version update neoboot is available!\nPlease upgrade your flash plugin.'), type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + _("New version update neoboot is available!\nPlease upgrade your flash plugin."), + type=MessageBox.TYPE_ERROR, + ) else: - session.open(MessageBox, _('Geen internet'), - type=MessageBox.TYPE_ERROR) - if not fileExists('/usr/lib/periodon/.accessdate'): # timeoff - session.open(MessageBox, _( - 'VIP access error. Reinstall the plugin.'), type=MessageBox.TYPE_ERROR) - if getAccesDate() == 'timeoff': # timeoff - session.open(MessageBox, _( - 'Neoboot vip version has expired, please re-access.'), type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + _("Geen internet"), + type=MessageBox.TYPE_ERROR) + if not fileExists("/usr/lib/periodon/.accessdate"): # timeoff + session.open( + MessageBox, + _("VIP access error. Reinstall the plugin."), + type=MessageBox.TYPE_ERROR, + ) + if getAccesDate() == "timeoff": # timeoff + session.open( + MessageBox, + _("Neoboot vip version has expired, please re-access."), + type=MessageBox.TYPE_ERROR, + ) version = 0 - if fileExists('%sImageBoot/.version' % getNeoLocation()): - f = open('%sImageBoot/.version' % getNeoLocation()) - version = float(f.read()) - f.close() + if fileExists("%sImageBoot/.version" % getNeoLocation()): + try: + f = open("%sImageBoot/.version" % getNeoLocation()) + version = float(f.read()) + f.close() + except BaseException: + version = 0.0 # Handle potential read errors - if fileExists('' + LinkNeoBoot + '/.location') and fileExists('%sImageBoot/.neonextboot' % getNeoLocation()): - f2 = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') + if fileExists("" + LinkNeoBoot + "/.location") and fileExists( + "%sImageBoot/.neonextboot" % getNeoLocation() + ): + f2 = open("%sImageBoot/.neonextboot" % getNeoLocation(), "r") mypath2 = f2.readline().strip() f2.close() - # and getCheckActivateVip() == getBoxMacAddres(): - if mypath2 != 'Flash' or mypath2 == 'Flash' and checkimage(): - if fileExists('/.multinfo') or fileExists('/usr/lib/periodon/.fullaccess'): + if mypath2 != "Flash" or mypath2 == "Flash" and checkimage(): + if fileExists("/.multinfo") or fileExists( + "/usr/lib/periodon/.fullaccess" + ): session.open(NeoBootImageChoose) else: if float(PLUGINVERSION) != version: @@ -2079,38 +3028,75 @@ def main(session, **kwargs): else: session.open(NeoBootImageChoose) else: - session.open(MessageBox, _( - 'Sorry, Unable to install, bad satellite receiver or you do not have the full plug-in version\n The full version of the NEO VIP plugin is on address:\nkrzysztofgutosie@.gmail.com'), type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + _("Sorry, Unable to install, bad satellite receiver or you do not have the full plug-in version\n The full version of the NEO VIP plugin is on address:\nkrzysztofgutosie@.gmail.com"), + type=MessageBox.TYPE_ERROR, + ) else: if (getSupportedTuners()) == (getBoxHostName()): session.open(NeoBootInstallation) else: - session.open(MessageBox, _( - 'Sorry cannot open neo menu. Not supported tuners. '), type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + _("Sorry cannot open neo menu. Not supported tuners. "), + type=MessageBox.TYPE_ERROR, + ) else: - session.open(MessageBox, (_('Sorry, Unable to install, bad satellite receiver or you do not have the full plug-in version\n\nThe full version of the NEO VIP plugin is on address:\nkrzysztofgutosie@.gmail.com')), type=MessageBox.TYPE_ERROR) + session.open( + MessageBox, + (_("Sorry, Unable to install, bad satellite receiver or you do not have the full plug-in version\n\nThe full version of the NEO VIP plugin is on address:\nkrzysztofgutosie@.gmail.com")), + type=MessageBox.TYPE_ERROR, + ) def menu(menuid, **kwargs): - if menuid == 'mainmenu': - return [(_('NeoBOOT'), - main, - 'neo_boot', - 1)] + if menuid == "mainmenu": + return [(_("NeoBOOT"), main, "neo_boot", 1)] return [] def Plugins(**kwargs): if isFHD(): - list = [PluginDescriptor(name='NeoBoot', description='NeoBoot', where=PluginDescriptor.WHERE_MENU, fnc=menu), PluginDescriptor( - name='NeoBoot', description=_('Installing multiple images'), icon='neo_fhd.png', where=PluginDescriptor.WHERE_PLUGINMENU, fnc=main)] - list.append(PluginDescriptor(name=_('NEOBOOT'), - where=PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)) + list = [ + PluginDescriptor( + name="NeoBoot", + description="NeoBoot", + where=PluginDescriptor.WHERE_MENU, + fnc=menu, + ), + PluginDescriptor( + name="NeoBoot", + description=_("Installing multiple images"), + icon="neo_fhd.png", + where=PluginDescriptor.WHERE_PLUGINMENU, + fnc=main, + ), + ] + list.append( + PluginDescriptor( + name=_("NEOBOOT"), + where=PluginDescriptor.WHERE_EXTENSIONSMENU, + fnc=main)) else: - list = [PluginDescriptor(name='NeoBoot', description='NeoBoot', where=PluginDescriptor.WHERE_MENU, fnc=menu), PluginDescriptor( - name='NeoBoot', description=_('Installing multiple images'), icon='neo_hd.png', where=PluginDescriptor.WHERE_PLUGINMENU, fnc=main)] - list.append(PluginDescriptor(name=_('NEOBOOT'), - where=PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)) + list = [ + PluginDescriptor( + name="NeoBoot", + description="NeoBoot", + where=PluginDescriptor.WHERE_MENU, + fnc=menu, + ), + PluginDescriptor( + name="NeoBoot", + description=_("Installing multiple images"), + icon="neo_hd.png", + where=PluginDescriptor.WHERE_PLUGINMENU, + fnc=main, + ), + ] + list.append( + PluginDescriptor( + name=_("NEOBOOT"), + where=PluginDescriptor.WHERE_EXTENSIONSMENU, + fnc=main)) return list - -####################### _q(-_-)p_ gutosie _q(-_-)p_ ####################### diff --git a/NeoBoot/tmpfiles/arm_run.py b/NeoBoot/tmpfiles/arm_run.py index 8d74e3f..576dc83 100644 --- a/NeoBoot/tmpfiles/arm_run.py +++ b/NeoBoot/tmpfiles/arm_run.py @@ -1,36 +1,84 @@ -# -*- coding: utf-8 -*- - -# from __init__ import _ from Plugins.Extensions.NeoBoot.__init__ import _ -from Plugins.Extensions.NeoBoot.files.stbbranding import getSupportedTuners, getCPUtype, getCPUSoC, getImageNeoBoot, getBoxHostName, getTunerModel, getNeoLocation, getNeoMount, getNeoMount2, getNeoMount3, getNeoMount4, getNeoMount5, getMountPointNeo2 +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getSupportedTuners, + getCPUtype, + getCPUSoC, + getImageNeoBoot, + getBoxHostName, + getNeoLocation, + getMountPointNeo2, +) from enigma import getDesktop -from enigma import eTimer from Screens.Screen import Screen from Screens.MessageBox import MessageBox -from Screens.ChoiceBox import ChoiceBox -from Screens.VirtualKeyBoard import VirtualKeyBoard from Screens.Standby import TryQuitMainloop -from Components.About import about -from Screens.Console import Console from Components.Sources.List import List -from Components.Button import Button -from Components.ActionMap import ActionMap, NumberActionMap +from Components.ActionMap import ActionMap from Components.GUIComponent import * -from Components.MenuList import MenuList -from Components.Input import Input from Components.Label import Label -from Components.ProgressBar import ProgressBar -from Components.ScrollLabel import ScrollLabel -from Components.Pixmap import Pixmap, MultiPixmap +from Components.Pixmap import Pixmap from Components.config import * -from Components.ConfigList import ConfigListScreen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import fileExists, pathExists, createDir, resolveFilename, SCOPE_PLUGINS -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen -from os.path import dirname, isdir, isdir as os_isdir +from Tools.Directories import fileExists import os -import time -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +import subprocess + + +def run_shell_command(cmd): + """ + Modern replacement for os.system(cmd) using subprocess.run. + Returns the exit code, mimicking os.system's behavior. + """ + try: + result = subprocess.run(cmd, shell=True, check=False) + return result.returncode + except Exception as e: + print(f"[run_shell_command] Failed to run '{cmd}'. Error: {e}") + return -1 # Return a non-zero code to indicate failure + + +def _is_device_mounted( + device="/dev/mmcblk0p23", + mount_point="/media/InternalFlash"): + """ + Checks if the specified device is currently mounted on the given mount point. + """ + try: + with open("/proc/mounts", "r") as f: + for line in f: + parts = line.split() + if len( + parts) >= 2 and parts[0] == device and parts[1] == mount_point: + return True + return False + except FileNotFoundError: + return False + + +def _append_fstab_entry(device, mount_point, fstab_file="/etc/fstab"): + """ + Appends the required fstab line if it's not already present. + """ + FSTAB_LINE = f"{device}\t\t{mount_point}\t\tauto\t\tdefaults\t\t\t\t\t\t0\t0\n" + try: + with open(fstab_file, "r") as f: + if any(line.strip().startswith(device) for line in f): + print( + f"Fstab entry for {device} already exists or device is in use.") + return False + except OSError as e: + print(f"Error reading {fstab_file}: {e}") + return False + try: + with open(fstab_file, "a") as f: + f.write(FSTAB_LINE) + return True + except OSError as e: + print(f"Error writing to {fstab_file}. Check permissions. Error: {e}") + return False + + +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" class StartImage(Screen): @@ -67,141 +115,217 @@ class StartImage(Screen): def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['list'] = List(self.list) + self["list"] = List(self.list) self.select() - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, - 'back': self.close}) - self['label1'] = Label(_('Start the chosen system now ?')) - self['label2'] = Label(_('Select OK to run the image.')) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "ok": self.KeyOk, "back": self.close}) + self["label1"] = Label(_("Start the chosen system now ?")) + self["label2"] = Label(_("Select OK to run the image.")) def select(self): self.list = [] - mypath = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' - if not fileExists(mypath + 'icons'): - mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png' + mypath = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + if not fileExists(mypath + "icons"): + mypixmap = ( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png" + ) png = LoadPixmap(mypixmap) - res = (_('OK Start image...'), png, 0) + res = (_("OK Start image..."), png, 0) self.list.append(res) - self['list'].list = self.list + self["list"].list = self.list def KeyOk(self): - if getImageNeoBoot() != 'Flash': - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) - self.StartImageInNeoBoot() - else: - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) - self.StartImageInNeoBoot() + image = getImageNeoBoot() + neo_location = getNeoLocation() + cmd = f"rm -rf {neo_location}ImageBoot/{image}/usr/bin/enigma2_pre_start.sh" + run_shell_command(cmd) - # --------------------------------------------- + self.StartImageInNeoBoot() getMountPointNeo2() - system('touch /tmp/.init_reboot') - # --------------------------------------------- + run_shell_command("touch /tmp/.init_reboot") + + def novalerReboot(self, result): + """Callback to reboot after the fstab edit message.""" + self.session.open(TryQuitMainloop, 2) def StartImageInNeoBoot(self): - if getImageNeoBoot() != 'Flash': - if fileExists('%sImageBoot/%s/.control_ok' % (getNeoLocation(), getImageNeoBoot())): - system('touch /tmp/.control_ok ') - else: - system('touch %sImageBoot/%s/.control_boot_new_image ' % - (getNeoLocation(), getImageNeoBoot())) - if fileExists('/.multinfo') and getCPUtype() == 'ARMv7': - os.system(' ' + LinkNeoBoot + - '/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash; sleep 1') + DEVICE = "/dev/mmcblk0p23" + MOUNT_POINT = "/media/InternalFlash" - self.sel = self['list'].getCurrent() + if getBoxHostName() == "novaler4kpro": + if not _is_device_mounted(DEVICE, MOUNT_POINT): + print( + f"Novaler4kpro: {DEVICE} not mounted on {MOUNT_POINT}. Checking fstab...") + if not os.path.isdir(MOUNT_POINT): + try: + os.mkdir(MOUNT_POINT) + print(f"Created mount point {MOUNT_POINT}") + except OSError as e: + print(f"Error creating mount point: {e}") + + if _append_fstab_entry(DEVICE, MOUNT_POINT): + print("fstab file edited. rebooting your novaler4kpro") + self.session.open( + MessageBox, + _("fstab file edited. rebooting your novaler4kpro"), + MessageBox.TYPE_INFO, + 5, # <--- TIMEOUT PASSED POSITIONALLY + self.novalerReboot, + ) + return # Exit the function after scheduling the reboot + else: + print( + "Novaler4kpro: fstab entry already present or write failed. Proceeding." + ) + + if getImageNeoBoot() != "Flash": + if fileExists( + "%sImageBoot/%s/.control_ok" % + (getNeoLocation(), getImageNeoBoot())): + run_shell_command("touch /tmp/.control_ok ") + else: + run_shell_command( + "touch %sImageBoot/%s/.control_boot_new_image " + % (getNeoLocation(), getImageNeoBoot()) + ) + + if fileExists("/.multinfo") and getCPUtype() == "ARMv7": + run_shell_command( + f"{LinkNeoBoot}/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash; sleep 1") + + self.sel = self["list"].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0: - if not fileExists('/bin/busybox.nosuid'): - os.system('ln -sf "busybox" "/bin/busybox.nosuid" ') - if fileExists('/media/InternalFlash/etc/init.d/neomountboot.sh'): - os.system( - 'rm -f /media/InternalFlash/etc/init.d/neomountboot.sh;') - if fileExists('/media/InternalFlash/linuxrootfs1/etc/init.d/neomountboot.sh'): - os.system( - 'rm -f /media/InternalFlash/linuxrootfs1/etc/init.d/neomountboot.sh;') - if fileExists('/media/InternalFlash/linuxrootfs2/etc/init.d/neomountboot.sh'): - os.system( - 'rm -f /media/InternalFlash/linuxrootfs2/etc/init.d/neomountboot.sh;') - if fileExists('/media/InternalFlash/linuxrootfs3/etc/init.d/neomountboot.sh'): - os.system( - 'rm -f /media/InternalFlash/linuxrootfs3/etc/init.d/neomountboot.sh;') - if fileExists('/media/InternalFlash/linuxrootfs4/etc/init.d/neomountboot.sh'): - os.system( - 'rm -f /media/InternalFlash/linuxrootfs4/etc/init.d/neomountboot.sh;') -# else: -# pass - # _____ARM procesor____ - if (getSupportedTuners()): - if getImageNeoBoot() == 'Flash': - if fileExists('/.multinfo'): - if fileExists('/media/InternalFlash/linuxrootfs1/sbin/neoinitarm'): - os.system( - 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs1/sbin/init"') - if fileExists('/media/InternalFlash/linuxrootfs2/sbin/neoinitarm'): - os.system( - 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs2/sbin/init"') - if fileExists('/media/InternalFlash/linuxrootfs3/sbin/neoinitarm'): - os.system( - 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs3/sbin/init"') - if fileExists('/media/InternalFlash/linuxrootfs4/sbin/neoinitarm'): - os.system( - 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs4/sbin/init"') - if fileExists('/media/InternalFlash/sbin/init'): - os.system( - 'ln -sfn "init.sysvinit" "/media/InternalFlash/sbin/init"') - if fileExists('/media/InternalFlash'): + if not fileExists("/bin/busybox.nosuid"): + run_shell_command('ln -sf "busybox" "/bin/busybox.nosuid" ') + if fileExists("/media/InternalFlash/etc/init.d/neomountboot.sh"): + run_shell_command( + "rm -f /media/InternalFlash/etc/init.d/neomountboot.sh;" + ) + if fileExists( + "/media/InternalFlash/linuxrootfs1/etc/init.d/neomountboot.sh" + ): + run_shell_command( + "rm -f /media/InternalFlash/linuxrootfs1/etc/init.d/neomountboot.sh;" + ) + if fileExists( + "/media/InternalFlash/linuxrootfs2/etc/init.d/neomountboot.sh" + ): + run_shell_command( + "rm -f /media/InternalFlash/linuxrootfs2/etc/init.d/neomountboot.sh;" + ) + if fileExists( + "/media/InternalFlash/linuxrootfs3/etc/init.d/neomountboot.sh" + ): + run_shell_command( + "rm -f /media/InternalFlash/linuxrootfs3/etc/init.d/neomountboot.sh;" + ) + if fileExists( + "/media/InternalFlash/linuxrootfs4/etc/init.d/neomountboot.sh" + ): + run_shell_command( + "rm -f /media/InternalFlash/linuxrootfs4/etc/init.d/neomountboot.sh;" + ) + + if getSupportedTuners(): + if getImageNeoBoot() == "Flash": + if fileExists("/.multinfo"): + if fileExists( + "/media/InternalFlash/linuxrootfs1/sbin/neoinitarm" + ): + run_shell_command( + 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs1/sbin/init"' + ) + if fileExists( + "/media/InternalFlash/linuxrootfs2/sbin/neoinitarm" + ): + run_shell_command( + 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs2/sbin/init"' + ) + if fileExists( + "/media/InternalFlash/linuxrootfs3/sbin/neoinitarm" + ): + run_shell_command( + 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs3/sbin/init"' + ) + if fileExists( + "/media/InternalFlash/linuxrootfs4/sbin/neoinitarm" + ): + run_shell_command( + 'ln -sf "init.sysvinit" "/media/InternalFlash/linuxrootfs4/sbin/init"' + ) + if fileExists("/media/InternalFlash/sbin/init"): + run_shell_command( + 'ln -sfn "init.sysvinit" "/media/InternalFlash/sbin/init"' + ) + + self.session.open(TryQuitMainloop, 2) + + else: + cmd = "ln -sfn /sbin/init.sysvinit /sbin/init" + run_shell_command(cmd) # Removed unused 'rc' + self.session.open(TryQuitMainloop, 2) + + elif getImageNeoBoot() != "Flash": + if fileExists("/.multinfo"): + if fileExists( + "/media/InternalFlash/linuxrootfs1/sbin/neoinitarm" + ): + cmd = "cd /media/InternalFlash/linuxrootfs1; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs1/sbin/init" + run_shell_command(cmd) # Removed unused 'rc' + self.session.open(TryQuitMainloop, 2) + elif fileExists( + "/media/InternalFlash/linuxrootfs2/sbin/neoinitarm" + ): + cmd = "cd /media/InternalFlash/linuxrootfs2; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs2/sbin/init" + run_shell_command(cmd) # Removed unused 'rc' + self.session.open(TryQuitMainloop, 2) + elif fileExists( + "/media/InternalFlash/linuxrootfs3/sbin/neoinitarm" + ): + cmd = "cd /media/InternalFlash/linuxrootfs3; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs3/sbin/init" + run_shell_command(cmd) # Removed unused 'rc' + self.session.open(TryQuitMainloop, 2) + elif fileExists( + "/media/InternalFlash/linuxrootfs4/sbin/neoinitarm" + ): + cmd = "cd /media/InternalFlash/linuxrootfs4; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs4/sbin/init" + run_shell_command(cmd) # Removed unused 'rc' self.session.open(TryQuitMainloop, 2) else: self.session.open(TryQuitMainloop, 2) - elif not fileExists('/.multinfo'): - cmd = 'ln -sfn /sbin/init.sysvinit /sbin/init' - rc = os.system(cmd) + + elif not fileExists("/.multinfo"): + cmd = "ln -sfn /sbin/neoinitarm /sbin/init" + run_shell_command(cmd) # Removed unused 'rc' self.session.open(TryQuitMainloop, 2) else: - cmd = 'ln -sfn /sbin/init.sysvinit /sbin/init' - rc = os.system(cmd) - self.session.open(TryQuitMainloop, 2) - elif getImageNeoBoot() != 'Flash': - if fileExists('/.multinfo'): - if fileExists('/media/InternalFlash/linuxrootfs1/sbin/neoinitarm'): - cmd = 'cd /media/InternalFlash/linuxrootfs1; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs1/sbin/init' - rc = os.system(cmd) - self.session.open(TryQuitMainloop, 2) - elif fileExists('/media/InternalFlash/linuxrootfs2/sbin/neoinitarm'): - cmd = 'cd /media/InternalFlash/linuxrootfs2; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs2/sbin/init' - rc = os.system(cmd) - self.session.open(TryQuitMainloop, 2) - elif fileExists('/media/InternalFlash/linuxrootfs3/sbin/neoinitarm'): - cmd = 'cd /media/InternalFlash/linuxrootfs3; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs3/sbin/init' - rc = os.system(cmd) - self.session.open(TryQuitMainloop, 2) - elif fileExists('/media/InternalFlash/linuxrootfs4/sbin/neoinitarm'): - cmd = 'cd /media/InternalFlash/linuxrootfs4; ln -sfn /sbin/neoinitarm /media/InternalFlash/linuxrootfs4/sbin/init' - rc = os.system(cmd) - self.session.open(TryQuitMainloop, 2) - else: - self.session.open(TryQuitMainloop, 2) - elif not fileExists('/.multinfo'): - cmd = 'ln -sfn /sbin/neoinitarm /sbin/init' - rc = os.system(cmd) - self.session.open(TryQuitMainloop, 2) - else: - cmd = 'ln -sfn /sbin/init.sysvinit /sbin/init' - rc = os.system(cmd) + cmd = "ln -sfn /sbin/init.sysvinit /sbin/init" + run_shell_command(cmd) # Removed unused 'rc' self.session.open(TryQuitMainloop, 2) else: - os.system('echo "Flash " >> ' + - getNeoLocation() + 'ImageBoot/.neonextboot') - self.messagebox = self.session.open(MessageBox, _( - 'It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) + run_shell_command( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot" + ) + self.messagebox = self.session.open( + MessageBox, + _("It looks like it that multiboot does not support this STB."), + MessageBox.TYPE_INFO, + 8, + ) self.close() - else: - os.system('echo "Flash " >> ' + getNeoLocation() + - 'ImageBoot/.neonextboot') - self.messagebox = self.session.open(MessageBox, _( - 'It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) + run_shell_command( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot") + self.messagebox = self.session.open( + MessageBox, + _("It looks like it that multiboot does not support this STB."), + MessageBox.TYPE_INFO, + 8, + ) self.close() diff --git a/NeoBoot/tmpfiles/mips_run.py b/NeoBoot/tmpfiles/mips_run.py index a82f97e..99f820e 100644 --- a/NeoBoot/tmpfiles/mips_run.py +++ b/NeoBoot/tmpfiles/mips_run.py @@ -1,7 +1,19 @@ -# -*- coding: utf-8 -*- - from Plugins.Extensions.NeoBoot.__init__ import _ -from Plugins.Extensions.NeoBoot.files.stbbranding import getSupportedTuners, getNeoLocation, getCPUtype, getCPUSoC, getImageNeoBoot, getBoxVuModel, getBoxHostName, getNeoMount, getNeoMount2, getNeoMount3, getNeoMount4, getNeoMount5, getMountPointNeo2 +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getSupportedTuners, + getNeoLocation, + getCPUtype, + getCPUSoC, + getImageNeoBoot, + getBoxVuModel, + getBoxHostName, + getNeoMount, + getNeoMount2, + getNeoMount3, + getNeoMount4, + getNeoMount5, + getMountPointNeo2, +) from enigma import getDesktop from enigma import eTimer from Screens.Screen import Screen @@ -24,12 +36,28 @@ from Components.Pixmap import Pixmap, MultiPixmap from Components.config import * from Components.ConfigList import ConfigListScreen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import fileExists, pathExists, createDir, resolveFilename, SCOPE_PLUGINS -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen +from Tools.Directories import ( + fileExists, + pathExists, + createDir, + resolveFilename, + SCOPE_PLUGINS, +) +from os import ( + system, + listdir, + mkdir, + chdir, + getcwd, + rename as os_rename, + remove as os_remove, + popen, +) from os.path import dirname, isdir, isdir as os_isdir import os import time -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' + +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" class StartImage(Screen): @@ -66,89 +94,122 @@ class StartImage(Screen): def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['list'] = List(self.list) + self["list"] = List(self.list) self.select() - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, - 'back': self.close}) - self['label1'] = Label(_('Start the chosen system now ?')) - self['label2'] = Label(_('Select OK to run the image.')) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "ok": self.KeyOk, "back": self.close}) + self["label1"] = Label(_("Start the chosen system now ?")) + self["label2"] = Label(_("Select OK to run the image.")) def select(self): self.list = [] - mypath = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' - if not fileExists(mypath + 'icons'): - mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png' + mypath = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + if not fileExists(mypath + "icons"): + mypixmap = ( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png" + ) png = LoadPixmap(mypixmap) - res = (_('OK Start image...'), png, 0) + res = (_("OK Start image..."), png, 0) self.list.append(res) - self['list'].list = self.list + self["list"].list = self.list def KeyOk(self): - if getImageNeoBoot() != 'Flash': - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) + if getImageNeoBoot() != "Flash": + os.system( + "rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh" + % (getNeoLocation(), getImageNeoBoot()) + ) self.StartImageInNeoBoot() else: - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) + os.system( + "rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh" + % (getNeoLocation(), getImageNeoBoot()) + ) self.StartImageInNeoBoot() - # --------------------------------------------- getMountPointNeo2() - system('touch /tmp/.init_reboot') - # --------------------------------------------- + system("touch /tmp/.init_reboot") def StartImageInNeoBoot(self): - if getImageNeoBoot() != 'Flash': - if fileExists('%sImageBoot/%s/.control_ok' % (getNeoLocation(), getImageNeoBoot())): - system('touch /tmp/.control_ok ') + if getImageNeoBoot() != "Flash": + if fileExists( + "%sImageBoot/%s/.control_ok" % + (getNeoLocation(), getImageNeoBoot())): + system("touch /tmp/.control_ok ") else: - system('touch %sImageBoot/%s/.control_boot_new_image ' % - (getNeoLocation(), getImageNeoBoot())) + system( + "touch %sImageBoot/%s/.control_boot_new_image " + % (getNeoLocation(), getImageNeoBoot()) + ) - # system('chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/kernel.sh') - self.sel = self['list'].getCurrent() + self.sel = self["list"].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0: - if fileExists('/media/InternalFlash/etc/init.d/neobootmount.sh'): + if fileExists("/media/InternalFlash/etc/init.d/neobootmount.sh"): os.system( - 'rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;') - if (getSupportedTuners()): - if getImageNeoBoot() == 'Flash': - cmd = 'ln -sfn /sbin/init.sysvinit /sbin/init' + "rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;") + if getSupportedTuners(): + if getImageNeoBoot() == "Flash": + cmd = "ln -sfn /sbin/init.sysvinit /sbin/init" rc = os.system(cmd) getTurnOffOnSystem() - elif getImageNeoBoot() != 'Flash': - if fileExists('/.multinfo'): + elif getImageNeoBoot() != "Flash": + if fileExists("/.multinfo"): getTurnOffOnSystem() - elif not fileExists('/.multinfo'): - cmd = 'ln -sfn /sbin/neoinitmips /sbin/init' + elif not fileExists("/.multinfo"): + cmd = "ln -sfn /sbin/neoinitmips /sbin/init" rc = os.system(cmd) getTurnOffOnSystem() else: - os.system('echo "Flash " >> ' + - getNeoLocation() + 'ImageBoot/.neonextboot') + os.system( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot" + ) getTurnOffOnSystem() else: - os.system('echo "Flash " >> ' + - getNeoLocation() + 'ImageBoot/.neonextboot') - self.messagebox = self.session.open(MessageBox, _( - 'It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) + os.system( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot" + ) + self.messagebox = self.session.open( + MessageBox, + _("It looks like it that multiboot does not support this STB."), + MessageBox.TYPE_INFO, + 8, + ) self.close() else: - os.system('echo "Flash " >> ' + getNeoLocation() + - 'ImageBoot/.neonextboot') - self.messagebox = self.session.open(MessageBox, _( - 'It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) + os.system( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot") + self.messagebox = self.session.open( + MessageBox, + _("It looks like it that multiboot does not support this STB."), + MessageBox.TYPE_INFO, + 8, + ) self.close() def getTurnOffOnSystem(): for line in open("/etc/hostname"): - if "dm500hd" in line or "dm800se" in line or "dm800" in line or "dm800se" in line or "dm8000" in line: - if fileExists('%sImageBoot/%s/squashfs-images' % (getNeoLocation(), getImageNeoBoot())): - os.system('ln -sf "%sImageBoot/%s/squashfs-images" "//squashfs-images"' % - (getNeoLocation(), getImageNeoBoot())) + if ( + "dm500hd" in line + or "dm800se" in line + or "dm800" in line + or "dm800se" in line + or "dm8000" in line + ): + if fileExists( + "%sImageBoot/%s/squashfs-images" % + (getNeoLocation(), getImageNeoBoot())): + os.system( + 'ln -sf "%sImageBoot/%s/squashfs-images" "//squashfs-images"' % + (getNeoLocation(), getImageNeoBoot())) os.system( - 'echo 3 > /proc/sys/vm/drop_caches; shutdown now -r; reboot -f -d -h -i') + "echo 3 > /proc/sys/vm/drop_caches; shutdown now -r; reboot -f -d -h -i" + ) diff --git a/NeoBoot/tmpfiles/vu4k_run.py b/NeoBoot/tmpfiles/vu4k_run.py index 223e79d..be610b5 100644 --- a/NeoBoot/tmpfiles/vu4k_run.py +++ b/NeoBoot/tmpfiles/vu4k_run.py @@ -1,9 +1,18 @@ -# -*- coding: utf-8 -*- - -# from __init__ import _ from Plugins.Extensions.NeoBoot.__init__ import _ -# from __future__ import print_function -from Plugins.Extensions.NeoBoot.files.stbbranding import getNeoLocation, getCPUtype, getCPUSoC, getImageNeoBoot, getBoxVuModel, getBoxHostName, getNeoMount, getNeoMount2, getNeoMount3, getNeoMount4, getNeoMount5, getMountPointNeo2 +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getNeoLocation, + getCPUtype, + getCPUSoC, + getImageNeoBoot, + getBoxVuModel, + getBoxHostName, + getNeoMount, + getNeoMount2, + getNeoMount3, + getNeoMount4, + getNeoMount5, + getMountPointNeo2, +) from enigma import getDesktop from enigma import eTimer from Screens.Screen import Screen @@ -26,22 +35,46 @@ from Components.Pixmap import Pixmap, MultiPixmap from Components.config import * from Components.ConfigList import ConfigListScreen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import fileExists, pathExists, createDir, resolveFilename, SCOPE_PLUGINS -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen +from Tools.Directories import ( + fileExists, + pathExists, + createDir, + resolveFilename, + SCOPE_PLUGINS, +) +import subprocess +from os import listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove from os.path import dirname, isdir, isdir as os_isdir import os import time -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' + +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" def getMmcBlockDevice(): - mmcblockdevice = 'UNKNOWN' - if getBoxHostName() == 'vuultimo4k' or getBoxHostName() == 'vusolo4k' or getBoxHostName() == 'vuuno4kse' or getBoxHostName() == 'vuuno4k' and getBoxHostName() != "ustym4kpro": - mmcblockdevice = 'mmcblk0p1' - elif getBoxHostName() == 'vuzero4k' and getBoxVuModel() == 'zero4k' and getCPUSoC() == '72604' and getBoxHostName() != "ustym4kpro": - mmcblockdevice = 'mmcblk0p4' - elif getBoxHostName() == 'vuduo4k' or getBoxHostName() == 'vuduo4kse' and getBoxHostName() != "vuultimo4k" and getBoxHostName() != "ustym4kpro": - mmcblockdevice = 'mmcblk0p6' + mmcblockdevice = "UNKNOWN" + if ( + getBoxHostName() == "vuultimo4k" + or getBoxHostName() == "vusolo4k" + or getBoxHostName() == "vuuno4kse" + or getBoxHostName() == "vuuno4k" + and getBoxHostName() != "ustym4kpro" + ): + mmcblockdevice = "mmcblk0p1" + elif ( + getBoxHostName() == "vuzero4k" + and getBoxVuModel() == "zero4k" + and getCPUSoC() == "72604" + and getBoxHostName() != "ustym4kpro" + ): + mmcblockdevice = "mmcblk0p4" + elif ( + getBoxHostName() == "vuduo4k" + or getBoxHostName() == "vuduo4kse" + and getBoxHostName() != "vuultimo4k" + and getBoxHostName() != "ustym4kpro" + ): + mmcblockdevice = "mmcblk0p6" return mmcblockdevice @@ -79,158 +112,358 @@ class StartImage(Screen): def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['list'] = List(self.list) + self["list"] = List(self.list) self.select() - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, - 'back': self.close}) - self['label1'] = Label(_('Start the chosen system now ?')) - self['label2'] = Label(_('Select OK to run the image.')) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "ok": self.KeyOk, "back": self.close}) + self["label1"] = Label(_("Start the chosen system now ?")) + self["label2"] = Label(_("Select OK to run the image.")) def select(self): self.list = [] - mypath = '' + LinkNeoBoot + '' - if not fileExists(mypath + 'icons'): - mypixmap = '' + LinkNeoBoot + '/images/ok.png' + mypath = "" + LinkNeoBoot + "" + if not fileExists(mypath + "icons"): + mypixmap = "" + LinkNeoBoot + "/images/ok.png" png = LoadPixmap(mypixmap) - res = (_('OK Start image...'), png, 0) + res = (_("OK Start image..."), png, 0) self.list.append(res) - self['list'].list = self.list + self["list"].list = self.list def KeyOk(self): if getImageNeoBoot() != "Flash": - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) + subprocess.run( + "rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh" + % (getNeoLocation(), getImageNeoBoot()), + shell=True, + ) self.StartImageInNeoBoot() else: - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) + subprocess.run( + "rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh" + % (getNeoLocation(), getImageNeoBoot()), + shell=True, + ) self.StartImageInNeoBoot() - # --------------------------------------------- getMountPointNeo2() - system('touch /tmp/.init_reboot') - # --------------------------------------------- + subprocess.run("touch /tmp/.init_reboot", shell=True) def StartImageInNeoBoot(self): if getImageNeoBoot() != "Flash": - if fileExists('%sImageBoot/%s/.control_ok' % (getNeoLocation(), getImageNeoBoot())): - system('touch /tmp/.control_ok ') + if fileExists( + "%sImageBoot/%s/.control_ok" % + (getNeoLocation(), getImageNeoBoot())): + subprocess.run("touch /tmp/.control_ok ", shell=True) else: - system('touch %sImageBoot/%s/.control_boot_new_image ' % - (getNeoLocation(), getImageNeoBoot())) + subprocess.run( + "touch %sImageBoot/%s/.control_boot_new_image " + % (getNeoLocation(), getImageNeoBoot()), + shell=True, + ) - if fileExists('/.multinfo') and getCPUtype() == "ARMv7": - if getBoxVuModel() == "uno4kse" or getBoxVuModel() == "uno4k" or getBoxVuModel() == "ultimo4k" or getBoxVuModel() == "solo4k": - os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') - elif getBoxVuModel() == 'duo4kse' or getBoxVuModel() == 'duo4k': - os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash') - elif getBoxVuModel() == 'zero4k': - os.system( - 'mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') + if fileExists("/.multinfo") and getCPUtype() == "ARMv7": + if ( + getBoxVuModel() == "uno4kse" + or getBoxVuModel() == "uno4k" + or getBoxVuModel() == "ultimo4k" + or getBoxVuModel() == "solo4k" + ): + subprocess.run( + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash", + shell=True, + ) + elif getBoxVuModel() == "duo4kse" or getBoxVuModel() == "duo4k": + subprocess.run( + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash", + shell=True, + ) + elif getBoxVuModel() == "zero4k": + subprocess.run( + "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash", + shell=True, + ) else: - os.system( - ' ' + LinkNeoBoot + '/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash') - # elif fileExists('/boot/STARTUP') and getCPUtype() == "ARMv7": - # os.system('ln -sf "neoinitarmvu" "/boot/sbin/init"') + subprocess.run( + " " + + LinkNeoBoot + + "/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash", + shell=True, + ) - self.sel = self['list'].getCurrent() + self.sel = self["list"].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0: - if fileExists('/media/InternalFlash/etc/init.d/neobootmount.sh'): - os.system( - 'rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;') - if not fileExists('/bin/busybox.nosuid'): - os.system('ln -sf "busybox" "/bin/busybox.nosuid" ') + if fileExists("/media/InternalFlash/etc/init.d/neobootmount.sh"): + subprocess.run( + "rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;", + shell=True) + if not fileExists("/bin/busybox.nosuid"): + subprocess.run( + 'ln -sf "busybox" "/bin/busybox.nosuid" ', + shell=True) - # VUPLUS Arm mmc block device if getCPUtype() == "ARMv7" and "vu" + getBoxVuModel() == getBoxHostName(): - if not fileExists('%sImagesUpload/.kernel/flash-kernel-%s.bin' % (getNeoLocation(), getBoxHostName())): - mess = (_('Error - in the location %sImagesUpload/.kernel/ \nkernel file not found flash-kernel-%s.bin') % - (getNeoLocation(), getBoxHostName())) + if not fileExists( + "%sImagesUpload/.kernel/flash-kernel-%s.bin" + % (getNeoLocation(), getBoxHostName()) + ): + mess = _( + "Error - in the location %sImagesUpload/.kernel/ \nkernel file not found flash-kernel-%s.bin" + ) % (getNeoLocation(), getBoxHostName()) self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) else: if getImageNeoBoot() == "Flash": if fileExists("/.multinfo"): cmd = "echo -e '\n\n%s '" % _( - '...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') + "...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) cmd1 = 'cd /media/InternalFlash; ln -sf "init.sysvinit" "/media/InternalFlash/sbin/init"' - # Vu+ Real Multiboot - if fileExists('/media/InternalFlash/STARTUP') and fileExists('/media/InternalFlash/zImage'): - cmd2 = 'dd if=/media/InternalFlash/zImage of=/dev/' + getMmcBlockDevice() + '' + if fileExists( + "/media/InternalFlash/STARTUP" + ) and fileExists("/media/InternalFlash/zImage"): + cmd2 = ( + "dd if=/media/InternalFlash/zImage of=/dev/" + + getMmcBlockDevice() + + "") else: - cmd2 = 'dd if=' + getNeoLocation() + 'ImagesUpload/.kernel/flash-kernel-' + \ - getBoxHostName() + '.bin of=/dev/' + getMmcBlockDevice() + '' - # cmd2 = 'dd if=' + getNeoLocation() + 'ImagesUpload/.kernel/flash-kernel-' + getBoxHostName() + '.bin of=/dev/' + getMmcBlockDevice() + '' - cmd3 = "echo -e '\n%s '" % _('Start image FLASH - kernel flash !\nSTB NAME: ' + getBoxHostName() + '\nMODEL: ' + getBoxVuModel() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; cat /dev/' + getMmcBlockDevice() + ' | grep "kernel"; echo "Used Kernel: " ' + \ - getImageNeoBoot() + ' > ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f' + cmd2 = ( + "dd if=" + + getNeoLocation() + + "ImagesUpload/.kernel/flash-kernel-" + + getBoxHostName() + + ".bin of=/dev/" + + getMmcBlockDevice() + + "" + ) + cmd3 = "echo -e '\n%s '" % _( + "Start image FLASH - kernel flash !\nSTB NAME: " + + getBoxHostName() + + "\nMODEL: " + + getBoxVuModel() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------" + ) + cmd4 = ( + "update-alternatives --remove vmlinux vmlinux-`uname -r` || true; cat /dev/" + + getMmcBlockDevice() + + ' | grep "kernel"; echo "Used Kernel: " ' + + getImageNeoBoot() + + " > " + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f") elif not fileExists("/.multinfo"): cmd = "echo -e '\n\n%s '" % _( - '...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') + "...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) cmd1 = 'sleep 5; ln -sf "init.sysvinit" "/sbin/init"' - cmd2 = 'echo "Used Kernel: " ' + getImageNeoBoot() + ' > ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/used_flash_kernel' - cmd3 = "echo -e '\n%s '" % _('Start image FLASH - kernel flash !\nSTB NAME: ' + getBoxHostName() + '\nMODEL: ' + getBoxVuModel() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sleep 8; reboot -d -f' + cmd2 = ( + 'echo "Used Kernel: " ' + + getImageNeoBoot() + + " > " + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel" + ) + cmd3 = "echo -e '\n%s '" % _( + "Start image FLASH - kernel flash !\nSTB NAME: " + + getBoxHostName() + + "\nMODEL: " + + getBoxVuModel() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------" + ) + cmd4 = "update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sleep 8; reboot -d -f" elif getImageNeoBoot() != "Flash": if not fileExists("/.multinfo"): - if not fileExists('%sImageBoot/%s/boot/zImage.%s' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + if not fileExists( + "%sImageBoot/%s/boot/zImage.%s" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n\n%s '" % _( - '...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'sleep 5; ln -sfn /sbin/neoinitarm /sbin/init' - cmd2 = 'echo "Used Kernel: " ' + getImageNeoBoot() + ' > ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/used_flash_kernel' - cmd3 = "echo -e '\n%s '" % _('Reboot system E2 now !\nSTB NAME: ' + getBoxHostName() + '\nMODEL: ' + getBoxVuModel() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will REBOOT in 5 seconds !____\n\n ------------ N E O B O O T ------------') - cmd4 = 'sleep 8; reboot -d -f ' - elif fileExists('%sImageBoot/%s/boot/zImage.%s' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + "...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = "sleep 5; ln -sfn /sbin/neoinitarm /sbin/init" + cmd2 = ( + 'echo "Used Kernel: " ' + + getImageNeoBoot() + + " > " + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel" + ) + cmd3 = "echo -e '\n%s '" % _( + "Reboot system E2 now !\nSTB NAME: " + + getBoxHostName() + + "\nMODEL: " + + getBoxVuModel() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUtype() + + " " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will REBOOT in 5 seconds !____\n\n ------------ N E O B O O T ------------" + ) + cmd4 = "sleep 8; reboot -d -f " + elif fileExists( + "%sImageBoot/%s/boot/zImage.%s" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n\n%s '" % _( - '...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'ln -sfn /sbin/neoinitarmvu /sbin/init' - cmd2 = 'dd if=' + getNeoLocation() + 'ImageBoot/' + getImageNeoBoot() + \ - '/boot/zImage.' + getBoxHostName() + ' of=/dev/' + getMmcBlockDevice() + '' - cmd3 = "echo -e '\n%s '" % _('Changed kernel COMPLETE !\nSTB NAME: ' + getBoxHostName() + '\nMODEL: ' + getBoxVuModel() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUtype() + ' ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; echo "Used Kernel: " ' + \ - getImageNeoBoot() + ' > ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f' + "...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = "ln -sfn /sbin/neoinitarmvu /sbin/init" + cmd2 = ( + "dd if=" + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/zImage." + + getBoxHostName() + + " of=/dev/" + + getMmcBlockDevice() + + "" + ) + cmd3 = "echo -e '\n%s '" % _( + "Changed kernel COMPLETE !\nSTB NAME: " + + getBoxHostName() + + "\nMODEL: " + + getBoxVuModel() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUtype() + + " " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------" + ) + cmd4 = ( + 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; echo "Used Kernel: " ' + + getImageNeoBoot() + + " > " + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f") elif fileExists("/.multinfo"): - if not fileExists('%sImageBoot/%s/boot/zImage.%s' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + if not fileExists( + "%sImageBoot/%s/boot/zImage.%s" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n\n%s '" % _( - '...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'dd if=' + getNeoLocation() + 'ImagesUpload/.kernel/flash-kernel-' + \ - getBoxHostName() + '.bin of=/dev/' + getMmcBlockDevice() + '' + "...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = ( + "dd if=" + + getNeoLocation() + + "ImagesUpload/.kernel/flash-kernel-" + + getBoxHostName() + + ".bin of=/dev/" + + getMmcBlockDevice() + + "" + ) cmd2 = 'cd /media/InternalFlash; ln -sf "neoinitarm" "/media/InternalFlash/sbin/init"' - cmd3 = "echo -e '\n%s '" % _('Start image without changing the kernel!\nSTB NAME: ' + getBoxHostName() + '\nMODEL: ' + getBoxVuModel() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------') - cmd4 = 'echo "Used Kernel: " ' + getImageNeoBoot() + ' > ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f' - elif fileExists('%sImageBoot/%s/boot/zImage.%s' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + cmd3 = "echo -e '\n%s '" % _( + "Start image without changing the kernel!\nSTB NAME: " + + getBoxHostName() + + "\nMODEL: " + + getBoxVuModel() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____\n\n ------------ N E O B O O T ------------" + ) + cmd4 = ( + 'echo "Used Kernel: " ' + + getImageNeoBoot() + + " > " + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f") + elif fileExists( + "%sImageBoot/%s/boot/zImage.%s" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n\n%s '" % _( - '...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') + "...............NEOBOOT - REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) cmd1 = 'cd /media/InternalFlash; ln -sf "neoinitarmvu" "/media/InternalFlash/sbin/init"' - cmd2 = 'dd if=' + getNeoLocation() + 'ImageBoot/' + getImageNeoBoot() + \ - '/boot/zImage.' + getBoxHostName() + ' of=/dev/' + getMmcBlockDevice() + '' - cmd3 = "echo -e '\n%s '" % _('Changed kernel COMPLETE !\nSTB NAME: ' + getBoxHostName() + '\nMODEL: ' + getBoxVuModel() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ \n\n ------------ N E O B O O T ------------') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; echo "Used Kernel: " ' + \ - getImageNeoBoot() + ' > ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f' + cmd2 = ( + "dd if=" + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/zImage." + + getBoxHostName() + + " of=/dev/" + + getMmcBlockDevice() + + "" + ) + cmd3 = "echo -e '\n%s '" % _( + "Changed kernel COMPLETE !\nSTB NAME: " + + getBoxHostName() + + "\nMODEL: " + + getBoxVuModel() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ \n\n ------------ N E O B O O T ------------" + ) + cmd4 = ( + 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; echo "Used Kernel: " ' + + getImageNeoBoot() + + " > " + + getNeoLocation() + + "ImagesUpload/.kernel/used_flash_kernel; sleep 8; reboot -d -f") self.session.open(Console, _( - 'NeoBoot ARM VU+....'), [cmd, cmd1, cmd2, cmd3, cmd4]) + "NeoBoot ARM VU+...."), [cmd, cmd1, cmd2, cmd3, cmd4]) self.close() else: - os.system('echo "Flash " >> ' + getNeoLocation() + - 'ImageBoot/.neonextboot') - self.messagebox = self.session.open(MessageBox, _( - 'It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) + subprocess.run( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot", + shell=True, + ) + self.messagebox = self.session.open( + MessageBox, + _("It looks like it that multiboot does not support this STB."), + MessageBox.TYPE_INFO, + 8, + ) self.close() def myclose2(self, message): diff --git a/NeoBoot/tmpfiles/vu_run.py b/NeoBoot/tmpfiles/vu_run.py index dde5dd2..8334187 100644 --- a/NeoBoot/tmpfiles/vu_run.py +++ b/NeoBoot/tmpfiles/vu_run.py @@ -1,7 +1,21 @@ -# -*- coding: utf-8 -*- - from Plugins.Extensions.NeoBoot.__init__ import _ -from Plugins.Extensions.NeoBoot.files.stbbranding import getNeoLocation, getCPUtype, getCPUSoC, getImageNeoBoot, getBoxVuModel, getBoxHostName, getNeoMount, getNeoMount2, getNeoMount3, getNeoMount4, getNeoMount5, getMountPointNeo2, getNandWrite, getExtCheckHddUsb, getImageBootNow +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getNeoLocation, + getCPUtype, + getCPUSoC, + getImageNeoBoot, + getBoxVuModel, + getBoxHostName, + getNeoMount, + getNeoMount2, + getNeoMount3, + getNeoMount4, + getNeoMount5, + getMountPointNeo2, + getNandWrite, + getExtCheckHddUsb, + getImageBootNow, +) from enigma import getDesktop from enigma import eTimer from Screens.Screen import Screen @@ -24,23 +38,65 @@ from Components.Pixmap import Pixmap, MultiPixmap from Components.config import * from Components.ConfigList import ConfigListScreen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import fileExists, pathExists, createDir, resolveFilename, SCOPE_PLUGINS -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen +from Tools.Directories import ( + fileExists, + pathExists, + createDir, + resolveFilename, + SCOPE_PLUGINS, +) +from os import ( + system, + listdir, + mkdir, + chdir, + getcwd, + rename as os_rename, + remove as os_remove, + popen, +) from os.path import dirname, isdir, isdir as os_isdir import os import time -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' + +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" def getMmcBlockDevice(): - if getBoxHostName() == 'vuultimo' or getBoxHostName() == 'bm750' or getBoxHostName() == 'vuduo' or getBoxHostName() == 'vuuno' or getBoxHostName() == 'vusolo' or getBoxHostName() == 'vuduo': - mmcblockdevice = 'mtd1' - if fileExists('' + getNeoLocation() + 'ImageBoot/' + getImageNeoBoot() + '/etc/vtiversion.info') and getExtCheckHddUsb() == 'ext4': - if fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): - os.system('rm -r %sImageBoot/%s/boot/%s.vmlinux.gz' % - (getNeoLocation(), getImageNeoBoot(), getBoxHostName())) - elif getBoxHostName() == 'vusolo2' or getBoxHostName() == 'vusolose' or getBoxHostName() == 'vuduo2' or getBoxHostName() == 'vuzero': - mmcblockdevice = 'mtd2' + if ( + getBoxHostName() == "vuultimo" + or getBoxHostName() == "bm750" + or getBoxHostName() == "vuduo" + or getBoxHostName() == "vuuno" + or getBoxHostName() == "vusolo" + or getBoxHostName() == "vuduo" + ): + mmcblockdevice = "mtd1" + if ( + fileExists( + "" + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/etc/vtiversion.info" + ) + and getExtCheckHddUsb() == "ext4" + ): + if fileExists( + "%sImageBoot/%s/boot/%s.vmlinux.gz" + % (getNeoLocation(), getImageNeoBoot(), getBoxHostName()) + ): + os.system( + "rm -r %sImageBoot/%s/boot/%s.vmlinux.gz" + % (getNeoLocation(), getImageNeoBoot(), getBoxHostName()) + ) + elif ( + getBoxHostName() == "vusolo2" + or getBoxHostName() == "vusolose" + or getBoxHostName() == "vuduo2" + or getBoxHostName() == "vuzero" + ): + mmcblockdevice = "mtd2" return mmcblockdevice @@ -78,170 +134,386 @@ class StartImage(Screen): def __init__(self, session): Screen.__init__(self, session) self.list = [] - self['list'] = List(self.list) + self["list"] = List(self.list) self.select() - self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, - 'back': self.close}) - self['label1'] = Label(_('Start the chosen system now ?')) - self['label2'] = Label(_('Select OK to run the image.')) + self["actions"] = ActionMap(["WizardActions", "ColorActions"], { + "ok": self.KeyOk, "back": self.close}) + self["label1"] = Label(_("Start the chosen system now ?")) + self["label2"] = Label(_("Select OK to run the image.")) def select(self): self.list = [] - mypath = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' - if not fileExists(mypath + 'icons'): - mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png' + mypath = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" + if not fileExists(mypath + "icons"): + mypixmap = ( + "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png" + ) png = LoadPixmap(mypixmap) - res = (_('OK Start image...'), png, 0) + res = (_("OK Start image..."), png, 0) self.list.append(res) - self['list'].list = self.list + self["list"].list = self.list def KeyOk(self): - if getImageNeoBoot() != 'Flash': - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) + if getImageNeoBoot() != "Flash": + os.system( + "rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh" + % (getNeoLocation(), getImageNeoBoot()) + ) self.StartImageInNeoBoot() else: - os.system('rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh' % - (getNeoLocation(), getImageNeoBoot())) + os.system( + "rm -rf %sImageBoot/%s/usr/bin/enigma2_pre_start.sh" + % (getNeoLocation(), getImageNeoBoot()) + ) self.StartImageInNeoBoot() - if getNandWrite() == 'nandwrite': + if getNandWrite() == "nandwrite": os.system('echo "nandwrite" > /tmp/check_nandwrite') - # --------------------------------------------- getMountPointNeo2() - system('touch /tmp/.init_reboot') - # --------------------------------------------- + system("touch /tmp/.init_reboot") def StartImageInNeoBoot(self): - if getImageNeoBoot() != 'Flash': - if fileExists('%sImageBoot/%s/.control_ok' % (getNeoLocation(), getImageNeoBoot())): - system('touch /tmp/.control_ok ') + if getImageNeoBoot() != "Flash": + if fileExists( + "%sImageBoot/%s/.control_ok" % + (getNeoLocation(), getImageNeoBoot())): + system("touch /tmp/.control_ok ") else: - system('touch %sImageBoot/%s/.control_boot_new_image ' % - (getNeoLocation(), getImageNeoBoot())) + system( + "touch %sImageBoot/%s/.control_boot_new_image " + % (getNeoLocation(), getImageNeoBoot()) + ) - system('chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/*') + system("chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/*") - self.sel = self['list'].getCurrent() + self.sel = self["list"].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0: - if fileExists('/media/InternalFlash/etc/init.d/neobootmount.sh'): + if fileExists("/media/InternalFlash/etc/init.d/neobootmount.sh"): os.system( - 'rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;') - if not fileExists('/bin/busybox.nosuid'): + "rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;") + if not fileExists("/bin/busybox.nosuid"): os.system('ln -sf "busybox" "/bin/busybox.nosuid" ') -################# _____mips___########################## - # VUPLUS MIPS vu_dev_mtd1.sh if "vu" + getBoxVuModel() == getBoxHostName(): getMmcBlockDevice() - if not fileExists('%sImagesUpload/.kernel/%s.vmlinux.gz' % (getNeoLocation(), getBoxHostName())): + if not fileExists( + "%sImagesUpload/.kernel/%s.vmlinux.gz" + % (getNeoLocation(), getBoxHostName()) + ): self.myclose2( - _('Error - in the location %sImagesUpload/.kernel/ \nkernel file not found flash kernel vmlinux.gz ' % getNeoLocation())) + _( + "Error - in the location %sImagesUpload/.kernel/ \nkernel file not found flash kernel vmlinux.gz " % + getNeoLocation())) else: - if getImageNeoBoot() == 'Flash': - if fileExists('/.multinfo'): + if getImageNeoBoot() == "Flash": + if fileExists("/.multinfo"): cmd = "echo -e '\n%s '" % _( - '...............NeoBoot REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'flash_erase /dev/' + getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1 ; flash_eraseall /dev/' + \ - getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1' - if getNandWrite() == 'nandwrite': - cmd2 = 'nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/' + getBoxHostName() + '.vmlinux.gz > /dev/null 2>&1' + "...............NeoBoot REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = ( + "flash_erase /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1 ; flash_eraseall /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1") + if getNandWrite() == "nandwrite": + cmd2 = ( + "nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImagesUpload/.kernel/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) else: - cmd2 = '' + LinkNeoBoot + '/bin/nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/' + getBoxHostName() + '.vmlinux.gz > /dev/null 2>&1' - cmd3 = "echo -e '\n%s '" % _('Start image FLASH - kernel flash !\n' + getNandWrite() + '\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ ') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f' + cmd2 = ( + "" + + LinkNeoBoot + + "/bin/nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImagesUpload/.kernel/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) + cmd3 = "echo -e '\n%s '" % _( + "Start image FLASH - kernel flash !\n" + + getNandWrite() + + "\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ " + ) + cmd4 = "update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f" - elif not fileExists('/.multinfo'): + elif not fileExists("/.multinfo"): cmd = "echo -e '\n%s '" % _( - '...............NEOBOOT >> Reboot...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'ln -sfn /sbin/init.sysvinit /sbin/init' - cmd2 = 'sync' - cmd3 = "echo -e '\n%s '" % _('Start image flash !\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ ') - cmd4 = 'sleep 8; reboot -d -f' + "...............NEOBOOT >> Reboot...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = "ln -sfn /sbin/init.sysvinit /sbin/init" + cmd2 = "sync" + cmd3 = "echo -e '\n%s '" % _( + "Start image flash !\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ " + ) + cmd4 = "sleep 8; reboot -d -f" - elif getImageNeoBoot() != 'Flash': - if fileExists('/.multinfo') and getImageNeoBoot() == getImageBootNow(): + elif getImageNeoBoot() != "Flash": + if ( + fileExists("/.multinfo") + and getImageNeoBoot() == getImageBootNow() + ): cmd = "echo -e '\n%s '" % _( - '...............NEOBOOT > REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'ln -sfn /sbin/init.sysvinit /sbin/init' - cmd2 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true' - cmd3 = "echo -e '\n%s '" % _('Reboot system E2 now !\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will REBOOT in 5 seconds !____ ') - cmd4 = 'sync; sleep 8; reboot -d -f ' + "...............NEOBOOT > REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = "ln -sfn /sbin/init.sysvinit /sbin/init" + cmd2 = "update-alternatives --remove vmlinux vmlinux-`uname -r` || true" + cmd3 = "echo -e '\n%s '" % _( + "Reboot system E2 now !\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will REBOOT in 5 seconds !____ " + ) + cmd4 = "sync; sleep 8; reboot -d -f " - elif not fileExists('/.multinfo'): - if fileExists('' + getNeoLocation() + 'ImageBoot/' + getImageNeoBoot() + '/boot/' + getBoxHostName() + '.vmlinux.gz'): + elif not fileExists("/.multinfo"): + if fileExists( + "" + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz" + ): cmd = "echo -e '\n%s '" % _( - '...............NEOBOOT-REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'flash_erase /dev/' + getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1; flash_eraseall /dev/' + \ - getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1' - if getNandWrite() == 'nandwrite': - cmd2 = 'nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + 'ImageBoot/' + \ - getImageNeoBoot() + '/boot/' + getBoxHostName() + '.vmlinux.gz > /dev/null 2>&1' + "...............NEOBOOT-REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = ( + "flash_erase /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1; flash_eraseall /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1") + if getNandWrite() == "nandwrite": + cmd2 = ( + "nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) else: - cmd2 = '' + LinkNeoBoot + '/bin/nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + \ - 'ImageBoot/' + getImageNeoBoot() + '/boot/' + getBoxHostName() + \ - '.vmlinux.gz > /dev/null 2>&1' - cmd3 = "echo -e '\n%s '" % _('Changed kernel COMPLETE ! ' + getNandWrite() + '\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUtype() + ' ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ ') - cmd4 = 'ln -sfn /sbin/neoinitmipsvu /sbin/init; update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f' + cmd2 = ( + "" + + LinkNeoBoot + + "/bin/nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) + cmd3 = "echo -e '\n%s '" % _( + "Changed kernel COMPLETE ! " + + getNandWrite() + + "\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUtype() + + " " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ " + ) + cmd4 = "ln -sfn /sbin/neoinitmipsvu /sbin/init; update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f" - elif not fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + elif not fileExists( + "%sImageBoot/%s/boot/%s.vmlinux.gz" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n%s '" % _( - '...............NEOBOOT > REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'ln -sfn /sbin/neoinitmipsvu /sbin/init' - cmd2 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true' - cmd3 = "echo -e '\n%s '" % _('Start image without changing the kernel!\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ ') - cmd4 = 'sync; sleep 8; reboot -d -f' + "...............NEOBOOT > REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = "ln -sfn /sbin/neoinitmipsvu /sbin/init" + cmd2 = "update-alternatives --remove vmlinux vmlinux-`uname -r` || true" + cmd3 = "echo -e '\n%s '" % _( + "Start image without changing the kernel!\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ " + ) + cmd4 = "sync; sleep 8; reboot -d -f" - elif fileExists('/.multinfo'): - if not fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + elif fileExists("/.multinfo"): + if not fileExists( + "%sImageBoot/%s/boot/%s.vmlinux.gz" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n%s '" % _( - '...............NeoBoot REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'flash_erase /dev/' + getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1 ; flash_eraseall /dev/' + \ - getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1' - if getNandWrite() == 'nandwrite': - cmd2 = 'nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/' + getBoxHostName() + '.vmlinux.gz > /dev/null 2>&1' + "...............NeoBoot REBOOT...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = ( + "flash_erase /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1 ; flash_eraseall /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1") + if getNandWrite() == "nandwrite": + cmd2 = ( + "nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImagesUpload/.kernel/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) else: - cmd2 = '' + LinkNeoBoot + '/bin/nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + \ - 'ImagesUpload/.kernel/' + getBoxHostName() + '.vmlinux.gz > /dev/null 2>&1' - cmd3 = "echo -e '\n%s '" % _('Changed kernel COMPLETE ! ' + getNandWrite() + '\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ ') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f' + cmd2 = ( + "" + + LinkNeoBoot + + "/bin/nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImagesUpload/.kernel/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) + cmd3 = "echo -e '\n%s '" % _( + "Changed kernel COMPLETE ! " + + getNandWrite() + + "\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ " + ) + cmd4 = "update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f" - elif fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % (getNeoLocation(), getImageNeoBoot(), getBoxHostName())): + elif fileExists( + "%sImageBoot/%s/boot/%s.vmlinux.gz" + % ( + getNeoLocation(), + getImageNeoBoot(), + getBoxHostName(), + ) + ): cmd = "echo -e '\n%s '" % _( - '...............REBOOT now...............\nPlease wait, in a moment the decoder will be restarted...') - cmd1 = 'flash_erase /dev/' + getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1 ; flash_eraseall /dev/' + \ - getMmcBlockDevice() + ' 0 0 > /dev/null 2>&1 ' - if getNandWrite() == 'nandwrite': - cmd2 = 'nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + 'ImageBoot/' + \ - getImageNeoBoot() + '/boot/' + getBoxHostName() + '.vmlinux.gz > /dev/null 2>&1' + "...............REBOOT now...............\nPlease wait, in a moment the decoder will be restarted..." + ) + cmd1 = ( + "flash_erase /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1 ; flash_eraseall /dev/" + + getMmcBlockDevice() + + " 0 0 > /dev/null 2>&1 ") + if getNandWrite() == "nandwrite": + cmd2 = ( + "nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) else: - cmd2 = '' + LinkNeoBoot + '/bin/nandwrite -p /dev/' + getMmcBlockDevice() + ' ' + getNeoLocation() + \ - 'ImageBoot/' + getImageNeoBoot() + '/boot/' + getBoxHostName() + \ - '.vmlinux.gz > /dev/null 2>&1' - cmd3 = "echo -e '\n%s '" % _('Changed kernel COMPLETE ! ' + getNandWrite() + '\nSTB NAME: ' + getBoxHostName() + '\nNeoBoot location:' + getNeoLocation( - ) + '\nCPU: ' + getCPUSoC() + '\nImage boot: ' + getImageNeoBoot() + '\n____Your device will reboot in 5 seconds !____ ') - cmd4 = 'update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f' + cmd2 = ( + "" + + LinkNeoBoot + + "/bin/nandwrite -p /dev/" + + getMmcBlockDevice() + + " " + + getNeoLocation() + + "ImageBoot/" + + getImageNeoBoot() + + "/boot/" + + getBoxHostName() + + ".vmlinux.gz > /dev/null 2>&1" + ) + cmd3 = "echo -e '\n%s '" % _( + "Changed kernel COMPLETE ! " + + getNandWrite() + + "\nSTB NAME: " + + getBoxHostName() + + "\nNeoBoot location:" + + getNeoLocation() + + "\nCPU: " + + getCPUSoC() + + "\nImage boot: " + + getImageNeoBoot() + + "\n____Your device will reboot in 5 seconds !____ " + ) + cmd4 = "update-alternatives --remove vmlinux vmlinux-`uname -r` || true; sync; sleep 8; reboot -d -f" - self.session.open(Console, _('NeoBoot MIPS....'), [ - cmd, cmd1, cmd2, cmd3, cmd4]) + self.session.open( + Console, _("NeoBoot MIPS...."), [ + cmd, cmd1, cmd2, cmd3, cmd4]) self.close() else: - os.system('echo "Flash " >> ' + getNeoLocation() + - 'ImageBoot/.neonextboot') - self.messagebox = self.session.open(MessageBox, _( - 'It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) + os.system( + 'echo "Flash " >> ' + + getNeoLocation() + + "ImageBoot/.neonextboot") + self.messagebox = self.session.open( + MessageBox, + _("It looks like it that multiboot does not support this STB."), + MessageBox.TYPE_INFO, + 8, + ) self.close() def myclose2(self, message): diff --git a/NeoBoot/ubi_reader_arm/argparse_neo.py b/NeoBoot/ubi_reader_arm/argparse_neo.py index 74824dc..31c91b0 100644 --- a/NeoBoot/ubi_reader_arm/argparse_neo.py +++ b/NeoBoot/ubi_reader_arm/argparse_neo.py @@ -1,21 +1,22 @@ - -__version__ = '1.1' -__all__ = ['ArgumentParser', - 'ArgumentError', - 'ArgumentTypeError', - 'FileType', - 'HelpFormatter', - 'ArgumentDefaultsHelpFormatter', - 'RawDescriptionHelpFormatter', - 'RawTextHelpFormatter', - 'Namespace', - 'Action', - 'ONE_OR_MORE', - 'OPTIONAL', - 'PARSER', - 'REMAINDER', - 'SUPPRESS', - 'ZERO_OR_MORE'] +__version__ = "1.1" +__all__ = [ + "ArgumentParser", + "ArgumentError", + "ArgumentTypeError", + "FileType", + "HelpFormatter", + "ArgumentDefaultsHelpFormatter", + "RawDescriptionHelpFormatter", + "RawTextHelpFormatter", + "Namespace", + "Action", + "ONE_OR_MORE", + "OPTIONAL", + "PARSER", + "REMAINDER", + "SUPPRESS", + "ZERO_OR_MORE", +] import collections as _collections import copy as _copy import os as _os @@ -26,16 +27,16 @@ from gettext import gettext as _ def _callable(obj): - return hasattr(obj, '__call__') or hasattr(obj, '__bases__') + return hasattr(obj, "__call__") or hasattr(obj, "__bases__") -SUPPRESS = '==SUPPRESS==' -OPTIONAL = '?' -ZERO_OR_MORE = '*' -ONE_OR_MORE = '+' -PARSER = 'A...' -REMAINDER = '...' -_UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args' +SUPPRESS = "==SUPPRESS==" +OPTIONAL = "?" +ZERO_OR_MORE = "*" +ONE_OR_MORE = "+" +PARSER = "A..." +REMAINDER = "..." +_UNRECOGNIZED_ARGS_ATTR = "_unrecognized_args" class _AttributeHolder(object): @@ -47,9 +48,9 @@ class _AttributeHolder(object): arg_strings.append(repr(arg)) for name, value in self._get_kwargs(): - arg_strings.append('%s=%r' % (name, value)) + arg_strings.append("%s=%r" % (name, value)) - return '%s(%s)' % (type_name, ', '.join(arg_strings)) + return "%s(%s)" % (type_name, ", ".join(arg_strings)) def _get_kwargs(self): return sorted(self.__dict__.items()) @@ -66,10 +67,15 @@ def _ensure_value(namespace, name, value): class HelpFormatter(object): - def __init__(self, prog, indent_increment=2, max_help_position=24, width=None): + def __init__( + self, + prog, + indent_increment=2, + max_help_position=24, + width=None): if width is None: try: - width = int(_os.environ['COLUMNS']) + width = int(_os.environ["COLUMNS"]) except (KeyError, ValueError): width = 80 @@ -83,8 +89,8 @@ class HelpFormatter(object): self._action_max_length = 0 self._root_section = self._Section(self, None) self._current_section = self._root_section - self._whitespace_matcher = _re.compile('\\s+') - self._long_break_matcher = _re.compile('\\n\\n\\n+') + self._whitespace_matcher = _re.compile("\\s+") + self._long_break_matcher = _re.compile("\\n\\n\\n+") return def _indent(self): @@ -114,17 +120,14 @@ class HelpFormatter(object): if self.parent is not None: self.formatter._dedent() if not item_help: - return '' + return "" else: if self.heading is not SUPPRESS and self.heading is not None: current_indent = self.formatter._current_indent - heading = '%*s%s:\n' % (current_indent, '', self.heading) + heading = "%*s%s:\n" % (current_indent, "", self.heading) else: - heading = '' - return join(['\n', - heading, - item_help, - '\n']) + heading = "" + return join(["\n", heading, item_help, "\n"]) return def _add_item(self, func, args): @@ -147,10 +150,7 @@ class HelpFormatter(object): def add_usage(self, usage, actions, groups, prefix=None): if usage is not SUPPRESS: - args = (usage, - actions, - groups, - prefix) + args = (usage, actions, groups, prefix) self._add_item(self._format_usage, args) def add_argument(self, action): @@ -173,22 +173,23 @@ class HelpFormatter(object): def format_help(self): help = self._root_section.format_help() if help: - help = self._long_break_matcher.sub('\n\n', help) - help = help.strip('\n') + '\n' + help = self._long_break_matcher.sub("\n\n", help) + help = help.strip("\n") + "\n" return help def _join_parts(self, part_strings): - return ''.join([part for part in part_strings if part and part is not SUPPRESS]) + return "".join( + [part for part in part_strings if part and part is not SUPPRESS]) def _format_usage(self, usage, actions, groups, prefix): if prefix is None: - prefix = _('usage: ') + prefix = _("usage: ") if usage is not None: usage = usage % dict(prog=self._prog) elif usage is None and not actions: - usage = '%(prog)s' % dict(prog=self._prog) + usage = "%(prog)s" % dict(prog=self._prog) elif usage is None: - prog = '%(prog)s' % dict(prog=self._prog) + prog = "%(prog)s" % dict(prog=self._prog) optionals = [] positionals = [] for action in actions: @@ -199,10 +200,10 @@ class HelpFormatter(object): format = self._format_actions_usage action_usage = format(optionals + positionals, groups) - usage = ' '.join([s for s in [prog, action_usage] if s]) + usage = " ".join([s for s in [prog, action_usage] if s]) text_width = self._width - self._current_indent if len(prefix) + len(usage) > text_width: - part_regexp = '\\(.*?\\)+|\\[.*?\\]+|\\S+' + part_regexp = "\\(.*?\\)+|\\[.*?\\]+|\\S+" opt_usage = format(optionals, groups) pos_usage = format(positionals, groups) opt_parts = _re.findall(part_regexp, opt_usage) @@ -217,20 +218,20 @@ class HelpFormatter(object): line_len = len(indent) - 1 for part in parts: if line_len + 1 + len(part) > text_width: - lines.append(indent + ' '.join(line)) + lines.append(indent + " ".join(line)) line = [] line_len = len(indent) - 1 line.append(part) line_len += len(part) + 1 if line: - lines.append(indent + ' '.join(line)) + lines.append(indent + " ".join(line)) if prefix is not None: lines[0] = lines[0][len(indent):] return lines if len(prefix) + len(prog) <= 0.75 * text_width: - indent = ' ' * (len(prefix) + len(prog) + 1) + indent = " " * (len(prefix) + len(prog) + 1) if opt_parts: lines = get_lines([prog] + opt_parts, indent, prefix) lines.extend(get_lines(pos_parts, indent)) @@ -239,7 +240,7 @@ class HelpFormatter(object): else: lines = [prog] else: - indent = ' ' * len(prefix) + indent = " " * len(prefix) parts = opt_parts + pos_parts lines = get_lines(parts, indent) if len(lines) > 1: @@ -247,8 +248,8 @@ class HelpFormatter(object): lines.extend(get_lines(opt_parts, indent)) lines.extend(get_lines(pos_parts, indent)) lines = [prog] + lines - usage = '\n'.join(lines) - return '%s%s\n\n' % (prefix, usage) + usage = "\n".join(lines) + return "%s%s\n\n" % (prefix, usage) def _format_actions_usage(self, actions, groups): group_actions = set() @@ -266,95 +267,93 @@ class HelpFormatter(object): if not group.required: if start in inserts: - inserts[start] += ' [' + inserts[start] += " [" else: - inserts[start] = '[' - inserts[end] = ']' + inserts[start] = "[" + inserts[end] = "]" else: if start in inserts: - inserts[start] += ' (' + inserts[start] += " (" else: - inserts[start] = '(' - inserts[end] = ')' + inserts[start] = "(" + inserts[end] = ")" for i in range(start + 1, end): - inserts[i] = '|' + inserts[i] = "|" parts = [] for i, action in enumerate(actions): if action.help is SUPPRESS: parts.append(None) - if inserts.get(i) == '|': + if inserts.get(i) == "|": inserts.pop(i) - elif inserts.get(i + 1) == '|': + elif inserts.get(i + 1) == "|": inserts.pop(i + 1) elif not action.option_strings: part = self._format_args(action, action.dest) if action in group_actions: - if part[0] == '[' and part[-1] == ']': + if part[0] == "[" and part[-1] == "]": part = part[1:-1] parts.append(part) else: option_string = action.option_strings[0] if action.nargs == 0: - part = '%s' % option_string + part = "%s" % option_string else: default = action.dest.upper() args_string = self._format_args(action, default) - part = '%s %s' % (option_string, args_string) + part = "%s %s" % (option_string, args_string) if not action.required and action not in group_actions: - part = '[%s]' % part + part = "[%s]" % part parts.append(part) for i in sorted(inserts, reverse=True): parts[i:i] = [inserts[i]] - text = ' '.join([item for item in parts if item is not None]) - open = '[\\[(]' - close = '[\\])]' - text = _re.sub('(%s) ' % open, '\\1', text) - text = _re.sub(' (%s)' % close, '\\1', text) - text = _re.sub('%s *%s' % (open, close), '', text) - text = _re.sub('\\(([^|]*)\\)', '\\1', text) + text = " ".join([item for item in parts if item is not None]) + open = "[\\[(]" + close = "[\\])]" + text = _re.sub("(%s) " % open, "\\1", text) + text = _re.sub(" (%s)" % close, "\\1", text) + text = _re.sub("%s *%s" % (open, close), "", text) + text = _re.sub("\\(([^|]*)\\)", "\\1", text) text = text.strip() return text def _format_text(self, text): - if '%(prog)' in text: + if "%(prog)" in text: text = text % dict(prog=self._prog) text_width = self._width - self._current_indent - indent = ' ' * self._current_indent - return self._fill_text(text, text_width, indent) + '\n\n' + indent = " " * self._current_indent + return self._fill_text(text, text_width, indent) + "\n\n" def _format_action(self, action): - help_position = min(self._action_max_length + - 2, self._max_help_position) + help_position = min( + self._action_max_length + 2, + self._max_help_position) help_width = self._width - help_position action_width = help_position - self._current_indent - 2 action_header = self._format_action_invocation(action) if not action.help: - tup = (self._current_indent, '', action_header) - action_header = '%*s%s\n' % tup + tup = (self._current_indent, "", action_header) + action_header = "%*s%s\n" % tup elif len(action_header) <= action_width: - tup = (self._current_indent, - '', - action_width, - action_header) - action_header = '%*s%-*s ' % tup + tup = (self._current_indent, "", action_width, action_header) + action_header = "%*s%-*s " % tup indent_first = 0 else: - tup = (self._current_indent, '', action_header) - action_header = '%*s%s\n' % tup + tup = (self._current_indent, "", action_header) + action_header = "%*s%s\n" % tup indent_first = help_position parts = [action_header] if action.help: help_text = self._expand_help(action) help_lines = self._split_lines(help_text, help_width) - parts.append('%*s%s\n' % (indent_first, '', help_lines[0])) + parts.append("%*s%s\n" % (indent_first, "", help_lines[0])) for line in help_lines[1:]: - parts.append('%*s%s\n' % (help_position, '', line)) + parts.append("%*s%s\n" % (help_position, "", line)) - elif not action_header.endswith('\n'): - parts.append('\n') + elif not action_header.endswith("\n"): + parts.append("\n") for subaction in self._iter_indented_subactions(action): parts.append(self._format_action(subaction)) @@ -362,7 +361,7 @@ class HelpFormatter(object): def _format_action_invocation(self, action): if not action.option_strings: - metavar, = self._metavar_formatter(action, action.dest)(1) + (metavar,) = self._metavar_formatter(action, action.dest)(1) return metavar else: parts = [] @@ -372,16 +371,16 @@ class HelpFormatter(object): default = action.dest.upper() args_string = self._format_args(action, default) for option_string in action.option_strings: - parts.append('%s %s' % (option_string, args_string)) + parts.append("%s %s" % (option_string, args_string)) - return ', '.join(parts) + return ", ".join(parts) def _metavar_formatter(self, action, default_metavar): if action.metavar is not None: result = action.metavar elif action.choices is not None: choice_strs = [str(choice) for choice in action.choices] - result = '{%s}' % ','.join(choice_strs) + result = "{%s}" % ",".join(choice_strs) else: result = default_metavar @@ -396,20 +395,20 @@ class HelpFormatter(object): def _format_args(self, action, default_metavar): get_metavar = self._metavar_formatter(action, default_metavar) if action.nargs is None: - result = '%s' % get_metavar(1) + result = "%s" % get_metavar(1) elif action.nargs == OPTIONAL: - result = '[%s]' % get_metavar(1) + result = "[%s]" % get_metavar(1) elif action.nargs == ZERO_OR_MORE: - result = '[%s [%s ...]]' % get_metavar(2) + result = "[%s [%s ...]]" % get_metavar(2) elif action.nargs == ONE_OR_MORE: - result = '%s [%s ...]' % get_metavar(2) + result = "%s [%s ...]" % get_metavar(2) elif action.nargs == REMAINDER: - result = '...' + result = "..." elif action.nargs == PARSER: - result = '%s ...' % get_metavar(1) + result = "%s ..." % get_metavar(1) else: - formats = ['%s' for _ in range(action.nargs)] - result = ' '.join(formats) % get_metavar(action.nargs) + formats = ["%s" for _ in range(action.nargs)] + result = " ".join(formats) % get_metavar(action.nargs) return result def _expand_help(self, action): @@ -419,12 +418,12 @@ class HelpFormatter(object): del params[name] for name in list(params): - if hasattr(params[name], '__name__'): + if hasattr(params[name], "__name__"): params[name] = params[name].__name__ - if params.get('choices') is not None: - choices_str = ', '.join([str(c) for c in params['choices']]) - params['choices'] = choices_str + if params.get("choices") is not None: + choices_str = ", ".join([str(c) for c in params["choices"]]) + params["choices"] = choices_str return self._get_help_string(action) % params def _iter_indented_subactions(self, action): @@ -440,12 +439,14 @@ class HelpFormatter(object): self._dedent() def _split_lines(self, text, width): - text = self._whitespace_matcher.sub(' ', text).strip() + text = self._whitespace_matcher.sub(" ", text).strip() return _textwrap.wrap(text, width) def _fill_text(self, text, width, indent): - text = self._whitespace_matcher.sub(' ', text).strip() - return _textwrap.fill(text, width, initial_indent=indent, subsequent_indent=indent) + text = self._whitespace_matcher.sub(" ", text).strip() + return _textwrap.fill( + text, width, initial_indent=indent, subsequent_indent=indent + ) def _get_help_string(self, action): return action.help @@ -454,7 +455,7 @@ class HelpFormatter(object): class RawDescriptionHelpFormatter(HelpFormatter): def _fill_text(self, text, width, indent): - return ''.join([indent + line for line in text.splitlines(True)]) + return "".join([indent + line for line in text.splitlines(True)]) class RawTextHelpFormatter(RawDescriptionHelpFormatter): @@ -467,11 +468,11 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter): def _get_help_string(self, action): help = action.help - if '%(default)' not in action.help: + if "%(default)" not in action.help: if action.default is not SUPPRESS: defaulting_nargs = [OPTIONAL, ZERO_OR_MORE] if action.option_strings or action.nargs in defaulting_nargs: - help += ' (default: %(default)s)' + help += " (default: %(default)s)" return help @@ -479,7 +480,7 @@ def _get_action_name(argument): if argument is None: return elif argument.option_strings: - return '/'.join(argument.option_strings) + return "/".join(argument.option_strings) elif argument.metavar not in (None, SUPPRESS): return argument.metavar elif argument.dest not in (None, SUPPRESS): @@ -497,10 +498,12 @@ class ArgumentError(Exception): def __str__(self): if self.argument_name is None: - format = '%(message)s' + format = "%(message)s" else: - format = 'argument %(argument_name)s: %(message)s' - return format % dict(message=self.message, argument_name=self.argument_name) + format = "argument %(argument_name)s: %(message)s" + return format % dict( + message=self.message, + argument_name=self.argument_name) class ArgumentTypeError(Exception): @@ -509,7 +512,19 @@ class ArgumentTypeError(Exception): class Action(_AttributeHolder): - def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None): + def __init__( + self, + option_strings, + dest, + nargs=None, + const=None, + default=None, + type=None, + choices=None, + required=False, + help=None, + metavar=None, + ): self.option_strings = option_strings self.dest = dest self.nargs = nargs @@ -522,31 +537,56 @@ class Action(_AttributeHolder): self.metavar = metavar def _get_kwargs(self): - names = ['option_strings', - 'dest', - 'nargs', - 'const', - 'default', - 'type', - 'choices', - 'help', - 'metavar'] + names = [ + "option_strings", + "dest", + "nargs", + "const", + "default", + "type", + "choices", + "help", + "metavar", + ] return [(name, getattr(self, name)) for name in names] def __call__(self, parser, namespace, values, option_string=None): - raise NotImplementedError(_('.__call__() not defined')) + raise NotImplementedError(_(".__call__() not defined")) class _StoreAction(Action): - def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None): + def __init__( + self, + option_strings, + dest, + nargs=None, + const=None, + default=None, + type=None, + choices=None, + required=False, + help=None, + metavar=None, + ): if nargs == 0: raise ValueError( - 'nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate') + "nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate" + ) if const is not None and nargs != OPTIONAL: - raise ValueError('nargs must be %r to supply const' % OPTIONAL) - super(_StoreAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, - default=default, type=type, choices=choices, required=required, help=help, metavar=metavar) + raise ValueError("nargs must be %r to supply const" % OPTIONAL) + super(_StoreAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=nargs, + const=const, + default=default, + type=type, + choices=choices, + required=required, + help=help, + metavar=metavar, + ) return def __call__(self, parser, namespace, values, option_string=None): @@ -555,9 +595,25 @@ class _StoreAction(Action): class _StoreConstAction(Action): - def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None): - super(_StoreConstAction, self).__init__(option_strings=option_strings, - dest=dest, nargs=0, const=const, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + const, + default=None, + required=False, + help=None, + metavar=None, + ): + super(_StoreConstAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=0, + const=const, + default=default, + required=required, + help=help, + ) def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, self.const) @@ -565,28 +621,75 @@ class _StoreConstAction(Action): class _StoreTrueAction(_StoreConstAction): - def __init__(self, option_strings, dest, default=False, required=False, help=None): - super(_StoreTrueAction, self).__init__(option_strings=option_strings, - dest=dest, const=True, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + default=False, + required=False, + help=None): + super(_StoreTrueAction, self).__init__( + option_strings=option_strings, + dest=dest, + const=True, + default=default, + required=required, + help=help, + ) class _StoreFalseAction(_StoreConstAction): - def __init__(self, option_strings, dest, default=True, required=False, help=None): - super(_StoreFalseAction, self).__init__(option_strings=option_strings, - dest=dest, const=False, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + default=True, + required=False, + help=None): + super(_StoreFalseAction, self).__init__( + option_strings=option_strings, + dest=dest, + const=False, + default=default, + required=required, + help=help, + ) class _AppendAction(Action): - def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None): + def __init__( + self, + option_strings, + dest, + nargs=None, + const=None, + default=None, + type=None, + choices=None, + required=False, + help=None, + metavar=None, + ): if nargs == 0: raise ValueError( - 'nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate') + "nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate" + ) if const is not None and nargs != OPTIONAL: - raise ValueError('nargs must be %r to supply const' % OPTIONAL) - super(_AppendAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, - default=default, type=type, choices=choices, required=required, help=help, metavar=metavar) + raise ValueError("nargs must be %r to supply const" % OPTIONAL) + super(_AppendAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=nargs, + const=const, + default=default, + type=type, + choices=choices, + required=required, + help=help, + metavar=metavar, + ) return def __call__(self, parser, namespace, values, option_string=None): @@ -597,9 +700,26 @@ class _AppendAction(Action): class _AppendConstAction(Action): - def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None): - super(_AppendConstAction, self).__init__(option_strings=option_strings, dest=dest, - nargs=0, const=const, default=default, required=required, help=help, metavar=metavar) + def __init__( + self, + option_strings, + dest, + const, + default=None, + required=False, + help=None, + metavar=None, + ): + super(_AppendConstAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=0, + const=const, + default=default, + required=required, + help=help, + metavar=metavar, + ) def __call__(self, parser, namespace, values, option_string=None): items = _copy.copy(_ensure_value(namespace, self.dest, [])) @@ -609,9 +729,21 @@ class _AppendConstAction(Action): class _CountAction(Action): - def __init__(self, option_strings, dest, default=None, required=False, help=None): - super(_CountAction, self).__init__(option_strings=option_strings, - dest=dest, nargs=0, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + default=None, + required=False, + help=None): + super(_CountAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=0, + default=default, + required=required, + help=help, + ) def __call__(self, parser, namespace, values, option_string=None): new_count = _ensure_value(namespace, self.dest, 0) + 1 @@ -620,9 +752,19 @@ class _CountAction(Action): class _HelpAction(Action): - def __init__(self, option_strings, dest=SUPPRESS, default=SUPPRESS, help=None): - super(_HelpAction, self).__init__(option_strings=option_strings, - dest=dest, default=default, nargs=0, help=help) + def __init__( + self, + option_strings, + dest=SUPPRESS, + default=SUPPRESS, + help=None): + super(_HelpAction, self).__init__( + option_strings=option_strings, + dest=dest, + default=default, + nargs=0, + help=help, + ) def __call__(self, parser, namespace, values, option_string=None): parser.print_help() @@ -631,9 +773,21 @@ class _HelpAction(Action): class _VersionAction(Action): - def __init__(self, option_strings, version=None, dest=SUPPRESS, default=SUPPRESS, help="show program's version number and exit"): - super(_VersionAction, self).__init__(option_strings=option_strings, - dest=dest, default=default, nargs=0, help=help) + def __init__( + self, + option_strings, + version=None, + dest=SUPPRESS, + default=SUPPRESS, + help="show program's version number and exit", + ): + super(_VersionAction, self).__init__( + option_strings=option_strings, + dest=dest, + default=default, + nargs=0, + help=help, + ) self.version = version def __call__(self, parser, namespace, values, option_string=None): @@ -654,19 +808,32 @@ class _SubParsersAction(Action): sup = super(_SubParsersAction._ChoicesPseudoAction, self) sup.__init__(option_strings=[], dest=name, help=help) - def __init__(self, option_strings, prog, parser_class, dest=SUPPRESS, help=None, metavar=None): + def __init__( + self, + option_strings, + prog, + parser_class, + dest=SUPPRESS, + help=None, + metavar=None): self._prog_prefix = prog self._parser_class = parser_class self._name_parser_map = _collections.OrderedDict() self._choices_actions = [] - super(_SubParsersAction, self).__init__(option_strings=option_strings, dest=dest, - nargs=PARSER, choices=self._name_parser_map, help=help, metavar=metavar) + super(_SubParsersAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=PARSER, + choices=self._name_parser_map, + help=help, + metavar=metavar, + ) def add_parser(self, name, **kwargs): - if kwargs.get('prog') is None: - kwargs['prog'] = '%s %s' % (self._prog_prefix, name) - if 'help' in kwargs: - help = kwargs.pop('help') + if kwargs.get("prog") is None: + kwargs["prog"] = "%s %s" % (self._prog_prefix, name) + if "help" in kwargs: + help = kwargs.pop("help") choice_action = self._ChoicesPseudoAction(name, help) self._choices_actions.append(choice_action) parser = self._parser_class(**kwargs) @@ -684,8 +851,8 @@ class _SubParsersAction(Action): try: parser = self._name_parser_map[parser_name] except KeyError: - tup = (parser_name, ', '.join(self._name_parser_map)) - msg = _('unknown parser %r (choices: %s)') % tup + tup = (parser_name, ", ".join(self._name_parser_map)) + msg = _("unknown parser %r (choices: %s)") % tup raise ArgumentError(self, msg) namespace, arg_strings = parser.parse_known_args( @@ -697,15 +864,15 @@ class _SubParsersAction(Action): class FileType(object): - def __init__(self, mode='r', bufsize=-1): + def __init__(self, mode="r", bufsize=-1): self._mode = mode self._bufsize = bufsize def __call__(self, string): - if string == '-': - if 'r' in self._mode: + if string == "-": + if "r" in self._mode: return _sys.stdin - if 'w' in self._mode: + if "w" in self._mode: return _sys.stdout msg = _('argument "-" with mode %r') % self._mode raise ValueError(msg) @@ -717,8 +884,8 @@ class FileType(object): def __repr__(self): args = (self._mode, self._bufsize) - args_str = ', '.join((repr(arg) for arg in args if arg != -1)) - return '%s(%s)' % (type(self).__name__, args_str) + args_str = ", ".join((repr(arg) for arg in args if arg != -1)) + return "%s(%s)" % (type(self).__name__, args_str) class Namespace(_AttributeHolder): @@ -741,31 +908,36 @@ class Namespace(_AttributeHolder): class _ActionsContainer(object): - def __init__(self, description, prefix_chars, argument_default, conflict_handler): + def __init__( + self, + description, + prefix_chars, + argument_default, + conflict_handler): super(_ActionsContainer, self).__init__() self.description = description self.argument_default = argument_default self.prefix_chars = prefix_chars self.conflict_handler = conflict_handler self._registries = {} - self.register('action', None, _StoreAction) - self.register('action', 'store', _StoreAction) - self.register('action', 'store_const', _StoreConstAction) - self.register('action', 'store_true', _StoreTrueAction) - self.register('action', 'store_false', _StoreFalseAction) - self.register('action', 'append', _AppendAction) - self.register('action', 'append_const', _AppendConstAction) - self.register('action', 'count', _CountAction) - self.register('action', 'help', _HelpAction) - self.register('action', 'version', _VersionAction) - self.register('action', 'parsers', _SubParsersAction) + self.register("action", None, _StoreAction) + self.register("action", "store", _StoreAction) + self.register("action", "store_const", _StoreConstAction) + self.register("action", "store_true", _StoreTrueAction) + self.register("action", "store_false", _StoreFalseAction) + self.register("action", "append", _AppendAction) + self.register("action", "append_const", _AppendConstAction) + self.register("action", "count", _CountAction) + self.register("action", "help", _HelpAction) + self.register("action", "version", _VersionAction) + self.register("action", "parsers", _SubParsersAction) self._get_handler() self._actions = [] self._option_string_actions = {} self._action_groups = [] self._mutually_exclusive_groups = [] self._defaults = {} - self._negative_number_matcher = _re.compile('^-\\d+$|^-\\d*\\.\\d+$') + self._negative_number_matcher = _re.compile("^-\\d+$|^-\\d*\\.\\d+$") self._has_negative_number_optionals = [] return @@ -792,30 +964,30 @@ class _ActionsContainer(object): def add_argument(self, *args, **kwargs): chars = self.prefix_chars if not args or len(args) == 1 and args[0][0] not in chars: - if args and 'dest' in kwargs: - raise ValueError('dest supplied twice for positional argument') + if args and "dest" in kwargs: + raise ValueError("dest supplied twice for positional argument") kwargs = self._get_positional_kwargs(*args, **kwargs) else: kwargs = self._get_optional_kwargs(*args, **kwargs) - if 'default' not in kwargs: - dest = kwargs['dest'] + if "default" not in kwargs: + dest = kwargs["dest"] if dest in self._defaults: - kwargs['default'] = self._defaults[dest] + kwargs["default"] = self._defaults[dest] elif self.argument_default is not None: - kwargs['default'] = self.argument_default + kwargs["default"] = self.argument_default action_class = self._pop_action_class(kwargs) if not _callable(action_class): raise ValueError('unknown action "%s"' % (action_class,)) action = action_class(**kwargs) - type_func = self._registry_get('type', action.type, action.type) + type_func = self._registry_get("type", action.type, action.type) if not _callable(type_func): - raise ValueError('%r is not callable' % (type_func,)) - if hasattr(self, '_get_formatter'): + raise ValueError("%r is not callable" % (type_func,)) + if hasattr(self, "_get_formatter"): try: self._get_formatter()._format_args(action, None) except TypeError: raise ValueError( - 'length of metavar tuple does not match nargs') + "length of metavar tuple does not match nargs") return self._add_action(action) @@ -850,7 +1022,7 @@ class _ActionsContainer(object): title_group_map = {} for group in self._action_groups: if group.title in title_group_map: - msg = _('cannot merge actions - two groups are named %r') + msg = _("cannot merge actions - two groups are named %r") raise ValueError(msg % group.title) title_group_map[group.title] = group @@ -858,7 +1030,10 @@ class _ActionsContainer(object): for group in container._action_groups: if group.title not in title_group_map: title_group_map[group.title] = self.add_argument_group( - title=group.title, description=group.description, conflict_handler=group.conflict_handler) + title=group.title, + description=group.description, + conflict_handler=group.conflict_handler, + ) for action in group._group_actions: group_map[action] = title_group_map[group.title] @@ -872,13 +1047,13 @@ class _ActionsContainer(object): group_map.get(action, self)._add_action(action) def _get_positional_kwargs(self, dest, **kwargs): - if 'required' in kwargs: + if "required" in kwargs: msg = _("'required' is an invalid argument for positionals") raise TypeError(msg) - if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]: - kwargs['required'] = True - if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs: - kwargs['required'] = True + if kwargs.get("nargs") not in [OPTIONAL, ZERO_OR_MORE]: + kwargs["required"] = True + if kwargs.get("nargs") == ZERO_OR_MORE and "default" not in kwargs: + kwargs["required"] = True return dict(kwargs, dest=dest, option_strings=[]) def _get_optional_kwargs(self, *args, **kwargs): @@ -886,7 +1061,7 @@ class _ActionsContainer(object): long_option_strings = [] for option_string in args: if option_string[0] not in self.prefix_chars: - msg = _('invalid option string %r: must start with a character %r') + msg = _("invalid option string %r: must start with a character %r") tup = (option_string, self.prefix_chars) raise ValueError(msg % tup) option_strings.append(option_string) @@ -895,7 +1070,7 @@ class _ActionsContainer(object): if option_string[1] in self.prefix_chars: long_option_strings.append(option_string) - dest = kwargs.pop('dest', None) + dest = kwargs.pop("dest", None) if dest is None: if long_option_strings: dest_option_string = long_option_strings[0] @@ -903,21 +1078,21 @@ class _ActionsContainer(object): dest_option_string = option_strings[0] dest = dest_option_string.lstrip(self.prefix_chars) if not dest: - msg = _('dest= is required for options like %r') + msg = _("dest= is required for options like %r") raise ValueError(msg % option_string) - dest = dest.replace('-', '_') + dest = dest.replace("-", "_") return dict(kwargs, dest=dest, option_strings=option_strings) def _pop_action_class(self, kwargs, default=None): - action = kwargs.pop('action', default) - return self._registry_get('action', action, action) + action = kwargs.pop("action", default) + return self._registry_get("action", action, action) def _get_handler(self): - handler_func_name = '_handle_conflict_%s' % self.conflict_handler + handler_func_name = "_handle_conflict_%s" % self.conflict_handler try: return getattr(self, handler_func_name) except AttributeError: - msg = _('invalid conflict_resolution value: %r') + msg = _("invalid conflict_resolution value: %r") raise ValueError(msg % self.conflict_handler) def _check_conflict(self, action): @@ -932,9 +1107,10 @@ class _ActionsContainer(object): conflict_handler(action, confl_optionals) def _handle_conflict_error(self, action, conflicting_actions): - message = _('conflicting option string(s): %s') - conflict_string = ', '.join( - [option_string for option_string, action in conflicting_actions]) + message = _("conflicting option string(s): %s") + conflict_string = ", ".join( + [option_string for option_string, action in conflicting_actions] + ) raise ArgumentError(action, message % conflict_string) def _handle_conflict_resolve(self, action, conflicting_actions): @@ -951,9 +1127,9 @@ class _ArgumentGroup(_ActionsContainer): def __init__(self, container, title=None, description=None, **kwargs): update = kwargs.setdefault - update('conflict_handler', container.conflict_handler) - update('prefix_chars', container.prefix_chars) - update('argument_default', container.argument_default) + update("conflict_handler", container.conflict_handler) + update("prefix_chars", container.prefix_chars) + update("argument_default", container.argument_default) super_init = super(_ArgumentGroup, self).__init__ super_init(description=description, **kwargs) self.title = title @@ -984,7 +1160,7 @@ class _MutuallyExclusiveGroup(_ArgumentGroup): def _add_action(self, action): if action.required: - msg = _('mutually exclusive arguments must be optional') + msg = _("mutually exclusive arguments must be optional") raise ValueError(msg) action = self._container._add_action(action) self._group_actions.append(action) @@ -997,14 +1173,35 @@ class _MutuallyExclusiveGroup(_ArgumentGroup): class ArgumentParser(_AttributeHolder, _ActionsContainer): - def __init__(self, prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True): + def __init__( + self, + prog=None, + usage=None, + description=None, + epilog=None, + version=None, + parents=[], + formatter_class=HelpFormatter, + prefix_chars="-", + fromfile_prefix_chars=None, + argument_default=None, + conflict_handler="error", + add_help=True, + ): if version is not None: import warnings + warnings.warn( - 'The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', DeprecationWarning) + 'The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', + DeprecationWarning, + ) superinit = super(ArgumentParser, self).__init__ - superinit(description=description, prefix_chars=prefix_chars, - argument_default=argument_default, conflict_handler=conflict_handler) + superinit( + description=description, + prefix_chars=prefix_chars, + argument_default=argument_default, + conflict_handler=conflict_handler, + ) if prog is None: prog = _os.path.basename(_sys.argv[0]) self.prog = prog @@ -1015,21 +1212,32 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): self.fromfile_prefix_chars = fromfile_prefix_chars self.add_help = add_help add_group = self.add_argument_group - self._positionals = add_group(_('positional arguments')) - self._optionals = add_group(_('optional arguments')) + self._positionals = add_group(_("positional arguments")) + self._optionals = add_group(_("optional arguments")) self._subparsers = None def identity(string): return string - self.register('type', None, identity) - default_prefix = '-' if '-' in prefix_chars else prefix_chars[0] + self.register("type", None, identity) + default_prefix = "-" if "-" in prefix_chars else prefix_chars[0] if self.add_help: - self.add_argument(default_prefix + 'h', default_prefix * 2 + 'help', - action='help', default=SUPPRESS, help=_('show this help message and exit')) + self.add_argument( + default_prefix + "h", + default_prefix * 2 + "help", + action="help", + default=SUPPRESS, + help=_("show this help message and exit"), + ) if self.version: - self.add_argument(default_prefix + 'v', default_prefix * 2 + 'version', action='version', - default=SUPPRESS, version=self.version, help=_("show program's version number and exit")) + self.add_argument( + default_prefix + "v", + default_prefix * 2 + "version", + action="version", + default=SUPPRESS, + version=self.version, + help=_("show program's version number and exit"), + ) for parent in parents: self._add_container_actions(parent) try: @@ -1042,32 +1250,34 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): return def _get_kwargs(self): - names = ['prog', - 'usage', - 'description', - 'version', - 'formatter_class', - 'conflict_handler', - 'add_help'] + names = [ + "prog", + "usage", + "description", + "version", + "formatter_class", + "conflict_handler", + "add_help", + ] return [(name, getattr(self, name)) for name in names] def add_subparsers(self, **kwargs): if self._subparsers is not None: - self.error(_('cannot have multiple subparser arguments')) - kwargs.setdefault('parser_class', type(self)) - if 'title' in kwargs or 'description' in kwargs: - title = _(kwargs.pop('title', 'subcommands')) - description = _(kwargs.pop('description', None)) + self.error(_("cannot have multiple subparser arguments")) + kwargs.setdefault("parser_class", type(self)) + if "title" in kwargs or "description" in kwargs: + title = _(kwargs.pop("title", "subcommands")) + description = _(kwargs.pop("description", None)) self._subparsers = self.add_argument_group(title, description) else: self._subparsers = self._positionals - if kwargs.get('prog') is None: + if kwargs.get("prog") is None: formatter = self._get_formatter() positionals = self._get_positional_actions() groups = self._mutually_exclusive_groups - formatter.add_usage(self.usage, positionals, groups, '') - kwargs['prog'] = formatter.format_help().strip() - parsers_class = self._pop_action_class(kwargs, 'parsers') + formatter.add_usage(self.usage, positionals, groups, "") + kwargs["prog"] = formatter.format_help().strip() + parsers_class = self._pop_action_class(kwargs, "parsers") action = parsers_class(option_strings=[], **kwargs) self._subparsers._add_action(action) return action @@ -1088,8 +1298,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, args=None, namespace=None): args, argv = self.parse_known_args(args, namespace) if argv: - msg = _('unrecognized arguments: %s') - self.error(msg % ' '.join(argv)) + msg = _("unrecognized arguments: %s") + self.error(msg % " ".join(argv)) return args def parse_known_args(self, args=None, namespace=None): @@ -1137,21 +1347,21 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): arg_string_pattern_parts = [] arg_strings_iter = iter(arg_strings) for i, arg_string in enumerate(arg_strings_iter): - if arg_string == '--': - arg_string_pattern_parts.append('-') + if arg_string == "--": + arg_string_pattern_parts.append("-") for arg_string in arg_strings_iter: - arg_string_pattern_parts.append('A') + arg_string_pattern_parts.append("A") else: option_tuple = self._parse_optional(arg_string) if option_tuple is None: - pattern = 'A' + pattern = "A" else: option_string_indices[i] = option_tuple - pattern = 'O' + pattern = "O" arg_string_pattern_parts.append(pattern) - arg_strings_pattern = ''.join(arg_string_pattern_parts) + arg_strings_pattern = "".join(arg_string_pattern_parts) seen_actions = set() seen_non_default_actions = set() @@ -1162,7 +1372,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): seen_non_default_actions.add(action) for conflict_action in action_conflicts.get(action, []): if conflict_action in seen_non_default_actions: - msg = _('not allowed with argument %s') + msg = _("not allowed with argument %s") action_name = _get_action_name(conflict_action) raise ArgumentError(action, msg % action_name) @@ -1179,7 +1389,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): extras.append(arg_strings[start_index]) return start_index + 1 if explicit_arg is not None: - arg_count = match_argument(action, 'A') + arg_count = match_argument(action, "A") chars = self.prefix_chars if arg_count == 0 and option_string[1] not in chars: action_tuples.append((action, [], option_string)) @@ -1191,7 +1401,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): action = optionals_map[option_string] explicit_arg = new_explicit_arg else: - msg = _('ignored explicit argument %r') + msg = _("ignored explicit argument %r") raise ArgumentError(action, msg % explicit_arg) elif arg_count == 1: stop = start_index + 1 @@ -1199,7 +1409,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): action_tuples.append((action, args, option_string)) break else: - msg = _('ignored explicit argument %r') + msg = _("ignored explicit argument %r") raise ArgumentError(action, msg % explicit_arg) else: start = start_index + 1 @@ -1222,7 +1432,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): selected_pattern = arg_strings_pattern[start_index:] arg_counts = match_partial(positionals, selected_pattern) for action, arg_count in zip(positionals, arg_counts): - args = arg_strings[start_index:start_index + arg_count] + args = arg_strings[start_index: start_index + arg_count] start_index += arg_count take_action(action, args) @@ -1237,7 +1447,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): max_option_string_index = -1 while start_index <= max_option_string_index: next_option_string_index = min( - [index for index in option_string_indices if index >= start_index]) + [index for index in option_string_indices if index >= start_index] + ) if start_index != next_option_string_index: positionals_end_index = consume_positionals(start_index) if positionals_end_index > start_index: @@ -1254,12 +1465,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): stop_index = consume_positionals(start_index) extras.extend(arg_strings[stop_index:]) if positionals: - self.error(_('too few arguments')) + self.error(_("too few arguments")) for action in self._actions: if action.required: if action not in seen_actions: name = _get_action_name(action) - self.error(_('argument %s is required') % name) + self.error(_("argument %s is required") % name) for group in self._mutually_exclusive_groups: if group.required: @@ -1267,10 +1478,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): if action in seen_non_default_actions: break else: - names = [_get_action_name( - action) for action in group._group_actions if action.help is not SUPPRESS] - msg = _('one of the arguments %s is required') - self.error(msg % ' '.join(names)) + names = [ + _get_action_name(action) + for action in group._group_actions + if action.help is not SUPPRESS + ] + msg = _("one of the arguments %s is required") + self.error(msg % " ".join(names)) return (namespace, extras) @@ -1306,10 +1520,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): nargs_pattern = self._get_nargs_pattern(action) match = _re.match(nargs_pattern, arg_strings_pattern) if match is None: - nargs_errors = {None: _('expected one argument'), - OPTIONAL: _('expected at most one argument'), - ONE_OR_MORE: _('expected at least one argument')} - default = _('expected %s argument(s)') % action.nargs + nargs_errors = { + None: _("expected one argument"), + OPTIONAL: _("expected at most one argument"), + ONE_OR_MORE: _("expected at least one argument"), + } + default = _("expected %s argument(s)") % action.nargs msg = nargs_errors.get(action.nargs, default) raise ArgumentError(action, msg) return len(match.group(1)) @@ -1318,8 +1534,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): result = [] for i in range(len(actions), 0, -1): actions_slice = actions[:i] - pattern = ''.join([self._get_nargs_pattern(action) - for action in actions_slice]) + pattern = "".join( + [self._get_nargs_pattern(action) for action in actions_slice] + ) match = _re.match(pattern, arg_strings_pattern) if match is not None: result.extend([len(string) for string in match.groups()]) @@ -1338,24 +1555,28 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): elif len(arg_string) == 1: return None else: - if '=' in arg_string: - option_string, explicit_arg = arg_string.split('=', 1) + if "=" in arg_string: + option_string, explicit_arg = arg_string.split("=", 1) if option_string in self._option_string_actions: action = self._option_string_actions[option_string] return (action, option_string, explicit_arg) option_tuples = self._get_option_tuples(arg_string) if len(option_tuples) > 1: - options = ', '.join( - [option_string for action, option_string, explicit_arg in option_tuples]) + options = ", ".join( + [ + option_string + for action, option_string, explicit_arg in option_tuples + ] + ) tup = (arg_string, options) - self.error(_('ambiguous option: %s could match %s') % tup) + self.error(_("ambiguous option: %s could match %s") % tup) elif len(option_tuples) == 1: - option_tuple, = option_tuples + (option_tuple,) = option_tuples return option_tuple if self._negative_number_matcher.match(arg_string): if not self._has_negative_number_optionals: return None - if ' ' in arg_string: + if " " in arg_string: return None return (None, arg_string, None) return None @@ -1364,8 +1585,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): result = [] chars = self.prefix_chars if option_string[0] in chars and option_string[1] in chars: - if '=' in option_string: - option_prefix, explicit_arg = option_string.split('=', 1) + if "=" in option_string: + option_prefix, explicit_arg = option_string.split("=", 1) else: option_prefix = option_string explicit_arg = None @@ -1391,33 +1612,33 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): result.append(tup) else: - self.error(_('unexpected option string: %s') % option_string) + self.error(_("unexpected option string: %s") % option_string) return result def _get_nargs_pattern(self, action): nargs = action.nargs if nargs is None: - nargs_pattern = '(-*A-*)' + nargs_pattern = "(-*A-*)" elif nargs == OPTIONAL: - nargs_pattern = '(-*A?-*)' + nargs_pattern = "(-*A?-*)" elif nargs == ZERO_OR_MORE: - nargs_pattern = '(-*[A-]*)' + nargs_pattern = "(-*[A-]*)" elif nargs == ONE_OR_MORE: - nargs_pattern = '(-*A[A-]*)' + nargs_pattern = "(-*A[A-]*)" elif nargs == REMAINDER: - nargs_pattern = '([-AO]*)' + nargs_pattern = "([-AO]*)" elif nargs == PARSER: - nargs_pattern = '(-*A[-AO]*)' + nargs_pattern = "(-*A[-AO]*)" else: - nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs) + nargs_pattern = "(-*%s-*)" % "-*".join("A" * nargs) if action.option_strings: - nargs_pattern = nargs_pattern.replace('-*', '') - nargs_pattern = nargs_pattern.replace('-', '') + nargs_pattern = nargs_pattern.replace("-*", "") + nargs_pattern = nargs_pattern.replace("-", "") return nargs_pattern def _get_values(self, action, arg_strings): if action.nargs not in [PARSER, REMAINDER]: - arg_strings = [s for s in arg_strings if s != '--'] + arg_strings = [s for s in arg_strings if s != "--"] if not arg_strings and action.nargs == OPTIONAL: if action.option_strings: value = action.const @@ -1426,14 +1647,18 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): if isinstance(value, str): value = self._get_value(action, value) self._check_value(action, value) - elif not arg_strings and action.nargs == ZERO_OR_MORE and not action.option_strings: + elif ( + not arg_strings + and action.nargs == ZERO_OR_MORE + and not action.option_strings + ): if action.default is not None: value = action.default else: value = arg_strings self._check_value(action, value) elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]: - arg_string, = arg_strings + (arg_string,) = arg_strings value = self._get_value(action, arg_string) self._check_value(action, value) elif action.nargs == REMAINDER: @@ -1449,40 +1674,44 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): return value def _get_value(self, action, arg_string): - type_func = self._registry_get('type', action.type, action.type) + type_func = self._registry_get("type", action.type, action.type) if not _callable(type_func): - msg = _('%r is not callable') + msg = _("%r is not callable") raise ArgumentError(action, msg % type_func) try: result = type_func(arg_string) except ArgumentTypeError: - name = getattr(action.type, '__name__', repr(action.type)) + name = getattr(action.type, "__name__", repr(action.type)) msg = str(_sys.exc_info()[1]) raise ArgumentError(action, msg) except (TypeError, ValueError): - name = getattr(action.type, '__name__', repr(action.type)) - msg = _('invalid %s value: %r') + name = getattr(action.type, "__name__", repr(action.type)) + msg = _("invalid %s value: %r") raise ArgumentError(action, msg % (name, arg_string)) return result def _check_value(self, action, value): if action.choices is not None and value not in action.choices: - tup = (value, ', '.join(map(repr, action.choices))) - msg = _('invalid choice: %r (choose from %s)') % tup + tup = (value, ", ".join(map(repr, action.choices))) + msg = _("invalid choice: %r (choose from %s)") % tup raise ArgumentError(action, msg) return def format_usage(self): formatter = self._get_formatter() - formatter.add_usage(self.usage, self._actions, - self._mutually_exclusive_groups) + formatter.add_usage( + self.usage, + self._actions, + self._mutually_exclusive_groups) return formatter.format_help() def format_help(self): formatter = self._get_formatter() - formatter.add_usage(self.usage, self._actions, - self._mutually_exclusive_groups) + formatter.add_usage( + self.usage, + self._actions, + self._mutually_exclusive_groups) formatter.add_text(self.description) for action_group in self._action_groups: formatter.start_section(action_group.title) @@ -1495,8 +1724,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def format_version(self): import warnings + warnings.warn( - 'The format_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning) + 'The format_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', + DeprecationWarning, + ) formatter = self._get_formatter() formatter.add_text(self.version) return formatter.format_help() @@ -1518,8 +1750,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def print_version(self, file=None): import warnings + warnings.warn( - 'The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning) + 'The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', + DeprecationWarning, + ) self._print_message(self.format_version(), file) def _print_message(self, message, file=None): @@ -1536,4 +1771,4 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def error(self, message): self.print_usage(_sys.stderr) - self.exit(2, _('%s: error: %s\n') % (self.prog, message)) + self.exit(2, _("%s: error: %s\n") % (self.prog, message)) diff --git a/NeoBoot/ubi_reader_arm/ubi/__init__.py b/NeoBoot/ubi_reader_arm/ubi/__init__.py index d96b797..a24bcbb 100644 --- a/NeoBoot/ubi_reader_arm/ubi/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubi/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import re from ubi.volume import get_volumes from ubi.block import sort, get_blocks_in_list, extract_blocks @@ -16,7 +15,7 @@ class ubi: self._blocks = extract_blocks(self) self._block_count = len(self.blocks) if self._block_count <= 0: - raise Exception('No blocks found.') + raise Exception("No blocks found.") layout_list, data_list, int_vol_list, unknown_list = sort.by_type( self.blocks) self._layout_blocks_list = layout_list @@ -28,7 +27,8 @@ class ubi: self._leb_size = self.file.block_size - arbitrary_block.ec_hdr.data_offset layout_pairs = layout.group_pairs(self.blocks, self.layout_blocks_list) layout_infos = layout.associate_blocks( - self.blocks, layout_pairs, self.first_peb_num) + self.blocks, layout_pairs, self.first_peb_num + ) self._images = [] for i in range(0, len(layout_infos)): self._images.append(image(self.blocks, layout_infos[i])) @@ -96,14 +96,14 @@ class ubi: blocks = property(_get_blocks) - def display(self, tab=''): + def display(self, tab=""): display.ubi(self, tab) def get_peb_size(path): file_offset = 0 offsets = [] - f = open(path, 'rb') + f = open(path, "rb") f.seek(0, 2) file_size = f.tell() + 1 f.seek(0) @@ -125,7 +125,7 @@ def get_peb_size(path): for i in range(0, len(offsets)): try: diff = offsets[i] - offsets[i - 1] - except: + except BaseException: diff = offsets[i] if diff not in occurances: diff --git a/NeoBoot/ubi_reader_arm/ubi/block/__init__.py b/NeoBoot/ubi_reader_arm/ubi/block/__init__.py index 7593f97..54bfe37 100644 --- a/NeoBoot/ubi_reader_arm/ubi/block/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubi/block/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import re from ubi import display from ubi.defines import * @@ -18,7 +17,11 @@ class description(object): self.ec_hdr = extract_ec_hdr(block_buf[0:UBI_EC_HDR_SZ]) if not self.ec_hdr.errors: self.vid_hdr = extract_vid_hdr( - block_buf[self.ec_hdr.vid_hdr_offset:self.ec_hdr.vid_hdr_offset + UBI_VID_HDR_SZ]) + block_buf[ + self.ec_hdr.vid_hdr_offset: self.ec_hdr.vid_hdr_offset + + UBI_VID_HDR_SZ + ] + ) self.is_internal_vol = self.vid_hdr.vol_id >= UBI_INTERNAL_VOL_START if self.vid_hdr.vol_id >= UBI_INTERNAL_VOL_START: self.vtbl_recs = extract_vtbl_rec( @@ -29,9 +32,9 @@ class description(object): return def __repr__(self): - return 'Block: PEB# %s: LEB# %s' % (self.peb_num, self.leb_num) + return "Block: PEB# %s: LEB# %s" % (self.peb_num, self.leb_num) - def display(self, tab=''): + def display(self, tab=""): display.block(self, tab) @@ -45,7 +48,10 @@ def extract_blocks(ubi): ubi.file.seek(ubi.file.start_offset) peb_count = 0 cur_offset = 0 - for i in range(ubi.file.start_offset, ubi.file.end_offset, ubi.file.block_size): + for i in range( + ubi.file.start_offset, + ubi.file.end_offset, + ubi.file.block_size): buf = ubi.file.read(ubi.file.block_size) if buf.startswith(UBI_EC_HDR_MAGIC): blk = description(buf) diff --git a/NeoBoot/ubi_reader_arm/ubi/block/layout.py b/NeoBoot/ubi_reader_arm/ubi/block/layout.py index b61772d..c1b1cac 100644 --- a/NeoBoot/ubi_reader_arm/ubi/block/layout.py +++ b/NeoBoot/ubi_reader_arm/ubi/block/layout.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubi.block import sort diff --git a/NeoBoot/ubi_reader_arm/ubi/block/sort.py b/NeoBoot/ubi_reader_arm/ubi/block/sort.py index 6d495fd..43ac02e 100644 --- a/NeoBoot/ubi_reader_arm/ubi/block/sort.py +++ b/NeoBoot/ubi_reader_arm/ubi/block/sort.py @@ -1,4 +1,3 @@ -#!/usr/bin/python def list_by_list(blist, slist): slist_blocks = [] for block in blist: @@ -24,11 +23,11 @@ def by_range(blocks, block_range): def by_leb(blocks): slist_len = len(blocks) - slist = ['x'] * slist_len + slist = ["x"] * slist_len for block in blocks: if blocks[block].leb_num >= slist_len: add_elements = blocks[block].leb_num - slist_len + 1 - slist += ['x'] * add_elements + slist += ["x"] * add_elements slist_len = len(slist) slist[blocks[block].leb_num] = block @@ -78,7 +77,4 @@ def by_type(blocks, slist=None): else: unknown.append(i) - return (layout, - data, - int_vol, - unknown) + return (layout, data, int_vol, unknown) diff --git a/NeoBoot/ubi_reader_arm/ubi/defines.py b/NeoBoot/ubi_reader_arm/ubi/defines.py index 95d5ff7..c113b38 100644 --- a/NeoBoot/ubi_reader_arm/ubi/defines.py +++ b/NeoBoot/ubi_reader_arm/ubi/defines.py @@ -1,63 +1,64 @@ -#!/usr/bin/python import struct + UBI_CRC32_INIT = 4294967295 UBI_MAX_VOLUMES = 128 UBI_INTERNAL_VOL_START = 2147479551 -UBI_EC_HDR_MAGIC = 'UBI#' -EC_HDR_FORMAT = '>4sB3sQIII32sI' -EC_HDR_FIELDS = ['magic', - 'version', - 'padding', - 'ec', - 'vid_hdr_offset', - 'data_offset', - 'image_seq', - 'padding2', - 'hdr_crc'] +UBI_EC_HDR_MAGIC = "UBI#" +EC_HDR_FORMAT = ">4sB3sQIII32sI" +EC_HDR_FIELDS = [ + "magic", + "version", + "padding", + "ec", + "vid_hdr_offset", + "data_offset", + "image_seq", + "padding2", + "hdr_crc", +] UBI_EC_HDR_SZ = struct.calcsize(EC_HDR_FORMAT) -UBI_VID_HDR_MAGIC = 'UBI!' -VID_HDR_FORMAT = '>4sBBBBII4sIIII4sQ12sI' -VID_HDR_FIELDS = ['magic', - 'version', - 'vol_type', - 'copy_flag', - 'compat', - 'vol_id', - 'lnum', - 'padding', - 'data_size', - 'used_ebs', - 'data_pad', - 'data_crc', - 'padding2', - 'sqnum', - 'padding3', - 'hdr_crc'] +UBI_VID_HDR_MAGIC = "UBI!" +VID_HDR_FORMAT = ">4sBBBBII4sIIII4sQ12sI" +VID_HDR_FIELDS = [ + "magic", + "version", + "vol_type", + "copy_flag", + "compat", + "vol_id", + "lnum", + "padding", + "data_size", + "used_ebs", + "data_pad", + "data_crc", + "padding2", + "sqnum", + "padding3", + "hdr_crc", +] UBI_VID_HDR_SZ = struct.calcsize(VID_HDR_FORMAT) -VTBL_REC_FORMAT = '>IIIBBH128sB23sI' -VTBL_REC_FIELDS = ['reserved_pebs', - 'alignment', - 'data_pad', - 'vol_type', - 'upd_marker', - 'name_len', - 'name', - 'flags', - 'padding', - 'crc'] +VTBL_REC_FORMAT = ">IIIBBH128sB23sI" +VTBL_REC_FIELDS = [ + "reserved_pebs", + "alignment", + "data_pad", + "vol_type", + "upd_marker", + "name_len", + "name", + "flags", + "padding", + "crc", +] UBI_VTBL_REC_SZ = struct.calcsize(VTBL_REC_FORMAT) UBI_VID_DYNAMIC = 1 UBI_VID_STATIC = 2 -PRINT_VOL_TYPE_LIST = [0, 'dynamic', 'static'] +PRINT_VOL_TYPE_LIST = [0, "dynamic", "static"] UBI_VTBL_AUTORESIZE_FLG = 1 UBI_COMPAT_DELETE = 1 UBI_COMPAT_RO = 2 UBI_COMPAT_PRESERVE = 4 UBI_COMPAT_REJECT = 5 -PRINT_COMPAT_LIST = [0, - 'Delete', - 'Read Only', - 0, - 'Preserve', - 'Reject'] +PRINT_COMPAT_LIST = [0, "Delete", "Read Only", 0, "Preserve", "Reject"] FILE_CHUNK_SZ = 5242880 diff --git a/NeoBoot/ubi_reader_arm/ubi/display.py b/NeoBoot/ubi_reader_arm/ubi/display.py index 7dc11f9..ad285ed 100644 --- a/NeoBoot/ubi_reader_arm/ubi/display.py +++ b/NeoBoot/ubi_reader_arm/ubi/display.py @@ -1,111 +1,111 @@ -#!/usr/bin/python from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG -def ubi(ubi, tab=''): - print(('%sUBI File' % tab)) - print(('%s---------------------' % tab)) - print(('\t%sMin I/O: %s' % (tab, ubi.min_io_size))) - print(('\t%sLEB Size: %s' % (tab, ubi.leb_size))) - print(('\t%sPEB Size: %s' % (tab, ubi.peb_size))) - print(('\t%sTotal Block Count: %s' % (tab, ubi.block_count))) - print(('\t%sData Block Count: %s' % (tab, len(ubi.data_blocks_list)))) - print(('\t%sLayout Block Count: %s' % (tab, len(ubi.layout_blocks_list)))) - print(('\t%sInternal Volume Block Count: %s' % +def ubi(ubi, tab=""): + print(("%sUBI File" % tab)) + print(("%s---------------------" % tab)) + print(("\t%sMin I/O: %s" % (tab, ubi.min_io_size))) + print(("\t%sLEB Size: %s" % (tab, ubi.leb_size))) + print(("\t%sPEB Size: %s" % (tab, ubi.peb_size))) + print(("\t%sTotal Block Count: %s" % (tab, ubi.block_count))) + print(("\t%sData Block Count: %s" % (tab, len(ubi.data_blocks_list)))) + print(("\t%sLayout Block Count: %s" % (tab, len(ubi.layout_blocks_list)))) + print(("\t%sInternal Volume Block Count: %s" % (tab, len(ubi.int_vol_blocks_list)))) - print(('\t%sUnknown Block Count: %s' % (tab, len(ubi.unknown_blocks_list)))) - print(('\t%sFirst UBI PEB Number: %s' % (tab, ubi.first_peb_num))) + print(("\t%sUnknown Block Count: %s" % + (tab, len(ubi.unknown_blocks_list)))) + print(("\t%sFirst UBI PEB Number: %s" % (tab, ubi.first_peb_num))) -def image(image, tab=''): - print(('%s%s' % (tab, image))) - print(('%s---------------------' % tab)) - print(('\t%sImage Sequence Num: %s' % (tab, image.image_seq))) +def image(image, tab=""): + print(("%s%s" % (tab, image))) + print(("%s---------------------" % tab)) + print(("\t%sImage Sequence Num: %s" % (tab, image.image_seq))) for volume in image.volumes: - print(('\t%sVolume Name:%s' % (tab, volume))) + print(("\t%sVolume Name:%s" % (tab, volume))) - print(('\t%sPEB Range: %s - %s' % - (tab, image.peb_range[0], image.peb_range[1]))) + print(("\t%sPEB Range: %s - %s" % + (tab, image.peb_range[0], image.peb_range[1]))) -def volume(volume, tab=''): - print(('%s%s' % (tab, volume))) - print(('%s---------------------' % tab)) - print(('\t%sVol ID: %s' % (tab, volume.vol_id))) - print(('\t%sName: %s' % (tab, volume.name))) - print(('\t%sBlock Count: %s' % (tab, volume.block_count))) - print('\n') - print(('\t%sVolume Record' % tab)) - print(('\t%s---------------------' % tab)) - vol_rec(volume.vol_rec, '\t\t%s' % tab) - print('\n') +def volume(volume, tab=""): + print(("%s%s" % (tab, volume))) + print(("%s---------------------" % tab)) + print(("\t%sVol ID: %s" % (tab, volume.vol_id))) + print(("\t%sName: %s" % (tab, volume.name))) + print(("\t%sBlock Count: %s" % (tab, volume.block_count))) + print("\n") + print(("\t%sVolume Record" % tab)) + print(("\t%s---------------------" % tab)) + vol_rec(volume.vol_rec, "\t\t%s" % tab) + print("\n") -def block(block, tab='\t'): - print(('%s%s' % (tab, block))) - print(('%s---------------------' % tab)) - print(('\t%sFile Offset: %s' % (tab, block.file_offset))) - print(('\t%sPEB #: %s' % (tab, block.peb_num))) - print(('\t%sLEB #: %s' % (tab, block.leb_num))) - print(('\t%sBlock Size: %s' % (tab, block.size))) - print(('\t%sInternal Volume: %s' % (tab, block.is_internal_vol))) - print(('\t%sIs Volume Table: %s' % (tab, block.is_vtbl))) - print(('\t%sIs Valid: %s' % (tab, block.is_valid))) +def block(block, tab="\t"): + print(("%s%s" % (tab, block))) + print(("%s---------------------" % tab)) + print(("\t%sFile Offset: %s" % (tab, block.file_offset))) + print(("\t%sPEB #: %s" % (tab, block.peb_num))) + print(("\t%sLEB #: %s" % (tab, block.leb_num))) + print(("\t%sBlock Size: %s" % (tab, block.size))) + print(("\t%sInternal Volume: %s" % (tab, block.is_internal_vol))) + print(("\t%sIs Volume Table: %s" % (tab, block.is_vtbl))) + print(("\t%sIs Valid: %s" % (tab, block.is_valid))) if not block.ec_hdr.errors: - print('\n') - print(('\t%sErase Count Header' % tab)) - print(('\t%s---------------------' % tab)) - ec_hdr(block.ec_hdr, '\t\t%s' % tab) + print("\n") + print(("\t%sErase Count Header" % tab)) + print(("\t%s---------------------" % tab)) + ec_hdr(block.ec_hdr, "\t\t%s" % tab) if block.vid_hdr and not block.vid_hdr.errors: - print('\n') - print(('\t%sVID Header Header' % tab)) - print(('\t%s---------------------' % tab)) - vid_hdr(block.vid_hdr, '\t\t%s' % tab) + print("\n") + print(("\t%sVID Header Header" % tab)) + print(("\t%s---------------------" % tab)) + vid_hdr(block.vid_hdr, "\t\t%s" % tab) if block.vtbl_recs: - print('\n') - print(('\t%sVolume Records' % tab)) - print(('\t%s---------------------' % tab)) + print("\n") + print(("\t%sVolume Records" % tab)) + print(("\t%s---------------------" % tab)) for vol in block.vtbl_recs: - vol_rec(vol, '\t\t%s' % tab) + vol_rec(vol, "\t\t%s" % tab) - print('\n') + print("\n") -def ec_hdr(ec_hdr, tab=''): +def ec_hdr(ec_hdr, tab=""): for key, value in ec_hdr: - if key == 'errors': - value = ','.join(value) - print(('%s%s: %r' % (tab, key, value))) + if key == "errors": + value = ",".join(value) + print(("%s%s: %r" % (tab, key, value))) -def vid_hdr(vid_hdr, tab=''): +def vid_hdr(vid_hdr, tab=""): for key, value in vid_hdr: - if key == 'errors': - value = ','.join(value) - elif key == 'compat': + if key == "errors": + value = ",".join(value) + elif key == "compat": if value in PRINT_COMPAT_LIST: value = PRINT_COMPAT_LIST[value] else: value = -1 - elif key == 'vol_type': + elif key == "vol_type": if value < len(PRINT_VOL_TYPE_LIST): value = PRINT_VOL_TYPE_LIST[value] else: value = -1 - print(('%s%s: %s' % (tab, key, value))) + print(("%s%s: %s" % (tab, key, value))) -def vol_rec(vol_rec, tab=''): +def vol_rec(vol_rec, tab=""): for key, value in vol_rec: - if key == 'errors': - value = ','.join(value) - elif key == 'vol_type': + if key == "errors": + value = ",".join(value) + elif key == "vol_type": if value < len(PRINT_VOL_TYPE_LIST): value = PRINT_VOL_TYPE_LIST[value] else: value = -1 - elif key == 'flags' and value == UBI_VTBL_AUTORESIZE_FLG: - value = 'autoresize' - elif key == 'name': - value = value.strip('\x00') - print(('%s%s: %s' % (tab, key, value))) + elif key == "flags" and value == UBI_VTBL_AUTORESIZE_FLG: + value = "autoresize" + elif key == "name": + value = value.strip("\x00") + print(("%s%s: %s" % (tab, key, value))) diff --git a/NeoBoot/ubi_reader_arm/ubi/headers/__init__.py b/NeoBoot/ubi_reader_arm/ubi/headers/__init__.py index 1ee4d07..698fd6d 100644 --- a/NeoBoot/ubi_reader_arm/ubi/headers/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubi/headers/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import struct from ubi.defines import * from ubi.headers import errors @@ -12,14 +11,14 @@ class ec_hdr(object): for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) + setattr(self, "errors", []) def __repr__(self): - return 'Error Count Header' + return "Error Count Header" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -31,15 +30,15 @@ class vid_hdr(object): for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) + setattr(self, "errors", []) def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) def __repr__(self): - return 'VID Header' + return "VID Header" class vtbl_rec(object): @@ -50,15 +49,15 @@ class vtbl_rec(object): for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) - setattr(self, 'rec_index', -1) + setattr(self, "errors", []) + setattr(self, "rec_index", -1) def __repr__(self): - return 'Volume Table Record: %s' % getattr(self, 'name') + return "Volume Table Record: %s" % getattr(self, "name") def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -79,10 +78,10 @@ def extract_vid_hdr(buf): def extract_vtbl_rec(buf): data_buf = buf vtbl_recs = [] - vtbl_rec_ret = '' + vtbl_rec_ret = "" for i in range(0, UBI_MAX_VOLUMES): offset = i * UBI_VTBL_REC_SZ - vtbl_rec_buf = data_buf[offset:offset + UBI_VTBL_REC_SZ] + vtbl_rec_buf = data_buf[offset: offset + UBI_VTBL_REC_SZ] if len(vtbl_rec_buf) == UBI_VTBL_REC_SZ: vtbl_rec_ret = vtbl_rec(vtbl_rec_buf) errors.vtbl_rec(vtbl_rec_ret, vtbl_rec_buf) diff --git a/NeoBoot/ubi_reader_arm/ubi/headers/errors.py b/NeoBoot/ubi_reader_arm/ubi/headers/errors.py index bc502b4..608235b 100644 --- a/NeoBoot/ubi_reader_arm/ubi/headers/errors.py +++ b/NeoBoot/ubi_reader_arm/ubi/headers/errors.py @@ -1,29 +1,28 @@ -#!/usr/bin/python from zlib import crc32 from ubi.defines import * def ec_hdr(ec_hdr, buf): if ec_hdr.hdr_crc != ~crc32(buf[:-4]) & 4294967295: - ec_hdr.errors.append('crc') + ec_hdr.errors.append("crc") return ec_hdr def vid_hdr(vid_hdr, buf): vid_hdr.errors = [] if vid_hdr.hdr_crc != ~crc32(buf[:-4]) & 4294967295: - vid_hdr.errors.append('crc') + vid_hdr.errors.append("crc") return vid_hdr def vtbl_rec(vtbl_rec, buf): likely_vtbl = True - if vtbl_rec.name_len != len(vtbl_rec.name.strip('\x00')): + if vtbl_rec.name_len != len(vtbl_rec.name.strip("\x00")): likely_vtbl = False elif vtbl_rec.vol_type not in (1, 2): likely_vtbl = False if vtbl_rec.crc != ~crc32(buf[:-4]) & 4294967295: - vtbl_rec.errors.append('crc') + vtbl_rec.errors.append("crc") if not likely_vtbl: - vtbl_rec.errors = ['False'] + vtbl_rec.errors = ["False"] return vtbl_rec diff --git a/NeoBoot/ubi_reader_arm/ubi/image.py b/NeoBoot/ubi_reader_arm/ubi/image.py index b732fe0..0ed99ae 100644 --- a/NeoBoot/ubi_reader_arm/ubi/image.py +++ b/NeoBoot/ubi_reader_arm/ubi/image.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubi import display from ubi.volume import get_volumes from ubi.block import get_blocks_in_list @@ -15,10 +14,12 @@ class description(object): self._volumes = get_volumes(blocks, layout_info) def __repr__(self): - return 'Image: %s' % self.image_seq + return "Image: %s" % self.image_seq def get_blocks(self, blocks): - return get_blocks_in_list(blocks, list(range(self._start_peb, self._end_peb + 1))) + return get_blocks_in_list( + blocks, list(range(self._start_peb, self._end_peb + 1)) + ) def _get_peb_range(self): return [self._start_peb, self._end_peb] @@ -35,5 +36,5 @@ class description(object): volumes = property(_get_volumes) - def display(self, tab=''): + def display(self, tab=""): display.image(self, tab) diff --git a/NeoBoot/ubi_reader_arm/ubi/volume/__init__.py b/NeoBoot/ubi_reader_arm/ubi/volume/__init__.py index f046055..221a7cd 100644 --- a/NeoBoot/ubi_reader_arm/ubi/volume/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubi/volume/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubi import display from ubi.block import sort, get_blocks_in_list @@ -12,7 +11,7 @@ class description(object): self._block_list = block_list def __repr__(self): - return 'Volume: %s' % self.name + return "Volume: %s" % self.name def _get_name(self): return self._name @@ -42,15 +41,15 @@ class description(object): def get_blocks(self, blocks): return get_blocks_in_list(blocks, self._block_list) - def display(self, tab=''): + def display(self, tab=""): display.volume(self, tab) def reader(self, ubi): last_leb = 0 for block in sort.by_leb(self.get_blocks(ubi.blocks)): - if block == 'x': + if block == "x": last_leb += 1 - yield '\xff' * ubi.leb_size + yield "\xff" * ubi.leb_size else: last_leb += 1 yield ubi.file.read_block_data(ubi.blocks[block]) @@ -60,10 +59,11 @@ def get_volumes(blocks, layout_info): volumes = {} vol_blocks_lists = sort.by_vol_id(blocks, layout_info[2]) for vol_rec in blocks[layout_info[0]].vtbl_recs: - vol_name = vol_rec.name.strip('\x00') + vol_name = vol_rec.name.strip("\x00") if vol_rec.rec_index not in vol_blocks_lists: vol_blocks_lists[vol_rec.rec_index] = [] volumes[vol_name] = description( - vol_rec.rec_index, vol_rec, vol_blocks_lists[vol_rec.rec_index]) + vol_rec.rec_index, vol_rec, vol_blocks_lists[vol_rec.rec_index] + ) return volumes diff --git a/NeoBoot/ubi_reader_arm/ubi_extract_files.py b/NeoBoot/ubi_reader_arm/ubi_extract_files.py index 8788602..1be743c 100644 --- a/NeoBoot/ubi_reader_arm/ubi_extract_files.py +++ b/NeoBoot/ubi_reader_arm/ubi_extract_files.py @@ -1,38 +1,58 @@ -#!/usr/bin/python - import os import sys -# import argparse_neo + try: import argparse -except: +except BaseException: import argparse_neo from ubi import ubi, get_peb_size from ubifs import ubifs from ubi_io import ubi_file, leb_virtual_file from ui.common import extract_files, output_dir -if __name__ == '__main__': + +if __name__ == "__main__": os.system( - 'echo "\n[NeoBoot] Zip file unzipped.\nInstallation in progress, please wait ..."') - description = 'Extract contents of UBI image.' - usage = 'ubi_extract_files.py [options] filepath' -# parser = argparse_neo.ArgumentParser(usage=usage, description=description) + 'echo "\n[NeoBoot] Zip file unzipped.\nInstallation in progress, please wait ..."' + ) + description = "Extract contents of UBI image." + usage = "ubi_extract_files.py [options] filepath" try: parser = argparse.ArgumentParser(usage=usage, description=description) - except: + except BaseException: parser = argparse_neo.ArgumentParser( usage=usage, description=description) - parser.add_argument('-l', '--log-file', dest='logpath', - help='Log output to file output/LOGPATH. (default: ubifs_output.log)') - parser.add_argument('-k', '--keep-permissions', action='store_true', dest='permissions', - help='Maintain file permissions, requires running as root. (default: False)') - parser.add_argument('-q', '--quiet', action='store_true', dest='quiet', - help='Suppress warnings and non-fatal errors. (default: False)') - parser.add_argument('-p', '--peb-size', type=int, - dest='block_size', help='Specify PEB size.') - parser.add_argument('-o', '--output-dir', dest='output_path', - help='Specify output directory path.') - parser.add_argument('filepath', help='File to extract contents of.') + parser.add_argument( + "-l", + "--log-file", + dest="logpath", + help="Log output to file output/LOGPATH. (default: ubifs_output.log)", + ) + parser.add_argument( + "-k", + "--keep-permissions", + action="store_true", + dest="permissions", + help="Maintain file permissions, requires running as root. (default: False)", + ) + parser.add_argument( + "-q", + "--quiet", + action="store_true", + dest="quiet", + help="Suppress warnings and non-fatal errors. (default: False)", + ) + parser.add_argument( + "-p", + "--peb-size", + type=int, + dest="block_size", + help="Specify PEB size.") + parser.add_argument( + "-o", + "--output-dir", + dest="output_path", + help="Specify output directory path.") + parser.add_argument("filepath", help="File to extract contents of.") if len(sys.argv) == 1: parser.print_help() sys.exit() @@ -69,13 +89,16 @@ if __name__ == '__main__': os.makedirs(vol_out_path) elif os.listdir(vol_out_path): parser.error( - 'Volume output directory is not empty. %s' % vol_out_path) + "Volume output directory is not empty. %s" % + vol_out_path) ufsfile = leb_virtual_file(uubi, image.volumes[volume]) uubifs = ubifs(ufsfile) uubifs.log.log_file = log_file uubifs.log.log_to_file = log_to_file uubifs.log.quiet = quiet - print("Wait almost over ...\nLoading the image to: %s" % vol_out_path) + print( + "Wait almost over ...\nLoading the image to: %s" % + vol_out_path) extract_files(uubifs, vol_out_path, perms) sys.exit(0) diff --git a/NeoBoot/ubi_reader_arm/ubi_io/__init__.py b/NeoBoot/ubi_reader_arm/ubi_io/__init__.py index 936872a..4319509 100644 --- a/NeoBoot/ubi_reader_arm/ubi_io/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubi_io/__init__.py @@ -1,11 +1,10 @@ -#!/usr/bin/python from ubi.block import sort class ubi_file(object): def __init__(self, path, block_size, start_offset=0, end_offset=None): - self._fhandle = open(path, 'rb') + self._fhandle = open(path, "rb") self._start_offset = start_offset if end_offset: self._end_offset = end_offset @@ -14,7 +13,7 @@ class ubi_file(object): self._end_offset = self.tell() self._block_size = block_size if start_offset >= self._end_offset: - raise Exception('Start offset larger than file size!') + raise Exception("Start offset larger than file size!") self._fhandle.seek(self._start_offset) def _set_start(self, i): @@ -69,7 +68,8 @@ class ubi_file(object): def read_block_data(self, block): self.seek(block.file_offset + block.ec_hdr.data_offset) buf = self._fhandle.read( - block.size - block.ec_hdr.data_offset - block.vid_hdr.data_pad) + block.size - block.ec_hdr.data_offset - block.vid_hdr.data_pad + ) return buf @@ -82,22 +82,22 @@ class leb_virtual_file: self._seek = 0 self.leb_data_size = len(self._blocks) * self._ubi.leb_size self._last_leb = -1 - self._last_buf = '' + self._last_buf = "" def read(self, i): - buf = '' + buf = "" leb = int(self.tell() / self._ubi.leb_size) offset = self.tell() % self._ubi.leb_size if leb == self._last_leb: self.seek(self.tell() + i) - return self._last_buf[offset:offset + i] + return self._last_buf[offset: offset + i] else: buf = self._ubi.file.read_block_data( self._ubi.blocks[self._blocks[leb]]) self._last_buf = buf self._last_leb = leb self.seek(self.tell() + i) - return buf[offset:offset + i] + return buf[offset: offset + i] def reset(self): self.seek(0) @@ -113,7 +113,7 @@ class leb_virtual_file: for block in self._blocks: while 0 != self._ubi.blocks[block].leb_num - last_leb: last_leb += 1 - yield '\xff' * self._ubi.leb_size + yield "\xff" * self._ubi.leb_size last_leb += 1 yield self._ubi.file.read_block_data(self._ubi.blocks[block]) diff --git a/NeoBoot/ubi_reader_arm/ubifs/__init__.py b/NeoBoot/ubi_reader_arm/ubifs/__init__.py index 0ad47ca..14585b3 100644 --- a/NeoBoot/ubi_reader_arm/ubifs/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubifs/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import re import struct from ubifs.defines import * @@ -50,7 +49,7 @@ class ubifs: def get_leb_size(path): - f = open(path, 'rb') + f = open(path, "rb") f.seek(0, 2) file_size = f.tell() + 1 f.seek(0) @@ -59,7 +58,7 @@ def get_leb_size(path): buf = f.read(FILE_CHUNK_SZ) for m in re.finditer(UBIFS_NODE_MAGIC, buf): start = m.start() - chdr = nodes.common_hdr(buf[start:start + UBIFS_COMMON_HDR_SZ]) + chdr = nodes.common_hdr(buf[start: start + UBIFS_COMMON_HDR_SZ]) if chdr and chdr.node_type == UBIFS_SB_NODE: sb_start = start + UBIFS_COMMON_HDR_SZ sb_end = sb_start + UBIFS_SB_NODE_SZ diff --git a/NeoBoot/ubi_reader_arm/ubifs/defines.py b/NeoBoot/ubi_reader_arm/ubifs/defines.py index 550fe49..9c0ddf9 100644 --- a/NeoBoot/ubi_reader_arm/ubifs/defines.py +++ b/NeoBoot/ubi_reader_arm/ubifs/defines.py @@ -1,6 +1,6 @@ -#!/usr/bin/python import struct -UBIFS_NODE_MAGIC = '1\x18\x10\x06' + +UBIFS_NODE_MAGIC = "1\x18\x10\x06" UBIFS_CRC32_INIT = 4294967295 UBIFS_MIN_COMPR_LEN = 128 UBIFS_MIN_COMPRESS_DIFF = 64 @@ -10,7 +10,7 @@ UBIFS_MAX_NLEN = 255 UBIFS_MAX_JHEADS = 1 UBIFS_BLOCK_SIZE = 4096 UBIFS_BLOCK_SHIFT = 12 -UBIFS_PADDING_BYTE = '\xce' +UBIFS_PADDING_BYTE = "\xce" UBIFS_MAX_KEY_LEN = 16 UBIFS_SK_LEN = 8 UBIFS_MIN_FANOUT = 3 @@ -37,7 +37,7 @@ UBIFS_ITYPE_SOCK = 6 UBIFS_ITYPES_CNT = 7 UBIFS_KEY_HASH_R5 = 0 UBIFS_KEY_HASH_TEST = 1 -PRINT_UBIFS_KEY_HASH = ['r5', 'test'] +PRINT_UBIFS_KEY_HASH = ["r5", "test"] UBIFS_SIMPLE_KEY_FMT = 0 UBIFS_S_KEY_BLOCK_BITS = 29 UBIFS_S_KEY_BLOCK_MASK = 536870911 @@ -64,7 +64,7 @@ UBIFS_COMPR_NONE = 0 UBIFS_COMPR_LZO = 1 UBIFS_COMPR_ZLIB = 2 UBIFS_COMPR_TYPES_CNT = 3 -PRINT_UBIFS_COMPR = ['none', 'lzo', 'zlib'] +PRINT_UBIFS_COMPR = ["none", "lzo", "zlib"] UBIFS_INO_NODE = 0 UBIFS_DATA_NODE = 1 UBIFS_DENT_NODE = 2 @@ -86,136 +86,133 @@ UBIFS_IN_NODE_GROUP = 1 UBIFS_LAST_OF_NODE_GROUP = 2 UBIFS_FLG_BIGLPT = 2 UBIFS_FLG_SPACE_FIXUP = 4 -UBIFS_COMMON_HDR_FORMAT = '> UBIFS_S_KEY_BLOCK_BITS khash = lkey - return {'type': key_type, - 'ino_num': ino_num, - 'khash': khash} + return {"type": key_type, "ino_num": ino_num, "khash": khash} def decompress(ctype, unc_len, data): - # if ctype == UBIFS_COMPR_LZO: - # return lzo.decompress(''.join(('\xf0', struct.pack('>I', unc_len), data))) if ctype == UBIFS_COMPR_ZLIB: return zlib.decompress(data, -11) else: diff --git a/NeoBoot/ubi_reader_arm/ubifs/nodes/__init__.py b/NeoBoot/ubi_reader_arm/ubifs/nodes/__init__.py index a287505..6de70d3 100644 --- a/NeoBoot/ubi_reader_arm/ubifs/nodes/__init__.py +++ b/NeoBoot/ubi_reader_arm/ubifs/nodes/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import struct from ubifs.defines import * from ubifs.misc import parse_key @@ -8,18 +7,18 @@ class common_hdr(object): def __init__(self, buf): fields = dict(list(zip(UBIFS_COMMON_HDR_FIELDS, - struct.unpack(UBIFS_COMMON_HDR_FORMAT, buf)))) + struct.unpack(UBIFS_COMMON_HDR_FORMAT, buf)))) for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) + setattr(self, "errors", []) def __repr__(self): - return 'UBIFS Common Header' + return "UBIFS Common Header" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -27,16 +26,17 @@ class sb_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_SB_NODE_FIELDS, struct.unpack(UBIFS_SB_NODE_FORMAT, buf)))) + list(zip(UBIFS_SB_NODE_FIELDS, struct.unpack(UBIFS_SB_NODE_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) def __repr__(self): - return 'UBIFS Super Block Node' + return "UBIFS Super Block Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -44,16 +44,17 @@ class mst_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_MST_NODE_FIELDS, struct.unpack(UBIFS_MST_NODE_FORMAT, buf)))) + list(zip(UBIFS_MST_NODE_FIELDS, struct.unpack(UBIFS_MST_NODE_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) def __repr__(self): - return 'UBIFS Master Block Node' + return "UBIFS Master Block Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -61,21 +62,24 @@ class dent_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_DENT_NODE_FIELDS, struct.unpack(UBIFS_DENT_NODE_FORMAT, buf)))) + list( + zip(UBIFS_DENT_NODE_FIELDS, struct.unpack(UBIFS_DENT_NODE_FORMAT, buf)) + ) + ) for key in fields: - if key == 'key': + if key == "key": setattr(self, key, parse_key(fields[key])) else: setattr(self, key, fields[key]) - setattr(self, 'name', '') + setattr(self, "name", "") def __repr__(self): - return 'UBIFS Directory Entry Node' + return "UBIFS Directory Entry Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -83,22 +87,25 @@ class data_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_DATA_NODE_FIELDS, struct.unpack(UBIFS_DATA_NODE_FORMAT, buf)))) + list( + zip(UBIFS_DATA_NODE_FIELDS, struct.unpack(UBIFS_DATA_NODE_FORMAT, buf)) + ) + ) for key in fields: - if key == 'key': + if key == "key": setattr(self, key, parse_key(fields[key])) else: setattr(self, key, fields[key]) - setattr(self, 'offset', 0) - setattr(self, 'compr_len', 0) + setattr(self, "offset", 0) + setattr(self, "compr_len", 0) def __repr__(self): - return 'UBIFS Data Node' + return "UBIFS Data Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -106,18 +113,19 @@ class idx_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_IDX_NODE_FIELDS, struct.unpack(UBIFS_IDX_NODE_FORMAT, buf)))) + list(zip(UBIFS_IDX_NODE_FIELDS, struct.unpack(UBIFS_IDX_NODE_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) - setattr(self, 'branches', []) + setattr(self, "branches", []) def __repr__(self): - return 'UBIFS Index Node' + return "UBIFS Index Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -125,21 +133,22 @@ class ino_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_INO_NODE_FIELDS, struct.unpack(UBIFS_INO_NODE_FORMAT, buf)))) + list(zip(UBIFS_INO_NODE_FIELDS, struct.unpack(UBIFS_INO_NODE_FORMAT, buf))) + ) for key in fields: - if key == 'key': + if key == "key": setattr(self, key, parse_key(fields[key])) else: setattr(self, key, fields[key]) - setattr(self, 'data', '') + setattr(self, "data", "") def __repr__(self): - return 'UBIFS Ino Node' + return "UBIFS Ino Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -147,14 +156,15 @@ class branch(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_BRANCH_FIELDS, struct.unpack(UBIFS_BRANCH_FORMAT, buf)))) + list(zip(UBIFS_BRANCH_FIELDS, struct.unpack(UBIFS_BRANCH_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) def __repr__(self): - return 'UBIFS Branch' + return "UBIFS Branch" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) diff --git a/NeoBoot/ubi_reader_arm/ubifs/nodes/extract.py b/NeoBoot/ubi_reader_arm/ubifs/nodes/extract.py index 8a5c549..4a72251 100644 --- a/NeoBoot/ubi_reader_arm/ubifs/nodes/extract.py +++ b/NeoBoot/ubi_reader_arm/ubifs/nodes/extract.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubifs import nodes from ubifs.defines import * @@ -28,7 +27,7 @@ def sb_node(ubifs, offset=0): def dent_node(ubifs, lnum, offset=0): ubifs.file.seek(ubifs.leb_size * lnum + offset) den = nodes.dent_node(ubifs.file.read(UBIFS_DENT_NODE_SZ)) - den.name = '%s' % ubifs.file.read(den.nlen) + den.name = "%s" % ubifs.file.read(den.nlen) return den diff --git a/NeoBoot/ubi_reader_arm/ubifs/output.py b/NeoBoot/ubi_reader_arm/ubifs/output.py index 96d716a..cc1eca7 100644 --- a/NeoBoot/ubi_reader_arm/ubifs/output.py +++ b/NeoBoot/ubi_reader_arm/ubifs/output.py @@ -1,11 +1,10 @@ -#!/usr/bin/python import os import struct from ubifs.defines import * from ubifs.misc import decompress -def dents(ubifs, inodes, dent_node, path='', perms=False): +def dents(ubifs, inodes, dent_node, path="", perms=False): inode = inodes[dent_node.inum] dent_path = os.path.join(path, dent_node.name) if dent_node.type == UBIFS_ITYPE_DIR: @@ -15,41 +14,42 @@ def dents(ubifs, inodes, dent_node, path='', perms=False): if perms: set_file_perms(dent_path, inode) except Exception as e: - ubifs.log.write('DIR Fail: %s' % e) + ubifs.log.write("DIR Fail: %s" % e) - if 'dent' in inode: - for dnode in inode['dent']: + if "dent" in inode: + for dnode in inode["dent"]: dents(ubifs, inodes, dnode, dent_path, perms) elif dent_node.type == UBIFS_ITYPE_REG: try: - if inode['ino'].nlink > 1: - if 'hlink' not in inode: - inode['hlink'] = dent_path + if inode["ino"].nlink > 1: + if "hlink" not in inode: + inode["hlink"] = dent_path buf = process_reg_file(ubifs, inode, dent_path) write_reg_file(dent_path, buf) else: - os.link(inode['hlink'], dent_path) + os.link(inode["hlink"], dent_path) else: buf = process_reg_file(ubifs, inode, dent_path) write_reg_file(dent_path, buf) if perms: set_file_perms(dent_path, inode) except Exception as e: - ubifs.log.write('FILE Fail: %s' % e) + ubifs.log.write("FILE Fail: %s" % e) elif dent_node.type == UBIFS_ITYPE_LNK: try: - os.symlink('%s' % inode['ino'].data, dent_path) + os.symlink("%s" % inode["ino"].data, dent_path) except Exception as e: - ubifs.log.write('SYMLINK Fail: %s : %s' % - (inode['ino'].data, dent_path)) + ubifs.log.write( + "SYMLINK Fail: %s : %s" % + (inode["ino"].data, dent_path)) elif dent_node.type in [UBIFS_ITYPE_BLK, UBIFS_ITYPE_CHR]: try: - dev = struct.unpack(' len(buf): - buf += '\x00' * (inode['ino'].size - len(buf)) + if inode["ino"].size > len(buf): + buf += "\x00" * (inode["ino"].size - len(buf)) return buf diff --git a/NeoBoot/ubi_reader_arm/ubifs/walk.py b/NeoBoot/ubi_reader_arm/ubifs/walk.py index b9df5a4..3721024 100644 --- a/NeoBoot/ubi_reader_arm/ubifs/walk.py +++ b/NeoBoot/ubi_reader_arm/ubifs/walk.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubifs import extract from ubifs.defines import * @@ -12,24 +11,28 @@ def index(ubifs, lnum, offset, inodes={}): elif chdr.node_type == UBIFS_INO_NODE: inon = extract.ino_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ) - ino_num = inon.key['ino_num'] + ino_num = inon.key["ino_num"] if ino_num not in inodes: inodes[ino_num] = {} - inodes[ino_num]['ino'] = inon + inodes[ino_num]["ino"] = inon elif chdr.node_type == UBIFS_DATA_NODE: datn = extract.data_node( - ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ, chdr.len) - ino_num = datn.key['ino_num'] + ubifs, + lnum, + offset + + UBIFS_COMMON_HDR_SZ, + chdr.len) + ino_num = datn.key["ino_num"] if ino_num not in inodes: inodes[ino_num] = {} - if 'data' not in inodes[ino_num]: - inodes[ino_num]['data'] = [] - inodes[ino_num]['data'].append(datn) + if "data" not in inodes[ino_num]: + inodes[ino_num]["data"] = [] + inodes[ino_num]["data"].append(datn) elif chdr.node_type == UBIFS_DENT_NODE: dn = extract.dent_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ) - ino_num = dn.key['ino_num'] + ino_num = dn.key["ino_num"] if ino_num not in inodes: inodes[ino_num] = {} - if 'dent' not in inodes[ino_num]: - inodes[ino_num]['dent'] = [] - inodes[ino_num]['dent'].append(dn) + if "dent" not in inodes[ino_num]: + inodes[ino_num]["dent"] = [] + inodes[ino_num]["dent"].append(dn) diff --git a/NeoBoot/ubi_reader_arm/ui/common.py b/NeoBoot/ubi_reader_arm/ui/common.py index 5d40084..40786f0 100644 --- a/NeoBoot/ubi_reader_arm/ui/common.py +++ b/NeoBoot/ubi_reader_arm/ui/common.py @@ -1,11 +1,12 @@ -#!/usr/bin/python import os from ubi_io import leb_virtual_file from ubifs import ubifs, walk, output from ubifs.defines import PRINT_UBIFS_KEY_HASH, PRINT_UBIFS_COMPR from ubi.defines import PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG -output_dir = os.path.join(os.path.dirname( - os.path.dirname(os.path.realpath(__file__))), 'output') + +output_dir = os.path.join( + os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "output" +) def extract_files(ubifs, out_path, perms=False): @@ -13,34 +14,37 @@ def extract_files(ubifs, out_path, perms=False): inodes = {} walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes) - for dent in inodes[1]['dent']: + for dent in inodes[1]["dent"]: output.dents(ubifs, inodes, dent, out_path, perms) except Exception as e: import traceback - ubifs.log.write('%s' % e) + + ubifs.log.write("%s" % e) traceback.print_exc() def get_ubi_params(ubi): - ubi_flags = {'min_io_size': '-m', - 'max_bud_bytes': '-j', - 'leb_size': '-e', - 'default_compr': '-x', - 'sub_page_size': '-s', - 'fanout': '-f', - 'key_hash': '-k', - 'orph_lebs': '-p', - 'log_lebs': '-l', - 'max_leb_cnt': '-c', - 'peb_size': '-p', - 'sub_page_size': '-s', - 'vid_hdr_offset': '-O', - 'version': '-x', - 'image_seq': '-Q', - 'alignment': '-a', - 'vol_id': '-n', - 'name': '-N'} + ubi_flags = { + "min_io_size": "-m", + "max_bud_bytes": "-j", + "leb_size": "-e", + "default_compr": "-x", + "sub_page_size": "-s", + "fanout": "-f", + "key_hash": "-k", + "orph_lebs": "-p", + "log_lebs": "-l", + "max_leb_cnt": "-c", + "peb_size": "-p", + "sub_page_size": "-s", + "vid_hdr_offset": "-O", + "version": "-x", + "image_seq": "-Q", + "alignment": "-a", + "vol_id": "-n", + "name": "-N", + } ubi_params = {} ubi_args = {} ini_params = {} @@ -52,41 +56,55 @@ def get_ubi_params(ubi): for volume in image.volumes: ubi_args[img_seq][volume] = {} ini_params[img_seq][volume] = {} - ini_params[img_seq][volume]['vol_type'] = PRINT_VOL_TYPE_LIST[image.volumes[volume].vol_rec.vol_type] + ini_params[img_seq][volume]["vol_type"] = PRINT_VOL_TYPE_LIST[ + image.volumes[volume].vol_rec.vol_type + ] if image.volumes[volume].vol_rec.flags == UBI_VTBL_AUTORESIZE_FLG: - ini_params[img_seq][volume]['vol_flags'] = 'autoresize' + ini_params[img_seq][volume]["vol_flags"] = "autoresize" else: - ini_params[img_seq][volume]['vol_flags'] = image.volumes[volume].vol_rec.flags - ini_params[img_seq][volume]['vol_id'] = image.volumes[volume].vol_id - ini_params[img_seq][volume]['vol_name'] = image.volumes[volume].name.rstrip( - '\x00') - ini_params[img_seq][volume]['vol_alignment'] = image.volumes[volume].vol_rec.alignment - ini_params[img_seq][volume]['vol_size'] = image.volumes[volume].vol_rec.reserved_pebs * ubi.leb_size + ini_params[img_seq][volume]["vol_flags"] = image.volumes[ + volume + ].vol_rec.flags + ini_params[img_seq][volume]["vol_id"] = image.volumes[volume].vol_id + ini_params[img_seq][volume]["vol_name"] = image.volumes[volume].name.rstrip( + "\x00") + ini_params[img_seq][volume]["vol_alignment"] = image.volumes[ + volume + ].vol_rec.alignment + ini_params[img_seq][volume]["vol_size"] = ( + image.volumes[volume].vol_rec.reserved_pebs * ubi.leb_size + ) ufsfile = leb_virtual_file(ubi, image.volumes[volume]) uubifs = ubifs(ufsfile) for key, value in uubifs.superblock_node: - if key == 'key_hash': + if key == "key_hash": value = PRINT_UBIFS_KEY_HASH[value] - elif key == 'default_compr': + elif key == "default_compr": value = PRINT_UBIFS_COMPR[value] if key in ubi_flags: ubi_args[img_seq][volume][key] = value for key, value in image.volumes[volume].vol_rec: - if key == 'name': - value = value.rstrip('\x00') + if key == "name": + value = value.rstrip("\x00") if key in ubi_flags: ubi_args[img_seq][volume][key] = value - ubi_args[img_seq][volume]['version'] = image.version - ubi_args[img_seq][volume]['vid_hdr_offset'] = image.vid_hdr_offset - ubi_args[img_seq][volume]['sub_page_size'] = ubi_args[img_seq][volume]['vid_hdr_offset'] - ubi_args[img_seq][volume]['sub_page_size'] = ubi_args[img_seq][volume]['vid_hdr_offset'] - ubi_args[img_seq][volume]['image_seq'] = image.image_seq - ubi_args[img_seq][volume]['peb_size'] = ubi.peb_size - ubi_args[img_seq][volume]['vol_id'] = image.volumes[volume].vol_id - ubi_params[img_seq][volume] = {'flags': ubi_flags, - 'args': ubi_args[img_seq][volume], - 'ini': ini_params[img_seq][volume]} + ubi_args[img_seq][volume]["version"] = image.version + ubi_args[img_seq][volume]["vid_hdr_offset"] = image.vid_hdr_offset + ubi_args[img_seq][volume]["sub_page_size"] = ubi_args[img_seq][volume][ + "vid_hdr_offset" + ] + ubi_args[img_seq][volume]["sub_page_size"] = ubi_args[img_seq][volume][ + "vid_hdr_offset" + ] + ubi_args[img_seq][volume]["image_seq"] = image.image_seq + ubi_args[img_seq][volume]["peb_size"] = ubi.peb_size + ubi_args[img_seq][volume]["vol_id"] = image.volumes[volume].vol_id + ubi_params[img_seq][volume] = { + "flags": ubi_flags, + "args": ubi_args[img_seq][volume], + "ini": ini_params[img_seq][volume], + } return ubi_params diff --git a/NeoBoot/ubi_reader_mips/argparse_neo.py b/NeoBoot/ubi_reader_mips/argparse_neo.py index 74824dc..31c91b0 100644 --- a/NeoBoot/ubi_reader_mips/argparse_neo.py +++ b/NeoBoot/ubi_reader_mips/argparse_neo.py @@ -1,21 +1,22 @@ - -__version__ = '1.1' -__all__ = ['ArgumentParser', - 'ArgumentError', - 'ArgumentTypeError', - 'FileType', - 'HelpFormatter', - 'ArgumentDefaultsHelpFormatter', - 'RawDescriptionHelpFormatter', - 'RawTextHelpFormatter', - 'Namespace', - 'Action', - 'ONE_OR_MORE', - 'OPTIONAL', - 'PARSER', - 'REMAINDER', - 'SUPPRESS', - 'ZERO_OR_MORE'] +__version__ = "1.1" +__all__ = [ + "ArgumentParser", + "ArgumentError", + "ArgumentTypeError", + "FileType", + "HelpFormatter", + "ArgumentDefaultsHelpFormatter", + "RawDescriptionHelpFormatter", + "RawTextHelpFormatter", + "Namespace", + "Action", + "ONE_OR_MORE", + "OPTIONAL", + "PARSER", + "REMAINDER", + "SUPPRESS", + "ZERO_OR_MORE", +] import collections as _collections import copy as _copy import os as _os @@ -26,16 +27,16 @@ from gettext import gettext as _ def _callable(obj): - return hasattr(obj, '__call__') or hasattr(obj, '__bases__') + return hasattr(obj, "__call__") or hasattr(obj, "__bases__") -SUPPRESS = '==SUPPRESS==' -OPTIONAL = '?' -ZERO_OR_MORE = '*' -ONE_OR_MORE = '+' -PARSER = 'A...' -REMAINDER = '...' -_UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args' +SUPPRESS = "==SUPPRESS==" +OPTIONAL = "?" +ZERO_OR_MORE = "*" +ONE_OR_MORE = "+" +PARSER = "A..." +REMAINDER = "..." +_UNRECOGNIZED_ARGS_ATTR = "_unrecognized_args" class _AttributeHolder(object): @@ -47,9 +48,9 @@ class _AttributeHolder(object): arg_strings.append(repr(arg)) for name, value in self._get_kwargs(): - arg_strings.append('%s=%r' % (name, value)) + arg_strings.append("%s=%r" % (name, value)) - return '%s(%s)' % (type_name, ', '.join(arg_strings)) + return "%s(%s)" % (type_name, ", ".join(arg_strings)) def _get_kwargs(self): return sorted(self.__dict__.items()) @@ -66,10 +67,15 @@ def _ensure_value(namespace, name, value): class HelpFormatter(object): - def __init__(self, prog, indent_increment=2, max_help_position=24, width=None): + def __init__( + self, + prog, + indent_increment=2, + max_help_position=24, + width=None): if width is None: try: - width = int(_os.environ['COLUMNS']) + width = int(_os.environ["COLUMNS"]) except (KeyError, ValueError): width = 80 @@ -83,8 +89,8 @@ class HelpFormatter(object): self._action_max_length = 0 self._root_section = self._Section(self, None) self._current_section = self._root_section - self._whitespace_matcher = _re.compile('\\s+') - self._long_break_matcher = _re.compile('\\n\\n\\n+') + self._whitespace_matcher = _re.compile("\\s+") + self._long_break_matcher = _re.compile("\\n\\n\\n+") return def _indent(self): @@ -114,17 +120,14 @@ class HelpFormatter(object): if self.parent is not None: self.formatter._dedent() if not item_help: - return '' + return "" else: if self.heading is not SUPPRESS and self.heading is not None: current_indent = self.formatter._current_indent - heading = '%*s%s:\n' % (current_indent, '', self.heading) + heading = "%*s%s:\n" % (current_indent, "", self.heading) else: - heading = '' - return join(['\n', - heading, - item_help, - '\n']) + heading = "" + return join(["\n", heading, item_help, "\n"]) return def _add_item(self, func, args): @@ -147,10 +150,7 @@ class HelpFormatter(object): def add_usage(self, usage, actions, groups, prefix=None): if usage is not SUPPRESS: - args = (usage, - actions, - groups, - prefix) + args = (usage, actions, groups, prefix) self._add_item(self._format_usage, args) def add_argument(self, action): @@ -173,22 +173,23 @@ class HelpFormatter(object): def format_help(self): help = self._root_section.format_help() if help: - help = self._long_break_matcher.sub('\n\n', help) - help = help.strip('\n') + '\n' + help = self._long_break_matcher.sub("\n\n", help) + help = help.strip("\n") + "\n" return help def _join_parts(self, part_strings): - return ''.join([part for part in part_strings if part and part is not SUPPRESS]) + return "".join( + [part for part in part_strings if part and part is not SUPPRESS]) def _format_usage(self, usage, actions, groups, prefix): if prefix is None: - prefix = _('usage: ') + prefix = _("usage: ") if usage is not None: usage = usage % dict(prog=self._prog) elif usage is None and not actions: - usage = '%(prog)s' % dict(prog=self._prog) + usage = "%(prog)s" % dict(prog=self._prog) elif usage is None: - prog = '%(prog)s' % dict(prog=self._prog) + prog = "%(prog)s" % dict(prog=self._prog) optionals = [] positionals = [] for action in actions: @@ -199,10 +200,10 @@ class HelpFormatter(object): format = self._format_actions_usage action_usage = format(optionals + positionals, groups) - usage = ' '.join([s for s in [prog, action_usage] if s]) + usage = " ".join([s for s in [prog, action_usage] if s]) text_width = self._width - self._current_indent if len(prefix) + len(usage) > text_width: - part_regexp = '\\(.*?\\)+|\\[.*?\\]+|\\S+' + part_regexp = "\\(.*?\\)+|\\[.*?\\]+|\\S+" opt_usage = format(optionals, groups) pos_usage = format(positionals, groups) opt_parts = _re.findall(part_regexp, opt_usage) @@ -217,20 +218,20 @@ class HelpFormatter(object): line_len = len(indent) - 1 for part in parts: if line_len + 1 + len(part) > text_width: - lines.append(indent + ' '.join(line)) + lines.append(indent + " ".join(line)) line = [] line_len = len(indent) - 1 line.append(part) line_len += len(part) + 1 if line: - lines.append(indent + ' '.join(line)) + lines.append(indent + " ".join(line)) if prefix is not None: lines[0] = lines[0][len(indent):] return lines if len(prefix) + len(prog) <= 0.75 * text_width: - indent = ' ' * (len(prefix) + len(prog) + 1) + indent = " " * (len(prefix) + len(prog) + 1) if opt_parts: lines = get_lines([prog] + opt_parts, indent, prefix) lines.extend(get_lines(pos_parts, indent)) @@ -239,7 +240,7 @@ class HelpFormatter(object): else: lines = [prog] else: - indent = ' ' * len(prefix) + indent = " " * len(prefix) parts = opt_parts + pos_parts lines = get_lines(parts, indent) if len(lines) > 1: @@ -247,8 +248,8 @@ class HelpFormatter(object): lines.extend(get_lines(opt_parts, indent)) lines.extend(get_lines(pos_parts, indent)) lines = [prog] + lines - usage = '\n'.join(lines) - return '%s%s\n\n' % (prefix, usage) + usage = "\n".join(lines) + return "%s%s\n\n" % (prefix, usage) def _format_actions_usage(self, actions, groups): group_actions = set() @@ -266,95 +267,93 @@ class HelpFormatter(object): if not group.required: if start in inserts: - inserts[start] += ' [' + inserts[start] += " [" else: - inserts[start] = '[' - inserts[end] = ']' + inserts[start] = "[" + inserts[end] = "]" else: if start in inserts: - inserts[start] += ' (' + inserts[start] += " (" else: - inserts[start] = '(' - inserts[end] = ')' + inserts[start] = "(" + inserts[end] = ")" for i in range(start + 1, end): - inserts[i] = '|' + inserts[i] = "|" parts = [] for i, action in enumerate(actions): if action.help is SUPPRESS: parts.append(None) - if inserts.get(i) == '|': + if inserts.get(i) == "|": inserts.pop(i) - elif inserts.get(i + 1) == '|': + elif inserts.get(i + 1) == "|": inserts.pop(i + 1) elif not action.option_strings: part = self._format_args(action, action.dest) if action in group_actions: - if part[0] == '[' and part[-1] == ']': + if part[0] == "[" and part[-1] == "]": part = part[1:-1] parts.append(part) else: option_string = action.option_strings[0] if action.nargs == 0: - part = '%s' % option_string + part = "%s" % option_string else: default = action.dest.upper() args_string = self._format_args(action, default) - part = '%s %s' % (option_string, args_string) + part = "%s %s" % (option_string, args_string) if not action.required and action not in group_actions: - part = '[%s]' % part + part = "[%s]" % part parts.append(part) for i in sorted(inserts, reverse=True): parts[i:i] = [inserts[i]] - text = ' '.join([item for item in parts if item is not None]) - open = '[\\[(]' - close = '[\\])]' - text = _re.sub('(%s) ' % open, '\\1', text) - text = _re.sub(' (%s)' % close, '\\1', text) - text = _re.sub('%s *%s' % (open, close), '', text) - text = _re.sub('\\(([^|]*)\\)', '\\1', text) + text = " ".join([item for item in parts if item is not None]) + open = "[\\[(]" + close = "[\\])]" + text = _re.sub("(%s) " % open, "\\1", text) + text = _re.sub(" (%s)" % close, "\\1", text) + text = _re.sub("%s *%s" % (open, close), "", text) + text = _re.sub("\\(([^|]*)\\)", "\\1", text) text = text.strip() return text def _format_text(self, text): - if '%(prog)' in text: + if "%(prog)" in text: text = text % dict(prog=self._prog) text_width = self._width - self._current_indent - indent = ' ' * self._current_indent - return self._fill_text(text, text_width, indent) + '\n\n' + indent = " " * self._current_indent + return self._fill_text(text, text_width, indent) + "\n\n" def _format_action(self, action): - help_position = min(self._action_max_length + - 2, self._max_help_position) + help_position = min( + self._action_max_length + 2, + self._max_help_position) help_width = self._width - help_position action_width = help_position - self._current_indent - 2 action_header = self._format_action_invocation(action) if not action.help: - tup = (self._current_indent, '', action_header) - action_header = '%*s%s\n' % tup + tup = (self._current_indent, "", action_header) + action_header = "%*s%s\n" % tup elif len(action_header) <= action_width: - tup = (self._current_indent, - '', - action_width, - action_header) - action_header = '%*s%-*s ' % tup + tup = (self._current_indent, "", action_width, action_header) + action_header = "%*s%-*s " % tup indent_first = 0 else: - tup = (self._current_indent, '', action_header) - action_header = '%*s%s\n' % tup + tup = (self._current_indent, "", action_header) + action_header = "%*s%s\n" % tup indent_first = help_position parts = [action_header] if action.help: help_text = self._expand_help(action) help_lines = self._split_lines(help_text, help_width) - parts.append('%*s%s\n' % (indent_first, '', help_lines[0])) + parts.append("%*s%s\n" % (indent_first, "", help_lines[0])) for line in help_lines[1:]: - parts.append('%*s%s\n' % (help_position, '', line)) + parts.append("%*s%s\n" % (help_position, "", line)) - elif not action_header.endswith('\n'): - parts.append('\n') + elif not action_header.endswith("\n"): + parts.append("\n") for subaction in self._iter_indented_subactions(action): parts.append(self._format_action(subaction)) @@ -362,7 +361,7 @@ class HelpFormatter(object): def _format_action_invocation(self, action): if not action.option_strings: - metavar, = self._metavar_formatter(action, action.dest)(1) + (metavar,) = self._metavar_formatter(action, action.dest)(1) return metavar else: parts = [] @@ -372,16 +371,16 @@ class HelpFormatter(object): default = action.dest.upper() args_string = self._format_args(action, default) for option_string in action.option_strings: - parts.append('%s %s' % (option_string, args_string)) + parts.append("%s %s" % (option_string, args_string)) - return ', '.join(parts) + return ", ".join(parts) def _metavar_formatter(self, action, default_metavar): if action.metavar is not None: result = action.metavar elif action.choices is not None: choice_strs = [str(choice) for choice in action.choices] - result = '{%s}' % ','.join(choice_strs) + result = "{%s}" % ",".join(choice_strs) else: result = default_metavar @@ -396,20 +395,20 @@ class HelpFormatter(object): def _format_args(self, action, default_metavar): get_metavar = self._metavar_formatter(action, default_metavar) if action.nargs is None: - result = '%s' % get_metavar(1) + result = "%s" % get_metavar(1) elif action.nargs == OPTIONAL: - result = '[%s]' % get_metavar(1) + result = "[%s]" % get_metavar(1) elif action.nargs == ZERO_OR_MORE: - result = '[%s [%s ...]]' % get_metavar(2) + result = "[%s [%s ...]]" % get_metavar(2) elif action.nargs == ONE_OR_MORE: - result = '%s [%s ...]' % get_metavar(2) + result = "%s [%s ...]" % get_metavar(2) elif action.nargs == REMAINDER: - result = '...' + result = "..." elif action.nargs == PARSER: - result = '%s ...' % get_metavar(1) + result = "%s ..." % get_metavar(1) else: - formats = ['%s' for _ in range(action.nargs)] - result = ' '.join(formats) % get_metavar(action.nargs) + formats = ["%s" for _ in range(action.nargs)] + result = " ".join(formats) % get_metavar(action.nargs) return result def _expand_help(self, action): @@ -419,12 +418,12 @@ class HelpFormatter(object): del params[name] for name in list(params): - if hasattr(params[name], '__name__'): + if hasattr(params[name], "__name__"): params[name] = params[name].__name__ - if params.get('choices') is not None: - choices_str = ', '.join([str(c) for c in params['choices']]) - params['choices'] = choices_str + if params.get("choices") is not None: + choices_str = ", ".join([str(c) for c in params["choices"]]) + params["choices"] = choices_str return self._get_help_string(action) % params def _iter_indented_subactions(self, action): @@ -440,12 +439,14 @@ class HelpFormatter(object): self._dedent() def _split_lines(self, text, width): - text = self._whitespace_matcher.sub(' ', text).strip() + text = self._whitespace_matcher.sub(" ", text).strip() return _textwrap.wrap(text, width) def _fill_text(self, text, width, indent): - text = self._whitespace_matcher.sub(' ', text).strip() - return _textwrap.fill(text, width, initial_indent=indent, subsequent_indent=indent) + text = self._whitespace_matcher.sub(" ", text).strip() + return _textwrap.fill( + text, width, initial_indent=indent, subsequent_indent=indent + ) def _get_help_string(self, action): return action.help @@ -454,7 +455,7 @@ class HelpFormatter(object): class RawDescriptionHelpFormatter(HelpFormatter): def _fill_text(self, text, width, indent): - return ''.join([indent + line for line in text.splitlines(True)]) + return "".join([indent + line for line in text.splitlines(True)]) class RawTextHelpFormatter(RawDescriptionHelpFormatter): @@ -467,11 +468,11 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter): def _get_help_string(self, action): help = action.help - if '%(default)' not in action.help: + if "%(default)" not in action.help: if action.default is not SUPPRESS: defaulting_nargs = [OPTIONAL, ZERO_OR_MORE] if action.option_strings or action.nargs in defaulting_nargs: - help += ' (default: %(default)s)' + help += " (default: %(default)s)" return help @@ -479,7 +480,7 @@ def _get_action_name(argument): if argument is None: return elif argument.option_strings: - return '/'.join(argument.option_strings) + return "/".join(argument.option_strings) elif argument.metavar not in (None, SUPPRESS): return argument.metavar elif argument.dest not in (None, SUPPRESS): @@ -497,10 +498,12 @@ class ArgumentError(Exception): def __str__(self): if self.argument_name is None: - format = '%(message)s' + format = "%(message)s" else: - format = 'argument %(argument_name)s: %(message)s' - return format % dict(message=self.message, argument_name=self.argument_name) + format = "argument %(argument_name)s: %(message)s" + return format % dict( + message=self.message, + argument_name=self.argument_name) class ArgumentTypeError(Exception): @@ -509,7 +512,19 @@ class ArgumentTypeError(Exception): class Action(_AttributeHolder): - def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None): + def __init__( + self, + option_strings, + dest, + nargs=None, + const=None, + default=None, + type=None, + choices=None, + required=False, + help=None, + metavar=None, + ): self.option_strings = option_strings self.dest = dest self.nargs = nargs @@ -522,31 +537,56 @@ class Action(_AttributeHolder): self.metavar = metavar def _get_kwargs(self): - names = ['option_strings', - 'dest', - 'nargs', - 'const', - 'default', - 'type', - 'choices', - 'help', - 'metavar'] + names = [ + "option_strings", + "dest", + "nargs", + "const", + "default", + "type", + "choices", + "help", + "metavar", + ] return [(name, getattr(self, name)) for name in names] def __call__(self, parser, namespace, values, option_string=None): - raise NotImplementedError(_('.__call__() not defined')) + raise NotImplementedError(_(".__call__() not defined")) class _StoreAction(Action): - def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None): + def __init__( + self, + option_strings, + dest, + nargs=None, + const=None, + default=None, + type=None, + choices=None, + required=False, + help=None, + metavar=None, + ): if nargs == 0: raise ValueError( - 'nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate') + "nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate" + ) if const is not None and nargs != OPTIONAL: - raise ValueError('nargs must be %r to supply const' % OPTIONAL) - super(_StoreAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, - default=default, type=type, choices=choices, required=required, help=help, metavar=metavar) + raise ValueError("nargs must be %r to supply const" % OPTIONAL) + super(_StoreAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=nargs, + const=const, + default=default, + type=type, + choices=choices, + required=required, + help=help, + metavar=metavar, + ) return def __call__(self, parser, namespace, values, option_string=None): @@ -555,9 +595,25 @@ class _StoreAction(Action): class _StoreConstAction(Action): - def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None): - super(_StoreConstAction, self).__init__(option_strings=option_strings, - dest=dest, nargs=0, const=const, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + const, + default=None, + required=False, + help=None, + metavar=None, + ): + super(_StoreConstAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=0, + const=const, + default=default, + required=required, + help=help, + ) def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, self.const) @@ -565,28 +621,75 @@ class _StoreConstAction(Action): class _StoreTrueAction(_StoreConstAction): - def __init__(self, option_strings, dest, default=False, required=False, help=None): - super(_StoreTrueAction, self).__init__(option_strings=option_strings, - dest=dest, const=True, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + default=False, + required=False, + help=None): + super(_StoreTrueAction, self).__init__( + option_strings=option_strings, + dest=dest, + const=True, + default=default, + required=required, + help=help, + ) class _StoreFalseAction(_StoreConstAction): - def __init__(self, option_strings, dest, default=True, required=False, help=None): - super(_StoreFalseAction, self).__init__(option_strings=option_strings, - dest=dest, const=False, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + default=True, + required=False, + help=None): + super(_StoreFalseAction, self).__init__( + option_strings=option_strings, + dest=dest, + const=False, + default=default, + required=required, + help=help, + ) class _AppendAction(Action): - def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None): + def __init__( + self, + option_strings, + dest, + nargs=None, + const=None, + default=None, + type=None, + choices=None, + required=False, + help=None, + metavar=None, + ): if nargs == 0: raise ValueError( - 'nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate') + "nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate" + ) if const is not None and nargs != OPTIONAL: - raise ValueError('nargs must be %r to supply const' % OPTIONAL) - super(_AppendAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, - default=default, type=type, choices=choices, required=required, help=help, metavar=metavar) + raise ValueError("nargs must be %r to supply const" % OPTIONAL) + super(_AppendAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=nargs, + const=const, + default=default, + type=type, + choices=choices, + required=required, + help=help, + metavar=metavar, + ) return def __call__(self, parser, namespace, values, option_string=None): @@ -597,9 +700,26 @@ class _AppendAction(Action): class _AppendConstAction(Action): - def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None): - super(_AppendConstAction, self).__init__(option_strings=option_strings, dest=dest, - nargs=0, const=const, default=default, required=required, help=help, metavar=metavar) + def __init__( + self, + option_strings, + dest, + const, + default=None, + required=False, + help=None, + metavar=None, + ): + super(_AppendConstAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=0, + const=const, + default=default, + required=required, + help=help, + metavar=metavar, + ) def __call__(self, parser, namespace, values, option_string=None): items = _copy.copy(_ensure_value(namespace, self.dest, [])) @@ -609,9 +729,21 @@ class _AppendConstAction(Action): class _CountAction(Action): - def __init__(self, option_strings, dest, default=None, required=False, help=None): - super(_CountAction, self).__init__(option_strings=option_strings, - dest=dest, nargs=0, default=default, required=required, help=help) + def __init__( + self, + option_strings, + dest, + default=None, + required=False, + help=None): + super(_CountAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=0, + default=default, + required=required, + help=help, + ) def __call__(self, parser, namespace, values, option_string=None): new_count = _ensure_value(namespace, self.dest, 0) + 1 @@ -620,9 +752,19 @@ class _CountAction(Action): class _HelpAction(Action): - def __init__(self, option_strings, dest=SUPPRESS, default=SUPPRESS, help=None): - super(_HelpAction, self).__init__(option_strings=option_strings, - dest=dest, default=default, nargs=0, help=help) + def __init__( + self, + option_strings, + dest=SUPPRESS, + default=SUPPRESS, + help=None): + super(_HelpAction, self).__init__( + option_strings=option_strings, + dest=dest, + default=default, + nargs=0, + help=help, + ) def __call__(self, parser, namespace, values, option_string=None): parser.print_help() @@ -631,9 +773,21 @@ class _HelpAction(Action): class _VersionAction(Action): - def __init__(self, option_strings, version=None, dest=SUPPRESS, default=SUPPRESS, help="show program's version number and exit"): - super(_VersionAction, self).__init__(option_strings=option_strings, - dest=dest, default=default, nargs=0, help=help) + def __init__( + self, + option_strings, + version=None, + dest=SUPPRESS, + default=SUPPRESS, + help="show program's version number and exit", + ): + super(_VersionAction, self).__init__( + option_strings=option_strings, + dest=dest, + default=default, + nargs=0, + help=help, + ) self.version = version def __call__(self, parser, namespace, values, option_string=None): @@ -654,19 +808,32 @@ class _SubParsersAction(Action): sup = super(_SubParsersAction._ChoicesPseudoAction, self) sup.__init__(option_strings=[], dest=name, help=help) - def __init__(self, option_strings, prog, parser_class, dest=SUPPRESS, help=None, metavar=None): + def __init__( + self, + option_strings, + prog, + parser_class, + dest=SUPPRESS, + help=None, + metavar=None): self._prog_prefix = prog self._parser_class = parser_class self._name_parser_map = _collections.OrderedDict() self._choices_actions = [] - super(_SubParsersAction, self).__init__(option_strings=option_strings, dest=dest, - nargs=PARSER, choices=self._name_parser_map, help=help, metavar=metavar) + super(_SubParsersAction, self).__init__( + option_strings=option_strings, + dest=dest, + nargs=PARSER, + choices=self._name_parser_map, + help=help, + metavar=metavar, + ) def add_parser(self, name, **kwargs): - if kwargs.get('prog') is None: - kwargs['prog'] = '%s %s' % (self._prog_prefix, name) - if 'help' in kwargs: - help = kwargs.pop('help') + if kwargs.get("prog") is None: + kwargs["prog"] = "%s %s" % (self._prog_prefix, name) + if "help" in kwargs: + help = kwargs.pop("help") choice_action = self._ChoicesPseudoAction(name, help) self._choices_actions.append(choice_action) parser = self._parser_class(**kwargs) @@ -684,8 +851,8 @@ class _SubParsersAction(Action): try: parser = self._name_parser_map[parser_name] except KeyError: - tup = (parser_name, ', '.join(self._name_parser_map)) - msg = _('unknown parser %r (choices: %s)') % tup + tup = (parser_name, ", ".join(self._name_parser_map)) + msg = _("unknown parser %r (choices: %s)") % tup raise ArgumentError(self, msg) namespace, arg_strings = parser.parse_known_args( @@ -697,15 +864,15 @@ class _SubParsersAction(Action): class FileType(object): - def __init__(self, mode='r', bufsize=-1): + def __init__(self, mode="r", bufsize=-1): self._mode = mode self._bufsize = bufsize def __call__(self, string): - if string == '-': - if 'r' in self._mode: + if string == "-": + if "r" in self._mode: return _sys.stdin - if 'w' in self._mode: + if "w" in self._mode: return _sys.stdout msg = _('argument "-" with mode %r') % self._mode raise ValueError(msg) @@ -717,8 +884,8 @@ class FileType(object): def __repr__(self): args = (self._mode, self._bufsize) - args_str = ', '.join((repr(arg) for arg in args if arg != -1)) - return '%s(%s)' % (type(self).__name__, args_str) + args_str = ", ".join((repr(arg) for arg in args if arg != -1)) + return "%s(%s)" % (type(self).__name__, args_str) class Namespace(_AttributeHolder): @@ -741,31 +908,36 @@ class Namespace(_AttributeHolder): class _ActionsContainer(object): - def __init__(self, description, prefix_chars, argument_default, conflict_handler): + def __init__( + self, + description, + prefix_chars, + argument_default, + conflict_handler): super(_ActionsContainer, self).__init__() self.description = description self.argument_default = argument_default self.prefix_chars = prefix_chars self.conflict_handler = conflict_handler self._registries = {} - self.register('action', None, _StoreAction) - self.register('action', 'store', _StoreAction) - self.register('action', 'store_const', _StoreConstAction) - self.register('action', 'store_true', _StoreTrueAction) - self.register('action', 'store_false', _StoreFalseAction) - self.register('action', 'append', _AppendAction) - self.register('action', 'append_const', _AppendConstAction) - self.register('action', 'count', _CountAction) - self.register('action', 'help', _HelpAction) - self.register('action', 'version', _VersionAction) - self.register('action', 'parsers', _SubParsersAction) + self.register("action", None, _StoreAction) + self.register("action", "store", _StoreAction) + self.register("action", "store_const", _StoreConstAction) + self.register("action", "store_true", _StoreTrueAction) + self.register("action", "store_false", _StoreFalseAction) + self.register("action", "append", _AppendAction) + self.register("action", "append_const", _AppendConstAction) + self.register("action", "count", _CountAction) + self.register("action", "help", _HelpAction) + self.register("action", "version", _VersionAction) + self.register("action", "parsers", _SubParsersAction) self._get_handler() self._actions = [] self._option_string_actions = {} self._action_groups = [] self._mutually_exclusive_groups = [] self._defaults = {} - self._negative_number_matcher = _re.compile('^-\\d+$|^-\\d*\\.\\d+$') + self._negative_number_matcher = _re.compile("^-\\d+$|^-\\d*\\.\\d+$") self._has_negative_number_optionals = [] return @@ -792,30 +964,30 @@ class _ActionsContainer(object): def add_argument(self, *args, **kwargs): chars = self.prefix_chars if not args or len(args) == 1 and args[0][0] not in chars: - if args and 'dest' in kwargs: - raise ValueError('dest supplied twice for positional argument') + if args and "dest" in kwargs: + raise ValueError("dest supplied twice for positional argument") kwargs = self._get_positional_kwargs(*args, **kwargs) else: kwargs = self._get_optional_kwargs(*args, **kwargs) - if 'default' not in kwargs: - dest = kwargs['dest'] + if "default" not in kwargs: + dest = kwargs["dest"] if dest in self._defaults: - kwargs['default'] = self._defaults[dest] + kwargs["default"] = self._defaults[dest] elif self.argument_default is not None: - kwargs['default'] = self.argument_default + kwargs["default"] = self.argument_default action_class = self._pop_action_class(kwargs) if not _callable(action_class): raise ValueError('unknown action "%s"' % (action_class,)) action = action_class(**kwargs) - type_func = self._registry_get('type', action.type, action.type) + type_func = self._registry_get("type", action.type, action.type) if not _callable(type_func): - raise ValueError('%r is not callable' % (type_func,)) - if hasattr(self, '_get_formatter'): + raise ValueError("%r is not callable" % (type_func,)) + if hasattr(self, "_get_formatter"): try: self._get_formatter()._format_args(action, None) except TypeError: raise ValueError( - 'length of metavar tuple does not match nargs') + "length of metavar tuple does not match nargs") return self._add_action(action) @@ -850,7 +1022,7 @@ class _ActionsContainer(object): title_group_map = {} for group in self._action_groups: if group.title in title_group_map: - msg = _('cannot merge actions - two groups are named %r') + msg = _("cannot merge actions - two groups are named %r") raise ValueError(msg % group.title) title_group_map[group.title] = group @@ -858,7 +1030,10 @@ class _ActionsContainer(object): for group in container._action_groups: if group.title not in title_group_map: title_group_map[group.title] = self.add_argument_group( - title=group.title, description=group.description, conflict_handler=group.conflict_handler) + title=group.title, + description=group.description, + conflict_handler=group.conflict_handler, + ) for action in group._group_actions: group_map[action] = title_group_map[group.title] @@ -872,13 +1047,13 @@ class _ActionsContainer(object): group_map.get(action, self)._add_action(action) def _get_positional_kwargs(self, dest, **kwargs): - if 'required' in kwargs: + if "required" in kwargs: msg = _("'required' is an invalid argument for positionals") raise TypeError(msg) - if kwargs.get('nargs') not in [OPTIONAL, ZERO_OR_MORE]: - kwargs['required'] = True - if kwargs.get('nargs') == ZERO_OR_MORE and 'default' not in kwargs: - kwargs['required'] = True + if kwargs.get("nargs") not in [OPTIONAL, ZERO_OR_MORE]: + kwargs["required"] = True + if kwargs.get("nargs") == ZERO_OR_MORE and "default" not in kwargs: + kwargs["required"] = True return dict(kwargs, dest=dest, option_strings=[]) def _get_optional_kwargs(self, *args, **kwargs): @@ -886,7 +1061,7 @@ class _ActionsContainer(object): long_option_strings = [] for option_string in args: if option_string[0] not in self.prefix_chars: - msg = _('invalid option string %r: must start with a character %r') + msg = _("invalid option string %r: must start with a character %r") tup = (option_string, self.prefix_chars) raise ValueError(msg % tup) option_strings.append(option_string) @@ -895,7 +1070,7 @@ class _ActionsContainer(object): if option_string[1] in self.prefix_chars: long_option_strings.append(option_string) - dest = kwargs.pop('dest', None) + dest = kwargs.pop("dest", None) if dest is None: if long_option_strings: dest_option_string = long_option_strings[0] @@ -903,21 +1078,21 @@ class _ActionsContainer(object): dest_option_string = option_strings[0] dest = dest_option_string.lstrip(self.prefix_chars) if not dest: - msg = _('dest= is required for options like %r') + msg = _("dest= is required for options like %r") raise ValueError(msg % option_string) - dest = dest.replace('-', '_') + dest = dest.replace("-", "_") return dict(kwargs, dest=dest, option_strings=option_strings) def _pop_action_class(self, kwargs, default=None): - action = kwargs.pop('action', default) - return self._registry_get('action', action, action) + action = kwargs.pop("action", default) + return self._registry_get("action", action, action) def _get_handler(self): - handler_func_name = '_handle_conflict_%s' % self.conflict_handler + handler_func_name = "_handle_conflict_%s" % self.conflict_handler try: return getattr(self, handler_func_name) except AttributeError: - msg = _('invalid conflict_resolution value: %r') + msg = _("invalid conflict_resolution value: %r") raise ValueError(msg % self.conflict_handler) def _check_conflict(self, action): @@ -932,9 +1107,10 @@ class _ActionsContainer(object): conflict_handler(action, confl_optionals) def _handle_conflict_error(self, action, conflicting_actions): - message = _('conflicting option string(s): %s') - conflict_string = ', '.join( - [option_string for option_string, action in conflicting_actions]) + message = _("conflicting option string(s): %s") + conflict_string = ", ".join( + [option_string for option_string, action in conflicting_actions] + ) raise ArgumentError(action, message % conflict_string) def _handle_conflict_resolve(self, action, conflicting_actions): @@ -951,9 +1127,9 @@ class _ArgumentGroup(_ActionsContainer): def __init__(self, container, title=None, description=None, **kwargs): update = kwargs.setdefault - update('conflict_handler', container.conflict_handler) - update('prefix_chars', container.prefix_chars) - update('argument_default', container.argument_default) + update("conflict_handler", container.conflict_handler) + update("prefix_chars", container.prefix_chars) + update("argument_default", container.argument_default) super_init = super(_ArgumentGroup, self).__init__ super_init(description=description, **kwargs) self.title = title @@ -984,7 +1160,7 @@ class _MutuallyExclusiveGroup(_ArgumentGroup): def _add_action(self, action): if action.required: - msg = _('mutually exclusive arguments must be optional') + msg = _("mutually exclusive arguments must be optional") raise ValueError(msg) action = self._container._add_action(action) self._group_actions.append(action) @@ -997,14 +1173,35 @@ class _MutuallyExclusiveGroup(_ArgumentGroup): class ArgumentParser(_AttributeHolder, _ActionsContainer): - def __init__(self, prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True): + def __init__( + self, + prog=None, + usage=None, + description=None, + epilog=None, + version=None, + parents=[], + formatter_class=HelpFormatter, + prefix_chars="-", + fromfile_prefix_chars=None, + argument_default=None, + conflict_handler="error", + add_help=True, + ): if version is not None: import warnings + warnings.warn( - 'The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', DeprecationWarning) + 'The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', + DeprecationWarning, + ) superinit = super(ArgumentParser, self).__init__ - superinit(description=description, prefix_chars=prefix_chars, - argument_default=argument_default, conflict_handler=conflict_handler) + superinit( + description=description, + prefix_chars=prefix_chars, + argument_default=argument_default, + conflict_handler=conflict_handler, + ) if prog is None: prog = _os.path.basename(_sys.argv[0]) self.prog = prog @@ -1015,21 +1212,32 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): self.fromfile_prefix_chars = fromfile_prefix_chars self.add_help = add_help add_group = self.add_argument_group - self._positionals = add_group(_('positional arguments')) - self._optionals = add_group(_('optional arguments')) + self._positionals = add_group(_("positional arguments")) + self._optionals = add_group(_("optional arguments")) self._subparsers = None def identity(string): return string - self.register('type', None, identity) - default_prefix = '-' if '-' in prefix_chars else prefix_chars[0] + self.register("type", None, identity) + default_prefix = "-" if "-" in prefix_chars else prefix_chars[0] if self.add_help: - self.add_argument(default_prefix + 'h', default_prefix * 2 + 'help', - action='help', default=SUPPRESS, help=_('show this help message and exit')) + self.add_argument( + default_prefix + "h", + default_prefix * 2 + "help", + action="help", + default=SUPPRESS, + help=_("show this help message and exit"), + ) if self.version: - self.add_argument(default_prefix + 'v', default_prefix * 2 + 'version', action='version', - default=SUPPRESS, version=self.version, help=_("show program's version number and exit")) + self.add_argument( + default_prefix + "v", + default_prefix * 2 + "version", + action="version", + default=SUPPRESS, + version=self.version, + help=_("show program's version number and exit"), + ) for parent in parents: self._add_container_actions(parent) try: @@ -1042,32 +1250,34 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): return def _get_kwargs(self): - names = ['prog', - 'usage', - 'description', - 'version', - 'formatter_class', - 'conflict_handler', - 'add_help'] + names = [ + "prog", + "usage", + "description", + "version", + "formatter_class", + "conflict_handler", + "add_help", + ] return [(name, getattr(self, name)) for name in names] def add_subparsers(self, **kwargs): if self._subparsers is not None: - self.error(_('cannot have multiple subparser arguments')) - kwargs.setdefault('parser_class', type(self)) - if 'title' in kwargs or 'description' in kwargs: - title = _(kwargs.pop('title', 'subcommands')) - description = _(kwargs.pop('description', None)) + self.error(_("cannot have multiple subparser arguments")) + kwargs.setdefault("parser_class", type(self)) + if "title" in kwargs or "description" in kwargs: + title = _(kwargs.pop("title", "subcommands")) + description = _(kwargs.pop("description", None)) self._subparsers = self.add_argument_group(title, description) else: self._subparsers = self._positionals - if kwargs.get('prog') is None: + if kwargs.get("prog") is None: formatter = self._get_formatter() positionals = self._get_positional_actions() groups = self._mutually_exclusive_groups - formatter.add_usage(self.usage, positionals, groups, '') - kwargs['prog'] = formatter.format_help().strip() - parsers_class = self._pop_action_class(kwargs, 'parsers') + formatter.add_usage(self.usage, positionals, groups, "") + kwargs["prog"] = formatter.format_help().strip() + parsers_class = self._pop_action_class(kwargs, "parsers") action = parsers_class(option_strings=[], **kwargs) self._subparsers._add_action(action) return action @@ -1088,8 +1298,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, args=None, namespace=None): args, argv = self.parse_known_args(args, namespace) if argv: - msg = _('unrecognized arguments: %s') - self.error(msg % ' '.join(argv)) + msg = _("unrecognized arguments: %s") + self.error(msg % " ".join(argv)) return args def parse_known_args(self, args=None, namespace=None): @@ -1137,21 +1347,21 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): arg_string_pattern_parts = [] arg_strings_iter = iter(arg_strings) for i, arg_string in enumerate(arg_strings_iter): - if arg_string == '--': - arg_string_pattern_parts.append('-') + if arg_string == "--": + arg_string_pattern_parts.append("-") for arg_string in arg_strings_iter: - arg_string_pattern_parts.append('A') + arg_string_pattern_parts.append("A") else: option_tuple = self._parse_optional(arg_string) if option_tuple is None: - pattern = 'A' + pattern = "A" else: option_string_indices[i] = option_tuple - pattern = 'O' + pattern = "O" arg_string_pattern_parts.append(pattern) - arg_strings_pattern = ''.join(arg_string_pattern_parts) + arg_strings_pattern = "".join(arg_string_pattern_parts) seen_actions = set() seen_non_default_actions = set() @@ -1162,7 +1372,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): seen_non_default_actions.add(action) for conflict_action in action_conflicts.get(action, []): if conflict_action in seen_non_default_actions: - msg = _('not allowed with argument %s') + msg = _("not allowed with argument %s") action_name = _get_action_name(conflict_action) raise ArgumentError(action, msg % action_name) @@ -1179,7 +1389,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): extras.append(arg_strings[start_index]) return start_index + 1 if explicit_arg is not None: - arg_count = match_argument(action, 'A') + arg_count = match_argument(action, "A") chars = self.prefix_chars if arg_count == 0 and option_string[1] not in chars: action_tuples.append((action, [], option_string)) @@ -1191,7 +1401,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): action = optionals_map[option_string] explicit_arg = new_explicit_arg else: - msg = _('ignored explicit argument %r') + msg = _("ignored explicit argument %r") raise ArgumentError(action, msg % explicit_arg) elif arg_count == 1: stop = start_index + 1 @@ -1199,7 +1409,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): action_tuples.append((action, args, option_string)) break else: - msg = _('ignored explicit argument %r') + msg = _("ignored explicit argument %r") raise ArgumentError(action, msg % explicit_arg) else: start = start_index + 1 @@ -1222,7 +1432,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): selected_pattern = arg_strings_pattern[start_index:] arg_counts = match_partial(positionals, selected_pattern) for action, arg_count in zip(positionals, arg_counts): - args = arg_strings[start_index:start_index + arg_count] + args = arg_strings[start_index: start_index + arg_count] start_index += arg_count take_action(action, args) @@ -1237,7 +1447,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): max_option_string_index = -1 while start_index <= max_option_string_index: next_option_string_index = min( - [index for index in option_string_indices if index >= start_index]) + [index for index in option_string_indices if index >= start_index] + ) if start_index != next_option_string_index: positionals_end_index = consume_positionals(start_index) if positionals_end_index > start_index: @@ -1254,12 +1465,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): stop_index = consume_positionals(start_index) extras.extend(arg_strings[stop_index:]) if positionals: - self.error(_('too few arguments')) + self.error(_("too few arguments")) for action in self._actions: if action.required: if action not in seen_actions: name = _get_action_name(action) - self.error(_('argument %s is required') % name) + self.error(_("argument %s is required") % name) for group in self._mutually_exclusive_groups: if group.required: @@ -1267,10 +1478,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): if action in seen_non_default_actions: break else: - names = [_get_action_name( - action) for action in group._group_actions if action.help is not SUPPRESS] - msg = _('one of the arguments %s is required') - self.error(msg % ' '.join(names)) + names = [ + _get_action_name(action) + for action in group._group_actions + if action.help is not SUPPRESS + ] + msg = _("one of the arguments %s is required") + self.error(msg % " ".join(names)) return (namespace, extras) @@ -1306,10 +1520,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): nargs_pattern = self._get_nargs_pattern(action) match = _re.match(nargs_pattern, arg_strings_pattern) if match is None: - nargs_errors = {None: _('expected one argument'), - OPTIONAL: _('expected at most one argument'), - ONE_OR_MORE: _('expected at least one argument')} - default = _('expected %s argument(s)') % action.nargs + nargs_errors = { + None: _("expected one argument"), + OPTIONAL: _("expected at most one argument"), + ONE_OR_MORE: _("expected at least one argument"), + } + default = _("expected %s argument(s)") % action.nargs msg = nargs_errors.get(action.nargs, default) raise ArgumentError(action, msg) return len(match.group(1)) @@ -1318,8 +1534,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): result = [] for i in range(len(actions), 0, -1): actions_slice = actions[:i] - pattern = ''.join([self._get_nargs_pattern(action) - for action in actions_slice]) + pattern = "".join( + [self._get_nargs_pattern(action) for action in actions_slice] + ) match = _re.match(pattern, arg_strings_pattern) if match is not None: result.extend([len(string) for string in match.groups()]) @@ -1338,24 +1555,28 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): elif len(arg_string) == 1: return None else: - if '=' in arg_string: - option_string, explicit_arg = arg_string.split('=', 1) + if "=" in arg_string: + option_string, explicit_arg = arg_string.split("=", 1) if option_string in self._option_string_actions: action = self._option_string_actions[option_string] return (action, option_string, explicit_arg) option_tuples = self._get_option_tuples(arg_string) if len(option_tuples) > 1: - options = ', '.join( - [option_string for action, option_string, explicit_arg in option_tuples]) + options = ", ".join( + [ + option_string + for action, option_string, explicit_arg in option_tuples + ] + ) tup = (arg_string, options) - self.error(_('ambiguous option: %s could match %s') % tup) + self.error(_("ambiguous option: %s could match %s") % tup) elif len(option_tuples) == 1: - option_tuple, = option_tuples + (option_tuple,) = option_tuples return option_tuple if self._negative_number_matcher.match(arg_string): if not self._has_negative_number_optionals: return None - if ' ' in arg_string: + if " " in arg_string: return None return (None, arg_string, None) return None @@ -1364,8 +1585,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): result = [] chars = self.prefix_chars if option_string[0] in chars and option_string[1] in chars: - if '=' in option_string: - option_prefix, explicit_arg = option_string.split('=', 1) + if "=" in option_string: + option_prefix, explicit_arg = option_string.split("=", 1) else: option_prefix = option_string explicit_arg = None @@ -1391,33 +1612,33 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): result.append(tup) else: - self.error(_('unexpected option string: %s') % option_string) + self.error(_("unexpected option string: %s") % option_string) return result def _get_nargs_pattern(self, action): nargs = action.nargs if nargs is None: - nargs_pattern = '(-*A-*)' + nargs_pattern = "(-*A-*)" elif nargs == OPTIONAL: - nargs_pattern = '(-*A?-*)' + nargs_pattern = "(-*A?-*)" elif nargs == ZERO_OR_MORE: - nargs_pattern = '(-*[A-]*)' + nargs_pattern = "(-*[A-]*)" elif nargs == ONE_OR_MORE: - nargs_pattern = '(-*A[A-]*)' + nargs_pattern = "(-*A[A-]*)" elif nargs == REMAINDER: - nargs_pattern = '([-AO]*)' + nargs_pattern = "([-AO]*)" elif nargs == PARSER: - nargs_pattern = '(-*A[-AO]*)' + nargs_pattern = "(-*A[-AO]*)" else: - nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs) + nargs_pattern = "(-*%s-*)" % "-*".join("A" * nargs) if action.option_strings: - nargs_pattern = nargs_pattern.replace('-*', '') - nargs_pattern = nargs_pattern.replace('-', '') + nargs_pattern = nargs_pattern.replace("-*", "") + nargs_pattern = nargs_pattern.replace("-", "") return nargs_pattern def _get_values(self, action, arg_strings): if action.nargs not in [PARSER, REMAINDER]: - arg_strings = [s for s in arg_strings if s != '--'] + arg_strings = [s for s in arg_strings if s != "--"] if not arg_strings and action.nargs == OPTIONAL: if action.option_strings: value = action.const @@ -1426,14 +1647,18 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): if isinstance(value, str): value = self._get_value(action, value) self._check_value(action, value) - elif not arg_strings and action.nargs == ZERO_OR_MORE and not action.option_strings: + elif ( + not arg_strings + and action.nargs == ZERO_OR_MORE + and not action.option_strings + ): if action.default is not None: value = action.default else: value = arg_strings self._check_value(action, value) elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]: - arg_string, = arg_strings + (arg_string,) = arg_strings value = self._get_value(action, arg_string) self._check_value(action, value) elif action.nargs == REMAINDER: @@ -1449,40 +1674,44 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): return value def _get_value(self, action, arg_string): - type_func = self._registry_get('type', action.type, action.type) + type_func = self._registry_get("type", action.type, action.type) if not _callable(type_func): - msg = _('%r is not callable') + msg = _("%r is not callable") raise ArgumentError(action, msg % type_func) try: result = type_func(arg_string) except ArgumentTypeError: - name = getattr(action.type, '__name__', repr(action.type)) + name = getattr(action.type, "__name__", repr(action.type)) msg = str(_sys.exc_info()[1]) raise ArgumentError(action, msg) except (TypeError, ValueError): - name = getattr(action.type, '__name__', repr(action.type)) - msg = _('invalid %s value: %r') + name = getattr(action.type, "__name__", repr(action.type)) + msg = _("invalid %s value: %r") raise ArgumentError(action, msg % (name, arg_string)) return result def _check_value(self, action, value): if action.choices is not None and value not in action.choices: - tup = (value, ', '.join(map(repr, action.choices))) - msg = _('invalid choice: %r (choose from %s)') % tup + tup = (value, ", ".join(map(repr, action.choices))) + msg = _("invalid choice: %r (choose from %s)") % tup raise ArgumentError(action, msg) return def format_usage(self): formatter = self._get_formatter() - formatter.add_usage(self.usage, self._actions, - self._mutually_exclusive_groups) + formatter.add_usage( + self.usage, + self._actions, + self._mutually_exclusive_groups) return formatter.format_help() def format_help(self): formatter = self._get_formatter() - formatter.add_usage(self.usage, self._actions, - self._mutually_exclusive_groups) + formatter.add_usage( + self.usage, + self._actions, + self._mutually_exclusive_groups) formatter.add_text(self.description) for action_group in self._action_groups: formatter.start_section(action_group.title) @@ -1495,8 +1724,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def format_version(self): import warnings + warnings.warn( - 'The format_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning) + 'The format_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', + DeprecationWarning, + ) formatter = self._get_formatter() formatter.add_text(self.version) return formatter.format_help() @@ -1518,8 +1750,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def print_version(self, file=None): import warnings + warnings.warn( - 'The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning) + 'The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', + DeprecationWarning, + ) self._print_message(self.format_version(), file) def _print_message(self, message, file=None): @@ -1536,4 +1771,4 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def error(self, message): self.print_usage(_sys.stderr) - self.exit(2, _('%s: error: %s\n') % (self.prog, message)) + self.exit(2, _("%s: error: %s\n") % (self.prog, message)) diff --git a/NeoBoot/ubi_reader_mips/ubi/__init__.py b/NeoBoot/ubi_reader_mips/ubi/__init__.py index d96b797..a24bcbb 100644 --- a/NeoBoot/ubi_reader_mips/ubi/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubi/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import re from ubi.volume import get_volumes from ubi.block import sort, get_blocks_in_list, extract_blocks @@ -16,7 +15,7 @@ class ubi: self._blocks = extract_blocks(self) self._block_count = len(self.blocks) if self._block_count <= 0: - raise Exception('No blocks found.') + raise Exception("No blocks found.") layout_list, data_list, int_vol_list, unknown_list = sort.by_type( self.blocks) self._layout_blocks_list = layout_list @@ -28,7 +27,8 @@ class ubi: self._leb_size = self.file.block_size - arbitrary_block.ec_hdr.data_offset layout_pairs = layout.group_pairs(self.blocks, self.layout_blocks_list) layout_infos = layout.associate_blocks( - self.blocks, layout_pairs, self.first_peb_num) + self.blocks, layout_pairs, self.first_peb_num + ) self._images = [] for i in range(0, len(layout_infos)): self._images.append(image(self.blocks, layout_infos[i])) @@ -96,14 +96,14 @@ class ubi: blocks = property(_get_blocks) - def display(self, tab=''): + def display(self, tab=""): display.ubi(self, tab) def get_peb_size(path): file_offset = 0 offsets = [] - f = open(path, 'rb') + f = open(path, "rb") f.seek(0, 2) file_size = f.tell() + 1 f.seek(0) @@ -125,7 +125,7 @@ def get_peb_size(path): for i in range(0, len(offsets)): try: diff = offsets[i] - offsets[i - 1] - except: + except BaseException: diff = offsets[i] if diff not in occurances: diff --git a/NeoBoot/ubi_reader_mips/ubi/block/__init__.py b/NeoBoot/ubi_reader_mips/ubi/block/__init__.py index 7593f97..54bfe37 100644 --- a/NeoBoot/ubi_reader_mips/ubi/block/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubi/block/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import re from ubi import display from ubi.defines import * @@ -18,7 +17,11 @@ class description(object): self.ec_hdr = extract_ec_hdr(block_buf[0:UBI_EC_HDR_SZ]) if not self.ec_hdr.errors: self.vid_hdr = extract_vid_hdr( - block_buf[self.ec_hdr.vid_hdr_offset:self.ec_hdr.vid_hdr_offset + UBI_VID_HDR_SZ]) + block_buf[ + self.ec_hdr.vid_hdr_offset: self.ec_hdr.vid_hdr_offset + + UBI_VID_HDR_SZ + ] + ) self.is_internal_vol = self.vid_hdr.vol_id >= UBI_INTERNAL_VOL_START if self.vid_hdr.vol_id >= UBI_INTERNAL_VOL_START: self.vtbl_recs = extract_vtbl_rec( @@ -29,9 +32,9 @@ class description(object): return def __repr__(self): - return 'Block: PEB# %s: LEB# %s' % (self.peb_num, self.leb_num) + return "Block: PEB# %s: LEB# %s" % (self.peb_num, self.leb_num) - def display(self, tab=''): + def display(self, tab=""): display.block(self, tab) @@ -45,7 +48,10 @@ def extract_blocks(ubi): ubi.file.seek(ubi.file.start_offset) peb_count = 0 cur_offset = 0 - for i in range(ubi.file.start_offset, ubi.file.end_offset, ubi.file.block_size): + for i in range( + ubi.file.start_offset, + ubi.file.end_offset, + ubi.file.block_size): buf = ubi.file.read(ubi.file.block_size) if buf.startswith(UBI_EC_HDR_MAGIC): blk = description(buf) diff --git a/NeoBoot/ubi_reader_mips/ubi/block/layout.py b/NeoBoot/ubi_reader_mips/ubi/block/layout.py index b61772d..c1b1cac 100644 --- a/NeoBoot/ubi_reader_mips/ubi/block/layout.py +++ b/NeoBoot/ubi_reader_mips/ubi/block/layout.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubi.block import sort diff --git a/NeoBoot/ubi_reader_mips/ubi/block/sort.py b/NeoBoot/ubi_reader_mips/ubi/block/sort.py index 6d495fd..43ac02e 100644 --- a/NeoBoot/ubi_reader_mips/ubi/block/sort.py +++ b/NeoBoot/ubi_reader_mips/ubi/block/sort.py @@ -1,4 +1,3 @@ -#!/usr/bin/python def list_by_list(blist, slist): slist_blocks = [] for block in blist: @@ -24,11 +23,11 @@ def by_range(blocks, block_range): def by_leb(blocks): slist_len = len(blocks) - slist = ['x'] * slist_len + slist = ["x"] * slist_len for block in blocks: if blocks[block].leb_num >= slist_len: add_elements = blocks[block].leb_num - slist_len + 1 - slist += ['x'] * add_elements + slist += ["x"] * add_elements slist_len = len(slist) slist[blocks[block].leb_num] = block @@ -78,7 +77,4 @@ def by_type(blocks, slist=None): else: unknown.append(i) - return (layout, - data, - int_vol, - unknown) + return (layout, data, int_vol, unknown) diff --git a/NeoBoot/ubi_reader_mips/ubi/defines.py b/NeoBoot/ubi_reader_mips/ubi/defines.py index 95d5ff7..c113b38 100644 --- a/NeoBoot/ubi_reader_mips/ubi/defines.py +++ b/NeoBoot/ubi_reader_mips/ubi/defines.py @@ -1,63 +1,64 @@ -#!/usr/bin/python import struct + UBI_CRC32_INIT = 4294967295 UBI_MAX_VOLUMES = 128 UBI_INTERNAL_VOL_START = 2147479551 -UBI_EC_HDR_MAGIC = 'UBI#' -EC_HDR_FORMAT = '>4sB3sQIII32sI' -EC_HDR_FIELDS = ['magic', - 'version', - 'padding', - 'ec', - 'vid_hdr_offset', - 'data_offset', - 'image_seq', - 'padding2', - 'hdr_crc'] +UBI_EC_HDR_MAGIC = "UBI#" +EC_HDR_FORMAT = ">4sB3sQIII32sI" +EC_HDR_FIELDS = [ + "magic", + "version", + "padding", + "ec", + "vid_hdr_offset", + "data_offset", + "image_seq", + "padding2", + "hdr_crc", +] UBI_EC_HDR_SZ = struct.calcsize(EC_HDR_FORMAT) -UBI_VID_HDR_MAGIC = 'UBI!' -VID_HDR_FORMAT = '>4sBBBBII4sIIII4sQ12sI' -VID_HDR_FIELDS = ['magic', - 'version', - 'vol_type', - 'copy_flag', - 'compat', - 'vol_id', - 'lnum', - 'padding', - 'data_size', - 'used_ebs', - 'data_pad', - 'data_crc', - 'padding2', - 'sqnum', - 'padding3', - 'hdr_crc'] +UBI_VID_HDR_MAGIC = "UBI!" +VID_HDR_FORMAT = ">4sBBBBII4sIIII4sQ12sI" +VID_HDR_FIELDS = [ + "magic", + "version", + "vol_type", + "copy_flag", + "compat", + "vol_id", + "lnum", + "padding", + "data_size", + "used_ebs", + "data_pad", + "data_crc", + "padding2", + "sqnum", + "padding3", + "hdr_crc", +] UBI_VID_HDR_SZ = struct.calcsize(VID_HDR_FORMAT) -VTBL_REC_FORMAT = '>IIIBBH128sB23sI' -VTBL_REC_FIELDS = ['reserved_pebs', - 'alignment', - 'data_pad', - 'vol_type', - 'upd_marker', - 'name_len', - 'name', - 'flags', - 'padding', - 'crc'] +VTBL_REC_FORMAT = ">IIIBBH128sB23sI" +VTBL_REC_FIELDS = [ + "reserved_pebs", + "alignment", + "data_pad", + "vol_type", + "upd_marker", + "name_len", + "name", + "flags", + "padding", + "crc", +] UBI_VTBL_REC_SZ = struct.calcsize(VTBL_REC_FORMAT) UBI_VID_DYNAMIC = 1 UBI_VID_STATIC = 2 -PRINT_VOL_TYPE_LIST = [0, 'dynamic', 'static'] +PRINT_VOL_TYPE_LIST = [0, "dynamic", "static"] UBI_VTBL_AUTORESIZE_FLG = 1 UBI_COMPAT_DELETE = 1 UBI_COMPAT_RO = 2 UBI_COMPAT_PRESERVE = 4 UBI_COMPAT_REJECT = 5 -PRINT_COMPAT_LIST = [0, - 'Delete', - 'Read Only', - 0, - 'Preserve', - 'Reject'] +PRINT_COMPAT_LIST = [0, "Delete", "Read Only", 0, "Preserve", "Reject"] FILE_CHUNK_SZ = 5242880 diff --git a/NeoBoot/ubi_reader_mips/ubi/display.py b/NeoBoot/ubi_reader_mips/ubi/display.py index 7c3342b..ad285ed 100644 --- a/NeoBoot/ubi_reader_mips/ubi/display.py +++ b/NeoBoot/ubi_reader_mips/ubi/display.py @@ -1,109 +1,111 @@ -#!/usr/bin/python from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG -def ubi(ubi, tab=''): - print(('%sUBI File' % tab)) - print(('%s---------------------' % tab)) - print(('\t%sMin I/O: %s' % (tab, ubi.min_io_size))) - print(('\t%sLEB Size: %s' % (tab, ubi.leb_size))) - print(('\t%sPEB Size: %s' % (tab, ubi.peb_size))) - print(('\t%sTotal Block Count: %s' % (tab, ubi.block_count))) - print(('\t%sData Block Count: %s' % (tab, len(ubi.data_blocks_list)))) - print(('\t%sLayout Block Count: %s' % (tab, len(ubi.layout_blocks_list)))) - print(('\t%sInternal Volume Block Count: %s' % (tab, len(ubi.int_vol_blocks_list)))) - print(('\t%sUnknown Block Count: %s' % (tab, len(ubi.unknown_blocks_list)))) - print(('\t%sFirst UBI PEB Number: %s' % (tab, ubi.first_peb_num))) +def ubi(ubi, tab=""): + print(("%sUBI File" % tab)) + print(("%s---------------------" % tab)) + print(("\t%sMin I/O: %s" % (tab, ubi.min_io_size))) + print(("\t%sLEB Size: %s" % (tab, ubi.leb_size))) + print(("\t%sPEB Size: %s" % (tab, ubi.peb_size))) + print(("\t%sTotal Block Count: %s" % (tab, ubi.block_count))) + print(("\t%sData Block Count: %s" % (tab, len(ubi.data_blocks_list)))) + print(("\t%sLayout Block Count: %s" % (tab, len(ubi.layout_blocks_list)))) + print(("\t%sInternal Volume Block Count: %s" % + (tab, len(ubi.int_vol_blocks_list)))) + print(("\t%sUnknown Block Count: %s" % + (tab, len(ubi.unknown_blocks_list)))) + print(("\t%sFirst UBI PEB Number: %s" % (tab, ubi.first_peb_num))) -def image(image, tab=''): - print(('%s%s' % (tab, image))) - print(('%s---------------------' % tab)) - print(('\t%sImage Sequence Num: %s' % (tab, image.image_seq))) +def image(image, tab=""): + print(("%s%s" % (tab, image))) + print(("%s---------------------" % tab)) + print(("\t%sImage Sequence Num: %s" % (tab, image.image_seq))) for volume in image.volumes: - print(('\t%sVolume Name:%s' % (tab, volume))) + print(("\t%sVolume Name:%s" % (tab, volume))) - print(('\t%sPEB Range: %s - %s' % (tab, image.peb_range[0], image.peb_range[1]))) + print(("\t%sPEB Range: %s - %s" % + (tab, image.peb_range[0], image.peb_range[1]))) -def volume(volume, tab=''): - print(('%s%s' % (tab, volume))) - print(('%s---------------------' % tab)) - print(('\t%sVol ID: %s' % (tab, volume.vol_id))) - print(('\t%sName: %s' % (tab, volume.name))) - print(('\t%sBlock Count: %s' % (tab, volume.block_count))) - print('\n') - print(('\t%sVolume Record' % tab)) - print(('\t%s---------------------' % tab)) - vol_rec(volume.vol_rec, '\t\t%s' % tab) - print('\n') +def volume(volume, tab=""): + print(("%s%s" % (tab, volume))) + print(("%s---------------------" % tab)) + print(("\t%sVol ID: %s" % (tab, volume.vol_id))) + print(("\t%sName: %s" % (tab, volume.name))) + print(("\t%sBlock Count: %s" % (tab, volume.block_count))) + print("\n") + print(("\t%sVolume Record" % tab)) + print(("\t%s---------------------" % tab)) + vol_rec(volume.vol_rec, "\t\t%s" % tab) + print("\n") -def block(block, tab='\t'): - print(('%s%s' % (tab, block))) - print(('%s---------------------' % tab)) - print(('\t%sFile Offset: %s' % (tab, block.file_offset))) - print(('\t%sPEB #: %s' % (tab, block.peb_num))) - print(('\t%sLEB #: %s' % (tab, block.leb_num))) - print(('\t%sBlock Size: %s' % (tab, block.size))) - print(('\t%sInternal Volume: %s' % (tab, block.is_internal_vol))) - print(('\t%sIs Volume Table: %s' % (tab, block.is_vtbl))) - print(('\t%sIs Valid: %s' % (tab, block.is_valid))) +def block(block, tab="\t"): + print(("%s%s" % (tab, block))) + print(("%s---------------------" % tab)) + print(("\t%sFile Offset: %s" % (tab, block.file_offset))) + print(("\t%sPEB #: %s" % (tab, block.peb_num))) + print(("\t%sLEB #: %s" % (tab, block.leb_num))) + print(("\t%sBlock Size: %s" % (tab, block.size))) + print(("\t%sInternal Volume: %s" % (tab, block.is_internal_vol))) + print(("\t%sIs Volume Table: %s" % (tab, block.is_vtbl))) + print(("\t%sIs Valid: %s" % (tab, block.is_valid))) if not block.ec_hdr.errors: - print('\n') - print(('\t%sErase Count Header' % tab)) - print(('\t%s---------------------' % tab)) - ec_hdr(block.ec_hdr, '\t\t%s' % tab) + print("\n") + print(("\t%sErase Count Header" % tab)) + print(("\t%s---------------------" % tab)) + ec_hdr(block.ec_hdr, "\t\t%s" % tab) if block.vid_hdr and not block.vid_hdr.errors: - print('\n') - print(('\t%sVID Header Header' % tab)) - print(('\t%s---------------------' % tab)) - vid_hdr(block.vid_hdr, '\t\t%s' % tab) + print("\n") + print(("\t%sVID Header Header" % tab)) + print(("\t%s---------------------" % tab)) + vid_hdr(block.vid_hdr, "\t\t%s" % tab) if block.vtbl_recs: - print('\n') - print(('\t%sVolume Records' % tab)) - print(('\t%s---------------------' % tab)) + print("\n") + print(("\t%sVolume Records" % tab)) + print(("\t%s---------------------" % tab)) for vol in block.vtbl_recs: - vol_rec(vol, '\t\t%s' % tab) + vol_rec(vol, "\t\t%s" % tab) - print('\n') + print("\n") -def ec_hdr(ec_hdr, tab=''): +def ec_hdr(ec_hdr, tab=""): for key, value in ec_hdr: - if key == 'errors': - value = ','.join(value) - print(('%s%s: %r' % (tab, key, value))) + if key == "errors": + value = ",".join(value) + print(("%s%s: %r" % (tab, key, value))) -def vid_hdr(vid_hdr, tab=''): +def vid_hdr(vid_hdr, tab=""): for key, value in vid_hdr: - if key == 'errors': - value = ','.join(value) - elif key == 'compat': + if key == "errors": + value = ",".join(value) + elif key == "compat": if value in PRINT_COMPAT_LIST: value = PRINT_COMPAT_LIST[value] else: value = -1 - elif key == 'vol_type': + elif key == "vol_type": if value < len(PRINT_VOL_TYPE_LIST): value = PRINT_VOL_TYPE_LIST[value] else: value = -1 - print(('%s%s: %s' % (tab, key, value))) + print(("%s%s: %s" % (tab, key, value))) -def vol_rec(vol_rec, tab=''): +def vol_rec(vol_rec, tab=""): for key, value in vol_rec: - if key == 'errors': - value = ','.join(value) - elif key == 'vol_type': + if key == "errors": + value = ",".join(value) + elif key == "vol_type": if value < len(PRINT_VOL_TYPE_LIST): value = PRINT_VOL_TYPE_LIST[value] else: value = -1 - elif key == 'flags' and value == UBI_VTBL_AUTORESIZE_FLG: - value = 'autoresize' - elif key == 'name': - value = value.strip('\x00') - print(('%s%s: %s' % (tab, key, value))) + elif key == "flags" and value == UBI_VTBL_AUTORESIZE_FLG: + value = "autoresize" + elif key == "name": + value = value.strip("\x00") + print(("%s%s: %s" % (tab, key, value))) diff --git a/NeoBoot/ubi_reader_mips/ubi/headers/__init__.py b/NeoBoot/ubi_reader_mips/ubi/headers/__init__.py index 1ee4d07..698fd6d 100644 --- a/NeoBoot/ubi_reader_mips/ubi/headers/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubi/headers/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import struct from ubi.defines import * from ubi.headers import errors @@ -12,14 +11,14 @@ class ec_hdr(object): for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) + setattr(self, "errors", []) def __repr__(self): - return 'Error Count Header' + return "Error Count Header" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -31,15 +30,15 @@ class vid_hdr(object): for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) + setattr(self, "errors", []) def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) def __repr__(self): - return 'VID Header' + return "VID Header" class vtbl_rec(object): @@ -50,15 +49,15 @@ class vtbl_rec(object): for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) - setattr(self, 'rec_index', -1) + setattr(self, "errors", []) + setattr(self, "rec_index", -1) def __repr__(self): - return 'Volume Table Record: %s' % getattr(self, 'name') + return "Volume Table Record: %s" % getattr(self, "name") def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -79,10 +78,10 @@ def extract_vid_hdr(buf): def extract_vtbl_rec(buf): data_buf = buf vtbl_recs = [] - vtbl_rec_ret = '' + vtbl_rec_ret = "" for i in range(0, UBI_MAX_VOLUMES): offset = i * UBI_VTBL_REC_SZ - vtbl_rec_buf = data_buf[offset:offset + UBI_VTBL_REC_SZ] + vtbl_rec_buf = data_buf[offset: offset + UBI_VTBL_REC_SZ] if len(vtbl_rec_buf) == UBI_VTBL_REC_SZ: vtbl_rec_ret = vtbl_rec(vtbl_rec_buf) errors.vtbl_rec(vtbl_rec_ret, vtbl_rec_buf) diff --git a/NeoBoot/ubi_reader_mips/ubi/headers/errors.py b/NeoBoot/ubi_reader_mips/ubi/headers/errors.py index bc502b4..608235b 100644 --- a/NeoBoot/ubi_reader_mips/ubi/headers/errors.py +++ b/NeoBoot/ubi_reader_mips/ubi/headers/errors.py @@ -1,29 +1,28 @@ -#!/usr/bin/python from zlib import crc32 from ubi.defines import * def ec_hdr(ec_hdr, buf): if ec_hdr.hdr_crc != ~crc32(buf[:-4]) & 4294967295: - ec_hdr.errors.append('crc') + ec_hdr.errors.append("crc") return ec_hdr def vid_hdr(vid_hdr, buf): vid_hdr.errors = [] if vid_hdr.hdr_crc != ~crc32(buf[:-4]) & 4294967295: - vid_hdr.errors.append('crc') + vid_hdr.errors.append("crc") return vid_hdr def vtbl_rec(vtbl_rec, buf): likely_vtbl = True - if vtbl_rec.name_len != len(vtbl_rec.name.strip('\x00')): + if vtbl_rec.name_len != len(vtbl_rec.name.strip("\x00")): likely_vtbl = False elif vtbl_rec.vol_type not in (1, 2): likely_vtbl = False if vtbl_rec.crc != ~crc32(buf[:-4]) & 4294967295: - vtbl_rec.errors.append('crc') + vtbl_rec.errors.append("crc") if not likely_vtbl: - vtbl_rec.errors = ['False'] + vtbl_rec.errors = ["False"] return vtbl_rec diff --git a/NeoBoot/ubi_reader_mips/ubi/image.py b/NeoBoot/ubi_reader_mips/ubi/image.py index b732fe0..0ed99ae 100644 --- a/NeoBoot/ubi_reader_mips/ubi/image.py +++ b/NeoBoot/ubi_reader_mips/ubi/image.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubi import display from ubi.volume import get_volumes from ubi.block import get_blocks_in_list @@ -15,10 +14,12 @@ class description(object): self._volumes = get_volumes(blocks, layout_info) def __repr__(self): - return 'Image: %s' % self.image_seq + return "Image: %s" % self.image_seq def get_blocks(self, blocks): - return get_blocks_in_list(blocks, list(range(self._start_peb, self._end_peb + 1))) + return get_blocks_in_list( + blocks, list(range(self._start_peb, self._end_peb + 1)) + ) def _get_peb_range(self): return [self._start_peb, self._end_peb] @@ -35,5 +36,5 @@ class description(object): volumes = property(_get_volumes) - def display(self, tab=''): + def display(self, tab=""): display.image(self, tab) diff --git a/NeoBoot/ubi_reader_mips/ubi/volume/__init__.py b/NeoBoot/ubi_reader_mips/ubi/volume/__init__.py index f046055..221a7cd 100644 --- a/NeoBoot/ubi_reader_mips/ubi/volume/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubi/volume/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubi import display from ubi.block import sort, get_blocks_in_list @@ -12,7 +11,7 @@ class description(object): self._block_list = block_list def __repr__(self): - return 'Volume: %s' % self.name + return "Volume: %s" % self.name def _get_name(self): return self._name @@ -42,15 +41,15 @@ class description(object): def get_blocks(self, blocks): return get_blocks_in_list(blocks, self._block_list) - def display(self, tab=''): + def display(self, tab=""): display.volume(self, tab) def reader(self, ubi): last_leb = 0 for block in sort.by_leb(self.get_blocks(ubi.blocks)): - if block == 'x': + if block == "x": last_leb += 1 - yield '\xff' * ubi.leb_size + yield "\xff" * ubi.leb_size else: last_leb += 1 yield ubi.file.read_block_data(ubi.blocks[block]) @@ -60,10 +59,11 @@ def get_volumes(blocks, layout_info): volumes = {} vol_blocks_lists = sort.by_vol_id(blocks, layout_info[2]) for vol_rec in blocks[layout_info[0]].vtbl_recs: - vol_name = vol_rec.name.strip('\x00') + vol_name = vol_rec.name.strip("\x00") if vol_rec.rec_index not in vol_blocks_lists: vol_blocks_lists[vol_rec.rec_index] = [] volumes[vol_name] = description( - vol_rec.rec_index, vol_rec, vol_blocks_lists[vol_rec.rec_index]) + vol_rec.rec_index, vol_rec, vol_blocks_lists[vol_rec.rec_index] + ) return volumes diff --git a/NeoBoot/ubi_reader_mips/ubi_extract_files.py b/NeoBoot/ubi_reader_mips/ubi_extract_files.py index 2ffd2d1..2056d77 100644 --- a/NeoBoot/ubi_reader_mips/ubi_extract_files.py +++ b/NeoBoot/ubi_reader_mips/ubi_extract_files.py @@ -1,34 +1,55 @@ -#!/usr/bin/python - import os import sys + try: import argparse -except: +except BaseException: import argparse_neo from ubi import ubi, get_peb_size from ubifs import ubifs from ubi_io import ubi_file, leb_virtual_file from ui.common import extract_files, output_dir -if __name__ == '__main__': - description = 'Extract contents of UBI image.' - usage = 'ubi_extract_files.py [options] filepath' + +if __name__ == "__main__": + description = "Extract contents of UBI image." + usage = "ubi_extract_files.py [options] filepath" try: parser = argparse.ArgumentParser(usage=usage, description=description) - except: + except BaseException: parser = argparse_neo.ArgumentParser( usage=usage, description=description) - parser.add_argument('-l', '--log-file', dest='logpath', - help='Log output to file output/LOGPATH. (default: ubifs_output.log)') - parser.add_argument('-k', '--keep-permissions', action='store_true', dest='permissions', - help='Maintain file permissions, requires running as root. (default: False)') - parser.add_argument('-q', '--quiet', action='store_true', dest='quiet', - help='Suppress warnings and non-fatal errors. (default: False)') - parser.add_argument('-p', '--peb-size', type=int, - dest='block_size', help='Specify PEB size.') - parser.add_argument('-o', '--output-dir', dest='output_path', - help='Specify output directory path.') - parser.add_argument('filepath', help='File to extract contents of.') + parser.add_argument( + "-l", + "--log-file", + dest="logpath", + help="Log output to file output/LOGPATH. (default: ubifs_output.log)", + ) + parser.add_argument( + "-k", + "--keep-permissions", + action="store_true", + dest="permissions", + help="Maintain file permissions, requires running as root. (default: False)", + ) + parser.add_argument( + "-q", + "--quiet", + action="store_true", + dest="quiet", + help="Suppress warnings and non-fatal errors. (default: False)", + ) + parser.add_argument( + "-p", + "--peb-size", + type=int, + dest="block_size", + help="Specify PEB size.") + parser.add_argument( + "-o", + "--output-dir", + dest="output_path", + help="Specify output directory path.") + parser.add_argument("filepath", help="File to extract contents of.") if len(sys.argv) == 1: parser.print_help() sys.exit() @@ -65,13 +86,14 @@ if __name__ == '__main__': os.makedirs(vol_out_path) elif os.listdir(vol_out_path): parser.error( - 'Volume output directory is not empty. %s' % vol_out_path) + "Volume output directory is not empty. %s" % + vol_out_path) ufsfile = leb_virtual_file(uubi, image.volumes[volume]) uubifs = ubifs(ufsfile) uubifs.log.log_file = log_file uubifs.log.log_to_file = log_to_file uubifs.log.quiet = quiet - print(('Writing to: %s' % vol_out_path)) + print(("Writing to: %s" % vol_out_path)) extract_files(uubifs, vol_out_path, perms) sys.exit(0) diff --git a/NeoBoot/ubi_reader_mips/ubi_io/__init__.py b/NeoBoot/ubi_reader_mips/ubi_io/__init__.py index 936872a..4319509 100644 --- a/NeoBoot/ubi_reader_mips/ubi_io/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubi_io/__init__.py @@ -1,11 +1,10 @@ -#!/usr/bin/python from ubi.block import sort class ubi_file(object): def __init__(self, path, block_size, start_offset=0, end_offset=None): - self._fhandle = open(path, 'rb') + self._fhandle = open(path, "rb") self._start_offset = start_offset if end_offset: self._end_offset = end_offset @@ -14,7 +13,7 @@ class ubi_file(object): self._end_offset = self.tell() self._block_size = block_size if start_offset >= self._end_offset: - raise Exception('Start offset larger than file size!') + raise Exception("Start offset larger than file size!") self._fhandle.seek(self._start_offset) def _set_start(self, i): @@ -69,7 +68,8 @@ class ubi_file(object): def read_block_data(self, block): self.seek(block.file_offset + block.ec_hdr.data_offset) buf = self._fhandle.read( - block.size - block.ec_hdr.data_offset - block.vid_hdr.data_pad) + block.size - block.ec_hdr.data_offset - block.vid_hdr.data_pad + ) return buf @@ -82,22 +82,22 @@ class leb_virtual_file: self._seek = 0 self.leb_data_size = len(self._blocks) * self._ubi.leb_size self._last_leb = -1 - self._last_buf = '' + self._last_buf = "" def read(self, i): - buf = '' + buf = "" leb = int(self.tell() / self._ubi.leb_size) offset = self.tell() % self._ubi.leb_size if leb == self._last_leb: self.seek(self.tell() + i) - return self._last_buf[offset:offset + i] + return self._last_buf[offset: offset + i] else: buf = self._ubi.file.read_block_data( self._ubi.blocks[self._blocks[leb]]) self._last_buf = buf self._last_leb = leb self.seek(self.tell() + i) - return buf[offset:offset + i] + return buf[offset: offset + i] def reset(self): self.seek(0) @@ -113,7 +113,7 @@ class leb_virtual_file: for block in self._blocks: while 0 != self._ubi.blocks[block].leb_num - last_leb: last_leb += 1 - yield '\xff' * self._ubi.leb_size + yield "\xff" * self._ubi.leb_size last_leb += 1 yield self._ubi.file.read_block_data(self._ubi.blocks[block]) diff --git a/NeoBoot/ubi_reader_mips/ubifs/__init__.py b/NeoBoot/ubi_reader_mips/ubifs/__init__.py index 0ad47ca..14585b3 100644 --- a/NeoBoot/ubi_reader_mips/ubifs/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubifs/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import re import struct from ubifs.defines import * @@ -50,7 +49,7 @@ class ubifs: def get_leb_size(path): - f = open(path, 'rb') + f = open(path, "rb") f.seek(0, 2) file_size = f.tell() + 1 f.seek(0) @@ -59,7 +58,7 @@ def get_leb_size(path): buf = f.read(FILE_CHUNK_SZ) for m in re.finditer(UBIFS_NODE_MAGIC, buf): start = m.start() - chdr = nodes.common_hdr(buf[start:start + UBIFS_COMMON_HDR_SZ]) + chdr = nodes.common_hdr(buf[start: start + UBIFS_COMMON_HDR_SZ]) if chdr and chdr.node_type == UBIFS_SB_NODE: sb_start = start + UBIFS_COMMON_HDR_SZ sb_end = sb_start + UBIFS_SB_NODE_SZ diff --git a/NeoBoot/ubi_reader_mips/ubifs/defines.py b/NeoBoot/ubi_reader_mips/ubifs/defines.py index 550fe49..9c0ddf9 100644 --- a/NeoBoot/ubi_reader_mips/ubifs/defines.py +++ b/NeoBoot/ubi_reader_mips/ubifs/defines.py @@ -1,6 +1,6 @@ -#!/usr/bin/python import struct -UBIFS_NODE_MAGIC = '1\x18\x10\x06' + +UBIFS_NODE_MAGIC = "1\x18\x10\x06" UBIFS_CRC32_INIT = 4294967295 UBIFS_MIN_COMPR_LEN = 128 UBIFS_MIN_COMPRESS_DIFF = 64 @@ -10,7 +10,7 @@ UBIFS_MAX_NLEN = 255 UBIFS_MAX_JHEADS = 1 UBIFS_BLOCK_SIZE = 4096 UBIFS_BLOCK_SHIFT = 12 -UBIFS_PADDING_BYTE = '\xce' +UBIFS_PADDING_BYTE = "\xce" UBIFS_MAX_KEY_LEN = 16 UBIFS_SK_LEN = 8 UBIFS_MIN_FANOUT = 3 @@ -37,7 +37,7 @@ UBIFS_ITYPE_SOCK = 6 UBIFS_ITYPES_CNT = 7 UBIFS_KEY_HASH_R5 = 0 UBIFS_KEY_HASH_TEST = 1 -PRINT_UBIFS_KEY_HASH = ['r5', 'test'] +PRINT_UBIFS_KEY_HASH = ["r5", "test"] UBIFS_SIMPLE_KEY_FMT = 0 UBIFS_S_KEY_BLOCK_BITS = 29 UBIFS_S_KEY_BLOCK_MASK = 536870911 @@ -64,7 +64,7 @@ UBIFS_COMPR_NONE = 0 UBIFS_COMPR_LZO = 1 UBIFS_COMPR_ZLIB = 2 UBIFS_COMPR_TYPES_CNT = 3 -PRINT_UBIFS_COMPR = ['none', 'lzo', 'zlib'] +PRINT_UBIFS_COMPR = ["none", "lzo", "zlib"] UBIFS_INO_NODE = 0 UBIFS_DATA_NODE = 1 UBIFS_DENT_NODE = 2 @@ -86,136 +86,133 @@ UBIFS_IN_NODE_GROUP = 1 UBIFS_LAST_OF_NODE_GROUP = 2 UBIFS_FLG_BIGLPT = 2 UBIFS_FLG_SPACE_FIXUP = 4 -UBIFS_COMMON_HDR_FORMAT = '> UBIFS_S_KEY_BLOCK_BITS khash = lkey - return {'type': key_type, - 'ino_num': ino_num, - 'khash': khash} + return {"type": key_type, "ino_num": ino_num, "khash": khash} def decompress(ctype, unc_len, data): if ctype == UBIFS_COMPR_LZO: - return lzo.decompress(''.join(('\xf0', struct.pack('>I', unc_len), data))) + return lzo.decompress( + "".join(("\xf0", struct.pack(">I", unc_len), data))) elif ctype == UBIFS_COMPR_ZLIB: return zlib.decompress(data, -11) else: diff --git a/NeoBoot/ubi_reader_mips/ubifs/nodes/__init__.py b/NeoBoot/ubi_reader_mips/ubifs/nodes/__init__.py index a287505..6de70d3 100644 --- a/NeoBoot/ubi_reader_mips/ubifs/nodes/__init__.py +++ b/NeoBoot/ubi_reader_mips/ubifs/nodes/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python import struct from ubifs.defines import * from ubifs.misc import parse_key @@ -8,18 +7,18 @@ class common_hdr(object): def __init__(self, buf): fields = dict(list(zip(UBIFS_COMMON_HDR_FIELDS, - struct.unpack(UBIFS_COMMON_HDR_FORMAT, buf)))) + struct.unpack(UBIFS_COMMON_HDR_FORMAT, buf)))) for key in fields: setattr(self, key, fields[key]) - setattr(self, 'errors', []) + setattr(self, "errors", []) def __repr__(self): - return 'UBIFS Common Header' + return "UBIFS Common Header" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -27,16 +26,17 @@ class sb_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_SB_NODE_FIELDS, struct.unpack(UBIFS_SB_NODE_FORMAT, buf)))) + list(zip(UBIFS_SB_NODE_FIELDS, struct.unpack(UBIFS_SB_NODE_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) def __repr__(self): - return 'UBIFS Super Block Node' + return "UBIFS Super Block Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -44,16 +44,17 @@ class mst_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_MST_NODE_FIELDS, struct.unpack(UBIFS_MST_NODE_FORMAT, buf)))) + list(zip(UBIFS_MST_NODE_FIELDS, struct.unpack(UBIFS_MST_NODE_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) def __repr__(self): - return 'UBIFS Master Block Node' + return "UBIFS Master Block Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -61,21 +62,24 @@ class dent_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_DENT_NODE_FIELDS, struct.unpack(UBIFS_DENT_NODE_FORMAT, buf)))) + list( + zip(UBIFS_DENT_NODE_FIELDS, struct.unpack(UBIFS_DENT_NODE_FORMAT, buf)) + ) + ) for key in fields: - if key == 'key': + if key == "key": setattr(self, key, parse_key(fields[key])) else: setattr(self, key, fields[key]) - setattr(self, 'name', '') + setattr(self, "name", "") def __repr__(self): - return 'UBIFS Directory Entry Node' + return "UBIFS Directory Entry Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -83,22 +87,25 @@ class data_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_DATA_NODE_FIELDS, struct.unpack(UBIFS_DATA_NODE_FORMAT, buf)))) + list( + zip(UBIFS_DATA_NODE_FIELDS, struct.unpack(UBIFS_DATA_NODE_FORMAT, buf)) + ) + ) for key in fields: - if key == 'key': + if key == "key": setattr(self, key, parse_key(fields[key])) else: setattr(self, key, fields[key]) - setattr(self, 'offset', 0) - setattr(self, 'compr_len', 0) + setattr(self, "offset", 0) + setattr(self, "compr_len", 0) def __repr__(self): - return 'UBIFS Data Node' + return "UBIFS Data Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -106,18 +113,19 @@ class idx_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_IDX_NODE_FIELDS, struct.unpack(UBIFS_IDX_NODE_FORMAT, buf)))) + list(zip(UBIFS_IDX_NODE_FIELDS, struct.unpack(UBIFS_IDX_NODE_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) - setattr(self, 'branches', []) + setattr(self, "branches", []) def __repr__(self): - return 'UBIFS Index Node' + return "UBIFS Index Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -125,21 +133,22 @@ class ino_node(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_INO_NODE_FIELDS, struct.unpack(UBIFS_INO_NODE_FORMAT, buf)))) + list(zip(UBIFS_INO_NODE_FIELDS, struct.unpack(UBIFS_INO_NODE_FORMAT, buf))) + ) for key in fields: - if key == 'key': + if key == "key": setattr(self, key, parse_key(fields[key])) else: setattr(self, key, fields[key]) - setattr(self, 'data', '') + setattr(self, "data", "") def __repr__(self): - return 'UBIFS Ino Node' + return "UBIFS Ino Node" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) @@ -147,14 +156,15 @@ class branch(object): def __init__(self, buf): fields = dict( - list(zip(UBIFS_BRANCH_FIELDS, struct.unpack(UBIFS_BRANCH_FORMAT, buf)))) + list(zip(UBIFS_BRANCH_FIELDS, struct.unpack(UBIFS_BRANCH_FORMAT, buf))) + ) for key in fields: setattr(self, key, fields[key]) def __repr__(self): - return 'UBIFS Branch' + return "UBIFS Branch" def __iter__(self): for key in dir(self): - if not key.startswith('_'): + if not key.startswith("_"): yield (key, getattr(self, key)) diff --git a/NeoBoot/ubi_reader_mips/ubifs/nodes/extract.py b/NeoBoot/ubi_reader_mips/ubifs/nodes/extract.py index 8a5c549..4a72251 100644 --- a/NeoBoot/ubi_reader_mips/ubifs/nodes/extract.py +++ b/NeoBoot/ubi_reader_mips/ubifs/nodes/extract.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubifs import nodes from ubifs.defines import * @@ -28,7 +27,7 @@ def sb_node(ubifs, offset=0): def dent_node(ubifs, lnum, offset=0): ubifs.file.seek(ubifs.leb_size * lnum + offset) den = nodes.dent_node(ubifs.file.read(UBIFS_DENT_NODE_SZ)) - den.name = '%s' % ubifs.file.read(den.nlen) + den.name = "%s" % ubifs.file.read(den.nlen) return den diff --git a/NeoBoot/ubi_reader_mips/ubifs/output.py b/NeoBoot/ubi_reader_mips/ubifs/output.py index 96d716a..cc1eca7 100644 --- a/NeoBoot/ubi_reader_mips/ubifs/output.py +++ b/NeoBoot/ubi_reader_mips/ubifs/output.py @@ -1,11 +1,10 @@ -#!/usr/bin/python import os import struct from ubifs.defines import * from ubifs.misc import decompress -def dents(ubifs, inodes, dent_node, path='', perms=False): +def dents(ubifs, inodes, dent_node, path="", perms=False): inode = inodes[dent_node.inum] dent_path = os.path.join(path, dent_node.name) if dent_node.type == UBIFS_ITYPE_DIR: @@ -15,41 +14,42 @@ def dents(ubifs, inodes, dent_node, path='', perms=False): if perms: set_file_perms(dent_path, inode) except Exception as e: - ubifs.log.write('DIR Fail: %s' % e) + ubifs.log.write("DIR Fail: %s" % e) - if 'dent' in inode: - for dnode in inode['dent']: + if "dent" in inode: + for dnode in inode["dent"]: dents(ubifs, inodes, dnode, dent_path, perms) elif dent_node.type == UBIFS_ITYPE_REG: try: - if inode['ino'].nlink > 1: - if 'hlink' not in inode: - inode['hlink'] = dent_path + if inode["ino"].nlink > 1: + if "hlink" not in inode: + inode["hlink"] = dent_path buf = process_reg_file(ubifs, inode, dent_path) write_reg_file(dent_path, buf) else: - os.link(inode['hlink'], dent_path) + os.link(inode["hlink"], dent_path) else: buf = process_reg_file(ubifs, inode, dent_path) write_reg_file(dent_path, buf) if perms: set_file_perms(dent_path, inode) except Exception as e: - ubifs.log.write('FILE Fail: %s' % e) + ubifs.log.write("FILE Fail: %s" % e) elif dent_node.type == UBIFS_ITYPE_LNK: try: - os.symlink('%s' % inode['ino'].data, dent_path) + os.symlink("%s" % inode["ino"].data, dent_path) except Exception as e: - ubifs.log.write('SYMLINK Fail: %s : %s' % - (inode['ino'].data, dent_path)) + ubifs.log.write( + "SYMLINK Fail: %s : %s" % + (inode["ino"].data, dent_path)) elif dent_node.type in [UBIFS_ITYPE_BLK, UBIFS_ITYPE_CHR]: try: - dev = struct.unpack(' len(buf): - buf += '\x00' * (inode['ino'].size - len(buf)) + if inode["ino"].size > len(buf): + buf += "\x00" * (inode["ino"].size - len(buf)) return buf diff --git a/NeoBoot/ubi_reader_mips/ubifs/walk.py b/NeoBoot/ubi_reader_mips/ubifs/walk.py index b9df5a4..3721024 100644 --- a/NeoBoot/ubi_reader_mips/ubifs/walk.py +++ b/NeoBoot/ubi_reader_mips/ubifs/walk.py @@ -1,4 +1,3 @@ -#!/usr/bin/python from ubifs import extract from ubifs.defines import * @@ -12,24 +11,28 @@ def index(ubifs, lnum, offset, inodes={}): elif chdr.node_type == UBIFS_INO_NODE: inon = extract.ino_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ) - ino_num = inon.key['ino_num'] + ino_num = inon.key["ino_num"] if ino_num not in inodes: inodes[ino_num] = {} - inodes[ino_num]['ino'] = inon + inodes[ino_num]["ino"] = inon elif chdr.node_type == UBIFS_DATA_NODE: datn = extract.data_node( - ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ, chdr.len) - ino_num = datn.key['ino_num'] + ubifs, + lnum, + offset + + UBIFS_COMMON_HDR_SZ, + chdr.len) + ino_num = datn.key["ino_num"] if ino_num not in inodes: inodes[ino_num] = {} - if 'data' not in inodes[ino_num]: - inodes[ino_num]['data'] = [] - inodes[ino_num]['data'].append(datn) + if "data" not in inodes[ino_num]: + inodes[ino_num]["data"] = [] + inodes[ino_num]["data"].append(datn) elif chdr.node_type == UBIFS_DENT_NODE: dn = extract.dent_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ) - ino_num = dn.key['ino_num'] + ino_num = dn.key["ino_num"] if ino_num not in inodes: inodes[ino_num] = {} - if 'dent' not in inodes[ino_num]: - inodes[ino_num]['dent'] = [] - inodes[ino_num]['dent'].append(dn) + if "dent" not in inodes[ino_num]: + inodes[ino_num]["dent"] = [] + inodes[ino_num]["dent"].append(dn) diff --git a/NeoBoot/ubi_reader_mips/ui/common.py b/NeoBoot/ubi_reader_mips/ui/common.py index 5d40084..40786f0 100644 --- a/NeoBoot/ubi_reader_mips/ui/common.py +++ b/NeoBoot/ubi_reader_mips/ui/common.py @@ -1,11 +1,12 @@ -#!/usr/bin/python import os from ubi_io import leb_virtual_file from ubifs import ubifs, walk, output from ubifs.defines import PRINT_UBIFS_KEY_HASH, PRINT_UBIFS_COMPR from ubi.defines import PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG -output_dir = os.path.join(os.path.dirname( - os.path.dirname(os.path.realpath(__file__))), 'output') + +output_dir = os.path.join( + os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "output" +) def extract_files(ubifs, out_path, perms=False): @@ -13,34 +14,37 @@ def extract_files(ubifs, out_path, perms=False): inodes = {} walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes) - for dent in inodes[1]['dent']: + for dent in inodes[1]["dent"]: output.dents(ubifs, inodes, dent, out_path, perms) except Exception as e: import traceback - ubifs.log.write('%s' % e) + + ubifs.log.write("%s" % e) traceback.print_exc() def get_ubi_params(ubi): - ubi_flags = {'min_io_size': '-m', - 'max_bud_bytes': '-j', - 'leb_size': '-e', - 'default_compr': '-x', - 'sub_page_size': '-s', - 'fanout': '-f', - 'key_hash': '-k', - 'orph_lebs': '-p', - 'log_lebs': '-l', - 'max_leb_cnt': '-c', - 'peb_size': '-p', - 'sub_page_size': '-s', - 'vid_hdr_offset': '-O', - 'version': '-x', - 'image_seq': '-Q', - 'alignment': '-a', - 'vol_id': '-n', - 'name': '-N'} + ubi_flags = { + "min_io_size": "-m", + "max_bud_bytes": "-j", + "leb_size": "-e", + "default_compr": "-x", + "sub_page_size": "-s", + "fanout": "-f", + "key_hash": "-k", + "orph_lebs": "-p", + "log_lebs": "-l", + "max_leb_cnt": "-c", + "peb_size": "-p", + "sub_page_size": "-s", + "vid_hdr_offset": "-O", + "version": "-x", + "image_seq": "-Q", + "alignment": "-a", + "vol_id": "-n", + "name": "-N", + } ubi_params = {} ubi_args = {} ini_params = {} @@ -52,41 +56,55 @@ def get_ubi_params(ubi): for volume in image.volumes: ubi_args[img_seq][volume] = {} ini_params[img_seq][volume] = {} - ini_params[img_seq][volume]['vol_type'] = PRINT_VOL_TYPE_LIST[image.volumes[volume].vol_rec.vol_type] + ini_params[img_seq][volume]["vol_type"] = PRINT_VOL_TYPE_LIST[ + image.volumes[volume].vol_rec.vol_type + ] if image.volumes[volume].vol_rec.flags == UBI_VTBL_AUTORESIZE_FLG: - ini_params[img_seq][volume]['vol_flags'] = 'autoresize' + ini_params[img_seq][volume]["vol_flags"] = "autoresize" else: - ini_params[img_seq][volume]['vol_flags'] = image.volumes[volume].vol_rec.flags - ini_params[img_seq][volume]['vol_id'] = image.volumes[volume].vol_id - ini_params[img_seq][volume]['vol_name'] = image.volumes[volume].name.rstrip( - '\x00') - ini_params[img_seq][volume]['vol_alignment'] = image.volumes[volume].vol_rec.alignment - ini_params[img_seq][volume]['vol_size'] = image.volumes[volume].vol_rec.reserved_pebs * ubi.leb_size + ini_params[img_seq][volume]["vol_flags"] = image.volumes[ + volume + ].vol_rec.flags + ini_params[img_seq][volume]["vol_id"] = image.volumes[volume].vol_id + ini_params[img_seq][volume]["vol_name"] = image.volumes[volume].name.rstrip( + "\x00") + ini_params[img_seq][volume]["vol_alignment"] = image.volumes[ + volume + ].vol_rec.alignment + ini_params[img_seq][volume]["vol_size"] = ( + image.volumes[volume].vol_rec.reserved_pebs * ubi.leb_size + ) ufsfile = leb_virtual_file(ubi, image.volumes[volume]) uubifs = ubifs(ufsfile) for key, value in uubifs.superblock_node: - if key == 'key_hash': + if key == "key_hash": value = PRINT_UBIFS_KEY_HASH[value] - elif key == 'default_compr': + elif key == "default_compr": value = PRINT_UBIFS_COMPR[value] if key in ubi_flags: ubi_args[img_seq][volume][key] = value for key, value in image.volumes[volume].vol_rec: - if key == 'name': - value = value.rstrip('\x00') + if key == "name": + value = value.rstrip("\x00") if key in ubi_flags: ubi_args[img_seq][volume][key] = value - ubi_args[img_seq][volume]['version'] = image.version - ubi_args[img_seq][volume]['vid_hdr_offset'] = image.vid_hdr_offset - ubi_args[img_seq][volume]['sub_page_size'] = ubi_args[img_seq][volume]['vid_hdr_offset'] - ubi_args[img_seq][volume]['sub_page_size'] = ubi_args[img_seq][volume]['vid_hdr_offset'] - ubi_args[img_seq][volume]['image_seq'] = image.image_seq - ubi_args[img_seq][volume]['peb_size'] = ubi.peb_size - ubi_args[img_seq][volume]['vol_id'] = image.volumes[volume].vol_id - ubi_params[img_seq][volume] = {'flags': ubi_flags, - 'args': ubi_args[img_seq][volume], - 'ini': ini_params[img_seq][volume]} + ubi_args[img_seq][volume]["version"] = image.version + ubi_args[img_seq][volume]["vid_hdr_offset"] = image.vid_hdr_offset + ubi_args[img_seq][volume]["sub_page_size"] = ubi_args[img_seq][volume][ + "vid_hdr_offset" + ] + ubi_args[img_seq][volume]["sub_page_size"] = ubi_args[img_seq][volume][ + "vid_hdr_offset" + ] + ubi_args[img_seq][volume]["image_seq"] = image.image_seq + ubi_args[img_seq][volume]["peb_size"] = ubi.peb_size + ubi_args[img_seq][volume]["vol_id"] = image.volumes[volume].vol_id + ubi_params[img_seq][volume] = { + "flags": ubi_flags, + "args": ubi_args[img_seq][volume], + "ini": ini_params[img_seq][volume], + } return ubi_params diff --git a/NeoBoot/unpack.py b/NeoBoot/unpack.py index 90a87a0..4971ea9 100644 --- a/NeoBoot/unpack.py +++ b/NeoBoot/unpack.py @@ -1,10 +1,15 @@ -# -*- coding: utf-8 -*- - -# from __init__ import _ - - from Plugins.Extensions.NeoBoot.__init__ import _ -from Plugins.Extensions.NeoBoot.files.stbbranding import getNeoLocation, getKernelVersionString, getKernelImageVersion, getCPUtype, getCPUSoC, getImageNeoBoot, getBoxVuModel, getBoxHostName, getTunerModel +from Plugins.Extensions.NeoBoot.files.stbbranding import ( + getNeoLocation, + getKernelVersionString, + getKernelImageVersion, + getCPUtype, + getCPUSoC, + getImageNeoBoot, + getBoxVuModel, + getBoxHostName, + getTunerModel, +) from enigma import getDesktop from enigma import eTimer from Screens.Screen import Screen @@ -27,16 +32,36 @@ from Components.Pixmap import Pixmap, MultiPixmap from Components.config import * from Components.ConfigList import ConfigListScreen from Tools.LoadPixmap import LoadPixmap -from Tools.Directories import fileExists, pathExists, createDir, resolveFilename, SCOPE_PLUGINS -from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen +from Tools.Directories import ( + fileExists, + pathExists, + createDir, + resolveFilename, + SCOPE_PLUGINS, +) +from os import ( + system, + listdir, + mkdir, + chdir, + getcwd, + rename as os_rename, + remove as os_remove, + popen, +) from os.path import dirname, isdir, isdir as os_isdir import os import time -if not fileExists('/etc/vtiversion.info') and not fileExists('/etc/bhversion') and fileExists('/usr/lib/python2.7'): + +if ( + not fileExists("/etc/vtiversion.info") + and not fileExists("/etc/bhversion") + and fileExists("/usr/lib/python2.7") +): from Plugins.Extensions.NeoBoot.files.neoconsole import Console else: from Screens.Console import Console -LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +LinkNeoBoot = "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" def getDS(): @@ -96,47 +121,47 @@ class InstallImage(Screen, ConfigListScreen): def __init__(self, session): Screen.__init__(self, session) - fn = 'NewImage' + fn = "NewImage" sourcelist = [] - for fn in os.listdir('%sImagesUpload' % getNeoLocation()): - if fn.find('.zip') != -1: - fn = fn.replace('.zip', '') + for fn in os.listdir("%sImagesUpload" % getNeoLocation()): + if fn.find(".zip") != -1: + fn = fn.replace(".zip", "") sourcelist.append((fn, fn)) continue - if fn.find('.rar') != -1: - fn = fn.replace('.rar', '') + if fn.find(".rar") != -1: + fn = fn.replace(".rar", "") sourcelist.append((fn, fn)) continue - if fn.find('.tar.xz') != -1: - fn = fn.replace('.tar.xz', '') + if fn.find(".tar.xz") != -1: + fn = fn.replace(".tar.xz", "") sourcelist.append((fn, fn)) continue - if fn.find('.tar.gz') != -1: - fn = fn.replace('.tar.gz', '') + if fn.find(".tar.gz") != -1: + fn = fn.replace(".tar.gz", "") sourcelist.append((fn, fn)) continue - if fn.find('.tar.bz2') != -1: - fn = fn.replace('.tar.bz2', '') + if fn.find(".tar.bz2") != -1: + fn = fn.replace(".tar.bz2", "") sourcelist.append((fn, fn)) continue - if fn.find('.tar') != -1: - fn = fn.replace('.tar', '') + if fn.find(".tar") != -1: + fn = fn.replace(".tar", "") sourcelist.append((fn, fn)) continue - if fn.find('.tar') != -1: - fn = fn.replace('.tar.gz', '') + if fn.find(".tar") != -1: + fn = fn.replace(".tar.gz", "") sourcelist.append((fn, fn)) continue - if fn.find('.mb') != -1: - fn = fn.replace('.mb', '') + if fn.find(".mb") != -1: + fn = fn.replace(".mb", "") sourcelist.append((fn, fn)) continue - if fn.find('.nfi') != -1: - fn = fn.replace('.nfi', '') + if fn.find(".nfi") != -1: + fn = fn.replace(".nfi", "") sourcelist.append((fn, fn)) continue if len(sourcelist) == 0: - sourcelist = [('None', 'None')] + sourcelist = [("None", "None")] self.source = ConfigSelection(choices=sourcelist) self.target = ConfigText(fixed_size=False) self.CopyFiles = ConfigYesNo(default=True) @@ -160,159 +185,224 @@ class InstallImage(Screen, ConfigListScreen): self.Kodi = ConfigYesNo(default=False) self.BlackHole = ConfigYesNo(default=False) for line in open("/etc/hostname"): - if getCPUtype() == 'MIPS' and not "dm500hd" in line and not "dm800se" in line and not "dm800" in line and not "dm8000" in line: + if ( + getCPUtype() == "MIPS" + and "dm500hd" not in line + and "dm800se" not in line + and "dm800" not in line + and "dm8000" not in line + ): self.Nandsim = ConfigYesNo(default=True) else: self.Nandsim = ConfigYesNo(default=False) - self.target.value = '' - self.curselimage = '' + self.target.value = "" + self.curselimage = "" try: if self.curselimage != self.source.value: self.target.value = self.source.value[:-13] self.curselimage = self.source.value - except: + except BaseException: pass self.createSetup() ConfigListScreen.__init__(self, self.list, session=session) self.source.addNotifier(self.typeChange) - self['actions'] = ActionMap(['OkCancelActions', - 'ColorActions', - 'CiSelectionActions', - 'VirtualKeyboardActions'], {'cancel': self.cancel, - 'red': self.cancel, - 'green': self.imageInstall, - 'yellow': self.HelpInstall, - 'blue': self.openKeyboard}, -2) - self['key_green'] = Label(_('Install')) - self['key_red'] = Label(_('Cancel')) - self['key_yellow'] = Label(_('Help')) - self['key_blue'] = Label(_('Keyboard')) - self['HelpWindow'] = Pixmap() - self['HelpWindow'].hide() + self["actions"] = ActionMap( + [ + "OkCancelActions", + "ColorActions", + "CiSelectionActions", + "VirtualKeyboardActions", + ], + { + "cancel": self.cancel, + "red": self.cancel, + "green": self.imageInstall, + "yellow": self.HelpInstall, + "blue": self.openKeyboard, + }, + -2, + ) + self["key_green"] = Label(_("Install")) + self["key_red"] = Label(_("Cancel")) + self["key_yellow"] = Label(_("Help")) + self["key_blue"] = Label(_("Keyboard")) + self["HelpWindow"] = Pixmap() + self["HelpWindow"].hide() def createSetup(self): self.list = [] - self.list.append(getConfigListEntry( - _('Source Image file'), self.source)) - self.list.append(getConfigListEntry(_('Image Name'), self.target)) - self.list.append(getConfigListEntry( - _('Copy files from Flash to the installed image ?'), self.CopyFiles)) - self.list.append(getConfigListEntry( - _('Copy the kernel of the installed system (recommended ?'), self.CopyKernel)) - self.list.append(getConfigListEntry( - _('Copy the channel list ?'), self.TvList)) - self.list.append(getConfigListEntry( - _('Copy network settings LAN-WLAN ?'), self.LanWlan)) - self.list.append(getConfigListEntry( - _('Copy the drivers ? (Recommended only other image.)'), self.Sterowniki)) - self.list.append(getConfigListEntry( - _('Copy mounting disks ? (Recommended)'), self.Montowanie)) - self.list.append(getConfigListEntry( - _('Copy Settings to the new Image'), self.InstallSettings)) - self.list.append(getConfigListEntry( - _('Delete Image zip after Install ?'), self.ZipDelete)) - self.list.append(getConfigListEntry( - _('Repair FTP ? (Recommended only other image if it does not work.)'), self.RepairFTP)) - self.list.append(getConfigListEntry( - _('Copy config SoftCam ?'), self.SoftCam)) - self.list.append(getConfigListEntry( - _('Copy MediaPortal ?'), self.MediaPortal)) - self.list.append(getConfigListEntry( - _('Copy picon flash to image install ?'), self.PiconR)) - self.list.append(getConfigListEntry( - _('Transfer kodi settings ?'), self.Kodi)) - self.list.append(getConfigListEntry( - _('Path BlackHole ? (Not recommended for VuPlus)'), self.BlackHole)) - if getCPUtype() == 'MIPS': - self.list.append(getConfigListEntry( - _('Use Nandsim to install image ?'), self.Nandsim)) + self.list.append( + getConfigListEntry( + _("Source Image file"), + self.source)) + self.list.append(getConfigListEntry(_("Image Name"), self.target)) + self.list.append( + getConfigListEntry( + _("Copy files from Flash to the installed image ?"), + self.CopyFiles)) + self.list.append( + getConfigListEntry( + _("Copy the kernel of the installed system (recommended ?"), + self.CopyKernel, + ) + ) + self.list.append( + getConfigListEntry( + _("Copy the channel list ?"), + self.TvList)) + self.list.append( + getConfigListEntry( + _("Copy network settings LAN-WLAN ?"), + self.LanWlan)) + self.list.append( + getConfigListEntry( + _("Copy the drivers ? (Recommended only other image.)"), + self.Sterowniki)) + self.list.append( + getConfigListEntry( + _("Copy mounting disks ? (Recommended)"), self.Montowanie + ) + ) + self.list.append( + getConfigListEntry( + _("Copy Settings to the new Image"), self.InstallSettings + ) + ) + self.list.append( + getConfigListEntry( + _("Delete Image zip after Install ?"), + self.ZipDelete)) + self.list.append( + getConfigListEntry( + _("Repair FTP ? (Recommended only other image if it does not work.)"), + self.RepairFTP, + )) + self.list.append( + getConfigListEntry( + _("Copy config SoftCam ?"), + self.SoftCam)) + self.list.append( + getConfigListEntry( + _("Copy MediaPortal ?"), + self.MediaPortal)) + self.list.append( + getConfigListEntry( + _("Copy picon flash to image install ?"), + self.PiconR)) + self.list.append( + getConfigListEntry( + _("Transfer kodi settings ?"), + self.Kodi)) + self.list.append( + getConfigListEntry( + _("Path BlackHole ? (Not recommended for VuPlus)"), + self.BlackHole)) + if getCPUtype() == "MIPS": + self.list.append( + getConfigListEntry( + _("Use Nandsim to install image ?"), + self.Nandsim)) def HelpInstall(self): self.session.open(HelpInstall) def typeChange(self, value): self.createSetup() - self['config'].l.setList(self.list) + self["config"].l.setList(self.list) if self.curselimage != self.source.value: self.target.value = self.source.value[:-13] self.curselimage = self.source.value def openKeyboard(self): - sel = self['config'].getCurrent() + sel = self["config"].getCurrent() if sel: if sel == self.target: - if self['config'].getCurrent()[1].help_window.instance is not None: - self['config'].getCurrent()[1].help_window.hide() + if self["config"].getCurrent( + )[1].help_window.instance is not None: + self["config"].getCurrent()[1].help_window.hide() self.vkvar = sel[0] - if self.vkvar == _('Image Name'): - self.session.openWithCallback(self.VirtualKeyBoardCallback, VirtualKeyBoard, title=self['config'].getCurrent()[ - 0], text=self['config'].getCurrent()[1].value) + if self.vkvar == _("Image Name"): + self.session.openWithCallback( + self.VirtualKeyBoardCallback, + VirtualKeyBoard, + title=self["config"].getCurrent()[0], + text=self["config"].getCurrent()[1].value, + ) return def VirtualKeyBoardCallback(self, callback=None): if callback is not None and len(callback): - self['config'].getCurrent()[1].setValue(callback) - self['config'].invalidate(self['config'].getCurrent()) + self["config"].getCurrent()[1].setValue(callback) + self["config"].invalidate(self["config"].getCurrent()) return def imageInstall(self): - pluginpath = '' + LinkNeoBoot + '' - myerror = '' - source = self.source.value.replace(' ', '') - target = self.target.value.replace(' ', '') - for fn in os.listdir('%sImageBoot' % getNeoLocation()): + pluginpath = "" + LinkNeoBoot + "" + myerror = "" + source = self.source.value.replace(" ", "") + target = self.target.value.replace(" ", "") + for fn in os.listdir("%sImageBoot" % getNeoLocation()): if fn == target: - myerror = _('Sorry, an Image with the name ') + target + \ - _(' is already installed.\n Please try another name.') + myerror = ( + _("Sorry, an Image with the name ") + + target + + _(" is already installed.\n Please try another name.") + ) continue - if source == 'None': + if source == "None": myerror = _( - 'You have to select one Image to install.\nPlease, upload your zip file in the folder: %sImagesUpload and select the image to install.') - if target == '': - myerror = _('You have to provide a name for the new Image.') - if target == 'Flash': + "You have to select one Image to install.\nPlease, upload your zip file in the folder: %sImagesUpload and select the image to install." + ) + if target == "": + myerror = _("You have to provide a name for the new Image.") + if target == "Flash": myerror = _( - 'Sorry this name is reserved. Choose another name for the new Image.') + "Sorry this name is reserved. Choose another name for the new Image." + ) if len(target) > 30: - myerror = _('Sorry the name of the new Image is too long.') + myerror = _("Sorry the name of the new Image is too long.") if myerror: myerror self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) else: myerror message = "echo -e '" - message += _('NeoBot started installing new image.\n') - message += _('The installation process may take a few minutes.\n') - message += _('Please: DO NOT reboot your STB and turn off the power.\n') - message += _('Please, wait...\n') + message += _("NeoBot started installing new image.\n") + message += _("The installation process may take a few minutes.\n") + message += _("Please: DO NOT reboot your STB and turn off the power.\n") + message += _("Please, wait...\n") message += "'" - cmd1 = 'python ' + pluginpath + '/ex_init.py' - cmd = '%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s ' % (cmd1, - source, - target.replace( - ' ', '.'), - str(self.CopyFiles.value), - str(self.CopyKernel.value), - str(self.TvList.value), - str(self.LanWlan.value), - str(self.Sterowniki.value), - str(self.Montowanie.value), - str( - self.InstallSettings.value), - str(self.ZipDelete.value), - str(self.RepairFTP.value), - str(self.SoftCam.value), - str(self.MediaPortal.value), - str(self.PiconR.value), - str(self.Kodi.value), - str(self.BlackHole.value), - str(self.Nandsim.value)) + cmd1 = "python " + pluginpath + "/ex_init.py" + cmd = "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s " % ( + cmd1, + source, + target.replace(" ", "."), + str(self.CopyFiles.value), + str(self.CopyKernel.value), + str(self.TvList.value), + str(self.LanWlan.value), + str(self.Sterowniki.value), + str(self.Montowanie.value), + str(self.InstallSettings.value), + str(self.ZipDelete.value), + str(self.RepairFTP.value), + str(self.SoftCam.value), + str(self.MediaPortal.value), + str(self.PiconR.value), + str(self.Kodi.value), + str(self.BlackHole.value), + str(self.Nandsim.value), + ) print("[MULTI-BOOT]: "), cmd from Plugins.Extensions.NeoBoot.plugin import PLUGINVERSION - self.session.open(Console, _( - 'NeoBoot v.%s - Install new image') % PLUGINVERSION, [message, cmd]) + + self.session.open( + Console, + _("NeoBoot v.%s - Install new image") % PLUGINVERSION, + [message, cmd], + ) def cancel(self): self.close() @@ -333,59 +423,86 @@ class HelpInstall(Screen): def __init__(self, session): Screen.__init__(self, session) - self['lab1'] = ScrollLabel('') - self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, - 'ok': self.close, - 'up': self['lab1'].pageUp, - 'left': self['lab1'].pageUp, - 'down': self['lab1'].pageDown, - 'right': self['lab1'].pageDown}) - self['lab1'].hide() + self["lab1"] = ScrollLabel("") + self["actions"] = ActionMap( + ["WizardActions", "ColorActions", "DirectionActions"], + { + "back": self.close, + "ok": self.close, + "up": self["lab1"].pageUp, + "left": self["lab1"].pageUp, + "down": self["lab1"].pageDown, + "right": self["lab1"].pageDown, + }, + ) + self["lab1"].hide() self.updatetext() def updatetext(self): - message = _('Source Image file') - message += _(' - Select the software to be installed with the cursor (left or right).\n\n') + message = _("Source Image file") + message += _( + " - Select the software to be installed with the cursor (left or right).\n\n" + ) - message += _('Image Name') - message += _(' - to change, press blue on the remote control.\n\n') + message += _("Image Name") + message += _(" - to change, press blue on the remote control.\n\n") - message += _('Copy files from Flash to the installed image ?') - message += _(' - this checking this option on it nothing will be copied from the image flash to the installed image in neoboot.\n\n') + message += _("Copy files from Flash to the installed image ?") + message += _( + " - this checking this option on it nothing will be copied from the image flash to the installed image in neoboot.\n\n" + ) - message += _('Copy the kernel of the installed system (recommended ?') - message += _('- after selecting this option, the kernel of the installed image will be copied to neoboot, only recommended for STB vuplus\n\n') + message += _("Copy the kernel of the installed system (recommended ?") + message += _( + "- after selecting this option, the kernel of the installed image will be copied to neoboot, only recommended for STB vuplus\n\n" + ) - message += _('Copy the channel list ?') - message += _(' - Option to copy channel list from flash to image installed in neoboot.\n\n') + message += _("Copy the channel list ?") + message += _( + " - Option to copy channel list from flash to image installed in neoboot.\n\n" + ) - message += _('Copy mounting disks ? (Recommended)') - message += _(' - the option transfers mounts to the image installed in neoboot from the flashlight, recommended only if you are installing an image from a different model than you have.\n\n') + message += _("Copy mounting disks ? (Recommended)") + message += _( + " - the option transfers mounts to the image installed in neoboot from the flashlight, recommended only if you are installing an image from a different model than you have.\n\n" + ) - message += _('Copy network settings LAN-WLAN ?') - message += _(' - the option moves files with the settings for lan and wlan.\n\n') + message += _("Copy network settings LAN-WLAN ?") + message += _( + " - the option moves files with the settings for lan and wlan.\n\n" + ) - message += _('Copy the drivers ? (Recommended only other image.)') - message += _(' - Option to copy drivers to the image installed in neoboot from the flashlight, recommended only if you are installing an image from a different model than you have.\n\n') + message += _("Copy the drivers ? (Recommended only other image.)") + message += _( + " - Option to copy drivers to the image installed in neoboot from the flashlight, recommended only if you are installing an image from a different model than you have.\n\n" + ) - message += _('Copy Settings to the new Image') - message += _(' - the option copies the software settings from the flashlight to the system being installed in the neobot.\n\n') + message += _("Copy Settings to the new Image") + message += _( + " - the option copies the software settings from the flashlight to the system being installed in the neobot.\n\n" + ) - message += _('Delete Image zip after Install ?') - message += _(' - po instalacji, opcja kasuje plik zip image z katalogu ImagesUpload.\n\n') + message += _("Delete Image zip after Install ?") + message += _( + " - po instalacji, opcja kasuje plik zip image z katalogu ImagesUpload.\n\n" + ) - message += _('Repair FTP ? (Recommended only other image if it does not work.)') - message += _(' - the option in some cases repairs the File Transfer Protocol connection in the installed image.\n\n') + message += _("Repair FTP ? (Recommended only other image if it does not work.)") + message += _( + " - the option in some cases repairs the File Transfer Protocol connection in the installed image.\n\n" + ) - message += _('Copy config SoftCam ?') - message += _(' - the option copies oscam configi and cccam, openpli default.\n\n') + message += _("Copy config SoftCam ?") + message += _( + " - the option copies oscam configi and cccam, openpli default.\n\n" + ) - message += _('Copy picon flash to image install ?') - message += _(' - cpuy picon from flash to image install in neoboot\n\n') + message += _("Copy picon flash to image install ?") + message += _(" - cpuy picon from flash to image install in neoboot\n\n") - message += _('Path BlackHole ? (Not recommended for VuPlus)') - message += _(' - option for image blackhole, helps to run BH in neoboot\n\n') + message += _("Path BlackHole ? (Not recommended for VuPlus)") + message += _(" - option for image blackhole, helps to run BH in neoboot\n\n") - self['lab1'].show() - self['lab1'].setText(message) + self["lab1"].show() + self["lab1"].setText(message) diff --git a/NeoBoot/usedskin.py b/NeoBoot/usedskin.py index 2384e97..ea387af 100644 --- a/NeoBoot/usedskin.py +++ b/NeoBoot/usedskin.py @@ -1,36 +1,8 @@ -# skin = ./meoskins/defaul_skin - gutosie - from Screens.Screen import Screen from Components.Pixmap import Pixmap import os -# Colors (#AARRGGBB) -# ____Recommended colors - Zalecane kolory : -# color name="white" value="#ffffff" -# color name="darkwhite" value="#00dddddd" -# color name="red" value="#f23d21" -# color name="green" value="#389416" -# color name="blue" value="#0064c7" -# color name="yellow" value="#bab329" -# color name="orange" value="#00ffa500" -# color name="gray" value="#808080" -# color name="lightgrey" value="#009b9b9b" -# green = '#00389416' lub #00389416 -# red = '#00ff2525' -# yellow = '#00ffe875' -# orange = '#00ff7f50' -# seledynowy = #00FF00 -# jasny-blue = #99FFFF -# Zamiast font=Regular ktory nie rozpoznaje polskich znakow np. na VTi, mozesz zmienic na ponizsze font="*: -# font - genel -# font - baslk -# font - tasat -# font - dugme - -# - -# ____ Skin Ultra HD - ImageChooseFULLHD ___ mod. gutosie___ ImageChooseFULLHD = """ @@ -88,7 +60,6 @@ ImageChooseFULLHD = """ """ -# ____ Skin Ultra HD - ImageChooseULTRAHD ___ mod. gutosie___ ImageChooseULTRAHD = """ @@ -137,7 +108,6 @@ ImageChooseULTRAHD = """ """ -# ____ Skin HD - ImageChoose ___mod. gutosie ___ ImageChooseHD = """ @@ -184,7 +154,6 @@ ImageChooseHD = """ """ -# ____ Skin FULLHD - MyUpgradeFULLHD ___mod. gutosie ___ MyUpgradeFULLHD = """ @@ -203,7 +172,6 @@ MyUpgradeFULLHD = """ """ -# ____ Skin UltraHD - MyUpgradeUltraHD ___mod. gutosie ___ MyUpgradeUltraHD = """ @@ -220,7 +188,6 @@ MyUpgradeUltraHD = """ """ -# ____ Skin MyUpgradeHD - MyUpgradeHD ___mod. gutosie ___ MyUpgradeHD = """ @@ -239,7 +206,6 @@ MyUpgradeHD = """ """ -# ____ Skin NeoBootInstallationFULLHD - NeoBootInstallationFULLHD ___mod. gutosie ___ NeoBootInstallationFULLHD = """ @@ -264,7 +230,6 @@ NeoBootInstallationFULLHD = """ """ -# ____ Skin NeoBootInstallationUltraHD - NeoBootInstallationUltraHD ___mod. gutosie ___ NeoBootInstallationUltraHD = """ @@ -296,7 +261,6 @@ NeoBootInstallationUltraHD = """ """ -# ____ Skin NeoBootInstallationHD - NeoBootInstallationHD ___mod. gutosie ___ NeoBootInstallationHD = """