diff --git a/NeoBoot/files/Harddisk.py b/NeoBoot/files/Harddisk.py new file mode 100644 index 0000000..1592fb7 --- /dev/null +++ b/NeoBoot/files/Harddisk.py @@ -0,0 +1,1057 @@ +# -*- coding: utf-8 -*- + +from Plugins.Extensions.NeoBoot.__init__ import _ +import os +import time +from Tools.Directories import fileExists, pathExists, fileCheck +from Tools.CList import CList +from Components.SystemInfo import SystemInfo +from Components.Console import Console +from Plugins.Extensions.NeoBoot.files import Task +if fileExists('/usr/lib/python3.8'): + from Components import Task +else: + import Task +try: + from Task import LoggingTask +except: + from Components.Task import LoggingTask +from Screens.Screen import Screen +from Components.ActionMap import ActionMap +from Components.MenuList import MenuList +from Components.Label import Label +from Components.Pixmap import Pixmap +from Screens.MessageBox import MessageBox + +def readFile(filename): + file = open(filename) + data = file.read().strip() + file.close() + return data + +def getProcMounts(): + try: + mounts = open('/proc/mounts', 'r') + except IOError as ex: + print (("[Harddisk] Failed to open /proc/mounts"), ex ) + return [] + + result = [ line.strip().split(' ') for line in mounts ] + for item in result: + item[1] = item[1].replace('\\040', ' ') + + return result + + +def getNonNetworkMediaMounts(): + return [ x[1] for x in getProcMounts() if x[1].startswith('/media/') and not x[0].startswith('//') ] + + +def isFileSystemSupported(filesystem): + try: + for fs in open('/proc/filesystems', 'r'): + if fs.strip().endswith(filesystem): + return True + + return False + except Exception as ex: + 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 + + +DEVTYPE_UDEV = 0 +DEVTYPE_DEVFS = 1 + +class Harddisk(): + + def __init__(self, device, removable = False): + self.device = device + if os.access('/dev/.udev', 0): + self.type = DEVTYPE_UDEV + 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.mount_path = None + self.mount_device = None + self.phys_path = os.path.realpath(self.sysfsPath('device')) + self.removable = removable + self.internal = 'pci' in self.phys_path or 'ahci' in self.phys_path or 'sata' in self.phys_path + try: + data = open('/sys/block/%s/queue/rotational' % device, 'r').read().strip() + self.rotational = int(data) + except: + self.rotational = True + + if self.type == DEVTYPE_UDEV: + self.dev_path = '/dev/' + self.device + self.disk_path = self.dev_path + self.card = 'sdhci' in self.phys_path + elif self.type == DEVTYPE_DEVFS: + tmp = readFile(self.sysfsPath('dev')).split(':') + s_major = int(tmp[0]) + s_minor = int(tmp[1]) + for disc in os.listdir('/dev/discs'): + dev_path = os.path.realpath('/dev/discs/' + disc) + disk_path = dev_path + '/disc' + try: + rdev = os.stat(disk_path).st_rdev + except OSError: + continue + + if s_major == os.major(rdev) and s_minor == os.minor(rdev): + self.dev_path = dev_path + self.disk_path = disk_path + break + + self.card = self.device[:2] == 'hd' and 'host0' not in self.dev_path + print ("[Harddisk] new device"), self.device, '->', self.dev_path, '->', self.disk_path + if not removable and not self.card: + self.startIdle() + return + + def __lt__(self, ob): + return self.device < ob.device + + def partitionPath(self, n): + if self.type == DEVTYPE_UDEV: + if self.dev_path.startswith('/dev/mmcblk0'): + return self.dev_path + 'p' + n + else: + return self.dev_path + n + elif self.type == DEVTYPE_DEVFS: + return self.dev_path + '/part' + n + + def sysfsPath(self, filename): + return os.path.join('/sys/block/', self.device, filename) + + def stop(self): + if self.timer: + self.timer.stop() + self.timer.callback.remove(self.runIdle) + + def bus(self): + ret = _('External') + if self.type == DEVTYPE_UDEV: + type_name = ' (SD/MMC)' + elif self.type == DEVTYPE_DEVFS: + type_name = ' (CF)' + if self.card: + ret += type_name + else: + if self.internal: + ret = _('Internal') + if not self.rotational: + ret += ' (SSD)' + return ret + + def diskSize(self): + cap = 0 + try: + 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 = int(stat.f_blocks * stat.f_bsize) + return cap / 1000 / 1000 + except: + pass + + return cap + + def capacity(self): + cap = self.diskSize() + if cap == 0: + return '' + if 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, ("[Harddisk] no hdX or sdX or mmcX")) + except Exception as e: + print ("[Harddisk] Failed to get model:"), e + return '-?-' + + def free(self): + dev = self.findMount() + if dev: + try: + stat = os.statvfs(dev) + return stat.f_bfree / 1000 * (stat.f_bsize / 1024) + except: + pass + + return -1 + + def numPartitions(self): + numPart = -1 + if self.type == DEVTYPE_UDEV: + try: + devdir = os.listdir('/dev') + except OSError: + return -1 + + for filename in devdir: + if filename.startswith(self.device): + numPart += 1 + + elif self.type == DEVTYPE_DEVFS: + try: + idedir = os.listdir(self.dev_path) + except OSError: + return -1 + + for filename in idedir: + if filename.startswith('disc'): + numPart += 1 + if filename.startswith('part'): + numPart += 1 + + return numPart + + def mountDevice(self): + for parts in getProcMounts(): + if os.path.realpath(parts[0]).startswith(self.dev_path): + self.mount_device = parts[0] + self.mount_path = parts[1] + return parts[1] + + return None + + def enumMountDevices(self): + for parts in getProcMounts(): + if os.path.realpath(parts[0]).startswith(self.dev_path): + yield parts[1] + + def findMount(self): + if self.mount_path is None: + return self.mountDevice() + else: + return self.mount_path + + def unmount(self): + dev = self.mountDevice() + if dev is None: + return 0 + else: + 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 + 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') + else: + dev = self.mount_device + try: + fstab = open('/etc/fstab') + lines = fstab.readlines() + fstab.close() + except IOError: + return -1 + + for line in lines: + parts = line.strip().split(' ') + fspath = os.path.realpath(parts[0]) + if fspath == dev: + print ("[Harddisk] mounting:"), fspath + cmd = 'mount -t auto ' + fspath + res = os.system(cmd) + return res >> 8 + + res = -1 + if self.type == DEVTYPE_UDEV: + 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 * '\x00' + h = open(self.dev_path, 'wb') + for i in range(9): + h.write(zero) + + h.close() + + def killPartition(self, n): + zero = 512 * '\x00' + part = self.partitionPath(n) + h = open(part, 'wb') + for i in range(3): + h.write(zero) + + h.close() + + def createInitializeJob(self): + job = Task.Job(_('Initializing storage device...')) + size = self.diskSize() + print ("[HD] size: %s MB") % size + task = UnmountTask(job, self) + task = Task.PythonTask(job, _('Removing partition table')) + task.work = self.killPartitionTable + task.weighting = 1 + task = Task.LoggingTask(job, _('Rereading partition table')) + task.weighting = 1 + 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.weighting = 1 + if os.path.exists('/usr/sbin/parted'): + use_parted = True + elif size > 2097151: + addInstallTask(job, 'parted') + use_parted = True + else: + use_parted = False + task = Task.LoggingTask(job, _('Creating partition')) + task.weighting = 5 + if use_parted: + task.setTool('parted') + if size < 1024: + alignment = 'min' + else: + alignment = 'opt' + if size > 2097151: + parttype = 'gpt' + else: + 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.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' + 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.weighting = 1 + task = MkfsTask(job, _('Creating filesystem')) + big_o_options = ['dir_index'] + +###__blokada hash dla ext4 >>> +# if isFileSystemSupported('ext4'): +# task.setTool('mkfs.ext4') +# if size > 20000: +# try: +# version = map(int, open('/proc/version', 'r').read().split(' ', 4)[2].split('.', 2)[:2]) +# if version[0] > 3 or version[0] > 2 and version[1] >= 2: +# task.args += ['-C', '262144'] +# big_o_options.append('bigalloc') +# except Exception as ex: +# print 'Failed to detect Linux version:', ex +# else: +# task.setTool('mkfs.ext3') + + task.setTool('mkfs.ext3') + if size > 250000: + 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') + elif size > 2048: + 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.check = self.mountDevice + task.weighting = 1 + return job + + def initialize(self): + return -5 + + def check(self): + return -5 + + def createCheckJob(self): + 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') + task.args.append(dev) + MountTask(job, self) + task = Task.ConditionTask(job, _('Waiting for mount')) + task.check = self.mountDevice + return job + + def getDeviceDir(self): + return self.dev_path + + def getDeviceName(self): + return self.disk_path + + def readStats(self): + try: + l = open('/sys/block/%s/stat' % self.device).read() + except IOError: + return (-1, -1) + + data = l.split(None, 5) + return (int(data[0]), int(data[4])) + + def startIdle(self): + 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)) + self.timer = eTimer() + self.timer.callback.append(self.runIdle) + self.idle_running = True + self.setIdleTime(self.max_idle_time) + + def runIdle(self): + if not self.max_idle_time: + return + t = time.time() + idle_time = t - self.last_access + stats = self.readStats() + l = sum(stats) + if l != self.last_stat and l >= 0: + self.last_stat = l + self.last_access = t + idle_time = 0 + self.is_sleeping = False + if idle_time >= self.max_idle_time and not self.is_sleeping: + self.setSleep() + self.is_sleeping = True + + def setSleep(self): + if self.bus() == _('External'): + Console().ePopen(('sdparm', + 'sdparm', + '--flexible', + '--readonly', + '--command=stop', + self.disk_path)) + else: + Console().ePopen(('hdparm', + 'hdparm', + '-y', + self.disk_path)) + + def setIdleTime(self, idle): + self.max_idle_time = idle + if self.idle_running: + if not idle: + self.timer.stop() + else: + self.timer.start(idle * 100, False) + + def isSleeping(self): + return self.is_sleeping + + +class Partition(): + + def __init__(self, mountpoint, device = None, description = '', force_mounted = False): + self.mountpoint = mountpoint + self.description = description + 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) + + def stat(self): + if self.mountpoint: + return os.statvfs(self.mountpoint) + raise (OSError, "Device %s is not mounted") % self.device + + def free(self): + try: + s = self.stat() + return s.f_bavail * s.f_bsize + except OSError: + return None + + return None + + def total(self): + try: + s = self.stat() + return s.f_blocks * s.f_bsize + except OSError: + return None + + return None + + def tabbedDescription(self): + if self.mountpoint.startswith('/media/net') or self.mountpoint.startswith('/media/autofs'): + return self.description + return self.description + '\t' + self.mountpoint + + def mounted(self, mounts = None): + if self.force_mounted: + return True + else: + if self.mountpoint: + if mounts is None: + mounts = getProcMounts() + for parts in mounts: + if self.mountpoint.startswith(parts[1]): + return True + + return False + + def filesystem(self, mounts = None): + if self.mountpoint: + if mounts is None: + mounts = getProcMounts() + for fields in mounts: + 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 '' + + +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.args.append(package) + + +class HarddiskManager(): + + def __init__(self): + self.hdd = [] + self.cd = '' + self.partitions = [] + self.devices_scanned_on_init = [] + self.on_partition_list_change = CList() + self.enumerateBlockDevices() + p = (('/media/hdd', _('Hard disk')), + ('/media/card', _('Card')), + ('/media/cf', _('Compact flash')), + ('/media/mmc1', _('MMC card')), + ('/media/net', _('Network mount')), + ('/media/net1', _('Network mount %s') % '1'), + ('/media/net2', _('Network mount %s') % '2'), + ('/media/net3', _('Network mount %s') % '3'), + ('/media/ram', _('Ram disk')), + ('/media/usb', _('USB stick')), + ('/media/usb1', _('USB1 stick')), + ('/media/usb2', _('USB2 stick')), + ('/', _('Internal flash'))) + 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 = 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'))) + if os.path.exists(devpath + '/dev'): + dev = int(readFile(devpath + '/dev').split(':')[0]) + else: + dev = None + blacklisted = dev in [1, + 7, + 31, + 253, + 254] + (['HasMMC'] and [179] or []) + if blockdev[0:2] == 'sr': + is_cdrom = True + if blockdev[0:2] == 'hd': + try: + media = readFile('/proc/ide/%s/media' % blockdev) + if 'cdrom' in media: + is_cdrom = True + except IOError: + error = True + + if not is_cdrom and os.path.exists(devpath): + for partition in os.listdir(devpath): + if partition[0:len(blockdev)] != blockdev: + continue + partitions.append(partition) + + else: + self.cd = blockdev + except IOError: + error = True + + medium_found = True + try: + open('/dev/' + blockdev).close() + except IOError as err: + if err.errno == 159: + medium_found = False + + return (error, + blacklisted, + removable, + is_cdrom, + partitions, + medium_found) + + def enumerateBlockDevices(self): + print ("[Harddisk] enumerating block devices...") + for blockdev in os.listdir('/sys/block'): + error, blacklisted, removable, is_cdrom, partitions, medium_found = self.addHotplugPartition(blockdev) + if not error and not blacklisted and medium_found: + for part in partitions: + self.addHotplugPartition(part) + + self.devices_scanned_on_init.append((blockdev, + removable, + is_cdrom, + medium_found)) + + def getAutofsMountpoint(self, device): + r = self.getMountpoint(device) + if r is None: + return '/media/' + device + else: + return r + + def getMountpoint(self, device): + dev = '/dev/%s' % device + for item in getProcMounts(): + if item[0] == dev: + return item[1] + + return None + + def addHotplugPartition(self, device, physdev = None): + if not physdev: + dev, part = self.splitDeviceName(device) + try: + physdev = os.path.realpath('/sys/block/' + dev + '/device')[4:] + except OSError: + physdev = dev + print (("couldn't determine blockdev physdev for device"), 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) + self.partitions.append(p) + if p.mountpoint: + self.on_partition_list_change('add', p) + l = len(device) + if l and (not device[l - 1].isdigit() or device == 'mmcblk0'): + self.hdd.append(Harddisk(device, removable)) + self.hdd.sort() + SystemInfo['Harddisk'] = True + return (error, + blacklisted, + removable, + is_cdrom, + partitions, + medium_found) + + def addHotplugAudiocd(self, device, physdev = None): + if not physdev: + dev, part = self.splitDeviceName(device) + try: + physdev = os.path.realpath('/sys/block/' + dev + '/device')[4:] + except OSError: + physdev = dev + print (("couldn't determine blockdev physdev for device"), 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) + self.partitions.append(p) + 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) + + l = len(device) + if l and not device[l - 1].isdigit(): + for hdd in self.hdd: + if hdd.device == device: + hdd.stop() + self.hdd.remove(hdd) + break + + SystemInfo['Harddisk'] = len(self.hdd) > 0 + + def HDDCount(self): + return len(self.hdd) + + def HDDList(self): + list = [] + for hd in self.hdd: + hdd = hd.model() + ' - ' + hd.bus() + cap = hd.capacity() + if cap != '': + hdd += ' (' + cap + ')' + list.append((hdd, hd)) + + return list + + def getCD(self): + return self.cd + + 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) ] + devs = set([ x.device for x in parts ]) + for devname in devs.copy(): + if not devname: + continue + dev, part = self.splitDeviceName(devname) + if part and dev in devs: + devs.remove(dev) + + return [ x for x in parts if not x.device or x.device in devs ] + + def splitDeviceName(self, devname): + dev = devname[:3] + part = devname[3:] + for p in part: + if not p.isdigit(): + return (devname, 0) + + return (dev, part and int(part) or 0) + + def getUserfriendlyDeviceName(self, dev, phys): + dev, part = self.splitDeviceName(dev) + description = _('External Storage %s') % dev + try: + description = readFile('/sys' + phys + '/model') + except IOError as s: + print (("couldn't read model: "), s) + + if part and part != 1: + 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) + + def setDVDSpeed(self, device, speed = 0): + ioctl_flag = int(21282) + if not device.startswith('/'): + device = '/dev/' + device + try: + from fcntl import ioctl + 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 + + +class UnmountTask(Task.LoggingTask): + + def __init__(self, job, hdd): + Task.LoggingTask.__init__(self, job, _('Unmount')) + self.hdd = hdd + self.mountpoints = [] + + def prepare(self): + try: + dev = self.hdd.disk_path.split('/')[-1] + open('/dev/nomount.%s' % dev, 'wb').close() + except Exception as e: + print ("ERROR: Failed to create /dev/nomount file:"), e + + self.setTool('umount') + self.args.append('-f') + for dev in self.hdd.enumMountDevices(): + self.args.append(dev) + self.postconditions.append(Task.ReturncodePostcondition()) + self.mountpoints.append(dev) + + if not self.mountpoints: + print ("UnmountTask: No mountpoints found?") + self.cmd = 'true' + self.args = [self.cmd] + + def afterRun(self): + for path in self.mountpoints: + try: + os.rmdir(path) + except Exception as ex: + print ("Failed to remove path '%s':") % path, ex + + +class MountTask(Task.LoggingTask): + + def __init__(self, job, hdd): + Task.LoggingTask.__init__(self, job, _('Mount')) + self.hdd = hdd + + def prepare(self): + try: + dev = self.hdd.disk_path.split('/')[-1] + os.unlink('/dev/nomount.%s' % dev) + except Exception as e: + print ("ERROR: Failed to remove /dev/nomount file:"), e + + if self.hdd.mount_device is None: + dev = self.hdd.partitionPath('1') + else: + dev = self.hdd.mount_device + fstab = open('/etc/fstab') + lines = fstab.readlines() + fstab.close() + for line in lines: + parts = line.strip().split(' ') + fspath = os.path.realpath(parts[0]) + if os.path.realpath(fspath) == dev: + 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) + self.postconditions.append(Task.ReturncodePostcondition()) + return + + +class MkfsTask(Task.LoggingTask): + + def prepare(self): + self.fsck_state = None + return + + def processOutput(self, data): + print ("[Mkfs]"), data + if 'Writing inode tables:' in data: + self.fsck_state = 'inode' + elif 'Creating journal' in data: + self.fsck_state = 'journal' + self.setProgress(80) + elif 'Writing superblocks ' in data: + self.setProgress(95) + elif self.fsck_state == 'inode': + if '/' in data: + try: + d = data.strip(' \x08\r\n').split('/', 1) + if '\x08' in d[1]: + d[1] = d[1].split('\x08', 1)[0] + self.setProgress(80 * int(d[0]) / int(d[1])) + except Exception as e: + print ("[Mkfs] E:"), e + + return + 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.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.') + self.session.openWithCallback(self.hddConfirmed, MessageBox, message) + + def hddConfirmed(self, confirmed): + if not confirmed: + return + try: + 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.close() + + +class HarddiskSelection(Screen): + def __init__(self, session): + Screen.__init__(self, session) + self.setTitle(_('Select hard disk')) + self.skinName = 'HarddiskSelection' + if harddiskmanager.HDDCount() == 0: + 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}) + + 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!')) + + def okbuttonClick(self): + 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!')) +###########################__end HarddiskSetup_################################ + + +harddiskmanager = HarddiskManager() + +def isSleepStateDevice(device): + ret = os.popen('hdparm -C %s' % device).read() + if 'SG_IO' in ret or 'HDIO_DRIVE_CMD' in ret: + return None + elif 'drive state is: standby' in ret or 'drive state is: idle' in ret: + return True + elif 'drive state is: active/idle' in ret: + return False + else: + return None + + +def internalHDDNotSleeping(external = False): + state = False + if harddiskmanager.HDDCount(): + for hdd in harddiskmanager.HDDList(): + if hdd[1].internal or external: + if hdd[1].idle_running and hdd[1].max_idle_time and not hdd[1].isSleeping(): + state = True + + return state + + +harddiskmanager = HarddiskManager() +SystemInfo['ext4'] = isFileSystemSupported('ext4') or isFileSystemSupported('ext3') diff --git a/NeoBoot/files/Harddisk.pyo b/NeoBoot/files/Harddisk.pyo new file mode 100644 index 0000000..e15ae99 Binary files /dev/null and b/NeoBoot/files/Harddisk.pyo differ diff --git a/NeoBoot/files/Task.py b/NeoBoot/files/Task.py new file mode 100644 index 0000000..4396306 --- /dev/null +++ b/NeoBoot/files/Task.py @@ -0,0 +1,522 @@ +# -*- coding: utf-8 -*- + +from Tools.CList import CList + +class Job(object): + NOT_STARTED, IN_PROGRESS, FINISHED, FAILED = range(4) + + def __init__(self, name): + self.tasks = [] + self.resident_tasks = [] + self.workspace = '/tmp' + self.current_task = 0 + self.callback = None + self.name = name + self.finished = False + self.end = 100 + self.__progress = 0 + self.weightScale = 1 + self.afterEvent = None + self.state_changed = CList() + self.status = self.NOT_STARTED + self.onSuccess = None + return + + def fromDescription(self, description): + pass + + def createDescription(self): + return None + + def getProgress(self): + 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] ]) + 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] + + def task_progress_changed_CB(self): + self.state_changed() + + def addTask(self, task): + task.job = self + task.task_progress_changed = self.task_progress_changed_CB + self.tasks.append(task) + + def start(self, callback): + self.callback = callback + self.restart() + + def restart(self): + self.status = self.IN_PROGRESS + self.state_changed() + self.runNext() + sumTaskWeightings = sum([ t.weighting for t in self.tasks ]) or 1 + self.weightScale = self.end / float(sumTaskWeightings) + + def runNext(self): + if self.current_task == len(self.tasks): + if len(self.resident_tasks) == 0: + self.status = self.FINISHED + self.state_changed() + 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)) + else: + self.tasks[self.current_task].run(self.taskCallback) + self.state_changed() + return + + def taskCallback(self, task, res, stay_resident = False): + cb_idx = self.tasks.index(task) + if stay_resident: + if cb_idx not in self.resident_tasks: + self.resident_tasks.append(self.current_task) + print ("task going resident:"), task + else: + print ("task keeps staying resident:"), task + return + if len(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 + self.resident_tasks.remove(cb_idx) + if res == []: + self.state_changed() + self.current_task += 1 + self.runNext() + + def retry(self): + self.restart() + + def abort(self): + if self.current_task < len(self.tasks): + self.tasks[self.current_task].abort() + for i in self.resident_tasks: + self.tasks[i].abort() + + def cancel(self): + self.abort() + + def __str__(self): + return 'Components.Task.Job name=%s #tasks=%s' % (self.name, len(self.tasks)) + + +class Task(object): + + def __init__(self, job, name): + self.name = name + self.immediate_preconditions = [] + self.global_preconditions = [] + self.postconditions = [] + self.returncode = None + self.initial_input = None + self.job = None + self.end = 100 + self.weighting = 100 + self.__progress = 0 + self.cmd = None + self.cwd = '/tmp' + self.args = [] + self.cmdline = None + self.task_progress_changed = None + self.output_line = '' + job.addTask(self) + self.container = None + return + + def setCommandline(self, cmd, args): + self.cmd = cmd + self.args = args + + def setTool(self, tool): + self.cmd = tool + self.args = [tool] + self.global_preconditions.append(ToolExistsPrecondition()) + self.postconditions.append(ReturncodePostcondition()) + + def setCmdline(self, cmdline): + self.cmdline = cmdline + + def checkPreconditions(self, immediate = False): + not_met = [] + if immediate: + preconditions = self.immediate_preconditions + else: + preconditions = self.global_preconditions + for precondition in preconditions: + if not precondition.check(self): + not_met.append(precondition) + + return not_met + + def _run(self): + if self.cmd is None and self.cmdline is None: + self.finish() + return + else: + from enigma import eConsoleAppContainer + self.container = eConsoleAppContainer() + self.container.appClosed.append(self.processFinished) + self.container.stdoutAvail.append(self.processStdout) + self.container.stderrAvail.append(self.processStderr) + 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 + else: + 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) + if failed_preconditions: + print ("[Task] preconditions failed") + callback(self, failed_preconditions) + return + self.callback = callback + try: + self.prepare() + self._run() + except Exception as ex: + print ("[Task] exception:"), ex + self.postconditions = [FailedPostcondition(ex)] + self.finish() + + def prepare(self): + pass + + def cleanup(self, failed): + pass + + def processStdout(self, data): + self.processOutput(data) + + def processStderr(self, data): + self.processOutput(data) + + def processOutput(self, data): + self.output_line += data + while True: + i = self.output_line.find('\n') + if i == -1: + break + 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] + + def processFinished(self, returncode): + self.returncode = returncode + self.finish() + + def abort(self): + if self.container: + self.container.kill() + self.finish(aborted=True) + + def finish(self, aborted = False): + self.afterRun() + not_met = [] + if aborted: + not_met.append(AbortedPostcondition()) + else: + for postcondition in self.postconditions: + if not postcondition.check(self): + not_met.append(postcondition) + + self.cleanup(not_met) + self.callback(self, not_met) + + def afterRun(self): + pass + + def writeInput(self, input): + self.container.write(input) + + def getProgress(self): + return self.__progress + + def setProgress(self, progress): + if progress > self.end: + progress = self.end + if progress < 0: + progress = 0 + self.__progress = progress + if self.task_progress_changed: + self.task_progress_changed() + + progress = property(getProgress, setProgress) + + def __str__(self): + return 'Components.Task.Task name=%s' % self.name + + +class LoggingTask(Task): + + def __init__(self, job, name): + Task.__init__(self, job, name) + self.log = [] + + def processOutput(self, data): + print ("[%s]") % self.name, data, + self.log.append(data) + + +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) + self.timer = eTimer() + self.timer.callback.append(self.onTimer) + self.timer.start(5) + + def work(self): + raise (NotImplemented, "work") + + def abort(self): + self.aborted = True + if self.callback is None: + self.finish(aborted=True) + return + + def onTimer(self): + self.setProgress(self.pos) + + def onComplete(self, result): + self.postconditions.append(FailedPostcondition(result)) + self.timer.stop() + del self.timer + self.finish() + + +class ConditionTask(Task): + + def __init__(self, job, name, timeoutCount = None): + Task.__init__(self, job, name) + self.timeoutCount = timeoutCount + + def _run(self): + self.triggerCount = 0 + + 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'): + self.timer.stop() + del self.timer + + def check(self): + return True + + def trigger(self): + self.triggerCount += 1 + try: + if self.timeoutCount is not None and self.triggerCount > self.timeoutCount: + raise (Exception, "Timeout elapsed, sorry") + res = self.check() + except Exception as e: + self.postconditions.append(FailedPostcondition(e)) + res = True + + if res: + self.finish() + return + + +class JobManager: + + def __init__(self): + self.active_jobs = [] + self.failed_jobs = [] + self.job_classes = [] + self.in_background = False + self.visible = False + self.active_job = None + return + + def AddJob(self, job, onSuccess = None, onFail = None): + job.onSuccess = onSuccess + if onFail is None: + job.onFail = self.notifyFailed + else: + job.onFail = onFail + self.active_jobs.append(job) + self.kick() + return + + def kick(self): + if self.active_job is None: + if self.active_jobs: + self.active_job = self.active_jobs.pop(0) + self.active_job.start(self.jobDone) + return + + 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)) + return True + else: + 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 + if problems: + if not job.onFail(job, task, problems): + self.errorCB(False) + else: + self.active_job = None + if job.onSuccess: + job.onSuccess(job) + self.kick() + return + + def popupTaskView(self, job): + if not self.visible: + from Tools import Notifications + from Screens.TaskView import JobView + self.visible = True + Notifications.AddNotification(JobView, job) + + def errorCB(self, answer): + if answer: + print ("retrying job") + self.active_job.retry() + else: + print ("not retrying job.") + self.failed_jobs.append(self.active_job) + self.active_job = None + self.kick() + return + + def getPendingJobs(self): + list = [] + if self.active_job: + list.append(self.active_job) + list += self.active_jobs + return list + + +class Condition: + RECOVERABLE = False + + def getErrorMessage(self, task): + return _('An unknown error occurred!') + ' (%s @ task %s)' % (self.__class__.__name__, task.__class__.__name__) + + +class WorkspaceExistsPrecondition(Condition): + + def check(self, task): + return os.access(task.job.workspace, os.W_OK) + + +class DiskspacePrecondition(Condition): + + def __init__(self, diskspace_required): + self.diskspace_required = diskspace_required + self.diskspace_available = 0 + + def check(self, task): + import os + try: + s = os.statvfs(task.job.workspace) + self.diskspace_available = s.f_bsize * s.f_bavail + return self.diskspace_available >= self.diskspace_required + except OSError: + 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) + + +class ToolExistsPrecondition(Condition): + + def check(self, task): + import os + if task.cmd[0] == '/': + self.realpath = task.cmd + 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 = 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 + + +class AbortedPostcondition(Condition): + + def getErrorMessage(self, task): + return 'Cancelled upon user request' + + +class ReturncodePostcondition(Condition): + + def check(self, task): + 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) + return log + else: + return _('Error code') + ': %s' % task.returncode + + +class FailedPostcondition(Condition): + + def __init__(self, exception): + self.exception = exception + + 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) + return log + else: + return _('Error code') + ' %s' % self.exception + return str(self.exception) + + def check(self, task): + return self.exception is None or self.exception == 0 + + +job_manager = JobManager() \ No newline at end of file diff --git a/NeoBoot/files/__init__.py b/NeoBoot/files/__init__.py new file mode 100644 index 0000000..4c06ca1 --- /dev/null +++ b/NeoBoot/files/__init__.py @@ -0,0 +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, gettext +PluginLanguageDomain = 'NeoBoot' +PluginLanguagePath = 'Extensions/NeoBoot/locale' + +def localeInit(): + lang = language.getLanguage()[:2] + os.environ['LANGUAGE'] = lang + print ("[NeoBoot] set language to "), lang + 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) + return t + + +localeInit() +language.addCallback(localeInit) diff --git a/NeoBoot/files/__init__.pyo b/NeoBoot/files/__init__.pyo new file mode 100644 index 0000000..a102baf Binary files /dev/null and b/NeoBoot/files/__init__.pyo differ diff --git a/NeoBoot/files/devices.py b/NeoBoot/files/devices.py new file mode 100644 index 0000000..6b8cbaf --- /dev/null +++ b/NeoBoot/files/devices.py @@ -0,0 +1,714 @@ +# -*- coding: utf-8 -*- + +from Plugins.Extensions.NeoBoot.__init__ import _ +from enigma import getDesktop +from Plugins.Plugin import PluginDescriptor +from Screens.ChoiceBox import ChoiceBox +from Screens.InputBox import InputBox +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Screens.Standby import TryQuitMainloop +from enigma import eTimer +from Components.ActionMap import ActionMap, NumberActionMap +from Components.Button import Button +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.Console import Console +from Components.Sources.List import List +from Components.Sources.StaticText import StaticText +from commands import getoutput +from Plugins.Extensions.NeoBoot.files.Harddisk import Harddisk +from Tools.LoadPixmap import LoadPixmap +from Tools.Directories import fileExists, resolveFilename, SCOPE_CURRENT_SKIN +from os import system, rename, path, mkdir, remove, listdir +from time import sleep +import fileinput +import re +import os +from Screens.VirtualKeyBoard import VirtualKeyBoard +import gettext, os +from Plugins.Extensions.NeoBoot.files.stbbranding import getTunerModel +LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' + + +class ManagerDevice(Screen): + screenwidth = getDesktop(0).size().width() + if screenwidth and screenwidth == 1920: + + skin = """ + + + + + + + + + \n\n\t\t\t\t{"template": [\n\n\t\t\t\t MultiContentEntryText(pos = (90, 5), size = (600, 75), font=0, text = 0),\n\n\t\t\t\t MultiContentEntryText(pos = (110, 60), size = (900, 80), font=1, flags = RT_VALIGN_TOP, text = 1),\n\n\t\t\t\t MultiContentEntryPixmapAlphaBlend(pos = (0, 0), size = (150, 130,)),\n\n\t\t\t\t],\n\t\t\t\t"fonts": [gFont("Regular", 33),gFont("Regular", 33)],\n\n\t\t\t\t"itemHeight": 140\n\t\t\t\t} + + + """ + else: + skin = """ + + + + + + + \n\t\t\t\t{"template": [\n\t\t\t\t MultiContentEntryText(pos = (90, 0), size = (600, 30), font=0, text = 0),\n\t\t\t\t MultiContentEntryText(pos = (110, 30), size = (600, 50), font=1, flags = RT_VALIGN_TOP, text = 1),\n\t\t\t\t MultiContentEntryPixmapAlphaBlend(pos = (0, 0), size = (80, 80)),\n\t\t\t\t],\n\t\t\t\t"fonts": [gFont("Regular", 24),gFont("Regular", 20)],\n\t\t\t\t"itemHeight": 85\n\t\t\t\t}\n\t\t\t + + + """ + + + def __init__(self, session): + Screen.__init__(self, session) + Screen.setTitle(self, _('Mount Manager')) + self['key_red'] = Label(_('Initialize ext3')) + self['key_green'] = Label(_('SetupMounts')) + self['key_yellow'] = Label(_('Initialize ext4')) + self['key_blue'] = Label(_('Exit')) + 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.ExitBack, + 'back': self.close}) + self.activityTimer = eTimer() + self.activityTimer.timeout.get().append(self.updateList2) + self.updateList() + self.onShown.append(self.setWindowTitle) + + 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) + else: + from Harddisk import HarddiskSelection + self.session.openWithCallback(self.updateList, HarddiskSelection) + except: + self.session.open(MessageBox, _("This option is available only from openpli or derivatives."), MessageBox.TYPE_INFO, timeout=10) + + def Format_ext4(self): + from Screens.HarddiskSetup import HarddiskSelection + self.session.openWithCallback(self.updateList, HarddiskSelection) + + def ExitBack(self): + self.close() + + def setWindowTitle(self): + self.setTitle(_('Mount Manager')) + + def createSummary(self): + return DeviceManagerSummary + + def selectionChanged(self): + if len(self.list) == 0: + return + self.sel = self['list'].getCurrent() + seldev = self.sel + if self.sel: + try: + name = str(self.sel[0]) + desc = str(self.sel[1].replace('\t', ' ')) + except: + name = '' + desc = '' + else: + 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) + self.activityTimer.start(10) + + def updateList2(self): + self.activityTimer.stop() + self.list = [] + list2 = [] + f = open('/proc/partitions', 'r') + for line in f.readlines(): + parts = line.strip().split() + if not parts: + continue + device = parts[3] + if not re.search('sd[a-z][1-9]', device): + continue + if device in list2: + continue + self.buildMy_rec(device) + list2.append(device) + + 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') + d2 = device + name = _('HARD DISK: ') + mypixmap = '' + LinkNeoBoot + '/images/dev_hdd.png' + model = file('/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") + sleep(0.5) + f = open('/tmp/devices.tmp', 'r') + swapdevices = f.read() + f.close() + if path.exists('/tmp/devices.tmp'): + remove('/tmp/devices.tmp') + swapdevices = swapdevices.replace('\n', '') + swapdevices = swapdevices.split('/') + f = open('/proc/mounts', 'r') + for line in f.readlines(): + if line.find(device) != -1: + parts = line.strip().split() + d1 = parts[1] + dtype = parts[2] + rw = parts[3] + break + continue + elif device in swapdevices: + parts = line.strip().split() + d1 = _('None') + dtype = 'swap' + rw = _('None') + break + continue + else: + d1 = _('None') + dtype = _('unavailable') + rw = _('None') + + f.close() + size = Harddisk(device).diskSize() + if float(size) / 1024 / 1024 >= 1: + des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') + elif size / 1024 >= 1: + des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB') + elif size >= 1: + 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' + else: + 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 not fileExists('/etc/fstab.org'): + os.system('cp -f /etc/fstab /etc/fstab.org') + elif fileExists('/etc/fstab.org'): + os.system('cp /etc/fstab.org /etc/fstab') + self.session.openWithCallback(self.updateList, DevicesConf) + + def Unmount(self): + 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) + try: + mounts = open('/proc/mounts') + mountcheck = mounts.readlines() + mounts.close() + for line in mountcheck: + 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) + + except IOError: + return -1 + + self.updateList() + + def saveMypoints(self): + 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]) + else: + 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('"', '') + if not path.exists(self.mountp): + mkdir(self.mountp, 493) + file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if '/media/hdd' not in l ]) + rename('/etc/fstab.tmp', '/etc/fstab') + file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if self.device not in l ]) + rename('/etc/fstab.tmp', '/etc/fstab') + file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/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) + + def restBo(self, answer): + if answer is True: + self.session.open(TryQuitMainloop, 2) + else: + self.updateList() + self.selectionChanged() + + +class DevicesConf(Screen, ConfigListScreen): + screenwidth = getDesktop(0).size().width() + if screenwidth and screenwidth == 1920: + skin = """ + + + + + """ + else: + skin = """ + + + + + """ + + def __init__(self, session): + 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}) + 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") + sleep(0.5) + f = open('/tmp/devices.tmp', 'r') + swapdevices = f.read() + f.close() + if path.exists('/tmp/devices.tmp'): + remove('/tmp/devices.tmp') + swapdevices = swapdevices.replace('\n', '') + swapdevices = swapdevices.split('/') + f = open('/proc/partitions', 'r') + for line in f.readlines(): + parts = line.strip().split() + if not parts: + continue + device = parts[3] + if not re.search('sd[a-z][1-9]', device): + continue + if device in list2: + continue + if device in swapdevices: + continue + self.buildMy_rec(device) + list2.append(device) + + f.close() + self['config'].list = self.list + self['config'].l.setList(self.list) + self['Linconn'].hide() + + def buildMy_rec(self, device): + mypath = SkinPath() + device2 = re.sub('[0-9]', '', device) + devicetype = path.realpath('/sys/block/' + device2 + '/device') + d2 = device + name = _('HARD DISK: ') + mypixmap = '' + LinkNeoBoot + '/images/dev_hdd.png' + model = file('/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 + 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 size / 1024 >= 1: + des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB') + elif size >= 1: + 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/card', '/media/card')])) + if dtype == 'Linux': + dtype = 'ext2', 'ext3', 'ext4' + else: + dtype = 'auto' + item.value = d1.strip() + text = name + ' ' + des + ' /dev/' + device + res = getConfigListEntry(text, item, device, dtype) + if des != '' and self.list.append(res): + pass + + def saveMypoints(self): + self.Console = Console() + mycheck = False + 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]) + + 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'): + #system('mv /etc/init.d/volatile-media.sh /etc/init.d/volatile-media.sh.org') + message = _('Completed assembly of disks.\nReturn to installation ?') + ybox = self.session.openWithCallback(self.myclose, MessageBox, message, MessageBox.TYPE_YESNO) + ybox.setTitle(_('MOUNTING....')) + + def myclose(self, answer): + if answer is True: + self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO) + self.close() + else: + 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 + 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 not path.exists(self.mountp): + mkdir(self.mountp, 493) + file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if self.device not in l ]) + rename('/etc/fstab.tmp', '/etc/fstab') + file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/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' + self.mountp + '\t' + self.device_type + '\tdefaults\t0 0\n' + out.write(line) + out.close() + + self.device_uuid2 = result.split('UUID=')[1].split(' ')[0].replace('"', '') +# 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: + skin =""" + + + + + + + + + + + + + + + + + + + + + + + + + """ % (_('!!!Do not set the label for /dev/mmcblk0p !!!')) + else: + skin = """ + + + + + + + + + + + + + + + + + + + """ + + def __init__(self, session): + global liczymy + Screen.__init__(self, session) + 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) + 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.cancel, + 'red': self.cancel, + '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 = [''] + if getTunerModel() in ('sf8008', 'sf8008s', 'sf8008t'): + blackL = 'mmcblk0' + else: + 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]) == True: + lista.append(devL[i]) + i += 1 + + if ilosc > 0: + lista.remove('') + elif lista[0] == '': + lista.remove('') + lista.insert(0, 'No Disk') + + def cancel(self): + self.close() + + def wlacz(self): + self.session.openWithCallback(self.wlaczyes, MessageBox, _('Set label on %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False) + + def wlaczyes(self, w): + if w == True: + os.system('e2label /dev/%s "%s"' % (str(self['devlist'].getCurrent()), self['listlabel'].getCurrent())) + self.session.open(MessageBox, _('Selected label is set'), type=MessageBox.TYPE_INFO, timeout=10) + self.sprLabel() + + def addlabel(self): + 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) + + def delabelyes(self, k): + if k == True: + os.system('e2label /dev/%s ""' % str(self['devlist'].getCurrent())) + self.session.open(MessageBox, _('Label is delete'), type=MessageBox.TYPE_INFO, timeout=10) + self.sprLabel() + + def zamknij(self, data): + self.close() + + def left(self): + self['devlist'].up() + self.sprLabel() + + def right(self): + self['devlist'].down() + self.sprLabel() + + def up(self): + self['listlabel'].up() + + def down(self): + self['listlabel'].down() + + def addlabeltolist(self, z): + if z is not None: + self.labList.insert(0, z) + return + + def sprLabel(self): + lab = getoutput('blkid /dev/' + self['devlist'].getCurrent()) + lab1 = lab.split(' ') + licz1 = len(lab1) + i = 0 + while i < licz1: + if lab1[i][:5] == 'LABEL': + self['disklabel'].setText(lab1[i][7:-1]) + break + else: + self['disklabel'].setText(_('No label')) + i += 1 + + def sprLinux(self, dev): + lab = getoutput('blkid /dev/' + dev) + lab1 = lab.split(' ') + licz1 = len(lab1) + jest = False + j = 0 + while j < licz1: + if lab1[j][:9] == 'TYPE="ext': + jest = True + return jest + jest = False + j += 1 + + return jest + + +class DeviceManagerSummary(Screen): + def __init__(self, session, parent): + Screen.__init__(self, session, parent=parent) + self['entry'] = StaticText('') + self['desc'] = StaticText('') + self.onShow.append(self.addWatcher) + self.onHide.append(self.removeWatcher) + + def addWatcher(self): + self.parent.onChangedEntry.append(self.selectionChanged) + self.parent.selectionChanged() + + def removeWatcher(self): + self.parent.onChangedEntry.remove(self.selectionChanged) + + def selectionChanged(self, name, desc): + self['entry'].text = name + self['desc'].text = desc + + +def SkinPath(): + myskinpath = resolveFilename(SCOPE_CURRENT_SKIN, '') + if myskinpath == '' + LinkNeoBoot + '/images/': + myskinpath = '' + LinkNeoBoot + '/images/' + return myskinpath diff --git a/NeoBoot/files/modulecheck.sh b/NeoBoot/files/modulecheck.sh new file mode 100644 index 0000000..6e33c21 --- /dev/null +++ b/NeoBoot/files/modulecheck.sh @@ -0,0 +1,16 @@ +#!/bin/sh +#DESCRIPTION=This script by gutosie + +opkg update +opkg install --force-reinstall mtd-utils +opkg install --force-reinstall mtd-utils-ubifs +opkg install --force-reinstall mtd-utils-jffs2 +opkg install --force-reinstall kernel-module-nandsim +opkg install --force-reinstall python-subprocess +opkg install --force-reinstall python-argparse +opkg install --force-reinstall curl +opkg install --force-reinstall liblzo2-2 +opkg install --force-reinstall python-imaging +opkg install --force-maintainer --force-reinstall --force-overwrite kernel-image +opkg configure update-modules +cd diff --git a/NeoBoot/files/neobackup.sh b/NeoBoot/files/neobackup.sh new file mode 100644 index 0000000..ca291ee --- /dev/null +++ b/NeoBoot/files/neobackup.sh @@ -0,0 +1,27 @@ +#!/bin/sh +#script by gutosie + +if `grep -q 'osd.language=pl_PL' /dev/null 2>&1 + /bin/tar -czf $NEOBOOTMOUNT/CopyNEOBoot/Copy_$UPDATEv$NB$TiME.tar.gz /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot*/ + echo " " + [ $PL ] && echo "Kopia wtyczki neoboot o nazwie Copy_$UPDATEv$NB$TiME.tar.gz utworzono w:" $NEOBOOTMOUNT$LOCATIONBACKUP" " || echo "Copy named Copy_$UPDATEv$NB$TiME.tar.gz was created at location:" $NEOBOOTMOUNT$LOCATIONBACKUP" " + echo " " +else + /bin/tar -czf $NEOBOOTMOUNT/CopyNEOBoot/Copy_$UPDATEv$NB$TiME.tar.gz /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot*/ + echo " " + [ $PL ] && echo "Kopia wtyczki o nazwie Copy_$UPDATEv$NB$TiME.tar.gz utworzono w:" $NEOBOOTMOUNT$LOCATIONBACKUP" " || echo "Copy named Copy_$UPDATEv$NB$TiME.tar.gz was created at location:" $NEOBOOTMOUNT$LOCATIONBACKUP" " + echo " " +fi +exit 0 \ No newline at end of file diff --git a/NeoBoot/files/neoconsole.py b/NeoBoot/files/neoconsole.py new file mode 100644 index 0000000..30b239d --- /dev/null +++ b/NeoBoot/files/neoconsole.py @@ -0,0 +1,221 @@ +# -*- 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 +from Components.ScrollLabel import ScrollLabel +from Components.Sources.StaticText import StaticText +from Screens.MessageBox import MessageBox +from Components.Label import Label + + +class Console(Screen): + skin = """ + + """ + +# 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.cmdlist = cmdlist + self.newtitle = title + self.screen_hide = False + self.cancel_msg = None + self.output_file = '' + self.onShown.append(self.updateTitle) + self.container = eConsoleAppContainer() + self.run = 0 + self.container.appClosed.append(self.runFinished) + self.container.dataAvail.append(self.dataAvail) + self.onLayoutFinish.append(self.startRun) + return + + def updateTitle(self): + self.setTitle(self.newtitle) + + def doExec(self, cmd): + if isinstance(cmd, (list, tuple)): + return self.container.execute(cmd[0], *cmd) + else: + 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] + if self.doExec(self.cmdlist[self.run]): + self.runFinished(-1) + + def runFinished(self, retval): + if retval: + self.errorOcurred = True + self.toggleScreenHide(True) + self.run += 1 + if self.run != len(self.cmdlist): + 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 self.finishedCallback is not None: + self.finishedCallback() + if not self.errorOcurred and self.closeOnSuccess: + self.output_file = 'end' + self.cancel() + return + + def key_up(self): + if self.screen_hide: + self.toggleScreenHide() + return + self['text'].pageUp() + + def key_down(self): + if self.screen_hide: + self.toggleScreenHide() + return + self['text'].pageDown() + + def key_green(self): + if self.screen_hide: + self.toggleScreenHide() + return + 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.run == len(self.cmdlist): + self.saveOutputText() + #self.toggleScreenHide() + else: + self.toggleScreenHide() + + def key_red(self): + if self.screen_hide: + self.toggleScreenHide() + return + 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) + + def cancelCB(self, ret = None): + self.cancel_msg = None + if ret: + self.cancel(True) + return + + 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) + + def formatCmdList(self, source): + if isinstance(source, (list, tuple)): + for x in source: + for y in self.formatCmdList(x): + yield y + + else: + yield source + + 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' + try: + cmdlist = list(self.formatCmdList(self.cmdlist)) + text += 'command line: %s\n\n' % cmdlist[0] + script = '' + for cmd in cmdlist[0].split(): + 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)) + if len(cmdlist) > 1: + 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() + try: + f = open(self.output_file, 'w') + f.write(text) + f.close() + self['key_green'].setText(_('Load')) + return + except: + failtext = _("File write error: '%s'") % self.output_file + + self.output_file = 'end' + self['key_green'].setText(_(' ')) + self.session.open(MessageBox, failtext, type=MessageBox.TYPE_ERROR) + else: + self.output_file = '' + + def toggleScreenHide(self, setshow = False): + if self.screen_hide or setshow: + self.show() + else: + self.hide() + self.screen_hide = not (self.screen_hide or setshow) + + def readFile(self, file): + try: + with open(file, 'r') as rdfile: + rd = rdfile.read() + rdfile.close() + except: + if file == self.output_file: + rd = self['text'].getText() + else: + rd = "File read error: '%s'\n" % file + + return rd + + def cancel(self, force = False): + if self.screen_hide: + self.toggleScreenHide() + return + if force or self.run == len(self.cmdlist): + self.close() + self.container.appClosed.remove(self.runFinished) + self.container.dataAvail.remove(self.dataAvail) + if self.run != len(self.cmdlist): + self.container.kill() + + def dataAvail(self, str): + self['text'].appendText(str) \ No newline at end of file diff --git a/NeoBoot/files/neoreboot.py b/NeoBoot/files/neoreboot.py new file mode 100644 index 0000000..f96fbed --- /dev/null +++ b/NeoBoot/files/neoreboot.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +# system modules + +from __future__ import print_function +#from Plugins.Extensions.NeoBoot.__init__ import _ +import codecs +from enigma import getDesktop +from Components.ActionMap import ActionMap +from Components.Label import Label +from Components.ScrollLabel import ScrollLabel +from Components.Pixmap import Pixmap +from Components.Sources.List import List +from Components.ConfigList import ConfigListScreen +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, fileCheck +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 getNeoLocation, getImageNeoBoot, getKernelVersionString, getBoxHostName, getCPUtype, getBoxVuModel, getTunerModel, getCPUSoC, getImageATv +import os +import time +import sys +import struct, shutil +if fileExists('/etc/vtiversion.info') or fileExists('/usr/lib/python3.8') and fileExists('/.multinfo'): + from Screens.Console import Console +else: + from Plugins.Extensions.NeoBoot.files.neoconsole import Console +LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' + +class ForceReboot(Screen): + __module__ = __name__ + skin = """ + + + + """ + + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('Force reboot to flash ?')) + self['key_red'] = Label(_('To reboot press red!')) + self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, + 'red': self.iNFO}) + + def iNFO(self): + try: + cmd = "echo -e '\n\n%s '" % _('Please wait, NeoBoot is working...') + cmd1 = 'chmod 0755 ' + LinkNeoBoot + '/files/mountpoint.sh' + cmd2 = '' + LinkNeoBoot + '/files/mountpoint.sh' + cmd3 = "echo -e '\n\n%s '" % _('NeoBoot: Force reboot to flash image now...') + cmd4 = 'sleep 8; reboot -dfhi' + self.session.open(Console, _('NeoBoot: Backu to flash!'), [cmd, + cmd1, + cmd2, + cmd3, + cmd4]) + out = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w' ) + out.write('Flash') + out.close() + self.close() + + except: + False + +def main(session, **kwargs): + try: + session.open(ForceReboot) + except: + False + + +def startSetup(menuid): + if menuid != 'setup': + return [] + return [(_('NeoReboot'), + main, + 'NeoReboot', + 50)] + +def Plugins(path, **kwargs): + global plugin_path + plugin_path = path + list = [PluginDescriptor(name=_('NeoReboot'), description=_('Force reboot to flash.'), where=PluginDescriptor.WHERE_MENU, fnc=startSetup)] + return list + + \ No newline at end of file diff --git a/NeoBoot/files/stbbranding.py b/NeoBoot/files/stbbranding.py new file mode 100644 index 0000000..b7bf591 --- /dev/null +++ b/NeoBoot/files/stbbranding.py @@ -0,0 +1,756 @@ +# -*- coding: utf-8 -*- + +#from Plugins.Extensions.NeoBoot.__init__ import _ +import sys +import os +import time +from Tools.Directories import fileExists, SCOPE_PLUGINS + +def fileCheck(f, mode = 'r'): + return fileExists(f, mode) and f + +def getSupportedTuners(): + supportedT='' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg', 'r') as f: + lines = f.read() + f.close() + if lines.find("%s" % getBoxHostName()) != -1: + supportedT='%s' % getBoxHostName() + return supportedT + + +def getFreespace(dev): + statdev = os.statvfs(dev) + space = statdev.f_bavail * statdev.f_frsize / 1024 + print ("[NeoBoot] Free space on %s = %i kilobytes") % (dev, space) + return space + +#check install +def getCheckInstal1(): + neocheckinstal='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install', 'r') as f: + lines1 = f.read() + f.close() + if not lines1.find('/dev/') != -1: + neocheckinstal='1' + return neocheckinstal + +def getCheckInstal2(): + neocheckinstal='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: + lines2 = f.read() + f.close() + if not lines2.find('/media/') != -1: + neocheckinstal='2' + return neocheckinstal + +def getCheckInstal3(): + neocheckinstal='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh', 'r') as f: + lines3 = f.read() + f.close() + if not lines3.find('/bin/mount') != -1: + neocheckinstal='3' + + return neocheckinstal + +#check imageATV +def getImageATv(): + atvimage='UNKNOWN' + if os.path.exists('/etc/issue.net'): + with open('/etc/issue.net', 'r') as f: + lines = f.read() + f.close() + if lines.find('openatv') != -1: + atvimage='okfeedCAMatv' + return atvimage + +#check install +def getNeoLocation(): + locatino='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: + locatino = f.readline().strip() + f.close() + return locatino + + +#check ext +def getFormat(): + neoformat='UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines = f.read() + f.close() + if lines.find('ext2') != -1: + neoformat='ext2' + elif lines.find('ext3') != -1: + neoformat='ext3' + elif lines.find('ext4') != -1: + neoformat='ext4' + elif lines.find('nfs') != -1: + neoformat='nfs' + + return neoformat + + +def getNEO_filesystems(): + neo_filesystems='UNKNOWN' + if os.path.exists('/tmp/.neo_format'): + with open('/tmp/.neo_format', 'r') as f: + lines = f.read() + f.close() + if lines.find('ext2') != -1: + neo_filesystems='1' + elif lines.find('ext3') != -1: + neo_filesystems='1' + elif lines.find('ext4') != -1: + neo_filesystems='1' + elif lines.find('nfs') != -1: + neo_filesystems='1' + + return neo_filesystems + + +def Log(param = ''): + global LogFileObj + #first close object if exists + if param.lower() in ['open','write','append','close']: + if LogFileObj is not None: + LogFileObj.close() + if LogFileObj.closed: + LogFileObj = None + try: + with open('/tmp/NeoBoot.log','a') as f: + f.write('LogFile closed properly\n') + f.close() + except Exception: + print("ERROR closing LogFile!!!") + else: + print("ERROR closing LogFile!!!") + #second create object if does not exist + if LogFileObj is None: + if param.lower() in ['open','write']: + LogFileObj = open(LogFile, "w") + elif param.lower() in ['append']: + LogFileObj = open(LogFile, "a") + elif param.lower() in ['close']: + pass + elif param.lower() in ['flush']: + LogFileObj.flush() + return LogFileObj + +def clearMemory(): + with open("/proc/sys/vm/drop_caches", "w") as f: + f.write("1\n") + f.close() +############################################### + +#typ procesora arm lub mips +def getCPUtype(): + cpu='UNKNOWN' + if os.path.exists('/proc/cpuinfo'): + with open('/proc/cpuinfo', 'r') as f: + lines = f.read() + f.close() + if lines.find('ARMv7') != -1: + cpu='ARMv7' + elif lines.find('mips') != -1: + cpu='MIPS' + return cpu + +#check install +def getFSTAB(): + install='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid', 'r') as f: + lines = f.read() + f.close() + if lines.find('UUID') != -1: + install='UUID' + elif not lines.find('UUID') != -1: + install='NOUUID' + return install + +def getFSTAB2(): + install='UNKNOWN' + if os.path.exists('/etc/fstab'): + with open('/etc/fstab', 'r') as f: + lines = f.read() + f.close() + if lines.find('UUID') != -1: + install='OKinstall' + elif not lines.find('UUID') != -1: + install='NOUUID' + return install + +def getINSTALLNeo(): + neoinstall='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo', 'r') as f: + lines = f.read() + f.close() + if lines.find('/dev/sda1') != -1: + neoinstall='/dev/sda1' + elif lines.find('/dev/sda2') != -1: + neoinstall='/dev/sda2' + elif lines.find('/dev/sdb1') != -1: + neoinstall='/dev/sdb1' + elif lines.find('/dev/sdb2') != -1: + neoinstall='/dev/sdb2' + elif lines.find('/dev/sdc1') != -1: + neoinstall='/dev/sdc1' + elif lines.find('/dev/sdd1') != -1: + neoinstall='/dev/sdd1' + elif lines.find('/dev/sde1') != -1: + neoinstall='/dev/sde1' + elif lines.find('/dev/sdf1') != -1: + neoinstall='/dev/sdf1' + + return neoinstall + + +def getLocationMultiboot(): + LocationMultiboot='UNKNOWN' + if os.path.exists('/media/sda1/ImageBoot'): + LocationMultiboot='/dev/sda1' + if os.path.exists('/media/sda2/ImageBoot'): + LocationMultiboot='/dev/sda2' + if os.path.exists('/media/sdb1/ImageBoot'): + LocationMultiboot='/dev/sdb1' + if os.path.exists('/media/sdb2/ImageBoot'): + LocationMultiboot='/dev/sdb2' + if os.path.exists('/media/sdc1/ImageBoot'): + LocationMultiboot='/dev/sdc1' + if os.path.exists('/media/sdd1/ImageBoot'): + LocationMultiboot='/dev/sdd1' + if os.path.exists('/media/sde1/ImageBoot'): + LocationMultiboot='/dev/sde1' + if os.path.exists('/media/sdf1/ImageBoot'): + LocationMultiboot='/dev/sdf1' + + return LocationMultiboot + +def getLabelDisck(): + label='UNKNOWN' + if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid'): + with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid', 'r') as f: + lines = f.read() + f.close() + if lines.find('LABEL=') != -1: + label='LABEL=' + return label + +#checking device neo +def getNeoMount(): + neo='UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines = f.read() + f.close() + if lines.find('/dev/sda1 /media/hdd') != -1: + neo='hdd_install_/dev/sda1' + elif lines.find('/dev/sdb1 /media/hdd') != -1: + neo='hdd_install_/dev/sdb1' + elif lines.find('/dev/sda2 /media/hdd') != -1: + neo='hdd_install_/dev/sda2' + elif lines.find('/dev/sdb2 /media/hdd') != -1: + neo='hdd_install_/dev/sdb2' + elif lines.find('/dev/sdc1 /media/hdd') != -1: + neo='hdd_install_/dev/sdc1' + elif lines.find('/dev/sdd1 /media/hdd') != -1: + neo='hdd_install_/dev/sdd1' + elif lines.find('/dev/sde1 /media/hdd') != -1: + neo='hdd_install_/dev/sde1' + elif lines.find('/dev/sdf1 /media/hdd') != -1: + neo='hdd_install_/dev/sdf1' + + return neo + +def getNeoMount2(): + neo='UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines = f.read() + f.close() + if lines.find('/dev/sda1 /media/usb') != -1: + neo='usb_install_/dev/sda1' + elif lines.find('/dev/sdb1 /media/usb') != -1: + neo='usb_install_/dev/sdb1' + elif lines.find('/dev/sdb2 /media/usb') != -1: + neo='usb_install_/dev/sdb2' + elif lines.find('/dev/sdc1 /media/usb') != -1: + neo='usb_install_/dev/sdc1' + elif lines.find('/dev/sdd1 /media/usb') != -1: + neo='usb_install_/dev/sdd1' + elif lines.find('/dev/sde1 /media/usb') != -1: + neo='usb_install_/dev/sde1' + elif lines.find('/dev/sdf1 /media/usb') != -1: + neo='usb_install_/dev/sdf1' + elif lines.find('/dev/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' + + return neo + +def getNeoMount3(): + neo='UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines = f.read() + f.close() + if lines.find('/dev/sda1 /media/cf') != -1: + neo='cf_install_/dev/sda1' + elif lines.find('/dev/sdb1 /media/cf') != -1: + neo='cf_install_/dev/sdb1' + return neo + +def getNeoMount4(): + neo='UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines = f.read() + f.close() + if lines.find('/dev/sda1 /media/card') != -1: + neo='card_install_/dev/sda1' + elif lines.find('/dev/sdb1 /media/card') != -1: + neo='card_install_/dev/sdb1' + return neo + +def getNeoMount5(): + neo='UNKNOWN' + if os.path.exists('/proc/mounts'): + with open('/proc/mounts', 'r') as f: + lines = f.read() + f.close() + if lines.find('/dev/sda1 /media/mmc') != -1: + neo='mmc_install_/dev/sda1' + elif lines.find('/dev/sdb1 /media/mmc') != -1: + neo='mmc_install_/dev/sdb1' + return neo + + +#zwraca typ chipa prcesora +def getCPUSoC(): + chipset='UNKNOWN' + if os.path.exists('/proc/stb/info/chipset'): + with open('/proc/stb/info/chipset', 'r') as f: + chipset = f.readline().strip() + f.close() + if chipset == '7405(with 3D)': + chipset = '7405' + return chipset + +def getCPUSoCModel(): + devicetree='UNKNOWN' + if os.path.exists('/proc/device-tree/model'): + with open('/proc/device-tree/model', 'r') as f: + devicetree = f.readline().strip() + f.close() + return devicetree + +#zwraca wybrane image w neoboot do uruchomienia +def getImageNeoBoot(): + imagefile='UNKNOWN' + if os.path.exists('%sImageBoot/.neonextboot' % getNeoLocation() ): + with open('%sImageBoot/.neonextboot' % getNeoLocation() , 'r') as f: + imagefile = f.readline().strip() + f.close() + return imagefile + +#zwraca model vuplus +def getBoxVuModel(): + vumodel='UNKNOWN' + if fileExists("/proc/stb/info/vumodel") and not fileExists("/proc/stb/info/boxtype"): + with open('/proc/stb/info/vumodel', 'r') as f: + vumodel = f.readline().strip() + f.close() + elif fileExists("/proc/stb/info/boxtype") and not fileExists("/proc/stb/info/vumodel"): + with open('/proc/stb/info/boxtype', 'r') as f: + vumodel = f.readline().strip() + f.close() + return vumodel + +def getVuModel(): + if fileExists("/proc/stb/info/vumodel") and not fileExists("/proc/stb/info/boxtype"): + brand = "Vu+" + f = open("/proc/stb/info/vumodel",'r') + procmodel = f.readline().strip() + f.close() + model = procmodel.title().replace("olose", "olo SE").replace("olo2se", "olo2 SE").replace("2", "²") + return model + +#zwraca nazwe stb z pliku hostname +def getBoxHostName(): + if os.path.exists('/etc/hostname'): + with open('/etc/hostname', 'r') as f: + myboxname = f.readline().strip() + f.close() + return myboxname + +#zwraca vuplus/vumodel +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 + +def getBoxModelVU(): + try: + if os.path.isfile('/proc/stb/info/vumodel'): + return open('/proc/stb/info/vumodel').read().strip().upper() + except: + pass + + return _('unavailable') + +#zwraca strukture folderu zip - vuplus/vumodel +def getImageFolder(): + 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: + return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] + except: + return _('unknown') + +# czysci pamiec +def runCMDS(cmdsList): + clearMemory() + if isinstance(cmdsList, (list, tuple)): + myCMD = '\n'.join(cmdsList)# + '\n' + ret = os.system(myCMD) + return rett + + +def getImageDistroN(): + image='Internal storage' + + if fileExists('/.multinfo') and fileExists ('%sImageBoot/.imagedistro' % getNeoLocation() ): + with open('%sImageBoot/.imagedistro' % getNeoLocation() , 'r') as f: + image = f.readline().strip() + f.close() + + elif not fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): + f = open("/etc/vtiversion.info",'r') + imagever = f.readline().strip().replace("Release ", " ") + f.close() + image = imagever + + elif not fileExists('/.multinfo') and fileExists('/etc/bhversion'): + f = open("/etc/bhversion",'r') + imagever = f.readline().strip() + f.close() + image = imagever + +# elif not fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): +# image = 'VTI Team Image ' + + elif fileExists('/.multinfo') and fileExists('/etc/bhversion'): + image = 'Flash ' + ' ' + getBoxHostName() + + elif fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): + image = 'Flash ' + ' ' + getBoxHostName() + + + elif fileExists('/usr/lib/enigma2/python/boxbranding.so') and not fileExists('/.multinfo'): + from boxbranding import getImageDistro + image = getImageDistro() + + elif fileExists('/media/InternalFlash/etc/issue.net') and fileExists('/.multinfo') and not fileExists('%sImageBoot/.imagedistro' % getNeoLocation() ): + obraz = open('/media/InternalFlash/etc/issue.net', 'r').readlines() + imagetype = obraz[0][:-3] + image = imagetype + + elif fileExists('/etc/issue.net') and not fileExists('/.multinfo'): + obraz = open('/etc/issue.net', 'r').readlines() + imagetype = obraz[0][:-3] + image = imagetype + + else: + image = 'Inernal Flash ' + ' ' + getBoxHostName() + + return image + + +def getKernelVersionString(): + try: + result = popen('uname -r', 'r').read().strip('\n').split('-') + kernel_version = result[0] + return kernel_version + except: + pass + + return 'unknown' + + +def getKernelImageVersion(): + try: + from glob import glob + lines = open(glob('/var/lib/opkg/info/kernel-*.control')[0], 'r').readlines() + kernelimage = lines[1][:-1] + except: + kernelimage = getKernelVersionString + + return kernelimage + +def getTypBoxa(): + if not fileExists('/etc/typboxa'): + os.system('touch /etc/typboxa') + f2 = open('/etc/hostname', 'r') + mypath2 = f2.readline().strip() + f2.close() + if mypath2 == 'vuuno': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Uno ') + out.close() + elif mypath2 == 'vuultimo': + out = open('/etc/typboxa', 'w') + out.write('Vu+Ultimo ') + out.close() + elif mypath2 == 'vuduo': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Duo ') + out.close() + elif mypath2 == 'vuduo2': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Duo2 ') + out.close() + elif mypath2 == 'vusolo': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Solo ') + out.close() + elif mypath2 == 'vusolo2': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Solo2 ') + out.close() + elif mypath2 == 'vusolose': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Solo-SE ') + out.close() + elif mypath2 == 'vuvzero': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Zero ') + out.close() + elif mypath2 == 'vuuno4k': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Uno4k ') + out.close() + elif mypath2 == 'vuultimo4k': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Ultimo4k ') + out.close() + elif mypath2 == 'vusolo4k': + out = open('/etc/typboxa ', 'w') + out.write('Vu+Solo4k ') + out.close() + elif mypath2 == 'mbmini': + out = open('/etc/typboxa', 'w') + out.write('Miraclebox-Mini ') + out.close() + elif mypath2 == 'mutant51': + out = open('/etc/typboxa', 'w') + out.write('Mutant 51 ') + out.close() + elif mypath2 == 'sf4008': + out = open('/etc/typboxa', 'w') + out.write('Ocatgon sf4008 ') + out.close() + elif mypath2 == 'ax51': + out = open('/etc/typboxa', 'w') + out.write('ax51 ') + out.close() + + try: + lines = open('/etc/typboxa', 'r').readlines() + typboxa = lines[0][:-1] + except: + typboxa = 'not detected' + + return typboxa + +def getImageVersionString(): + try: + if os.path.isfile('/var/lib/opkg/status'): + st = os.stat('/var/lib/opkg/status') + else: + st = os.stat('/usr/lib/ipkg/status') + tm = time.localtime(st.st_mtime) + if tm.tm_year >= 2015: + return time.strftime('%Y-%m-%d %H:%M:%S', tm) + except: + pass + + return _('unavailable') + +def getModelString(): + try: + file = open('/proc/stb/info/boxtype', 'r') + model = file.readline().strip() + file.close() + return model + except IOError: + return 'unknown' + +def getChipSetString(): + try: + f = open('/proc/stb/info/chipset', 'r') + chipset = f.read() + f.close() + return str(chipset.lower().replace('\n', '').replace('bcm', '')) + except IOError: + return 'unavailable' + +def getCPUString(): + try: + file = open('/proc/cpuinfo', 'r') + lines = file.readlines() + for x in lines: + splitted = x.split(': ') + if len(splitted) > 1: + splitted[1] = splitted[1].replace('\n', '') + if splitted[0].startswith('system type'): + system = splitted[1].split(' ')[0] + elif splitted[0].startswith('Processor'): + system = splitted[1].split(' ')[0] + + file.close() + return system + except IOError: + return 'unavailable' + +def getCpuCoresString(): + try: + file = open('/proc/cpuinfo', 'r') + lines = file.readlines() + for x in lines: + splitted = x.split(': ') + if len(splitted) > 1: + splitted[1] = splitted[1].replace('\n', '') + if splitted[0].startswith('processor'): + if int(splitted[1]) > 0: + cores = 2 + else: + cores = 1 + + file.close() + return cores + except IOError: + return 'unavailable' + +def getEnigmaVersionString(): + import enigma + enigma_version = enigma.getEnigmaVersionString() + if '-(no branch)' in enigma_version: + enigma_version = enigma_version[:-12] + return enigma_version + +def getKernelVersionString(): + try: + f = open('/proc/version', 'r') + kernelversion = f.read().split(' ', 4)[2].split('-', 2)[0] + f.close() + return kernelversion + except: + return _('unknown') + +def getHardwareTypeString(): + try: + if os.path.isfile('/proc/stb/info/boxtype'): + return open('/proc/stb/info/boxtype').read().strip().upper() + ' (' + open('/proc/stb/info/board_revision').read().strip() + '-' + open('/proc/stb/info/version').read().strip() + ')' + if os.path.isfile('/proc/stb/info/vumodel'): + return 'VU+' + open('/proc/stb/info/vumodel').read().strip().upper() + '(' + open('/proc/stb/info/version').read().strip().upper() + ')' + if os.path.isfile('/proc/stb/info/model'): + return open('/proc/stb/info/model').read().strip().upper() + except: + pass + + return _('unavailable') + +def getImageTypeString(): + try: + return open('/etc/issue').readlines()[-2].capitalize().strip()[:-6] + except: + pass + + return _('undefined') + +def getMachineBuild(): + try: + return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] + except: + return 'unknown' + +def getVuBoxModel(): + if fileExists('/proc/stb/info/vumodel'): + try: + l = open('/proc/stb/info/vumodel') + model = l.read() + l.close() + BOX_NAME = str(model.lower().strip()) + l.close() + BOX_MODEL = 'vuplus' + except: + BOX_MODEL = 'not detected' + + return BOX_MODEL + +def getMachineProcModel(): + if os.path.isfile('/proc/stb/info/vumodel'): + BOX_NAME = getBoxModel() + 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 + + +boxbrand = sys.modules[__name__] + diff --git a/NeoBoot/files/tools.py b/NeoBoot/files/tools.py new file mode 100644 index 0000000..c3d2ec7 --- /dev/null +++ b/NeoBoot/files/tools.py @@ -0,0 +1,1853 @@ +# -*- coding: utf-8 -*- +# system modules + +from Plugins.Extensions.NeoBoot.__init__ import _ +import codecs +from enigma import getDesktop +from Components.About import about +from Components.ActionMap import ActionMap, NumberActionMap +from Components.Button import Button +from Components.GUIComponent import * +from Components.Input import Input +from Components.Label import Label +from Components.ProgressBar import ProgressBar +from Components.ScrollLabel import ScrollLabel +from Components.Pixmap import Pixmap, MultiPixmap +from Components.config import * +from Screens.VirtualKeyBoard import VirtualKeyBoard +from Screens.MessageBox import MessageBox +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 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, fileCheck +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 stbbranding import getNeoLocation, getImageNeoBoot, getKernelVersionString, getBoxHostName, getCPUtype, getBoxVuModel, getTunerModel, getCPUSoC, getImageATv +import os +import time +import sys +import struct, shutil +if fileExists('/etc/vtiversion.info') or fileExists('/usr/lib/python3.8') and fileExists('/.multinfo'): + from Screens.Console import Console +else: + from Plugins.Extensions.NeoBoot.files.neoconsole import Console +LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' +neoboot = getNeoLocation() +media = getNeoLocation() +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: + 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: + lines = f.read() + f.close() + if lines.find('ARMv7') != -1: + cpu='ARMv7' + elif lines.find('mips') != -1: + cpu='MIPS' + return cpu + +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: + vumodel = f.readline().strip() + f.close() + +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__ + + def __init__(self, fnc, *args): + self.fnc = fnc + self.args = args + + def __call__(self): + self.fnc(*self.args) + + +class MBTools(Screen): + if isFHD(): + skin = """ + + + + + + \n \t\t{"template": [\n \t\t\tMultiContentEntryText(pos = (50, 1), size = (920, 56), flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER, text = 0),\n \t\t\tMultiContentEntryPixmapAlphaTest(pos = (6, 4), size = (66, 66), png = 1),\n \t\t\t],\n \t\t\t"fonts": [gFont("Regular", 35)],\n \t\t\t"itemHeight": 60\n \t\t}\n \t\t + + """ + else: + skin = '\n \n\t\t\n\t\t\t\n \t\t{"template": [\n \t\t\tMultiContentEntryText(pos = (50, 1), size = (520, 36), flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER, text = 0),\n \t\t\tMultiContentEntryPixmapAlphaTest(pos = (4, 2), size = (36, 36), png = 1),\n \t\t\t],\n \t\t\t"fonts": [gFont("Regular", 22)],\n \t\t\t"itemHeight": 36\n \t\t}\n \t\t\n\t\t\n ' + __module__ = __name__ + + def __init__(self, session): + Screen.__init__(self, session) + self.list = [] + self['list'] = List(self.list) + self.updateList() + 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' + png = LoadPixmap(mypixmap) + + 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 = (_ ('Delete image ZIP from the ImagesUpload directory'), png, 3) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('NeoBoot Backup'), png, 4) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Uninstall NeoBoot'), png, 5) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Reinstall NeoBoot'), png, 6) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Update NeoBoot on all images.'), png, 7) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Update TV list on installed image.'), png, 8) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Update IPTVPlayer on installed image.'), png, 9) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Update FeedExtra on the installed image.'), png, 10) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Removing the root password.'), png, 11) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Check the correctness of neoboot installation'), png, 12) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Skin change'), png, 13) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Block or unlock skins.'), png, 14) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Mount Internal Flash'), png, 15) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Deleting languages'), png, 16) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('Updates feed cam OpenATV softcam'), png, 17) + self.list.append (res) + self ['list']. list = self.list + +# res = (_ ('Rename image'), png, 18) +# self.list.append (res) +# self ['list']. list = self.list + + res = (_ ('Supported sat tuners'), png, 18) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('NeoBoot Information'), png, 19) + self.list.append (res) + self ['list']. list = self.list + + res = (_ ('NeoBoot donate'), png, 20) + self.list.append (res) + self ['list']. list = self.list + + + def KeyOk(self): + self.sel = self['list'].getCurrent() + if self.sel: + self.sel = self.sel[2] + if self.sel == 0 and self.session.open(MBBackup): + pass + if self.sel == 1 and self.session.open(MBRestore): + pass + if self.sel == 2 and self.session.open(MenagerDevices): + pass + if self.sel == 3 and self.session.open(MBDeleUpload): + pass + if self.sel == 4 and self.session.open(BackupMultiboot): + pass + if self.sel == 5 and self.session.open(UnistallMultiboot): + pass + if self.sel == 6 and self.session.open(ReinstllNeoBoot): + pass + if self.sel == 7 and self.session.open(UpdateNeoBoot): + pass + if self.sel == 8 and self.session.open(ListTv): + pass + if self.sel == 9 and self.session.open(IPTVPlayer): + pass + if self.sel == 10 and self.session.open(FeedExtra): + pass + if self.sel == 11 and self.session.open(SetPasswd): + pass + if self.sel == 12 and self.session.open(CheckInstall): + pass + if self.sel == 13 and self.session.open(SkinChange): + pass + if self.sel == 14 and self.session.open(BlocUnblockImageSkin): + pass + if self.sel == 15 and self.session.open(InternalFlash): + pass + if self.sel == 16 and self.session.open(DeletingLanguages): + pass + if self.sel == 17 and self.session.open(ATVcamfeed): + pass +# if self.sel == 18 and self.session.open(RenameImage): +# pass + if self.sel == 18 and self.session.open(TunerInfo): + pass + if self.sel == 19 and self.session.open(MultiBootMyHelp): + pass + if self.sel == 20 and self.session.open(neoDONATION): + pass + + +class MBBackup(Screen): + if isFHD(): + skin = """ + + + + + + + + + """ + else: + skin = """ + + + + \ + + \n + + """ + + 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.onShow.append(self.updateInfo) + + def updateInfo(self): + if pathExists('/media/usb/ImageBoot'): + neoboot = 'usb' + elif pathExists('/media/hdd/ImageBoot'): + neoboot = 'hdd' + device = '/media/' + neoboot + '' + usfree = '0' + devicelist = ['cf', + 'hdd', + 'card', + 'usb', + 'usb2'] + for d in devicelist: + test = '/media/' + d + '/ImageBoot/.neonextboot' + if fileExists(test): + device = '/media/' + d + + rc = system('df > /tmp/ninfo.tmp') + f = open('/proc/mounts', 'r') + for line in f.readlines(): + if line.find('/hdd') != -1: + self.backupdir = '/media/' + neoboot + '/CopyImageNEO' + device = '/media/' + neoboot + '' + + f.close() + if pathExists(self.backupdir) == 0 and createDir(self.backupdir): + pass + if fileExists('/tmp/ninfo.tmp'): + f = open('/tmp/ninfo.tmp', 'r') + for line in f.readlines(): + line = line.replace('part1', ' ') + parts = line.strip().split() + totsp = len(parts) - 1 + if parts[totsp] == device: + if totsp == 5: + usfree = parts[3] + else: + usfree = parts[2] + break + + f.close() + os_remove('/tmp/ninfo.tmp') + self.availablespace = usfree[0:-3] + strview = _('You have the following images installed') + self['lab1'].setText(strview) + strview = _('You still have free: ') + self.availablespace + ' MB' + self['lab2'].setText(strview) + imageslist = ['Flash'] + for fn in listdir('/media/' + neoboot + '/ImageBoot'): + dirfile = '/media/' + neoboot + '/ImageBoot/' + fn + if os_isdir(dirfile) and imageslist.append(fn): + pass + + self['list'].list = imageslist + + def backupImage(self): + if not fileExists('/.multinfo'): + self.backupImage2() + else: + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + + def backupImage2(self): + 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.') + 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')) + 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]) + self.close() + else: + self.close() + + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + +class MBRestore(Screen): + __module__ = __name__ + skin = """ + + + + + + + + + """ + + 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.onShow.append(self.updateInfo) + + def updateInfo(self): + 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'] + for d in devicelist: + test = '/media/' + d + '/ImageBoot/.neonextboot' + if fileExists(test): + device = device + d + + 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' + 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') + + imageslist = [] + for fn in listdir(self.backupdir): + imageslist.append(fn) + + self['list'].list = imageslist + + def deleteback(self): + if not fileExists('/.multinfo'): + self.deleteback2() + else: + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + + def deleteback2(self): + 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...')) + + 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]) + self.updateInfo() + else: + self.close() + + def restoreImage(self): + if not fileExists('/.multinfo'): + self.restoreImage2() + else: + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + + def restoreImage2(self): + image = self['list'].getCurrent() + if image: + 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 = '' + 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')) + 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]) + self.close() + else: + self.close() + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + +class MenagerDevices(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def MD(self): + try: + from Plugins.Extensions.NeoBoot.files.devices import ManagerDevice + self.session.open(ManagerDevice) + + except: + False + + +class MBDeleUpload(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + 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')) + + 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]) + self.close() + else: + self.close() + + +class BackupMultiboot(Screen): + __module__ = __name__ + skin = """ + + \n\t\t{"template": [\n\t\t\tMultiContentEntryText(pos = (50, 1), size = (620, 46), flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER, text = 0),\n\t\t\tMultiContentEntryPixmapAlphaTest(pos = (6, 4), size = (46, 46), png = 1),\n\t\t\t],\n\t\t\t"fonts": [gFont("dugme", 30)],\n\t\t\t"itemHeight": 46\n\t\t}\n\t\t + + + + """ + + skin = """ + + + + """ + + 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}) + + 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() + + +class UnistallMultiboot(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def usun(self): + if not fileExists('/.multinfo'): + self.usun2() + else: + 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() + + 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')) + + 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' + 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' + 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 ' + 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]) + else: + self.close() + + def myClose(self, message): + 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() + + def restareE2(self): + self.session.open(TryQuitMainloop, 3) + + +class ReinstllNeoBoot(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def reinstallMB(self): + self.session.open(ReinstllNeoBoot2) + + +class ReinstllNeoBoot2(Screen): + __module__ = __name__ + skin = """ + + + + + + + + + """ + + 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.onShow.append(self.updateInfo) + + def updateInfo(self): + self.backupdir = '' + getNeoLocation() + 'CopyNEOBoot' + if pathExists(self.backupdir) == 0 and createDir(self.backupdir): + pass + + imageslist = [] + for fn in listdir(self.backupdir): + imageslist.append(fn) + + self['list'].list = imageslist + + def deleteback(self): + 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...')) + + 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]) + 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')) + else: + self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) + + def dorestoreImage(self, answer): + 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]) + self.close() + else: + self.close() + + +class UpdateNeoBoot(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def mbupload(self): + if not fileExists('/.multinfo'): + self.session.open(MyUpgrade2) + else: + 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() + +class MyUpgrade2(Screen): + 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): + 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+ '' + cmd = 'rm -r ' + target + ' > /dev/null 2>&1' + system(cmd) + cmd = 'cp -r ' +LinkNeoBoot+ ' ' + target + 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() + + +class ListTv(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def listupload(self): + if not fileExists('/.multinfo'): + self.listupload2() + else: + 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() + + +class ListTv2(Screen): + __module__ = __name__ + + if isFHD(): + skin = """ + + """ + else: + skin = '\n\t\t\n\t' + + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('NeoBoot: Upgrading in progress\nPlease wait...')) + 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): + 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() + 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 + if isdir(dirfile): + target = dirfile + '/etc/' + cmd = 'cp -r -f /etc/enigma2 ' + target + system(cmd) + target1 = dirfile + '/etc/tuxbox' + cmd = 'cp -r -f /etc/tuxbox/satellites.xml ' + target1 + system(cmd) + target2 = dirfile + '/etc/tuxbox' + cmd = 'cp -r -f /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 !!')) + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + + +class IPTVPlayer(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def IPTVPlayerUpload(self): + if not fileExists('/.multinfo'): + self.IPTVPlayerUpload2() + else: + 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() + +class IPTVPlayer2(Screen): + __module__ = __name__ + + if isFHD(): + skin = """ + + """ + else: + skin = '\n\t\t\n\t' + + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('NeoBoot: Upgrading in progress\nPlease wait...')) + 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): + 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/IPTVPlayer'): + self.myClose(_('Sorry, IPTVPlayer not found.')) + self.close() + else: + 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' + system(cmd) + cmd = 'cp -r /usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer ' + target + system(cmd) + + 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): + __module__ = __name__ + skin = """ + + + + """ + + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('Copy the FeedExtra Player plugin from flash to all images')) + self['key_red'] = Label(_('Install')) + self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, + 'red': self.FeedExtraUpload}) + + def FeedExtraUpload(self): + if not fileExists('/.multinfo'): + self.FeedExtraUpload2() + else: + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + + def FeedExtraUpload2(self): + self.session.open(FeedExtra2) + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + +class FeedExtra2(Screen): + __module__ = __name__ + + if isFHD(): + skin = """ + + """ + else: + skin = '\n\t\t\n\t' + + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('NeoBoot: Upgrading in progress\nPlease wait...')) + 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): + 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() + 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() + + +class SetPasswd(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + 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?')) + + def restartGUI(self, answer): + if answer is True: + self.session.open(TryQuitMainloop, 3) + else: + self.close() + + +class CheckInstall(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def neocheck(self): + if not fileExists('/.multinfo'): + self.neocheck2() + else: + self.myClose(_('Sorry, Neoboot can be installed or upgraded only when booted from Flash')) + + def neocheck2(self): + try: + cmd = ' ' +LinkNeoBoot+ '/files/modulecheck.sh' + self.session.openWithCallback(self.close, Console, _('NeoBoot....'), [cmd, + cmd]) + self.close() + + except: + False + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + + +class SkinChange(Screen): + if isFHD(): + skin = """ + + + + + + + + + """ + + else: + skin = ' \n\n \n\n \n \n \n\t\t\t\n \n\n\n\n \n\n ' + + 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.onShow.append(self.updateInfo) + + def updateInfo(self): + 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 + if os_isdir(dirfile) and skinlist.append(fn): + pass + + self['list'].list = skinlist + + + def SkinGO(self): + skin = self['list'].getCurrent() + if skin: + self.selectedskin = skin.strip() + 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')) + else: + self.session.open(MessageBox, myerror, MessageBox.TYPE_INFO) + +#ln -sf "neoskins/default.py" "/usr/lib/enigma2/python/Plugins /Extensions/NeoBoot/skin.py" + def DefaultSkin(self): + cmd = "echo -e '\n\n%s '" % _('Please wait, NeoBot is working, skin change is progress...') + cmd1 = "echo -e '\n\n%s '" % _('NeoBoot: Complete Skin Change!') +# cmd2 = 'cp -r ' +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 answer is True: + if getBoxHostName() == 'vuultimo4k': + system('cp -r ' + LinkNeoBoot + '/images/ultimo4k.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'vusolo4k': + system('cp -r ' + LinkNeoBoot + '/images/solo4k.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'vuduo4k': + system('cp -r ' + LinkNeoBoot + '/images/duo4k.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'vuduo4kse': + system('cp -r ' + LinkNeoBoot + '/images/duo4k.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'vuuno4k': + system('cp -r ' + LinkNeoBoot + '/images/uno4k.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'vuuno4kse': + system('cp -r ' + LinkNeoBoot + '/images/uno4kse.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'vuzero4kse': + system('cp -r ' + LinkNeoBoot + '/images/zero4kse.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'sf4008': + system('cp -r ' + LinkNeoBoot + '/images/sf4008.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'ustym4kpro': + system('cp -r ' + LinkNeoBoot + '/images/ustym4kpro.png ' + LinkNeoBoot + '/images/box.png') + elif getBoxHostName() == 'h7' or getBoxHostName() == 'zgemmah7' : + system('cp -r ' + LinkNeoBoot + '/images/zgmmah7.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 -r ' + 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]) + else: + self.close() + + def checkimageskin(self): + if fileCheck('/etc/vtiversion.info'): +# fail = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/usedskin.py' +# f = open(fail, 'r') +# content = f.read() +# f.close() +# localfile2 = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/usedskin.py' +# temp_file2 = open(localfile2, 'w') +# temp_file2.write(content.replace('selektor.png', 'slekvti.png')) +# temp_file2.close() + 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?')) + + def restartGUI(self, answer): + if answer is True: + self.session.open(TryQuitMainloop, 3) + else: + self.close() + + +class BlocUnblockImageSkin(Screen): + __module__ = __name__ + skin = """ + + + + + + + """ + + 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.onShow.append(self.updateInfo) + + def updateInfo(self): + self.backupdir = '/usr/share/enigma2' + if pathExists(self.backupdir) == 0 and createDir(self.backupdir): + pass + + imageslist = [] + for fn in listdir(self.backupdir): + imageslist.append(fn) + + self['list'].list = imageslist + + def deleteback(self): + image = self['list'].getCurrent() + self.delimage = image.strip() + if fileExists(self.backupdir + '/' + self.delimage + '/skin.xml'): + self.deleteback2() + else: + self.myClose(_('Sorry, not find skin neoboot.')) + + def deleteback2(self): + 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...')) + + 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() + 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() + + + 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?')) + + def restartGUI(self, answer): + if answer is True: + self.session.open(TryQuitMainloop, 3) + else: + self.close() + + def myClose(self, message): + self.session.open(MessageBox, message, MessageBox.TYPE_INFO) + self.close() + + +class InternalFlash(Screen): + __module__ = __name__ + skin = """ + + + + """ + + 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}) + + def mountIF(self): + if fileExists('/.multinfo'): + self.mountinternalflash() + else: + self.myClose(_('Sorry, the operation is not possible from Flash')) + 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 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 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() == 'zgemmah9combo': +# 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 getBoxHostName == 'ax60': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p21 /media/InternalFlash') + + if getBoxHostName() == 'ustym4kpro' or getTunerModel() == 'ustym4kpro': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p13 /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() == 'uno4kse' or getBoxVuModel() == 'uno4k' or getBoxVuModel() == 'ultimo4k' or getBoxVuModel() == 'solo4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p4 /media/InternalFlash') + + if getBoxVuModel() == 'zero4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p7 /media/InternalFlash') + + if getBoxVuModel() == 'duo4k': + os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p9 /media/InternalFlash') + + if getBoxVuModel() == 'duo4kse': + 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 getBoxHostName == 'osmio4k': + #os.system('mkdir -p /media/InternalFlash; mount /dev/mmcblk0p5 /media/InternalFlash') + + 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) + self.close() + + + +class DeletingLanguages(Screen): + __module__ = __name__ + skin = """ + + + + + + + """ + + 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.onShow.append(self.updateInfo) + + def updateInfo(self): + self.backupdir = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/locale' + if pathExists(self.backupdir) == 0 and createDir(self.backupdir): + pass + + imageslist = [] + for fn in listdir(self.backupdir): + imageslist.append(fn) + + self['list'].list = imageslist + + def deleteback(self): + 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...')) + + 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]) + self.updateInfo() + else: + self.close() + + +class ATVcamfeed(Screen): + __module__ = __name__ + skin = """ + + + + """ + + def __init__(self, session): + Screen.__init__(self, session) + self['lab1'] = Label(_('Add Cam dowloand 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]) + + 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 = """ + + + + """ + + 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}) + + def iNFO(self): + try: + cmd = ' cat ' +LinkNeoBoot+ '/stbinfo.cfg' + cmd1 = '' + self.session.openWithCallback(self.close, Console, _('NeoBoot....'), [cmd, + cmd1]) + self.close() + + except: + False + + +class MultiBootMyHelp(Screen): + if isFHD(): + skin = """ + + + """ + else: + skin = '\n\n' + __module__ = __name__ + + 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.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) + + +###______\\\\\\----for plugin----////_____### + +class MyHelpNeo(Screen): + if isFHD(): + skin = """ + + """ + else: + skin = """ + + """ + + __module__ = __name__ + + 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.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 = _('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): + if isFHD(): + skin = """ """ + else: + skin = """""" + __module__ = __name__ + def __init__(self, session): + Screen.__init__(self, session) + self['key_red'] = Label(_('Remove NeoBoot of STB')) + self['lab1'] = ScrollLabel('') + self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'DirectionActions'], {'back': self.close, + 'red': self.delete, + '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 + '\n\n') + message += _('NeoBoot Ver. updates ' + UPDATEVERSION + '\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 += _('Have fun !!!') + 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 += _('----------------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 += _('If you want to support the neoboot project, you can do so by contacting us by e-mail:\n') + message += _(' krzysztofgutosie@gmail.com\n') + message += _('---------------- ¯\_(ツ)_/¯ ----------------\n') + self['lab1'].show() + self['lab1'].setText(message) + + 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.')) + + def mbdelete(self, answer): + if answer is True: + if fileExists('/etc/fstab.org'): + system('rm -r /etc/fstab; mv /etc/fstab.org /etc/fstab') + if fileExists('/etc/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 = '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,]) + self.close() + else: + self.close() + +class ReinstallKernel(Screen): + __module__ = __name__ + + skin = """ + + + + """ + + 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}) + + def InfoCheck(self): + 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.') + self.session.open(MessageBox, mess, MessageBox.TYPE_INFO) + else: + self.kernel_update() + + else: + self.kernel_update() + + def kernel_update(self): + 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): + if isFHD(): + skin = """ + + """ + else: + skin = """ + + """ + + __module__ = __name__ + + 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.updatetext() + + def updatetext(self): + message = _('NeoBoot Ver. ' + PLUGINVERSION + ' Enigma2\n\n') + message += _('NeoBoot Ver. updates ' + UPDATEVERSION + ' \n\n') + message += _('----------------Free donate----------------\n\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 += _('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 += _('----------------Free donate----------------\n') + message += _('¯\_(ツ)_/¯ Have fun !!!') + self['lab1'].show() + self['lab1'].setText(message) + + +def myboot(session, **kwargs): + session.open(MBTools) + +def Plugins(path, **kwargs): + global pluginpath + pluginpath = path + 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 new file mode 100644 index 0000000..fdc2dc9 --- /dev/null +++ b/NeoBoot/files/userscript.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# script gutosie +# here you can add your own command to perform +# line - Checking internet connection by @j00zek thank you + +IMAGEKATALOG=ImageBoot + +if [ -e /.control_boot_new_image ] ; then + passwd -d root + ln -sf "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" "/NeoBoot" +fi + + +if [ ! -e `cat /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location`$IMAGEKATALOG/.neonextboot ] ; then + mkdir `cat /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location` + /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh + echo "_(_________Start mountpoint location NEOBOOT_________)" +fi + +echo "_(Checking internet connection)..." +ping -c 1 github.com 1>/dev/null 2>%1 +if [ $? -gt 0 ]; then + echo -n "_(github server unavailable, update impossible)\n!!! network restart...!!! )" + /etc/init.d/networking stop; + echo "_____(stopping network connection)_____" + sleep 1; + /etc/init.d/networking start; + echo "_____(start network connection)_____" + sleep 5 + + if [ $? -gt 0 ]; then + if [ -e /usr/bin/curl ]; then + cd /tmp; curl -O --ftp-ssl https://raw.githubusercontent.com/gutosie/NeoBoot8/master/ver.txt; + cd / + elif [ -e /usr/bin/wget ]; then + wget https://raw.githubusercontent.com/gutosie/NeoBoot8/master/ver.txt -O /tmp/ver.txt + cd / + + fi + if [ ! -f /tmp/ver.txt ] ; then + /etc/init.d/networking stop; + echo "_____(stopping network connection)_____" + sleep 2; + /etc/init.d/networking start; + echo "_____(start network connection)_____" + + fi + fi + +# echo " dns-nameservers 1.1.1.1 " >> /etc/network/interfaces +else + echo "_____!!!(github server available)!!!_____" +fi + +if [ -e /%1 ] ; then + rm -f /%1 +fi +if [ -e /home/root/%1 ] ; then + rm -f /home/root/%1 +fi + +echo "!!!_____([NEOBOOT] used userscript)_____!!! " +echo ok + +exit 0 + \ No newline at end of file