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 __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 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 __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(_('Formatting Disk')) self['lab1'] = Label() self.onChangedEntry = [] self.list = [] self['list'] = List(self.list) self['list'].onSelectionChanged.append(self.selectionChanged) self['actions'] = ActionMap( ['WizardActions', 'ColorActions', 'MenuActions'], { 'back': self.close, 'red': self.Format_ext3, 'green': self.SetupMounts, 'yellow': self.Format_ext4, 'blue': self.InitializationNeoB, 'back': self.close }) self.activityTimer = eTimer() self.activityTimer.timeout.get().append(self.updateList2) self.updateList() self.onShown.append(self.setWindowTitle)
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 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 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 __init__(self, session): Screen.__init__(self, session) self.list = [] self['list'] = List(self.list) self.select() self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'ok': self.KeyOk, 'back': self.close}) self['label1'] = Label(_('Start the chosen system now ?')) self['label2'] = Label(_('Select OK to run the image.'))
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!' ))
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 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 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 StartImageInNeoBoot(self): if getImageNeoBoot() != 'Flash': if fileExists('%sImageBoot/%s/.control_ok' % ( getNeoLocation(), getImageNeoBoot())): system('touch /tmp/.control_ok ') else: system('touch %sImageBoot/%s/.control_boot_new_image ' % ( getNeoLocation(), getImageNeoBoot() )) system('chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/kernel.sh') self.sel = self['list'].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0: if fileExists('/media/InternalFlash/etc/init.d/neobootmount.sh'): os.system('rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;') if not fileExists('/bin/busybox.nosuid'): os.system('ln -sf "busybox" "/bin/busybox.nosuid" ') #################_____mips___########################## #VUPLUS MIPS vu_dev_mtd1.sh if getBoxHostName() == 'vuultimo' or getBoxHostName() == 'bm750' or getBoxHostName() == 'vuduo' or getBoxHostName() == 'vuuno' or getBoxHostName() == 'vusolo' or getBoxHostName() == 'vuduo': if not fileExists('%sImagesUpload/.kernel/%s.vmlinux.gz' % (getNeoLocation(), getBoxHostName()) ): self.myclose2(_('Error - in the location %sImagesUpload/.kernel/ \nkernel file not found flash kernel vmlinux.gz ' % getNeoLocation() )) else: if getImageNeoBoot() == 'Flash': if fileExists('/.multinfo'): cmd = "echo -e '\n\n%s '" % _('...............NeoBoot REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') cmd1 = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/kernel.sh' elif not fileExists('/.multinfo'): cmd = "echo -e '\n\n%s '" % _('...............NEOBOOT >> Reboot...............\nPlease wait, in a moment the decoder will be restarted...') cmd1 = 'ln -sfn /sbin/init.sysvinit /sbin/init; /etc/init.d/reboot' elif getImageNeoBoot() != 'Flash': if not fileExists('/.multinfo'): if fileExists('' + getNeoLocation() + 'ImageBoot/' + getImageNeoBoot() + '/boot/' + getBoxHostName() + '.vmlinux.gz'): cmd = "echo -e '\n\n%s '" % _('...............NEOBOOT-REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') cmd1 = 'ln -sfn /sbin/neoinitmipsvu /sbin/init; /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/kernel.sh' elif not fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % ( getNeoLocation(), getImageNeoBoot(), getBoxHostName())): cmd = "echo -e '\n\n%s '" % _('...............NEOBOOT > REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') cmd1 = 'ln -sfn /sbin/neoinitmipsvu /sbin/init; /etc/init.d/reboot' elif fileExists('/.multinfo'): if not fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % ( getNeoLocation(), getImageNeoBoot(), getBoxHostName())): cmd = "echo -e '\n\n%s '" % _('...............NEOBOOT_REBOOT...............\nPlease wait, in a moment the decoder will be restarted...') cmd1 = 'flash_eraseall /dev/mtd1; sleep 2; ' + LinkNeoBoot + '/bin/nandwrite -p /dev/mtd1 %sImagesUpload/.kernel/%s.vmlinux.gz; /etc/init.d/reboot' % ( getNeoLocation(), getBoxHostName()) elif fileExists('%sImageBoot/%s/boot/%s.vmlinux.gz' % ( getNeoLocation(), getImageNeoBoot(), getBoxHostName())): cmd = "echo -e '\n\n%s '" % _('...............REBOOT now...............\nPlease wait, in a moment the decoder will be restarted...') cmd1 = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/kernel.sh' self.session.open(Console, _('NeoBoot MIPS....'), [cmd, cmd1]) self.close() else: os.system('echo "Flash " >> ' + getNeoLocation() + 'ImageBoot/.neonextboot') self.messagebox = self.session.open(MessageBox, _('It looks like it that multiboot does not support this STB.'), MessageBox.TYPE_INFO, 8) self.close()
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 StartImageInNeoBoot(self): if getImageNeoBoot() != 'Flash': if fileExists('%sImageBoot/%s/.control_ok' % (getNeoLocation(), getImageNeoBoot())): system('touch /tmp/.control_ok ') else: system('touch %sImageBoot/%s/.control_boot_new_image ' % (getNeoLocation(), getImageNeoBoot())) #system('chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/kernel.sh') self.sel = self['list'].getCurrent() if self.sel: self.sel = self.sel[2] if self.sel == 0: if fileExists('/media/InternalFlash/etc/init.d/neobootmount.sh'): os.system( 'rm -f /media/InternalFlash/etc/init.d/neobootmount.sh;') if (getSupportedTuners()): if getImageNeoBoot() == 'Flash': cmd = 'ln -sfn /sbin/init.sysvinit /sbin/init' rc = os.system(cmd) self.session.open(TryQuitMainloop, 2) elif getImageNeoBoot() != 'Flash': if fileExists('/.multinfo'): self.session.open(TryQuitMainloop, 2) elif not fileExists('/.multinfo'): cmd = 'ln -sfn /sbin/neoinitmips /sbin/init' rc = os.system(cmd) self.session.open(TryQuitMainloop, 2) else: os.system('echo "Flash " >> ' + getNeoLocation() + 'ImageBoot/.neonextboot') self.session.open(TryQuitMainloop, 2) else: os.system('echo "Flash " >> ' + getNeoLocation() + 'ImageBoot/.neonextboot') self.messagebox = self.session.open( MessageBox, _('It looks like it that multiboot does not support this STB.' ), MessageBox.TYPE_INFO, 8) self.close() else: os.system('echo "Flash " >> ' + getNeoLocation() + 'ImageBoot/.neonextboot') self.messagebox = self.session.open( MessageBox, _('It looks like it that multiboot does not support this STB.' ), MessageBox.TYPE_INFO, 8) self.close()
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 __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 wlacz(self): self.session.openWithCallback(self.wlaczyes, MessageBox, _('Set label on %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False)
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 dellabel(self): self.session.openWithCallback(self.delabelyes, MessageBox, _('Delete label from %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False)
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 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 select(self): self.list = [] mypath = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' if not fileExists(mypath + 'icons'): mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/ok.png' png = LoadPixmap(mypixmap) res = (_('OK Start image...'), png, 0) self.list.append(res) self['list'].list = self.list
def InitializationNeoB(self): if fileExists('/.multinfo'): self.session.open(MessageBox, _("This option is available only from Flash"), MessageBox.TYPE_INFO, timeout=10) else: from Plugins.Extensions.NeoBoot.files.tools import InitializationFormattingDisk self.session.open(InitializationFormattingDisk)
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 select(self): self.list = [] mypath = '' + LinkNeoBoot + '' if not fileExists(mypath + 'icons'): mypixmap = '' + LinkNeoBoot + '/images/ok.png' png = LoadPixmap(mypixmap) res = (_('OK Start image...'), png, 0) self.list.append(res) self['list'].list = self.list
def SetupMounts(self): if getCheckExt() != 'vfat' and getCheckExt() == 'ext3' or getCheckExt( ) == 'ext4': self.SetupMountsGo() else: self.session.open( MessageBox, _('Disk the directory HDD or USB is not a ext2, ext3 or ext4.\nMake sure you select a valid partition type to install neoboot.' ), type=MessageBox.TYPE_ERROR)
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 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 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)