From a78e5c87699ec68e9d013993f9e13b7a855946f9 Mon Sep 17 00:00:00 2001 From: gutosie Date: Sun, 7 Dec 2025 14:41:58 +0200 Subject: [PATCH] Add files via upload --- NeoBoot/files/Harddisk.py | 1120 +++++------ NeoBoot/files/Task.py | 161 +- NeoBoot/files/__init__.py | 18 +- NeoBoot/files/devices.py | 934 ++++------ NeoBoot/files/neoconsole.py | 152 +- NeoBoot/files/stbbranding.py | 2008 ++++++++++---------- NeoBoot/files/testinout | 4 +- NeoBoot/files/tools.py | 3401 ++++++++++++++-------------------- NeoBoot/files/userscript.sh | 4 - 9 files changed, 3295 insertions(+), 4507 deletions(-) diff --git a/NeoBoot/files/Harddisk.py b/NeoBoot/files/Harddisk.py index c8028f5..a44f791 100644 --- a/NeoBoot/files/Harddisk.py +++ b/NeoBoot/files/Harddisk.py @@ -1,19 +1,20 @@ +# -*- 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 - -if fileExists("/usr/lib/python2.7"): +#from Plugins.Extensions.NeoBoot.files import Task +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 Exception: +except: from Components.Task import LoggingTask from Screens.Screen import Screen from Components.ActionMap import ActionMap @@ -24,55 +25,46 @@ from Screens.MessageBox import MessageBox def readFile(filename): - try: - with open(filename, "r", encoding="utf-8", errors="ignore") as fh: - return fh.read().strip() - except Exception: - return "" + file = open(filename) + data = file.read().strip() + file.close() + return data 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: - with open("/proc/mounts", "r", encoding="utf-8", errors="ignore") as mounts: - result = [line.strip().split(" ") for line in mounts] + mounts = open('/proc/mounts', 'r') 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: - if len(item) > 1: - item[1] = item[1].replace("\\040", " ") + item[1] = item[1].replace('\\040', ' ') + return result def getNonNetworkMediaMounts(): - return [ - x[1] - for x in getProcMounts() - if x and len(x) > 1 and x[1].startswith("/media/") and not x[0].startswith("//") - ] + return [x[1] for x in getProcMounts() if x[1].startswith('/media/') and not x[0].startswith('//')] def isFileSystemSupported(filesystem): try: - with open("/proc/filesystems", "r", encoding="utf-8", errors="ignore") as fh: - for fs in fh: - if fs.strip().endswith(filesystem): - return True + for fs in open('/proc/filesystems', 'r'): + if fs.strip().endswith(filesystem): + return True + return False except Exception as ex: - print("[Harddisk] Failed to read /proc/filesystems:", ex) - return False + print(("[Harddisk] Failed to read /proc/filesystems:'"), ex) def findMountPoint(path): path = os.path.abspath(path) while not os.path.ismount(path): path = os.path.dirname(path) + return path @@ -80,70 +72,48 @@ DEVTYPE_UDEV = 0 DEVTYPE_DEVFS = 1 -class Harddisk: +class Harddisk(): def __init__(self, device, removable=False): self.device = device - if os.path.exists("/dev/.udev"): + if os.access('/dev/.udev', 0): self.type = DEVTYPE_UDEV - elif os.path.exists("/dev/.devfsd"): + elif os.access('/dev/.devfsd', 0): 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 - try: - self.phys_path = os.path.realpath(self.sysfsPath("device")) - except Exception: - self.phys_path = "" + 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 - ) + 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() + data = open('/sys/block/%s/queue/rotational' % device, 'r').read().strip() self.rotational = int(data) - except Exception: + except: 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(":") - 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" + 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' try: rdev = os.stat(disk_path).st_rdev except OSError: @@ -154,79 +124,61 @@ 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 getattr(self, "card", False): - try: - self.startIdle() - except Exception: - pass + 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() 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_str + if self.dev_path.startswith('/dev/mmcblk0'): + return self.dev_path + 'p' + n else: - return self.dev_path + n_str + return self.dev_path + n elif self.type == DEVTYPE_DEVFS: - return self.dev_path + "/part" + n_str + return self.dev_path + '/part' + n 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: - try: - self.timer.stop() - try: - self.timer.callback.remove(self.runIdle) - except Exception: - pass - except Exception: - pass + self.timer.stop() + self.timer.callback.remove(self.runIdle) def bus(self): - ret = _("External") - type_name = "" + ret = _('External') if self.type == DEVTYPE_UDEV: - type_name = " (SD/MMC)" + type_name = ' (SD/MMC)' elif self.type == DEVTYPE_DEVFS: - type_name = " (CF)" - if getattr(self, "card", False): + type_name = ' (CF)' + if self.card: 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) if line else 0 - return (cap * 512) // 1000000 - except Exception: + line = readFile(self.sysfsPath('size')) + cap = int(line) + return cap / 1000 * 512 / 1000 + except: dev = self.findMount() if dev: try: stat = os.statvfs(dev) - cap_bytes = int(stat.f_blocks * stat.f_bsize) - return cap_bytes // 1000000 - except Exception: + cap = int(stat.f_blocks * stat.f_bsize) + return cap / 1000 / 1000 + except: pass return cap @@ -234,41 +186,42 @@ 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("unknown device type") + 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, ("[Harddisk] no hdX or sdX or mmcX")) 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_bavail * stat.f_bsize - except Exception: + return stat.f_bfree / 1000 * (stat.f_bsize / 1024) + except: 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 @@ -283,34 +236,26 @@ 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 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 + if os.path.realpath(parts[0]).startswith(self.dev_path): + self.mount_device = parts[0] + self.mount_path = parts[1] + return parts[1] + return None def enumMountDevices(self): for parts in getProcMounts(): - if parts and len(parts) > 0: - try: - if os.path.realpath(parts[0]).startswith(self.dev_path): - yield parts[1] - except Exception: - continue + if os.path.realpath(parts[0]).startswith(self.dev_path): + yield parts[1] def findMount(self): if self.mount_path is None: @@ -323,162 +268,164 @@ class Harddisk: if dev is None: return 0 else: - cmd = ["umount", dev] - print("[Harddisk]", " ".join(cmd)) - try: - res = subprocess.run(cmd) - return res.returncode - except Exception: - return -1 + cmd = 'umount ' + dev + print("[Harddisk]"), cmd + res = os.system(cmd) + return res >> 8 def createPartition(self): cmd = 'printf "8,\n;0,0\n;0,0\n;0,0\ny\n" | sfdisk -f -uS ' + self.disk_path - try: - res = subprocess.run(cmd, shell=True) - return res.returncode - except Exception: - return -1 + res = os.system(cmd) + return res >> 8 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: - with open("/etc/fstab", "r", encoding="utf-8", errors="ignore") as fstab: - lines = fstab.readlines() + fstab = open('/etc/fstab') + lines = fstab.readlines() + fstab.close() except IOError: return -1 for line in lines: - parts = line.strip().split() - if not parts: - continue + parts = line.strip().split(' ') fspath = os.path.realpath(parts[0]) if fspath == dev: - print("[Harddisk] mounting:", fspath) - try: - res = subprocess.run(["mount", "-t", "auto", fspath]) - return res.returncode - except Exception: - return -1 + print("[Harddisk] mounting:"), fspath + cmd = 'mount -t auto ' + fspath + res = os.system(cmd) + return res >> 8 res = -1 if self.type == DEVTYPE_UDEV: - try: - subprocess.run(["hdparm", "-z", self.disk_path]) - from time import sleep - - sleep(3) - except Exception: - pass - return res + res = os.system('hdparm -z ' + self.disk_path) + from time import sleep + sleep(3) + return res >> 8 def fsck(self): return 1 def killPartitionTable(self): - 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) + zero = 512 * '\x00' + h = open(self.dev_path, 'wb') + for i in range(9): + h.write(zero) + + h.close() def killPartition(self, n): - zero = 512 * b"\x00" + zero = 512 * '\x00' part = self.partitionPath(n) - try: - with open(part, "wb") as h: - for i in range(3): - h.write(zero) - except Exception as ex: - print("[Harddisk] killPartition failed:", ex) + h = open(part, 'wb') + for i in range(3): + h.write(zero) + + h.close() 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")) + task = Task.ConditionTask(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'] - task.setTool("mkfs.ext3") +###__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') 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 @@ -490,19 +437,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 @@ -514,34 +461,25 @@ class Harddisk: def readStats(self): try: - with open( - "/sys/block/%s/stat" % self.device, - "r", - encoding="utf-8", - errors="ignore", - ) as f: - l = f.read() + l = open('/sys/block/%s/stat' % self.device).read() except IOError: return (-1, -1) data = l.split(None, 5) - try: - return (int(data[0]), int(data[4])) - except Exception: - return (-1, -1) + return (int(data[0]), int(data[4])) def startIdle(self): - try: - from enigma import eTimer - except Exception: - eTimer = None - - if self.bus() == _("External"): - Console().ePopen(("sdparm", "sdparm", "--set=SCT=0", self.disk_path)) + from enigma import eTimer + if self.bus() == _('External'): + Console().ePopen(('sdparm', + 'sdparm', + '--set=SCT=0', + self.disk_path)) else: - Console().ePopen(("hdparm", "hdparm", "-S0", self.disk_path)) - if eTimer is None: - return + Console().ePopen(('hdparm', + 'hdparm', + '-S0', + self.disk_path)) self.timer = eTimer() self.timer.callback.append(self.runIdle) self.idle_running = True @@ -553,7 +491,7 @@ class Harddisk: t = time.time() idle_time = t - self.last_access stats = self.readStats() - l = sum(stats) if isinstance(stats, (list, tuple)) else 0 + l = sum(stats) if l != self.last_stat and l >= 0: self.last_stat = l self.last_access = t @@ -564,63 +502,47 @@ 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 and self.timer: + if self.idle_running: if not idle: - try: - self.timer.stop() - except Exception: - pass + self.timer.stop() else: - try: - self.timer.start(int(idle * 100), False) - except Exception: - pass + self.timer.start(idle * 100, False) 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 = bool(mountpoint) and force_mounted + self.force_mounted = 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: @@ -629,6 +551,8 @@ class Partition: except OSError: return None + return None + def total(self): try: s = self.stat() @@ -636,11 +560,12 @@ 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: @@ -650,12 +575,9 @@ class Partition: if mounts is None: mounts = getProcMounts() for parts in mounts: - if ( - parts - and len(parts) > 1 - and self.mountpoint.startswith(parts[1]) - ): + if self.mountpoint.startswith(parts[1]): return True + return False def filesystem(self, mounts=None): @@ -663,107 +585,88 @@ class Partition: if mounts is None: mounts = getProcMounts() for fields in mounts: - if len(fields) < 3: - continue - if self.mountpoint.endswith( - "/") and not self.mountpoint == "/": - if fields[1] + "/" == self.mountpoint: + 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() - 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]) + 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'))) + known = set([os.path.normpath(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 = 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 + HasMMC = fileExists('/proc/cmdline') and 'root=/dev/mmcblk' in open('/proc/cmdline', 'r').read() + 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") or 0)) - if os.path.exists(devpath + "/dev"): - dev_raw = readFile(devpath + "/dev") - try: - dev = int(dev_raw.split(":")[0]) - except Exception: - dev = None + 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]) else: dev = None - 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"): + blacklisted = dev in [1, + 7, + 31, + 253, + 254] + (['HasMMC'] and [179] or []) + if blockdev[0:2] == 'sr': is_cdrom = True - if blockdev.startswith("hd"): + if blockdev[0:2] == '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 not partition.startswith(blockdev): + if partition[0:len(blockdev)] != blockdev: continue partitions.append(partition) + else: self.cd = blockdev except IOError: @@ -771,162 +674,127 @@ class HarddiskManager: medium_found = True try: - open("/dev/" + blockdev).close() + open('/dev/' + blockdev).close() except IOError as err: - try: - if hasattr(err, "errno") and err.errno == 159: - medium_found = False - except Exception: - medium_found = True + if err.errno == 159: + medium_found = False - 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...") - 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) + 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)) 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 and item[0] == dev: + if item[0] == dev: return item[1] + return None def addHotplugPartition(self, device, physdev=None): if not physdev: dev, part = self.splitDeviceName(device) try: - raw = os.path.realpath("/sys/block/" + dev + "/device") - physdev = raw[4:] if len(raw) > 4 else raw + physdev = os.path.realpath('/sys/block/' + dev + '/device')[4:] 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"): - 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) + 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) def addHotplugAudiocd(self, device, physdev=None): if not physdev: dev, part = self.splitDeviceName(device) try: - raw = os.path.realpath("/sys/block/" + dev + "/device") - physdev = raw[4:] if len(raw) > 4 else raw + physdev = os.path.realpath('/sys/block/' + dev + '/device')[4:] 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: - try: - hdd.stop() - except Exception: - pass - try: - self.hdd.remove(hdd) - except ValueError: - pass + hdd.stop() + self.hdd.remove(hdd) break - SystemInfo["Harddisk"] = len(self.hdd) > 0 + + SystemInfo['Harddisk'] = len(self.hdd) > 0 def HDDCount(self): return len(self.hdd) def HDDList(self): - ret = [] + list = [] for hd in self.hdd: - hddname = hd.model() + " - " + hd.bus() + hdd = hd.model() + ' - ' + hd.bus() cap = hd.capacity() - if cap != "": - hddname += " (" + cap + ")" - ret.append((hddname, hd)) - return ret + if cap != '': + hdd += ' (' + cap + ')' + list.append((hdd, hd)) + + return list def getCD(self): return self.cd @@ -934,101 +802,88 @@ 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 list(devs): + for devname in devs.copy(): if not devname: continue dev, part = self.splitDeviceName(devname) if part and dev in devs: - devs.discard(dev) + devs.remove(dev) + return [x for x in parts if not x.device or x.device in devs] def splitDeviceName(self, devname): - if len(devname) >= 3: - dev = devname[:3] - part = devname[3:] - else: - dev = devname - part = "" + dev = devname[:3] + part = devname[3:] for p in part: if not p.isdigit(): return (devname, 0) - return (dev, int(part) if part else 0) + + return (dev, part and int(part) or 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") or description + description = readFile('/sys' + phys + '/model') 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 - - with open(device, "rb") as cd: - ioctl(cd.fileno(), ioctl_flag, speed) + cd = open(device) + ioctl(cd.fileno(), ioctl_flag, speed) + cd.close() 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] - with open( - "/dev/nomount.%s" % dev, "w", encoding="utf-8", errors="ignore" - ) as f: - f.write("") + dev = self.hdd.disk_path.split('/')[-1] + open('/dev/nomount.%s' % dev, 'wb').close() 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) - try: - self.postconditions.append(Task.ReturncodePostcondition()) - except Exception: - pass + self.postconditions.append(Task.ReturncodePostcondition()) 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): @@ -1036,54 +891,40 @@ 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] - try: - os.unlink("/dev/nomount.%s" % dev) - except Exception: - pass + dev = self.hdd.disk_path.split('/')[-1] + os.unlink('/dev/nomount.%s' % dev) 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 - try: - with open("/etc/fstab", "r", encoding="utf-8", errors="ignore") as fstab: - lines = fstab.readlines() - except Exception: - lines = [] - + fstab = open('/etc/fstab') + lines = fstab.readlines() + fstab.close() for line in lines: - parts = line.strip().split() - if not parts: - continue + parts = line.strip().split(' ') fspath = os.path.realpath(parts[0]) if os.path.realpath(fspath) == dev: - self.setCmdline("mount -t auto " + fspath) - try: - self.postconditions.append(Task.ReturncodePostcondition()) - except Exception: - pass + self.setCmdline('mount -t auto ' + fspath) + self.postconditions.append(Task.ReturncodePostcondition()) return if self.hdd.type == DEVTYPE_UDEV: - self.setCmdline("sleep 2; hdparm -z " + self.hdd.disk_path) - try: - self.postconditions.append(Task.ReturncodePostcondition()) - except Exception: - pass + self.setCmdline('sleep 2; hdparm -z ' + self.hdd.disk_path) + self.postconditions.append(Task.ReturncodePostcondition()) return @@ -1094,196 +935,127 @@ 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" - 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: + 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: try: - 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 + 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])) except Exception as e: - print("[Mkfs] E:", e) + print("[Mkfs] E:"), e + return - try: - self.log.append(data) - except Exception: - pass + self.log.append(data) +###########################__From HarddiskSetup_################################ class HarddiskSetup(Screen): def __init__(self, session, hdd, action, text, question): Screen.__init__(self, session) self.action = action self.question = question - 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} - ) + 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): if not confirmed: return try: - from .Task import job_manager - except Exception: + from Task import job_manager + except: 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 and selection[1] != 0: + selection = self['hddlist'].getCurrent() + if 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!" - ), - ) + 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() def isSleepStateDevice(device): - """ - 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: + ret = os.popen('hdparm -C %s' % device).read() + if 'SG_IO' in ret or 'HDIO_DRIVE_CMD' in ret: return None - if "drive state is: standby" in ret or "drive state is: idle" in ret: + elif 'drive state is: standby' in ret or 'drive state is: idle' in ret: return True - if "drive state is: active/idle" in ret or "drive state is: active/idle" in ret: + elif 'drive state is: active/idle' in ret: return False - return None + else: + return None def internalHDDNotSleeping(external=False): state = False if harddiskmanager.HDDCount(): for hdd in harddiskmanager.HDDList(): - 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 + if hdd[1].internal or external: + if hdd[1].idle_running and hdd[1].max_idle_time and not hdd[1].isSleeping(): + state = True + return state -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 +harddiskmanager = HarddiskManager() +SystemInfo['ext4'] = isFileSystemSupported('ext4') or isFileSystemSupported('ext3') diff --git a/NeoBoot/files/Task.py b/NeoBoot/files/Task.py index c2a04ca..8bc5642 100644 --- a/NeoBoot/files/Task.py +++ b/NeoBoot/files/Task.py @@ -1,13 +1,15 @@ +# -*- coding: utf-8 -*- + from Tools.CList import CList class Job(object): - NOT_STARTED, IN_PROGRESS, FINISHED, FAILED = list(range(4)) + NOT_STARTED, IN_PROGRESS, FINISHED, FAILED = range(4) 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 @@ -31,20 +33,16 @@ 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,10 +71,7 @@ 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() @@ -87,18 +82,18 @@ class Job(object): if stay_resident: if cb_idx not in self.resident_tasks: self.resident_tasks.append(self.current_task) - print(("task going resident:"), task) + print("task going resident:"), task else: - print(("task keeps staying resident:"), task) + print("task keeps staying resident:"), task return if len(res): - print((">>> Error:"), res) + print(">>> Error:"), res self.status = self.FAILED self.state_changed() self.callback(self, task, res) if cb_idx != self.current_task: if cb_idx in self.resident_tasks: - print(("resident task finished:"), task) + print("resident task finished:"), task self.resident_tasks.remove(cb_idx) if res == []: self.state_changed() @@ -118,12 +113,8 @@ class Job(object): self.abort() def __str__(self): - try: - return "Components.Task.Job name=%s #tasks=%s" % ( - self.name, len(self.tasks)) - except Exception as ex: - 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): @@ -139,11 +130,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 @@ -179,7 +170,6 @@ class Task(object): return else: from enigma import eConsoleAppContainer - self.container = eConsoleAppContainer() self.container.appClosed.append(self.processFinished) self.container.stdoutAvail.append(self.processStdout) @@ -187,25 +177,16 @@ 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 return def run(self, callback): - failed_preconditions = self.checkPreconditions( - True) + self.checkPreconditions(False) + failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False) if failed_preconditions: print("[Task] preconditions failed") callback(self, failed_preconditions) @@ -215,7 +196,7 @@ class Task(object): self.prepare() self._run() except Exception as ex: - print(("[Task] exception:"), ex) + print("[Task] exception:"), ex self.postconditions = [FailedPostcondition(ex)] self.finish() @@ -234,14 +215,14 @@ 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): - print(("[Task %s]") % self.name, line[:-1]) + print("[Task %s]") % self.name, line[:-1] def processFinished(self, returncode): self.returncode = returncode @@ -286,10 +267,7 @@ class Task(object): progress = property(getProgress, setProgress) def __str__(self): - try: - return "Components.Task.Task name=%s" % self.name - except Exception as ex: - return 'Components.Task.Task name=%s' % self.name + return 'Components.Task.Task name=%s' % self.name class LoggingTask(Task): @@ -299,7 +277,7 @@ class LoggingTask(Task): self.log = [] def processOutput(self, data): - print(("[%s]") % self.name, data, end=" ") + print("[%s]") % self.name, data, self.log.append(data) @@ -308,7 +286,6 @@ 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) @@ -317,7 +294,7 @@ class PythonTask(Task): self.timer.start(5) def work(self): - raise NotImplemented + raise (NotImplemented, "work") def abort(self): self.aborted = True @@ -346,13 +323,12 @@ 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 @@ -363,7 +339,7 @@ class ConditionTask(Task): self.triggerCount += 1 try: if self.timeoutCount is not None and self.triggerCount > self.timeoutCount: - raise Exception + raise (Exception, "Timeout elapsed, sorry") res = self.check() except Exception as e: self.postconditions.append(FailedPostcondition(e)) @@ -405,27 +381,15 @@ 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): - print(("job"), job, ("completed with"), problems, ("in"), task) + print("job"), job, ("completed with"), problems, ("in"), task if problems: if not job.onFail(job, task, problems): self.errorCB(False) @@ -440,7 +404,6 @@ class JobManager: if not self.visible: from Tools import Notifications from Screens.TaskView import JobView - self.visible = True Notifications.AddNotification(JobView, job) @@ -467,10 +430,7 @@ 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): @@ -487,7 +447,6 @@ 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 @@ -496,50 +455,34 @@ 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!" - ) + print("[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 = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file=task.cmd: os.path.join(directory, file), path)) 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): @@ -548,13 +491,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): @@ -564,13 +507,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 3d598c1..9f8891e 100644 --- a/NeoBoot/files/__init__.py +++ b/NeoBoot/files/__init__.py @@ -1,28 +1,26 @@ +# -*- coding: utf-8 -*- + +from __future__ import print_function 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 9138282..3c9350d 100644 --- a/NeoBoot/files/devices.py +++ b/NeoBoot/files/devices.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from Plugins.Extensions.NeoBoot.__init__ import _ from enigma import getDesktop from Plugins.Plugin import PluginDescriptor @@ -13,13 +15,7 @@ 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 @@ -30,24 +26,15 @@ 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, -) - - -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" - +from Plugins.Extensions.NeoBoot.files.stbbranding import getTunerModel, getCheckExt, getBoxHostName, getMyUUID +if not fileExists('/usr/lib/python2.7'): + open = file + getoutput = "os.system" +else: + from commands import getoutput +LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' class ManagerDevice(Screen): screenwidth = getDesktop(0).size().width() @@ -81,27 +68,22 @@ 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() @@ -109,49 +91,27 @@ 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 BaseException: - 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: + 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 @@ -159,197 +119,154 @@ 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 BaseException: - name = "" - desc = "" + desc = str(self.sel[1].replace('\t', ' ')) + except: + 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 = [] - 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 = 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) - self["list"].list = self.list - self["lab1"].hide() + f.close() + 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" - - 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 = _('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 = 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') - 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 - + f.close() size = Harddisk(device).diskSize() if float(size) / 1024 / 1024 >= 1: - des = _("Size: ") + \ - str(round(float(size) / 1024 / 1024, 2)) + _("TB") - elif float(size) / 1024 >= 1: - des = _("Size: ") + str(round(float(size) / 1024, 2)) + _("GB") + des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') + elif 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 @@ -357,64 +274,37 @@ 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) - - 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) - - + 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) + + class DevicesConf(Screen, ConfigListScreen): screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth == 1920: @@ -436,240 +326,197 @@ 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) - 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() + f.close() + 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" - - 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 = _('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 = name + model - 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 = 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') + f.close() size = Harddisk(device).diskSize() if float(size) / 1024 / 1024 >= 1: - des = _("Size: ") + \ - str(round(float(size) / 1024 / 1024, 2)) + _("TB") - elif float(size) / 1024 >= 1: - des = _("Size: ") + str(round(float(size) / 1024, 2)) + _("GB") + des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') + elif 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) # Python 3 print function + print("[MountManager] RESULT:"), result if result: self.device = extra_args[0] self.mountp = extra_args[1] - - 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 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' if not path.exists(self.mountp): mkdir(self.mountp, 493) - - 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('"', "") + 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() +#SetDiskLabel - dziekuje autorowi class SetDiskLabel(Screen): screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth == 1920: @@ -698,7 +545,7 @@ class SetDiskLabel(Screen): - """ % (_("!!!Do not set the label for /dev/mmcblk0p !!!")) + """ % (_('!!!Do not set the label for /dev/mmcblk0p !!!')) else: skin = """ @@ -724,146 +571,104 @@ 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 = [""] - blackL = "" - if getTunerModel() in ("sf8008", "sf8008s", "sf8008t"): - blackL = "mmcblk0" - if getTunerModel() in ("h9se"): - blackL = "mmcblk1" + lista = [''] + if getTunerModel() in ('sf8008', 'sf8008s', 'sf8008t'): + blackL = 'mmcblk0' + if getTunerModel() in ('h9se'): + blackL = 'mmcblk1' else: - blackL_output = getoutput( - 'cat /etc/udev/mount-helper.sh | grep "BLACKLISTED="' - ) - if blackL_output: - blackL = blackL_output[13:-1] - - devL = getoutput( - "cat /proc/partitions | grep \"sd\\|mmc\" | awk '{print $4}'") - devL = devL.split("\n") + blackL = getoutput('cat /etc/udev/mount-helper.sh | grep "BLACKLISTED="') + blackL = blackL[13:-1] + 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]): + if self.sprLinux(devL[i]) == True: lista.append(devL[i]) i += 1 if ilosc > 0: - lista.remove("") - elif lista[0] == "": - lista.remove("") - lista.insert(0, "No Disk") + 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: - 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 == 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) 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: - os.system('e2label /dev/%s ""' % str(self["devlist"].getCurrent())) - self.session.open( - MessageBox, - _("Label is delete"), - type=MessageBox.TYPE_INFO, - timeout=10) + 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) 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: @@ -871,21 +676,21 @@ class SetDiskLabel(Screen): return def sprLabel(self): - lab = getoutput("blkid /dev/" + self["devlist"].getCurrent()) - lab1 = lab.split(" ") + 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]) + if lab1[i][:5] == 'LABEL': + self['disklabel'].setText(lab1[i][7:-1]) break else: - self["disklabel"].setText(_("No label")) + self['disklabel'].setText(_('No label')) i += 1 def sprLinux(self, dev): - lab = getoutput("blkid /dev/" + dev) - lab1 = lab.split(" ") + lab = getoutput('blkid /dev/' + dev) + lab1 = lab.split(' ') licz1 = len(lab1) jest = False j = 0 @@ -897,28 +702,25 @@ class SetDiskLabel(Screen): 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) @@ -930,12 +732,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 f4785f3..7c201dc 100644 --- a/NeoBoot/files/neoconsole.py +++ b/NeoBoot/files/neoconsole.py @@ -1,4 +1,7 @@ +# -*- 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 @@ -13,39 +16,29 @@ class Console(Screen): """ - 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) + + 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 @@ -64,14 +57,9 @@ 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) @@ -84,20 +72,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 @@ -105,26 +93,27 @@ 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() @@ -135,13 +124,7 @@ 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 @@ -151,18 +134,9 @@ class Console(Screen): def saveOutputText(self): from time import time, localtime - lt = localtime(time()) - 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.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) def formatCmdList(self, source): if isinstance(source, (list, tuple)): @@ -176,47 +150,41 @@ 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 BaseException: - text += "error read commands!!!\n\n" + text += 'next commands:\n\n' + '\n'.join(cmdlist[1:]) + '\n\n' + except: + 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 BaseException: + except: 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: @@ -227,12 +195,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 BaseException: + except: if file == self.output_file: - rd = self["text"].getText() + rd = self['text'].getText() else: rd = "File read error: '%s'\n" % file @@ -250,4 +218,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 228420e..eff8602 100644 --- a/NeoBoot/files/stbbranding.py +++ b/NeoBoot/files/stbbranding.py @@ -1,1297 +1,1223 @@ +# -*- coding: utf-8 -*- + +#from Plugins.Extensions.NeoBoot.__init__ import _ import sys import os import time -import subprocess -from glob import glob +from Tools.Directories import fileExists, SCOPE_PLUGINS +LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' -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 _(s): - return s - - -def Log(param=""): - """ - Basic file-backed logger handler. Modes: 'open', 'write', 'append', 'close', 'flush'. - Returns the file object or None. - """ +def Log(param=''): global LogFileObj - p = str(param).lower() - if p in ("open", "write", "append", "close"): + #first close object if exists + if param.lower() in ['open', 'write', 'append', 'close']: if LogFileObj is not None: - 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!!!") - except Exception: + 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: + print("ERROR closing LogFile!!!") + else: + print("ERROR closing LogFile!!!") + #second create object if does not exist if LogFileObj is None: - 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": + if param.lower() in ['open', 'write']: + LogFileObj = open(LogFile, "w") + elif param.lower() in ['append']: + LogFileObj = open(LogFile, "a") + elif param.lower() in ['close']: pass - elif p == "flush": - try: - LogFileObj.flush() - except Exception: - pass - + elif param.lower() in ['flush']: + LogFileObj.flush() return LogFileObj def clearMemory(): - try: - with open( - "/proc/sys/vm/drop_caches", "w", encoding="utf-8", errors="ignore" - ) as f: - f.write("1\n") - except Exception: - pass + with open("/proc/sys/vm/drop_caches", "w") as f: + f.write("1\n") + f.close() def LogCrashGS(line): - 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"): + 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() + + +def fileCheck(f, mode='r'): return fileExists(f, mode) and f +# if not IsImageName(): +# from Components.PluginComponent import plugins +# plugins.reloadPlugins() + def IsImageName(): - 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 + if fileExists("/etc/issue"): + for line in open("/etc/issue"): + if "BlackHole" in line or "vuplus" in line: + return True + return False def mountp(): - pathmp = [] - 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 + 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/') + return pathmp def getSupportedTuners(): - 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 + 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() return supportedT def getFreespace(dev): - 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 + 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 def getCheckInstal1(): - 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 + 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' return neocheckinstal def getCheckInstal2(): - 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 + 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' return neocheckinstal def getCheckInstal3(): - 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 + 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' + return neocheckinstal +#check imageATV + def getImageATv(): - 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 + 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' return atvimage +#check install + def getNeoLocation(): - 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 + 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 return locatinoneo +#check ext def getFormat(): - 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 + 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' + return neoformat def getNEO_filesystems(): - 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 + 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' + return neo_filesystems +#typ procesora arm lub mips + def getCPUtype(): - 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 + 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' return cpu +#check install + def getFSTAB(): - 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 + 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' return install def getFSTAB2(): - 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 + 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' return install def getINSTALLNeo(): - 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 + 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' + return neoinstall def getLocationMultiboot(): - 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 + 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' + return LocationMultiboot def getLabelDisck(): - 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 + 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=' return label +#checking device neo + def getNeoMountDisc(): - 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 + lines_mount = 'UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines_mount = f.read() + f.close() + return lines_mount + def getNeoMount(): - 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 + 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' + return neo - - + + def getNeoMount2(): - 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 + 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' + return neo def getNeoMount3(): - 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 + 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' return neo def getNeoMount4(): - 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 + 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' return neo def getNeoMount5(): - 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 + 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' return neo +#zwraca typ chipa prcesora def getCPUSoC(): - 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 + 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' return chipset def getCPUSoCModel(): - 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 + 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() return devicetree +#zwraca wybrane image w neoboot do uruchomienia + def getImageNeoBoot(): - 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 + imagefile = 'UNKNOWN' + if os.path.exists('%sImageBoot/.neonextboot' % getNeoLocation()): + with open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') as f: + imagefile = f.readline().strip() + f.close() return imagefile +#zwraca model vuplus + def getBoxVuModel(): - 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 + 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() return vumodel def getVuModel(): - try: - 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 - - except Exception: - pass - return "unknown" + 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 def getBoxHostName(): - 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" + if os.path.exists('/etc/hostname'): + with open('/etc/hostname', 'r') as f: + myboxname = f.readline().strip() + f.close() + return myboxname + +#zwraca vuplus/vumodel -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 +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() return BOX_NAME +#zwraca strukture folderu zip - vuplus/vumodel + def getImageFolder(): - ImageFolder = None - try: - if os.path.isfile("/proc/stb/info/vumodel"): - BOX_NAME = getBoxModelVU() - ImageFolder = "vuplus/" + BOX_NAME - except Exception: - pass + if os.path.isfile('/proc/stb/info/vumodel'): + BOX_NAME = getBoxModelVU() + ImageFolder = 'vuplus/' + BOX_NAME return ImageFolder +#zwraca nazwe kernela z /lib/modules + def getKernelVersion(): 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") + return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] + except: + return _('unknown') + +# czysci pamiec 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(str(x) for x in cmdsList) - else: - myCMD = str(cmdsList) - try: - result = subprocess.run(myCMD, shell=True) - return result.returncode - except Exception: - return -1 + myCMD = '\n'.join(cmdsList)# + '\n' + ret = os.system(myCMD) + return rett def getImageDistroN(): - 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 = '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 = 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: - out = subprocess.check_output(["uname", "-r"]) - kernel_version = out.decode( - "utf-8", errors="ignore").strip().split("-")[0] + result = open('uname -r', 'r').read().strip('\n').split('-') + kernel_version = result[0] return kernel_version - 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" + except: + pass + + return 'unknown' def getKernelImageVersion(): try: - 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() + 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 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: - 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" + lines = open('/etc/typboxa', 'r').readlines() + typboxa = lines[0][:-1] + except: + typboxa = 'not detected' + + return typboxa def getImageVersionString(): try: - 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: + 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: pass - return _("unavailable") + + return _('unavailable') def getModelString(): try: - with open( - "/proc/stb/info/boxtype", "r", encoding="utf-8", errors="ignore" - ) as file: - model = file.readline().strip() + file = open('/proc/stb/info/boxtype', 'r') + model = file.readline().strip() + file.close() return model - except Exception: - return "unknown" + except IOError: + return 'unknown' def getChipSetString(): try: - 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" + f = open('/proc/stb/info/chipset', 'r') + chipset = f.read() + f.close() + return str(chipset.lower().replace('\n', '').replace('bcm', '')) + except IOError: + return 'unavailable' def getCPUString(): try: - 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] + 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() return system - except Exception: - return "unavailable" + except IOError: + return 'unavailable' def getCpuCoresString(): try: - 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 + 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() return cores - except Exception: - return "unavailable" + except IOError: + return 'unavailable' def getEnigmaVersionString(): - try: - import enigma + import enigma + enigma_version = enigma.getEnigmaVersionString() + if '-(no branch)' in enigma_version: + enigma_version = enigma_version[:-12] + return enigma_version - enigma_version = enigma.getEnigmaVersionString() - if "-(no branch)" in enigma_version: - enigma_version = enigma_version[:-12] - return enigma_version - except Exception: - return _("unavailable") + +def getKernelVersionString(): + try: + f = open('/proc/version', 'r') + kernelversion = f.read().split(' ', 4)[2].split('-', 2)[0] + f.close() + return kernelversion + except: + return _('unknown') def getHardwareTypeString(): try: - 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: + 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: pass - return _("unavailable") + + return _('unavailable') def getImageTypeString(): try: - lines = open( - "/etc/issue", - "r", - encoding="utf-8", - errors="ignore").readlines() - if len(lines) >= 2: - return lines[-2].capitalize().strip()[:-6] - except Exception: + return open('/etc/issue').readlines()[-2].capitalize().strip()[:-6] + except: pass - return _("undefined") + + return _('undefined') def getMachineBuild(): 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" + return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] + except: + return 'unknown' def getVuBoxModel(): - 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() + if fileExists('/proc/stb/info/vumodel'): + try: + l = open('/proc/stb/info/vumodel') + model = l.read() + l.close() BOX_NAME = str(model.lower().strip()) - BOX_MODEL = "vuplus" - except Exception: - BOX_MODEL = "not detected" + l.close() + BOX_MODEL = 'vuplus' + except: + BOX_MODEL = 'not detected' + return BOX_MODEL def getBoxModelVU(): try: - 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: + if os.path.isfile('/proc/stb/info/vumodel'): + return open('/proc/stb/info/vumodel').read().strip().upper() + except: pass - return _("unavailable") + + return _('unavailable') def 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 + 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() return procmodel def getMountPointAll(): - 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 + 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') def getMountPointNeo(): - 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 + 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') def getMountPointNeo2(): - 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 - - + #--------------------------------------------- + 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') + def getBoxMacAddres(): - 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 + 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' + return ethernetmac def getCheckActivateVip(): - 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 + 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() return supportedvip - - + def getMountDiskSTB(): - 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 + 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:') + return neo_disk def getCheckExtDisk(): - 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" - - + 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 + def getCheckExt(): - 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 + 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' return neoExt - def getExtCheckHddUsb(): - 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 + 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' return neoExt - def getNandWrite(): - 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 + 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' + 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: - 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: + if os.path.isfile('/tmp/.myuuid'): + return open('/tmp/.myuuid').read().strip().upper() + except: pass - return _("unavailable") + return _('unavailable') def getImageBootNow(): - 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 + imagefile = 'UNKNOWN' + if os.path.exists('/.multinfo'): + with open('/.multinfo' , 'r') as f: + imagefile = f.readline().strip() + f.close() return imagefile - def getNeoActivatedtest(): - 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 + 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' + return neoactivated boxbrand = sys.modules[__name__] diff --git a/NeoBoot/files/testinout b/NeoBoot/files/testinout index 2ff3289..80eb8e4 100644 --- a/NeoBoot/files/testinout +++ b/NeoBoot/files/testinout @@ -10,8 +10,8 @@ from Tools.Directories import fileExists, SCOPE_PLUGINS def getAccesDate(): timego = '' - dana = getTestOutTime() # etc Nie! Szukana liczba jest wieksza! - strzal = getTestInTime() # tmp Nie! Szukana liczba jest mniejsza! + dana = getTestOutTime() # etc Nie! Szukana liczba jest wieksza! + strzal = getTestInTime() # tmp Nie! Szukana liczba jest mniejsza! if strzal == dana: timego = 'access' elif strzal < dana: diff --git a/NeoBoot/files/tools.py b/NeoBoot/files/tools.py index 2c90bfc..9041b36 100644 --- a/NeoBoot/files/tools.py +++ b/NeoBoot/files/tools.py @@ -1,3 +1,7 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# system modules + from __future__ import absolute_import from __future__ import print_function from Plugins.Extensions.NeoBoot.__init__ import _ @@ -19,165 +23,99 @@ 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(): s = getDesktop(0).size() return (s.width(), s.height()) - def isFHD(): desktopSize = getDS() return desktopSize[0] == 1920 - def isHD(): desktopSize = getDS() return desktopSize[0] >= 1280 and desktopSize[0] < 1920 - def isUHD(): desktopSize = getDS() return desktopSize[0] >= 1920 and desktopSize[0] < 3840 - def getKernelVersion(): try: - 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") - - + return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] + except: + 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"): - 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' + 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' - return neoactivated + 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() - class BoundFunction: __module__ = __name__ @@ -188,7 +126,6 @@ class BoundFunction: def __call__(self): self.fnc(*self.args) - class MBTools(Screen): if isFHD(): skin = """ @@ -210,142 +147,139 @@ 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(mypath + "icons"): - mypixmap = "" + LinkNeoBoot + "/images/ok.png" + 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' 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 + + res = (_('Restore a copy of the image to NeoBoot'), png, 1) + self.list.append(res) + self['list']. list = self.list + + res = (_('Device manager'), png, 2) + self.list.append(res) + self['list']. list = self.list + + res = (_('Set the disk label and uuid'), png, 3) + self.list.append(res) + self['list']. list = self.list + + res = (_('Delete image ZIP from the ImagesUpload directory'), png, 4) + self.list.append(res) + self['list']. list = self.list + + res = (_('NeoBoot Backup'), png, 5) + self.list.append(res) + self['list']. list = self.list + + res = (_('Restore neoboot backup'), png, 6) + self.list.append(res) + self['list']. list = self.list + + res = (_('Uninstall NeoBoot'), png, 7) + self.list.append(res) + self['list']. list = self.list + + res = (_('Update NeoBoot on all images.'), png, 8) + self.list.append(res) + self['list']. list = self.list + + res = (_('Update TV list on installed image.'), png, 9) + self.list.append(res) + self['list']. list = self.list + + res = (_('Update IPTVPlayer on installed image.'), png, 10) + self.list.append(res) + self['list']. list = self.list + + res = (_("Install VAVOO."), png, 11) self.list.append(res) self["list"].list = self.list - res = (_("Restore a copy of the image to NeoBoot"), png, 1) + res = (_('Removing the root password.'), png, 12) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("Device manager"), png, 2) + res = (_('Check the correctness of neoboot installation'), png, 13) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("Set the disk label and uuid"), png, 3) + res = (_('Skin change'), png, 14) 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 = (_('Block or unlock skins.'), png, 15) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("NeoBoot Backup"), png, 5) + res = (_('Mount Internal Flash'), png, 16) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("Restore neoboot backup"), png, 6) + res = (_('Deleting languages'), png, 17) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("Uninstall NeoBoot"), png, 7) + res = (_('Updates feed cam OpenATV softcam'), png, 18) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("Update NeoBoot on all images."), png, 8) + res = (_('Create swap- file.'), png, 19) self.list.append(res) - self["list"].list = self.list + self['list']. list = self.list - res = (_("Update TV list on installed image."), png, 9) + res = (_('Supported sat tuners'), png, 20) self.list.append(res) - self["list"].list = self.list - - res = (_("Update IPTVPlayer on installed image."), png, 10) + self['list']. list = self.list + + res = (_('Install IPTVPlayer'), png, 21) self.list.append(res) - self["list"].list = self.list - - res = (_("Update FeedExtra on the installed image."), png, 11) + self['list']. list = self.list + + res = (_('Install Multi Stalker'), png, 22) self.list.append(res) - self["list"].list = self.list - - res = (_("Removing the root password."), png, 12) + self['list']. list = self.list + + res = (_('Install Multiboot Flash Online'), png, 23) self.list.append(res) - self["list"].list = self.list - - res = (_("Check the correctness of neoboot installation"), png, 13) + self['list']. list = self.list + + res = (_('Install Dream Sat Panel'), png, 24) self.list.append(res) - self["list"].list = self.list - - res = (_("Skin change"), png, 14) + self['list']. list = self.list + + res = (_('Initialization - formatting disk for neoboot.'), png, 25) self.list.append(res) - self["list"].list = self.list - - res = (_("Block or unlock skins."), png, 15) - self.list.append(res) - self["list"].list = self.list - - res = (_("Mount Internal Flash"), png, 16) - self.list.append(res) - self["list"].list = self.list - - res = (_("Deleting languages"), png, 17) - self.list.append(res) - self["list"].list = self.list - - res = (_("Updates feed cam OpenATV softcam"), png, 18) - self.list.append(res) - self["list"].list = self.list - - res = (_("Create swap- file."), png, 19) - self.list.append(res) - self["list"].list = self.list - - res = (_("Supported sat tuners"), png, 20) - self.list.append(res) - self["list"].list = self.list - - res = (_("Install IPTVPlayer"), png, 21) - self.list.append(res) - self["list"].list = self.list - - res = (_("Install Multi Stalker"), png, 22) - self.list.append(res) - self["list"].list = self.list - - res = (_("Install Multiboot Flash Online"), png, 23) - self.list.append(res) - self["list"].list = self.list - - res = (_("Install Dream Sat Panel"), png, 24) - self.list.append(res) - self["list"].list = self.list - - res = (_("Initialization - formatting disk for neoboot."), png, 25) - self.list.append(res) - self["list"].list = self.list - - if ( - "vu" + getBoxVuModel() == getBoxHostName() - or getBoxHostName() == "et5x00" - and getCPUtype() == "MIPS" - and not fileExists("/.multinfo") - ): - res = (_("Boot Managers."), png, 26) + self['list']. list = self.list + + 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 - - res = (_("NeoBoot Information"), png, 27) + self['list']. list = self.list + + 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): @@ -355,7 +289,7 @@ class MBTools(Screen): if self.sel == 2 and self.session.open(MenagerDevices): pass if self.sel == 3 and self.session.open(SetDiskLabel): - pass + pass if self.sel == 4 and self.session.open(MBDeleUpload): pass if self.sel == 5 and self.session.open(BackupMultiboot): @@ -370,7 +304,7 @@ class MBTools(Screen): pass if self.sel == 10 and self.session.open(IPTVPlayer): pass - if self.sel == 11 and self.session.open(FeedExtra): + if self.sel == 11 and self.session.open(VAVOO): pass if self.sel == 12 and self.session.open(SetPasswd): pass @@ -391,22 +325,23 @@ class MBTools(Screen): if self.sel == 20 and self.session.open(TunerInfo): pass if self.sel == 21 and self.session.open(IPTVPlayerInstall): - pass + pass if self.sel == 22 and self.session.open(MultiStalker): pass if self.sel == 23 and self.session.open(MultibootFlashonline): - pass + pass if self.sel == 24 and self.session.open(DreamSatPanel): - pass + pass if self.sel == 25 and self.session.open(InitializationFormattingDisk): - pass + pass if self.sel == 26 and self.session.open(BootManagers): - pass + pass if self.sel == 27 and self.session.open(MultiBootMyHelp): pass if self.sel == 28 and self.session.open(neoDONATION): - pass - + pass +# if self.sel == 28and self.session.open(CheckInternet): +# pass class MBBackup(Screen): if isFHD(): @@ -433,50 +368,104 @@ 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 + # 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") + # 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'] + 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 + "" + 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: @@ -487,93 +476,67 @@ 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) - - imageslist = ["Flash"] - for fn in listdir("/media/" + neoboot + "/ImageBoot"): - dirfile = "/media/" + neoboot + "/ImageBoot/" + fn + 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): 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")) + self.myClose(_('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 = _( - "Unfortunately you cannot backup from flash with this plugin. \nInstall backupsuite to a copy of the image from flash memory." - ) + 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.') 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 - ybox = self.session.openWithCallback( - self.dobackupImage, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_("Backup confirmation")) + 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) + ybox = self.session.openWithCallback(self.dobackupImage, MessageBox, message, MessageBox.TYPE_YESNO) + 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" - 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] - ) + 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]) self.close() else: self.close() def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class MBRestore(Screen): @@ -591,56 +554,50 @@ 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: @@ -651,119 +608,91 @@ 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")) + self.myClose(_('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 - ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Confirmation of Deletion...")) + message = (_('Software selected: %s remove ?') % image) + ybox = self.session.openWithCallback(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]) + 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]) 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")) + self.myClose(_('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 == "": - message = ( - _("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")) + 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) + ybox = self.session.openWithCallback(self.dorestoreImage, MessageBox, message, MessageBox.TYPE_YESNO) + ybox.setTitle(_('Restore Confirmation')) else: self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) def dorestoreImage(self, answer): 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], - ) + 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]) self.close() else: self.close() def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class MenagerDevices(Screen): @@ -776,25 +705,22 @@ 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 + from Plugins.Extensions.NeoBoot.files.devices import ManagerDevice + self.session.open(ManagerDevice) - self.session.open(ManagerDevice) - - except BaseException: - self.myClose( - _("Sorry, the operation is not possible from Flash or not supported.")) + except: + self.myClose(_('Sorry, the operation is not possible from Flash or not supported.')) def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() - + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class SetDiskLabel(Screen): __module__ = __name__ @@ -806,29 +732,25 @@ 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"): - from Plugins.Extensions.NeoBoot.files.devices import SetDiskLabel - - self.session.open(SetDiskLabel) + 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 BaseException: - self.myClose( - _("Sorry, the operation is not possible from Flash or not supported.")) + from Plugins.Extensions.NeoBoot.files.tools import DiskLabelSet + self.session.open(DiskLabelSet) + except: + self.myClose(_('Sorry, the operation is not possible from Flash or not supported.')) def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() - + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class MBDeleUpload(Screen): __module__ = __name__ @@ -840,26 +762,21 @@ 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") - ybox = self.session.openWithCallback( - self.pedeleup, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("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')) 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() @@ -883,21 +800,15 @@ 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], - ) - self.close() + cmd = 'sh ' + LinkNeoBoot + '/files/neobackup.sh -i' + self.session.open(Console, _('The backup will be saved to /media/neoboot. Performing ...'), [cmd]) + self.close() class UnistallMultiboot(Screen): @@ -910,113 +821,68 @@ 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")) + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() def usun2(self): - message = _( - "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")) + message = _('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')) 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() def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() def checkNeo(self): - if not fileCheck("" + LinkNeoBoot + "/.location") and not fileCheck( - " " + getNeoLocation() + "ImageBoot/.neonextboot" - ): - self.restareE2() - else: - self.close() + if not fileCheck('' + LinkNeoBoot + '/.location') and not fileCheck(' ' + getNeoLocation() + 'ImageBoot/.neonextboot'): + self.restareE2() + else: + self.close() def restareE2(self): self.session.open(TryQuitMainloop, 3) @@ -1032,15 +898,13 @@ 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) + self.session.open(ReinstllNeoBoot2) class ReinstllNeoBoot2(Screen): @@ -1058,24 +922,19 @@ 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 @@ -1083,57 +942,46 @@ 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 - ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Confirmation of Deletion...")) + message = (_('Software selected: %s remove ?') % image) + ybox = self.session.openWithCallback(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]) + 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]) self.updateInfo() else: self.close() def restoreImage(self): - 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) - ybox = self.session.openWithCallback( - self.dorestoreImage, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Restore Confirmation")) + 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) + ybox = self.session.openWithCallback(self.dorestoreImage, MessageBox, message, MessageBox.TYPE_YESNO) + ybox.setTitle(_('Restore Confirmation')) else: - self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) + 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]) + 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]) self.close() else: self.close() @@ -1149,153 +997,117 @@ 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")) + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class MyUpgrade2(Screen): - if isFHD(): - skin = """ + if isFHD(): + skin = """ """ - else: - skin = '\n\t\t\n\t' - - def __init__(self, session): - Screen.__init__(self, session) - self["lab1"] = Label( - _("[NeoBoot]Please wait, updating in progress ...")) - self.activityTimer = eTimer() - self.activityTimer.timeout.get().append(self.updateInfo) - self.onShow.append(self.startShow) - - def startShow(self): - 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" - self.activityTimer.stop() - f2 = open("%sImageBoot/.neonextboot" % getNeoLocation(), "r") - mypath2 = f2.readline().strip() - f2.close() - if mypath2 != "Flash": - self.myClose( - _("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 - 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" + skin = '\n\t\t\n\t' - cmd = "rm -r " + target + " > /dev/null 2>&1" - system(cmd) - cmd1 = "cp -af " + periodo + " " + target1 - system(cmd1) - cmd2 = "cp -af " + testinout + " " + target2 - system(cmd2) - if fileExists("%s" % target3): - if fileExists("/var/lib/zerotier-one/identity.secret"): - cmd = "cp -aRf " + zerotier + " " + target3 + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('[NeoBoot]Please wait, updating in progress ...')) + self.activityTimer = eTimer() + self.activityTimer.timeout.get().append(self.updateInfo) + self.onShow.append(self.startShow) + + def startShow(self): + 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' + self.activityTimer.stop() + f2 = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'r') + mypath2 = f2.readline().strip() + f2.close() + if mypath2 != 'Flash': + self.myClose(_('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 + 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' + + cmd = 'rm -r ' + target + ' > /dev/null 2>&1' + system(cmd) + cmd1 = 'cp -af ' + periodo + ' ' + target1 + system(cmd1) + 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 + system(cmd) + + cmd4 = 'cp -aRf ' + S99neo + ' ' + target4 + system(cmd4) + + 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' + system(cmd6) + + 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') + + #przenoszenie wtyczki neoboot + cmd = 'cp -af ' + LinkNeoBoot + ' ' + target + system(cmd) + + #multiboot_vu+ + if fileExists('/linuxrootfs1'): + cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs1' + LinkNeoBoot + ' ' system(cmd) + if fileExists('/linuxrootfs2'): + cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs2' + LinkNeoBoot + ' ' + system(cmd) + if fileExists('/linuxrootfs3'): + cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs3' + LinkNeoBoot + ' ' + system(cmd) + if fileExists('/linuxrootfs4'): + cmd = 'cp -af ' + LinkNeoBoot + ' /linuxrootfs4' + LinkNeoBoot + ' ' + system(cmd) - cmd4 = "cp -aRf " + S99neo + " " + target4 - system(cmd4) - - 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" - system(cmd6) - - 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" - ) - - cmd = "cp -af " + LinkNeoBoot + " " + target - system(cmd) - - if fileExists("/linuxrootfs1"): - cmd = ( - "cp -af " - + LinkNeoBoot - + " /linuxrootfs1" - + LinkNeoBoot - + " " - ) - system(cmd) - if fileExists("/linuxrootfs2"): - cmd = ( - "cp -af " - + LinkNeoBoot - + " /linuxrootfs2" - + LinkNeoBoot - + " " - ) - system(cmd) - if fileExists("/linuxrootfs3"): - cmd = ( - "cp -af " - + LinkNeoBoot - + " /linuxrootfs3" - + LinkNeoBoot - + " " - ) - system(cmd) - if fileExists("/linuxrootfs4"): - cmd = ( - "cp -af " - + LinkNeoBoot - + " /linuxrootfs4" - + LinkNeoBoot - + " " - ) - system(cmd) - - out = open("%sImageBoot/.version" % getNeoLocation(), "w") - out.write(PLUGINVERSION) - out.close() - self.myClose( - _("NeoBoot successfully updated. You can restart the plugin now.\nHave fun !!")) - - def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + out = open('%sImageBoot/.version' % getNeoLocation(), 'w') + out.write(PLUGINVERSION) + out.close() + self.myClose(_('NeoBoot successfully updated. You can restart the plugin now.\nHave fun !!')) + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class ListTv(Screen): @@ -1308,26 +1120,23 @@ 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")) + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) def listupload2(self): self.session.open(ListTv2) def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class ListTv2(Screen): @@ -1342,8 +1151,7 @@ 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) @@ -1353,36 +1161,34 @@ 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": - self.myClose( - _("Sorry, NeoBoot can installed or upgraded only when booted from Flash.")) + if mypath2 != 'Flash': + self.myClose(_('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/") - self.myClose( - _("NeoBoot successfully updated list tv.\nHave fun !!")) + os.system('rm -f -R /etc/enigma2') + os.system('mv /etc/enigma2.tmp /etc/enigma2/') + self.myClose(_('NeoBoot successfully updated list tv.\nHave fun !!')) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1399,27 +1205,23 @@ 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")) + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) def IPTVPlayerUpload2(self): self.session.open(IPTVPlayer2) def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class IPTVPlayer2(Screen): @@ -1434,8 +1236,7 @@ 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) @@ -1445,41 +1246,35 @@ 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": - self.myClose( - _("Sorry, NeoBoot can installed or upgraded only when booted from Flash.")) + if mypath2 != 'Flash': + self.myClose(_('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 !!")) + self.myClose(_('NeoBoot successfully updated IPTVPlayer.\nHave fun !!')) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) self.close() -class FeedExtra(Screen): +class VAVOO(Screen): __module__ = __name__ - skin = """ + skin = """ @@ -1488,43 +1283,43 @@ class FeedExtra(Screen): def __init__(self, session): Screen.__init__(self, session) self["lab1"] = Label( - _("Copy the FeedExtra Player plugin from flash to all images") + _("Install VAVOO") ) self["key_red"] = Label(_("Install")) self["actions"] = ActionMap( ["WizardActions", "ColorActions"], - {"back": self.close, "red": self.FeedExtraUpload}, + {"back": self.close, "red": self.vavooUpload}, ) - def FeedExtraUpload(self): + def vavooUpload(self): if not fileExists("/.multinfo"): - self.FeedExtraUpload2() + self.vavooUpload2() else: self.myClose( _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) - def FeedExtraUpload2(self): - self.session.open(FeedExtra2) + def vavooUpload2(self): + self.session.open(vavoo2) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) self.close() -class FeedExtra2(Screen): +class vavoo2(Screen): __module__ = __name__ if isFHD(): - skin = """ + skin = """ """ else: - skin = '\n\t\t\n\t' + skin = '\n\t\t\n\t' def __init__(self, session): Screen.__init__(self, session) self["lab1"] = Label( - _("NeoBoot: Upgrading in progress\nPlease wait...")) + _("NeoBoot: VAVOO installed in progress\nPlease wait...")) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateInfo) self.onShow.append(self.startShow) @@ -1533,37 +1328,38 @@ class FeedExtra2(Screen): self.activityTimer.start(10) def updateInfo(self): - self.activityTimer.stop() - f2 = open("" + getNeoLocation() + "ImageBoot/.neonextboot", "r") - mypath2 = f2.readline().strip() - f2.close() - if mypath2 != "Flash": - self.myClose( - _("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.")) - self.close() + if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/vavoo"): + os.system( + "rm -r /usr/lib/enigma2/python/Plugins/Extensions/vavoo" + ) + + if fileExists("/tmp/installer.sh"): + os.system( + "rm -r /tmp/installer.sh" + ) + + if fileExists("/usr/bin/curl"): + os.system( + "cd /tmp; curl -O --ftp-ssl https://raw.githubusercontent.com/Belfagor2005/vavoo/main/installer.sh") + + if not fileExists("/tmp/installer.sh"): + if fileExists("/usr/bin/fullwget"): + cmd1 = "cd /tmp; fullwget --no-check-certificate https://raw.githubusercontent.com/Belfagor2005/vavoo/main/installer.sh" + system(cmd1) + + if not fileExists("/tmp/installer.sh"): + if fileExists("/usr/bin/wget"): + os.system("cd /tmp; wget --no-check-certificate https://raw.githubusercontent.com/Belfagor2005/vavoo/main/installer.sh") + + if fileExists("/tmp/installer.sh"): + os.system("chmod 755 /tmp/installer.sh; sleep 5; /tmp/installer.sh") else: - 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" - system(cmd) - cmd = ( - "cp -r /usr/lib/enigma2/python/Plugins/Extensions/FeedExtra " + - target) - system(cmd) - - self.myClose( - _("NeoBoot successfully updated FeedExtra.\nHave fun !!")) - - def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open( + MessageBox, + _("The plugin not installed.\nAccess Fails with Error code error-panel_install."), + MessageBox.TYPE_INFO, + 10,) + self.close() class SetPasswd(Screen): @@ -1576,20 +1372,15 @@ 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: @@ -1608,174 +1399,64 @@ 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")) + self.myClose(_('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') + else: + os.system('echo "\n* opkg packed everything is OK !" >> ' + 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" - ) - else: - 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] - ) - self.close() + 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): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -1800,138 +1481,127 @@ 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 - ybox = self.session.openWithCallback( - self.doSkinChange, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_("Skin Change confirmation")) + elif myerror == '': + message = (_('Skin Change: %s now ?') % skin) + ybox = self.session.openWithCallback(self.doSkinChange, MessageBox, message, MessageBox.TYPE_YESNO) + 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 = "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]) + 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' + cmd3 = 'ln -sf "neoskins/default.py" "' + LinkNeoBoot + '/usedskin.py"' + self.session.open(Console, _('NeoBoot Skin Change'), [cmd, cmd1, cmd2, cmd3]) def doSkinChange(self, answer): - if not 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: 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"): - self.restareE2() - else: - self.restareE2() + 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() + 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: @@ -1953,20 +1623,16 @@ 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 @@ -1974,58 +1640,47 @@ 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 - ybox = self.session.openWithCallback( - self.Block_Unlock_Skin, MessageBox, message, MessageBox.TYPE_YESNO) - ybox.setTitle(_("Confirmation...")) + 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...')) def Block_Unlock_Skin(self, answer): if answer is True: - 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") - ) - temp_file2.close() + 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')) + temp_file2.close() else: - 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") - ) - temp_file2.close() + 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')) + 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: @@ -2034,8 +1689,8 @@ class BlocUnblockImageSkin(Screen): self.close() def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() class InternalFlash(Screen): @@ -2048,115 +1703,83 @@ 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.")) + self.myClose(_('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' - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash" - ) + 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') - 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" - ) + 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') - 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" - ) + 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') - 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" - ) + 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') - if os.path.exists("/proc/stb/info/boxtype"): - if getBoxHostName() == "zgemmah9s": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash" - ) + if os.path.exists('/proc/stb/info/boxtype'): + if getBoxHostName() == 'zgemmah9s': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') - if getBoxHostName == "sf8008": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p13 /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 == "ax60": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p21 /media/InternalFlash" - ) + if getBoxHostName == 'sf8008': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p13 /media/InternalFlash') - if getBoxHostName() == "ustym4kpro" or getTunerModel() == "ustym4kpro": - os.system( - " " + - LinkNeoBoot + - "/files/findsk.sh; mkdir -p /media/InternalFlash; mount /tmp/root /media/InternalFlash") + if getBoxHostName == 'ax60': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p21 /media/InternalFlash') - 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" - ) + 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') - if ( - getBoxVuModel() == "uno4kse" - or getBoxVuModel() == "uno4k" - or getBoxVuModel() == "ultimo4k" - or getBoxVuModel() == "solo4k" - ): - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash" - ) + 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') - if getBoxVuModel() == "zero4k": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash" - ) + if getBoxVuModel() == 'uno4kse' or getBoxVuModel() == 'uno4k' or getBoxVuModel() == 'ultimo4k' or getBoxVuModel() == 'solo4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') - if getBoxVuModel() == "duo4k": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash" - ) + if getBoxVuModel() == 'zero4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') - if getBoxVuModel() == "duo4kse": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash" - ) + if getBoxVuModel() == 'duo4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash') - if getCPUSoC() == "bcm7252s" or getBoxHostName() == "gbquad4k": - os.system( - "mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash" - ) + if getBoxVuModel() == 'duo4kse': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash') - else: - self.myClose(_("Your image flash cannot be mounted.")) + if getCPUSoC() == 'bcm7252s' or getBoxHostName() == 'gbquad4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash') - if fileExists("/media/InternalFlash/etc/init.d/neobootmount.sh"): - os.system("rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;") + #if getBoxHostName == 'osmio4k': + #os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash') - self.myClose(_("Your image flash is mounted in the media location")) + else: + 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;') + + self.myClose(_('Your image flash is mounted in the media location')) def myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) @@ -2176,18 +1799,17 @@ 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 @@ -2195,26 +1817,21 @@ 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 - ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Confirmation of Deletion...")) + message = (_('File: %s remove ?') % image) + ybox = self.session.openWithCallback(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]) + 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]) self.updateInfo() else: self.close() @@ -2230,29 +1847,25 @@ 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) self.close() - - + + class TunerInfo(Screen): __module__ = __name__ skin = """ @@ -2263,197 +1876,141 @@ 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 BaseException: + except: False - + class CreateSwap(Screen): __module__ = __name__ skin = """ - - """ + + """ - def __init__(self, session): + 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") - ): - self.goCreateSwap() + 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): if partition.filesystem(mounts) in supported_filesystems: - candidates.append( - (partition.description, partition.mountpoint)) + 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 - cmd3 = 'echo "' + myfile + ' swap swap defaults 0 0" >> /etc/fstab' - 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] - ) + 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 + '' + cmd5 = "echo -e '\n\n%s '" % _('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"): - system( - "/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") - - swapfileinstall = " " - if os.path.exists("/etc/fstab"): - with open("/etc/fstab", "r") as f: + 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'): + 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') + + 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") + f.close() + fail = '/etc/fstab' + f = open(fail, 'r') content = f.read() f.close() - 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", "") - ) + 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","")) 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) self.close() @@ -2470,37 +2027,21 @@ 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( - "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, - ) - self.close() + 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') + if fileExists('/usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer'): + self.session.open(MessageBox, _('The plugin IPTVPlayer installed.'), MessageBox.TYPE_INFO, 10) + self.close() class MultiStalker(Screen): __module__ = __name__ @@ -2513,19 +2054,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") - 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.close() - + 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.close() + class MultibootFlashonline(Screen): __module__ = __name__ @@ -2538,50 +2077,32 @@ 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" - 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]) - self.close() - else: - self.session.open( - MessageBox, - _("The plugin not installed.\nAccess Fails with Error code error-panel_install."), - MessageBox.TYPE_INFO, - 10, - ) - self.close() - - + 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]) + self.close() + else: + self.session.open(MessageBox, _('The plugin not installed.\nAccess Fails with Error code error-panel_install.'), MessageBox.TYPE_INFO, 10) + self.close() + + class DreamSatPanel(Screen): __module__ = __name__ @@ -2593,20 +2114,18 @@ 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") - 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.close() - - + 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.close() + + class InitializationFormattingDisk(Screen): __module__ = __name__ @@ -2618,23 +2137,22 @@ 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 @@ -2642,115 +2160,89 @@ 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) - ybox = self.session.openWithCallback( - self.dodeleteback, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Format the disk ???")) + message = (_('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 ???')) def dodeleteback(self, answer): if answer is True: - 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" - 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], - ) + 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' + 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]) self.updateInfo() else: self.close() - + def myClose(self): - self.close() - - + self.close() + + class BootManagers(Screen): __module__ = __name__ skin = """ - + """ - def __init__(self, session): + 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"): - cmd0 = "echo -e '\n\n%s '" % _( - "Creation Boot Manager , please wait...") - if getBoxHostName() == "et5x00": - cmd1 = "cp -af " + LinkNeoBoot + "/bin/neoinitmips /sbin/neoinitmips" + if not fileExists('/.multinfo'): + cmd0 = "echo -e '\n\n%s '" % _('Creation Boot Manager , please wait...') + if getBoxHostName() == "et5x00": + cmd1 = 'cp -af ' + LinkNeoBoot + '/bin/neoinitmips /sbin/neoinitmips' + else: + 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]) + self.close() else: - 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]) - self.close() - else: - self.myClose( - _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) - + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + def RemoveBootManagers(self): - if not fileExists("/.multinfo"): - cmd0 = "echo -e '\n\n%s '" % _( - "Creation Boot Manager , please wait...") - if getBoxHostName() == "et5x00": - cmd1 = "cp -af " + LinkNeoBoot + "/bin/neoinitmipsvu /sbin/neoinitmips" + if not fileExists('/.multinfo'): + cmd0 = "echo -e '\n\n%s '" % _('Creation Boot Manager , please wait...') + if getBoxHostName() == "et5x00": + cmd1 = 'cp -af ' + LinkNeoBoot + '/bin/neoinitmipsvu /sbin/neoinitmips' else: - 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]) + 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]) self.close() else: - self.myClose( - _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) - + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + def myClose(self, message): - self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() - - + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + + class DiskLabelSet(Screen): __module__ = __name__ @@ -2762,81 +2254,71 @@ 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): - 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: + #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: 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") - - with open("/etc/fstab", "r") as f: + 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: flines = f.read() f.close() - - 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..." - ) - 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] - ) - - + + 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...') + 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]) + + class MultiBootMyHelp(Screen): if isFHD(): skin = """ @@ -2849,39 +2331,32 @@ 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 = """ @@ -2896,51 +2371,31 @@ 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) + 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): @@ -2982,127 +2437,95 @@ class Opis(Screen): 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["key_blue"] = Label(_("Install NeoBOOT Stable")) - self["lab1"] = ScrollLabel("") - self["lab2"] = Label(_("" + getNeoActivatedtest() + "")) - self["actions"] = ActionMap( - ["WizardActions", "ColorActions", "DirectionActions"], - { - "back": self.close, - "red": self.delete, - "green": self.neoinstallgithub, - "blue": self.installneostable, - "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["key_blue"] = Label(_("Install NeoBOOT PY3")) + self['lab1'] = ScrollLabel('') + self['lab2'] = Label(_('' + getNeoActivatedtest() + '')) + self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, + 'red': self.delete, + 'green': self.neoinstallgithub, + "blue": self.installneoPY3, + '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.") - ybox = self.session.openWithCallback( - self.neogithub, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Install.")) + 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.')) def neogithub(self, answer): - if fileExists("/.multinfo"): - self.myClose( - _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) + if fileExists('/.multinfo'): + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) self.close() - else: + 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]) - 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]) - 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]) - self.close() + 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]) + 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]) + self.close() else: - pass + pass else: - self.close() - - def installneostable(self): + self.close() + + + def installneoPY3(self): message = _("Are you sure you want to reinstall neoboot from github.") ybox = self.session.openWithCallback( - self.neostable, MessageBox, message, MessageBox.TYPE_YESNO + self.neoPY3, MessageBox, message, MessageBox.TYPE_YESNO ) ybox.setTitle(_("Install.")) - def neostable(self, answer): + + def neoPY3(self, answer): if fileExists("/.multinfo"): self.myClose( _("Sorry, Neoboot can be installed or upgraded only when booted from Flash")) @@ -3148,68 +2571,54 @@ class Opis(Screen): 5, ) 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." - ) - ybox = self.session.openWithCallback( - self.mbdelete, MessageBox, message, MessageBox.TYPE_YESNO - ) - ybox.setTitle(_("Removed successfully.")) + 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.')) 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"): - 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" + 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'): + 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' 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 myClose(self, message): self.session.open(MessageBox, message, MessageBox.TYPE_INFO) - self.close() - + self.close() class ReinstallKernel(Screen): __module__ = __name__ @@ -3222,25 +2631,23 @@ 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() @@ -3249,23 +2656,16 @@ class ReinstallKernel(Screen): self.kernel_update() def kernel_update(self): - 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") - 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]) - self.close() + 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') + 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]) + self.close() class neoDONATION(Screen): @@ -3282,45 +2682,34 @@ 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): @@ -3330,10 +2719,4 @@ 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/files/userscript.sh b/NeoBoot/files/userscript.sh index c2f2bff..1fd25b2 100644 --- a/NeoBoot/files/userscript.sh +++ b/NeoBoot/files/userscript.sh @@ -16,10 +16,6 @@ /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/mountpoint.sh echo "...Start -mountpoint.sh- location NEOBOOT..." fi - - if [ -e /var/lib/tailscale ] || [ -e /.multinfo ] ; then - opkg install kernel-module-tun - fi if [ -f /.control_boot_new_image ] ; then break ;