class Ceparted(Screen): skin = """<screen position="center,center" size="600,200" title="eParted OpenLD"> <widget name="list" position="5,5" size="590,190" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions"], { "cancel": self.Exit, "ok": self.Ok }, -1) self["list"] = MenuList(list=[]) self.Console = Console() global rereaddevices rereaddevices = True self.__readDev() def Ok(self): sel = self["list"].getCurrent() if sel and sel[1]: global rereaddevices rereaddevices = False self.session.openWithCallback(self.__readDev, Cpart, sel[1]) def __readDev(self): global rereaddevices if rereaddevices: self.Console.ePopen("parted -m -l", self.__FinishedConsole) def Exit(self): self.Console.killAll() self.close() def __FinishedConsole(self, result, retval, extra_args=None): if retval == 0 and '\n' in result: list = [] for x in parseCmd(result): if x[0][LIST_TYPE] == LIST_TYPE_DEV: name = x[0][DEV_NAME] if len(name) == 0: name = x[0][DEV_PATH] tstr = name tstr += " (%s - %d %s %s)" % (x[0][DEV_SIZE], len(x) - 1, _("partition(s)"), x[0][DEV_PATH]) list.append((tstr, (name, x[0][DEV_PATH], x[0][DEV_SIZE]))) self["list"].setList(list)
class Ceparted(Screen): skin = """<screen position="center,center" size="600,200" title="eParted OpenLD"> <widget name="list" position="5,5" size="590,190" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions"], { "cancel": self.Exit, "ok": self.Ok }, -1) self["list"] = MenuList(list=[]) self.Console = Console() global rereaddevices rereaddevices=True self.__readDev() def Ok(self): sel = self["list"].getCurrent() if sel and sel[1]: global rereaddevices rereaddevices=False self.session.openWithCallback(self.__readDev, Cpart, sel[1]) def __readDev(self): global rereaddevices if rereaddevices: self.Console.ePopen("parted -m -l", self.__FinishedConsole) def Exit(self): self.Console.killAll() self.close() def __FinishedConsole(self, result, retval, extra_args = None): if retval==0 and '\n' in result: list=[] for x in parseCmd(result): if x[0][LIST_TYPE]==LIST_TYPE_DEV: name = x[0][DEV_NAME] if len(name)==0: name = x[0][DEV_PATH] tstr = name tstr += " (%s - %d %s %s)" %(x[0][DEV_SIZE],len(x)-1,_("partition(s)"),x[0][DEV_PATH]) list.append((tstr,(name,x[0][DEV_PATH], x[0][DEV_SIZE]))) self["list"].setList(list)
class CleanupWizard(WizardLanguage, Rc): skin = """ <screen name="CleanupWizard" position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" > <widget name="text" position="153,40" size="380,330" font="Regular;22" /> <widget source="list" render="Listbox" position="43,300" size="460,220" scrollbarMode="showOnDemand" > <convert type="StringList" /> </widget> <widget name="config" position="53,340" zPosition="1" size="440,180" transparent="1" scrollbarMode="showOnDemand" /> <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" /> <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" /> <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on" /> <widget name="rc" pixmaps="skin_default/rc0.png,skin_default/rc1.png,skin_default/rc2.png" position="530,50" zPosition="10" size="154,500" alphatest="on" /> <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> </screen>""" def __init__(self, session): self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/CleanupWizard/cleanupwizard.xml") WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False) Rc.__init__(self) self.session = session self["wizard"] = Pixmap() self.selectedAction = None self.selectedPackage = None self.NextStep = None self.Text = None self.buildListRef = None self.RemoveRef = None self.excluded_extensions = ('-skins', '-streamproxy', '-frontprocessorupgrade', '-crashlogautosubmit', '-hotplug', '-webinterface', '-mediascanner', '-genuinedreambox', '-mediaplayer', '-pictureplayer', '-dvdplayer', '-dvdburn', '-videotune', '-videomode', '-softwaremanager', '-skinselector', '-satfinder' ) self.Console = Console() self.installed_packetlist = [] self.ipkg = IpkgComponent() self.ipkg.addCallback(self.ipkgCallback) def markDone(self): pass def listAction(self): list = [] list.append((_("OK, remove some extensions"), "removeextensions")) list.append((_("Exit the cleanup wizard"), "end")) return list def listAgainAction(self): list = [] list.append((_("OK, remove another extensions"), "removeextensions")) list.append((_("Exit the cleanup wizard"), "end")) return list def ActionSelectionMade(self, index): self.selectedAction = index self.ActionSelect(index) def ActionSelect(self, index): if index == 'end': self.NextStep = 'end' else: self.NextStep = 'removeextensions' def ActionSelectionMoved(self): self.ActionSelect(self.selection) def buildList(self,action): if self.NextStep is not 'end': if not self.Console: self.Console = Console() cmd = "opkg list_installed | grep enigma2" self.Console.ePopen(cmd, self.buildListInstalled_Finished) self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _("Please wait while searching for removable packages..."), type = MessageBox.TYPE_INFO, enable_input = False) else: self.buildListfinishedCB(False) def buildListInstalled_Finished(self, result, retval, extra_args = None): if len(result): self.installed_packetlist = [] for x in result.splitlines(): split = x.split(' - ') if not any(split[0].strip().endswith(x) for x in self.excluded_extensions): #ignore some base plugins if split[0].strip() != 'enigma2': self.installed_packetlist.append((split[0].strip())) self.buildListRef.close(True) def buildListfinishedCB(self,data): self.buildListRef = None if data is True: self.currStep = self.getStepWithID(self.NextStep) self.afterAsyncCode() else: self.currStep = self.getStepWithID(self.NextStep) self.afterAsyncCode() def listInstalledPackages(self): list = [] if self.installed_packetlist and len(self.installed_packetlist): for x in self.installed_packetlist: if x.startswith('enigma2-plugin-'): pluginname = x.replace("enigma2-plugin-","") elif x.startswith('enigma2-skin-'): pluginname = x.replace("enigma2-","") else: pluginname = x list.append( (pluginname,x) ) return list def PackageSelectionMade(self, index): self.PackageSelect(index) def PackageSelectionMoved(self): self.PackageSelect(self.selection) def PackageSelect(self, package): self.selectedPackage = package def ipkgCallback(self, event, param): if event == IpkgComponent.EVENT_ERROR: freeSpace = checkFreeSpaceAvailable() txt_line1 = _("There was an error. The package:") + "\n" + str(self.selectedPackage) + "\n" + _("could not be removed") + "\n" txt_line2 = _("There are now ") + str(freeSpace) + " kB " + _("available") + "\n\n" txt_line3 = _("Please select an option below.") self.Text = txt_line1 + txt_line2 + txt_line3 self.NextStep = 'StatusRemoveERROR' self.RemoveRef.close(True) elif event == IpkgComponent.EVENT_DONE: freeSpace = checkFreeSpaceAvailable() txt_line1 = _("The package:") + "\n" + str(self.selectedPackage) + "\n" + _("was removed successfully") + "\n" txt_line2 = _("There are now ") + str(freeSpace) + " kB " + _("available") + "\n\n" txt_line3 = _("Please select an option below.") self.Text = txt_line1 + txt_line2 + txt_line3 self.NextStep = 'StatusRemoveOK' self.RemoveRef.close(True) pass def removeExtension(self,extension): if self.NextStep is not 'end': self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': extension}) self.RemoveRef = self.session.openWithCallback(self.removeExtensionFinishedCB, MessageBox, _("Please wait while removing selected package..."), type = MessageBox.TYPE_INFO, enable_input = False) else: self.buildListfinishedCB(False) def removeExtensionFinishedCB(self,data): self.RemoveRef = None if data is True: self.currStep = self.getStepWithID(self.NextStep) self.afterAsyncCode() else: self.currStep = self.getStepWithID(self.NextStep) self.afterAsyncCode()
class EasySetup(ConfigListScreen, Screen): __module__ = __name__ def __init__(self, session, args=0): Screen.__init__(self, session) self.skinName = ["EasySetup"] config.easysetup = ConfigSubsection() config.easysetup.restart = ConfigBoolean(default=False) config.easysetup.backup = ConfigYesNo(default=True) config.easysetup.hddsetup = ConfigYesNo(default=False) config.easysetup.records = ConfigYesNo(default=False) config.easysetup.timeshift = ConfigYesNo(default=False) config.easysetup.Keymap = ConfigYesNo(default=False) config.easysetup.Hotkey = ConfigYesNo(default=False) config.easysetup.channellist = ConfigYesNo(default=False) config.easysetup.m3u = ConfigYesNo(default=False) config.easysetup.hdmicec = ConfigYesNo(default=False) config.easysetup.password = ConfigYesNo(default=False) config.easysetup.displaysetup = ConfigYesNo(default=False) config.wizardsetup.UserInterfacePositioner = ConfigYesNo(default=False) config.wizardsetup.OpenWebifConfig = ConfigYesNo(default=False) config.wizardsetup.poweroffsetup = ConfigYesNo(default=False) config.wizardsetup.ipkinstall = ConfigYesNo(default=False) self.backup = '0' self.runed = '0' self['spaceused'] = ProgressBar() self["status"] = ScrollLabel() self.onShown.append(self.setWindowTitle) self["description"] = Label(_("")) list = [] list.append( getConfigListEntry( _('Enable Fullbackup after Easy-Setup?'), config.easysetup.backup, _("Default is enable and Fullbackup will start after all Setups are ready." ))) list.append( getConfigListEntry( _('Enable HDD/USB/SD Mounts Setup?'), config.easysetup.hddsetup, _("Choose your Device mounts (USB, HDD, others...)."))) list.append( getConfigListEntry(_('Enable Records Setup?'), config.easysetup.records, _("Choose your recording config."))) list.append( getConfigListEntry(_('Enable Timeshift Setup?'), config.easysetup.timeshift, _("Choose your timeshift config."))) list.append( getConfigListEntry(_('Enable Keymap Setup?'), config.easysetup.Keymap, _("Choose your keymap."))) list.append( getConfigListEntry(_('Enable Hotkey Setup?'), config.easysetup.Hotkey, _("Choose your remote buttons."))) list.append( getConfigListEntry(_('Enable Channellist Setup?'), config.easysetup.channellist, _("Choose your Channel selection config."))) list.append( getConfigListEntry( _('Enable M3U Convert to Channellist Setup?'), config.easysetup.m3u, _("Install your IPTV-m3u-files into channellist.\nFirst you must coppy a M3U-List to /etc/enigma2" ))) if os.path.isfile( "/usr/lib/enigma2/python/Plugins/SystemPlugins/HdmiCEC/plugin.pyo" ) is True: list.append( getConfigListEntry(_('Enable HDMI-CEC Setup?'), config.easysetup.hdmicec, _("Choose your HDMI-CEC config."))) list.append( getConfigListEntry( _('Enable Password change?'), config.easysetup.password, _("Change the rootpassword for login in ftp, telnet and webif." ))) list.append( getConfigListEntry(_('Enable Display Setup?'), config.easysetup.displaysetup, _("Choose your Display config."))) list.append( getConfigListEntry(_('Enable Position Setup?'), config.wizardsetup.UserInterfacePositioner, _("Choose your OSD Position in TV"))) list.append( getConfigListEntry(_('Enable OpenWebif Setup?'), config.wizardsetup.OpenWebifConfig, _("Choose your Openwebif config."))) list.append( getConfigListEntry( _('Enable Install local extension Setup?'), config.wizardsetup.ipkinstall, _("Scan for local extensions and install them."))) list.append( getConfigListEntry( _('Enable Power Off Menu Setup?'), config.wizardsetup.poweroffsetup, _("Choose your Powerbutton Funktion on Remotecontrol."))) self["key_red"] = Label(_("Exit")) self["key_green"] = Label(_("Start Easy-Setup")) self['label1'] = Label(_('')) self['label2'] = Label(_('% Flash Used....')) self['label3'] = Label(_('')) ConfigListScreen.__init__(self, list) self['actions'] = ActionMap( ['OkCancelActions', 'ColorActions'], { 'red': self.dontSaveAndExit, 'green': self.run1, 'cancel': self.dontSaveAndExit }, -1) def setWindowTitle(self): self.title = _('EasySetup') def run1(self): self.runed = '1' if config.easysetup.hddsetup.value is True: self.session.openWithCallback(self.run2, HddSetup) else: self.run2() def run2(self): self.runed = '2' if config.easysetup.records.value is True: self.openSetup("recording") else: self.run3() def run3(self): self.runed = '3' if config.easysetup.timeshift.value is True: self.openSetup("timeshift") else: self.run4() def run4(self): self.runed = '4' if config.easysetup.Keymap.value is True: self.session.openWithCallback(self.run5, KeymapSel) else: config.easysetup.restart.setValue(False) config.easysetup.restart.save() self.run5() def run5(self): self.runed = "5" if config.easysetup.Hotkey.value is True: self.session.openWithCallback(self.run6, HotkeySetup) else: self.run6() def run6(self): self.runed = "6" if config.easysetup.channellist.value is True: self.openSetup("channelselection") else: self.run7() def run7(self): self.runed = "7" if config.easysetup.m3u.value is True: self.session.openWithCallback(self.run8, IPTV) else: self.run8() def run8(self): self.runed = "8" if config.easysetup.hdmicec.value is True and os.path.isfile( "/usr/lib/enigma2/python/Plugins/SystemPlugins/HdmiCEC/plugin.pyo" ) is True: self.session.openWithCallback(self.run10, HdmiCECSetupScreen) else: self.run9() def run9(self): self.runed = "9" if config.easysetup.password.value is True: self.session.openWithCallback(self.run11, NFRPasswdScreen) else: self.run10() def run10(self): self.runed = "10" if config.easysetup.displaysetup.value is True: self.openSetup("display") else: self.run11() def run11(self): self.runed = "11" if config.wizardsetup.UserInterfacePositioner.value is True: self.Console = Console() self.Console.ePopen( '/usr/bin/showiframe /usr/share/enigma2/hd-testcard.mvi') self.session.openWithCallback(self.run11b, UserInterfacePositioner) else: self.run11a() def run11a(self): self.runed = "11a" if config.wizardsetup.OpenWebifConfig.value is True: self.session.openWithCallback(self.run11c, OpenWebifConfig) else: self.run11b() def run11b(self): self.runed = "11b" if config.wizardsetup.ipkinstall.value is True: self.session.openWithCallback(self.run11e, InfopanelManagerScreen) else: self.run11c() def run11c(self): self.runed = "11c" if config.wizardsetup.poweroffsetup.value is True: self.openSetup("remotesetup") else: self.run12() def run12(self): self.runed = "12" if config.easysetup.backup.value is True: self.session.openWithCallback(self.closetest, ImageBackup) else: self.closetest() def closetest(self, res=None): config.misc.firstrun = ConfigBoolean(default=True) if config.easysetup.restart.value == True: if config.misc.firstrun.value == False: config.easysetup.restart.setValue(False) config.easysetup.restart.save() quitMainloop(3) else: print("restart after Wizard") self.close() else: config.easysetup.restart.setValue(False) config.easysetup.restart.save() self.close() def openSetup(self, dialog): self.session.openWithCallback(self.menuClosed, Setup, dialog) def menuClosed(self, *res): if self.runed == "1": self.run2() elif self.runed == "2": self.run3() elif self.runed == "3": self.run4() elif self.runed == "4": self.run5() elif self.runed == "5": self.run6() elif self.runed == "6": self.run7() elif self.runed == "7": self.run8() elif self.runed == "8": self.run9() elif self.runed == "9": self.run10() elif self.runed == "10": self.run11() elif self.runed == "11": self.run11a() elif self.runed == "11a": self.run11b() elif self.runed == "11b": self.run11c() elif self.runed == "11c": self.run12() def dontSaveAndExit(self): for x in self['config'].list: x[1].cancel() self.close()
class Cpart(Screen): PA_TYPE_USE = 1 PA_TYPE_LAST = 2 PA_TYPE_FREE = 4 skin = """<screen position="center,center" size="670,200" title="eParted"> <widget source="list" render="Listbox" position="0,0" size="670,160" scrollbarMode="showOnDemand" enableWrapAround="on"> <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryText(pos = (0,5), size = (50, 30), font=0, flags = RT_HALIGN_LEFT, text=0), MultiContentEntryText(pos = (60,5), size = (150, 30), font=0, flags = RT_HALIGN_LEFT, text=1), MultiContentEntryText(pos = (210,5), size = (150, 30), font=0, flags = RT_HALIGN_LEFT, text=2), MultiContentEntryText(pos = (360,5), size = (150, 30), font=0, flags = RT_HALIGN_LEFT, text=3), MultiContentEntryText(pos = (510,5), size = (160, 30), font=0, flags = RT_HALIGN_LEFT, text=4) ], "fonts": [gFont("Regular", 20)], "itemHeight": 35 } </convert> </widget> <widget name="PixmapRed" position="25,170" size="15,16" pixmaps="skin_default/buttons/button_red_off.png,skin_default/buttons/button_red.png" transparent="1" alphatest="on" /> <widget name="LabelRed" position="50,160" size="150,40" font="Regular;19" valign="center" /> <widget name="PixmapGreen" position="225,170" size="15,16" pixmaps="skin_default/buttons/button_green_off.png,skin_default/buttons/button_green.png" transparent="1" alphatest="on" /> <widget name="LabelGreen" position="250,160" size="150,40" font="Regular;19" valign="center" /> <widget name="PixmapBlue" position="425,170" size="15,16" pixmaps="skin_default/buttons/button_blue_off.png,skin_default/buttons/button_blue.png" transparent="1" alphatest="on" /> <widget name="LabelBlue" position="450,160" size="150,40" font="Regular;19" valign="center" /> </screen>""" def __init__(self, session, entry): Screen.__init__(self, session) self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], { "cancel": self.Exit, "green": self.KeyGreen, "blue": self.KeyBlue, "red": self.KeyRed }, -1) self["list"] = List(list=[]) self["list"].onSelectionChanged.append(self.__SetLabels) self["PixmapRed"] = MultiPixmap() self["PixmapGreen"] = MultiPixmap() self["PixmapBlue"] = MultiPixmap() self["LabelRed"] = Label() self["LabelGreen"] = Label() self["LabelBlue"] = Label() self.__devpath = entry[DEV_PATH] self.__fullsize = 0 self.__old_part_list = [] self.__new_part_list = [] self.__comlist = [] self.__unit = entry[2][len(entry[2]) - 2:] self.Console = Console() self.__getPartInfo() def Exit(self): self.Console.killAll() self.close() def __getPartInfo(self, val=None): self.Console.ePopen( "parted -m %s unit %s print" % (self.__devpath, self.__unit), self.__FinishedConsole) def __Filllist(self): list = [] index = self["list"].getIndex() for x in self.__new_part_list: if x[LIST_TYPE] == LIST_TYPE_PAR: p0 = "%s: %s" % (_("Nr"), x[PA_NR]) p1 = "%s: %d%s" % (_("Start"), x[PA_START], self.__unit) p2 = "%s: %d%s" % (_("End"), x[PA_END], self.__unit) p3 = "%s: %d%s" % (_("Size"), x[PA_SIZE], self.__unit) p4 = "%s: %s" % (_("Type"), x[PA_FS]) list.append((p0, p1, p2, p3, p4, x)) self["list"].setList(list) self["list"].setIndex(index) self.__createCommandList() def __SetLabels(self): sel = self["list"].getCurrent() self["LabelGreen"].setText("") self["LabelRed"].setText("") if sel and sel[5]: if sel[5][PA_TYPE] & self.PA_TYPE_FREE and len( self.__new_part_list) < 6: self["PixmapGreen"].setPixmapNum(1) self["LabelGreen"].setText(_("add")) else: self["PixmapGreen"].setPixmapNum(0) if sel[5][PA_TYPE] & self.PA_TYPE_LAST and bool( sel[5][PA_TYPE] & self.PA_TYPE_FREE) == False: self["PixmapRed"].setPixmapNum(1) self["LabelRed"].setText(_("delete")) else: self["PixmapRed"].setPixmapNum(0) def __addFreePart(self, plist, lastPartEnd): x = [ LIST_TYPE_PAR, str(len(plist)), lastPartEnd, self.__fullsize, 0, _("free"), (self.PA_TYPE_FREE | self.PA_TYPE_LAST), ";" ] plist.append(x) def __FinishedConsole(self, result, retval, extra_args=None): if retval == 0 and '\n' in result: tlist = parseCmd(result) if len(tlist): self.__old_part_list = tlist[0][:] self.__new_part_list = tlist[0][:] lastPartEnd = 0 count = 2 for x in self.__old_part_list: if x[LIST_TYPE] == LIST_TYPE_DEV: self.__fullsize = getInt_epart(x[DEV_SIZE]) name = x[DEV_NAME] if len(name) == 0: name = x[DEV_PATH] name += " (%s)" % x[DEV_SIZE] self.setTitle(name) else: lastPartEnd = x[PA_END] x[PA_TYPE] = self.PA_TYPE_USE if count == len(self.__old_part_list): x[PA_TYPE] |= self.PA_TYPE_LAST count += 1 if lastPartEnd < self.__fullsize: self.__addFreePart(self.__old_part_list, lastPartEnd) self.__addFreePart(self.__new_part_list, lastPartEnd) self.__Filllist() def KeyBlue(self): if len(self.__comlist): self.session.openWithCallback(self.__getPartInfo, Cpartexe, self.__comlist) def KeyRed(self): sel = self["list"].getCurrent() if sel and sel[1] and sel[5][PA_TYPE] & self.PA_TYPE_LAST and bool( sel[5][PA_TYPE] & self.PA_TYPE_FREE) == False: try: self.__new_part_list.remove(sel[5]) for x in self.__new_part_list: if x[LIST_TYPE] == LIST_TYPE_PAR: if x[PA_TYPE] & self.PA_TYPE_FREE: self.__new_part_list.remove(x) break else: x[PA_TYPE] = self.PA_TYPE_USE lastPartEnd = 0 if len(self.__new_part_list) > 1: self.__new_part_list[ len(self.__new_part_list) - 1][PA_TYPE] = self.PA_TYPE_USE | self.PA_TYPE_LAST lastPartEnd = self.__new_part_list[ len(self.__new_part_list) - 1][PA_END] if lastPartEnd < self.__fullsize: self.__addFreePart(self.__new_part_list, lastPartEnd) except: print "[eParted] <remove part>" self.__Filllist() def KeyGreen(self): sel = self["list"].getCurrent() if sel and sel[5] and sel[5][PA_TYPE] & self.PA_TYPE_FREE and sel[5][ PA_START] < sel[5][PA_END] and len(self.__new_part_list) < 6: self.session.openWithCallback(self.__CallbackAddPart, AddPart, sel[5][PA_END] - sel[5][PA_START], self.__unit, len(self.__new_part_list) - 1) def __CallbackAddPart(self, val=None): if val: for x in self.__new_part_list: if x[LIST_TYPE] == LIST_TYPE_PAR: if x[PA_TYPE] & self.PA_TYPE_FREE: x[PA_SIZE] = val[0] x[PA_FS] = val[1] x[PA_END] = x[PA_START] + x[PA_SIZE] x[PA_TYPE] = self.PA_TYPE_USE | self.PA_TYPE_LAST if x[PA_END] < self.__fullsize: self.__addFreePart(self.__new_part_list, x[PA_END]) break else: x[PA_TYPE] = self.PA_TYPE_USE self.__Filllist() def __addPart2Comlist(self, list, val, mkpart=True): partnr = val[PA_NR] if mkpart: fs = val[PA_FS] com = "parted -s -a none %s mkpart primary %s %s%s %s%s" % ( self.__devpath, fs, val[PA_START], self.__unit, val[PA_END], self.__unit) list.append((com, _("create partition %s") % partnr, None)) mountdev = None if val[PA_FS] == "linux-swap": mkfs = "/sbin/mkswap" elif val[PA_FS] == "fat": self.mbox = self.session.open( MessageBox, _("Verify a partition smaller than 4G has been created on the USB device. If it is higher, it appears as FAT32." ), MessageBox.TYPE_INFO) mkfs = "/sbin/mkfs.fat" elif val[PA_FS] == "fat16": self.mbox = self.session.open( MessageBox, _("Verify a partition smaller than 4G has been created on the USB device. If it is higher, it will fail." ), MessageBox.TYPE_INFO) mkfs = "/sbin/mkfs.msdos -F 16" elif val[PA_FS] == "fat32": mkfs = "/sbin/mkfs.vfat" else: mkfs = "/sbin/mkfs." + val[PA_FS] mountdev = self.__devpath + partnr if val[PA_FS] == "xfs": mkfs += " -f" com = "%s %s%s" % (mkfs, self.__devpath, partnr) list.append( (com, _("make filesystem '%s' on partition %s (%d %s)") % (val[PA_FS], partnr, val[PA_SIZE], self.__unit), mountdev)) def __delPart2Comlist(self, list, val): partnr = val[PA_NR] dev = "%s%s" % (self.__devpath, partnr) mp = ismounted(dev) if mp is not None: if myExecute("umount %s" % mp, self.session): return list.insert(0, ("parted -s -a none %s rm %s" % (self.__devpath, partnr), _("delete partition %s") % partnr, None)) def __createCommandList(self): self.__comlist = [] for x in range(len(self.__old_part_list)): if self.__old_part_list[x][LIST_TYPE] == LIST_TYPE_PAR: if bool(self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False: if len(self.__new_part_list) > x: if self.__old_part_list[x][ PA_SIZE] != self.__new_part_list[x][PA_SIZE]: self.__delPart2Comlist(self.__comlist, self.__old_part_list[x]) else: self.__delPart2Comlist(self.__comlist, self.__old_part_list[x]) for x in range(len(self.__new_part_list)): if self.__new_part_list[x][LIST_TYPE] == LIST_TYPE_PAR: if bool(self.__new_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False: if len(self.__old_part_list) > x and bool( self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False: if self.__new_part_list[x][ PA_SIZE] != self.__old_part_list[x][PA_SIZE]: self.__addPart2Comlist(self.__comlist, self.__new_part_list[x]) else: if self.__new_part_list[x][ PA_FS] != self.__old_part_list[x][PA_FS]: self.__addPart2Comlist(self.__comlist, self.__new_part_list[x], False) else: self.__addPart2Comlist(self.__comlist, self.__new_part_list[x]) if len(self.__comlist): self["PixmapBlue"].setPixmapNum(1) self["LabelBlue"].setText(_("execute")) else: self["PixmapBlue"].setPixmapNum(0) self["LabelBlue"].setText("")
class SySInfoPlay(Screen): skin = '\n\t\t<screen position="center,center" size="720,495" title="">\n\t\t\t<widget name="red" position="20,456" size="140,40" valign="center" halign="center" zPosition="1" transparent="1" foregroundColor="white" font="Regular;18"/>\n\t\t\t<widget name="green" position="200,456" size="140,40" valign="center" halign="center" zPosition="1" transparent="1" foregroundColor="white" font="Regular;18"/>\n\t\t\t<widget name="yellow" position="380,456" size="140,40" valign="center" halign="center" zPosition="1" transparent="1" foregroundColor="white" font="Regular;18"/>\n\t\t\t<widget name="blue" position="560,456" size="140,40" valign="center" halign="center" zPosition="1" transparent="1" foregroundColor="white" font="Regular;18"/>\n\n\t\t\t<ePixmap name="pred" position="20,455" size="140,40" zPosition="0" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on"/>\n\t\t\t<ePixmap name="pgreen" position="200,455" size="140,40" zPosition="0" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on"/>\n\t\t\t<ePixmap name="pyellow" position="380,455" size="140,40" zPosition="0" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on"/>\n\t\t\t<ePixmap name="pblue" position="560,455" size="140,40" zPosition="0" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on"/>\n\t\t\t<widget name="infoM1" position="10,5" zPosition="2" size="700,18" font="Regular;18" foregroundColor="#ffffff" transparent="1" halign="center" valign="center" />\n\t\t\t<widget name="list1" position="10,30" size="710,405" scrollbarMode="showOnDemand" foregroundColor="#aaaaaa" />\n\t\t</screen>' def __init__(self, session, pateka): self.session = session Screen.__init__(self, session) self['red'] = Label(_('PS')) self['green'] = Label(_('dmesg')) self['yellow'] = Label(_('IfConfig')) self['blue'] = Label(_('Top')) self['actions'] = ActionMap([ 'ChannelSelectBaseActions', 'WizardActions', 'DirectionActions', 'MenuActions', 'NumberActions', 'ColorActions'], { 'back': self.exit, 'ok': self.exit, 'red': self.doRed, 'green': self.doGreen, 'yellow': self.doYellow, 'blue': self.doBlue }, -1) self['infoM1'] = Label() self.setTitle('RTi SySInfo v.1.3') self.pateka = pateka self.encname = [] self['list1'] = MenuList(self.encname) self.onLayoutFinish.append(self.openTest) def openTest(self): self['infoM1'].setText('Filename : ' + str(self.pateka)) if self.pateka == 'ps': self.doRed() if self.pateka == 'dmsg': self.doGreen() if self.pateka == 'ifconfig': self.doYellow() if self.pateka == 'top': self.doBlue() def doRed(self): self['infoM1'].setText('ps - process status') self.Console = Console() self.Console.ePopen('ps >/tmp/tt', self.AddToList) def doGreen(self): self['infoM1'].setText('dmesg - driver/kernel message') self.Console = Console() self.Console.ePopen('dmesg >/tmp/tt', self.AddToList) def doYellow(self): self['infoM1'].setText('IfConfig - Network Parameters') self.Console = Console() self.Console.ePopen('ifconfig >/tmp/tt', self.AddToList) def doBlue(self): self['infoM1'].setText('TOP - displays all the running process ') self.Console = Console() self.Console.ePopen('top -n1 >/tmp/tt', self.AddToList) def AddToList(self, result, retval, extra_args): dat = '/tmp/tt' ps = [] try: f = open(dat, 'r') lines = f.readlines() for line in lines: ps.append(str(line)) self['list1'].setList(ps) except Exception: print 'error' def exit(self): self.close()
class Cpart(Screen): PA_TYPE_USE=1 PA_TYPE_LAST=2 PA_TYPE_FREE=4 skin = """<screen position="center,center" size="670,200" title="eParted"> <widget source="list" render="Listbox" position="0,0" size="670,160" scrollbarMode="showOnDemand" enableWrapAround="on"> <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryText(pos = (0,5), size = (50, 30), font=0, flags = RT_HALIGN_LEFT, text=0), MultiContentEntryText(pos = (60,5), size = (150, 30), font=0, flags = RT_HALIGN_LEFT, text=1), MultiContentEntryText(pos = (210,5), size = (150, 30), font=0, flags = RT_HALIGN_LEFT, text=2), MultiContentEntryText(pos = (360,5), size = (150, 30), font=0, flags = RT_HALIGN_LEFT, text=3), MultiContentEntryText(pos = (510,5), size = (160, 30), font=0, flags = RT_HALIGN_LEFT, text=4) ], "fonts": [gFont("Regular", 20)], "itemHeight": 35 } </convert> </widget> <widget name="PixmapRed" position="25,170" size="15,16" pixmaps="skin_default/buttons/button_red_off.png,skin_default/buttons/button_red.png" transparent="1" alphatest="on" /> <widget name="LabelRed" position="50,160" size="150,40" font="Regular;19" valign="center" /> <widget name="PixmapGreen" position="225,170" size="15,16" pixmaps="skin_default/buttons/button_green_off.png,skin_default/buttons/button_green.png" transparent="1" alphatest="on" /> <widget name="LabelGreen" position="250,160" size="150,40" font="Regular;19" valign="center" /> <widget name="PixmapBlue" position="425,170" size="15,16" pixmaps="skin_default/buttons/button_blue_off.png,skin_default/buttons/button_blue.png" transparent="1" alphatest="on" /> <widget name="LabelBlue" position="450,160" size="150,40" font="Regular;19" valign="center" /> </screen>""" def __init__(self, session, entry): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "cancel": self.Exit, "green": self.KeyGreen, "blue": self.KeyBlue, "red": self.KeyRed }, -1) self["list"] = List(list=[]) self["list"].onSelectionChanged.append(self.__SetLabels) self["PixmapRed"] = MultiPixmap() self["PixmapGreen"] = MultiPixmap() self["PixmapBlue"] = MultiPixmap() self["LabelRed"] = Label() self["LabelGreen"] = Label() self["LabelBlue"] = Label() self.__devpath=entry[DEV_PATH] self.__fullsize=0 self.__old_part_list=[] self.__new_part_list=[] self.__comlist=[] self.__unit=entry[2][len(entry[2])-2:] self.Console = Console() self.__getPartInfo() def Exit(self): self.Console.killAll() self.close() def __getPartInfo(self,val=None): self.Console.ePopen("parted -m %s unit %s print" %(self.__devpath,self.__unit), self.__FinishedConsole) def __Filllist(self): list=[] index = self["list"].getIndex() for x in self.__new_part_list: if x[LIST_TYPE]==LIST_TYPE_PAR: p0 = "%s: %s" %(_("Nr"), x[PA_NR]) p1 = "%s: %d%s" %(_("Start"), x[PA_START], self.__unit) p2 = "%s: %d%s" %(_("End"), x[PA_END], self.__unit) p3 = "%s: %d%s" %(_("Size"), x[PA_SIZE], self.__unit) p4 = "%s: %s" %(_("Type"), x[PA_FS]) list.append((p0,p1,p2,p3,p4,x)) self["list"].setList(list) self["list"].setIndex(index) self.__createCommandList() def __SetLabels(self): sel=self["list"].getCurrent() self["LabelGreen"].setText("") self["LabelRed"].setText("") if sel and sel[5]: if sel[5][PA_TYPE] & self.PA_TYPE_FREE and len(self.__new_part_list)<6: self["PixmapGreen"].setPixmapNum(1) self["LabelGreen"].setText(_("add")) else: self["PixmapGreen"].setPixmapNum(0) if sel[5][PA_TYPE] & self.PA_TYPE_LAST and bool(sel[5][PA_TYPE] & self.PA_TYPE_FREE)==False: self["PixmapRed"].setPixmapNum(1) self["LabelRed"].setText(_("delete")) else: self["PixmapRed"].setPixmapNum(0) def __addFreePart(self,plist,lastPartEnd): x = [LIST_TYPE_PAR,str(len(plist)), lastPartEnd, self.__fullsize, 0,_("free"),(self.PA_TYPE_FREE | self.PA_TYPE_LAST),";"] plist.append(x) def __FinishedConsole(self, result, retval, extra_args = None): if retval==0 and '\n' in result: tlist = parseCmd(result) if len(tlist): self.__old_part_list = tlist[0][:] self.__new_part_list = tlist[0][:] lastPartEnd=0 count=2 for x in self.__old_part_list: if x[LIST_TYPE]==LIST_TYPE_DEV: self.__fullsize = getInt_epart(x[DEV_SIZE]) name = x[DEV_NAME] if len(name)==0: name = x[DEV_PATH] name += " (%s)" %x[DEV_SIZE] self.setTitle(name) else: lastPartEnd=x[PA_END] x[PA_TYPE]=self.PA_TYPE_USE if count == len(self.__old_part_list): x[PA_TYPE] |= self.PA_TYPE_LAST count += 1 if lastPartEnd < self.__fullsize: self.__addFreePart(self.__old_part_list, lastPartEnd) self.__addFreePart(self.__new_part_list, lastPartEnd) self.__Filllist() def KeyBlue(self): if len(self.__comlist): self.session.openWithCallback(self.__getPartInfo,Cpartexe,self.__comlist) def KeyRed(self): sel=self["list"].getCurrent() if sel and sel[1] and sel[5][PA_TYPE] & self.PA_TYPE_LAST and bool(sel[5][PA_TYPE] & self.PA_TYPE_FREE)==False: try: self.__new_part_list.remove(sel[5]) for x in self.__new_part_list: if x[LIST_TYPE]==LIST_TYPE_PAR: if x[PA_TYPE] & self.PA_TYPE_FREE: self.__new_part_list.remove(x) break else: x[PA_TYPE]=self.PA_TYPE_USE lastPartEnd=0 if len(self.__new_part_list)>1: self.__new_part_list[len(self.__new_part_list)-1][PA_TYPE] = self.PA_TYPE_USE | self.PA_TYPE_LAST lastPartEnd=self.__new_part_list[len(self.__new_part_list)-1][PA_END] if lastPartEnd < self.__fullsize: self.__addFreePart(self.__new_part_list, lastPartEnd) except: print "[eParted] <remove part>" self.__Filllist() def KeyGreen(self): sel=self["list"].getCurrent() if sel and sel[5] and sel[5][PA_TYPE] & self.PA_TYPE_FREE and sel[5][PA_START]<sel[5][PA_END] and len(self.__new_part_list)<6: self.session.openWithCallback(self.__CallbackAddPart, AddPart, sel[5][PA_END]-sel[5][PA_START], self.__unit, len(self.__new_part_list)-1) def __CallbackAddPart(self, val=None): if val: for x in self.__new_part_list: if x[LIST_TYPE]==LIST_TYPE_PAR: if x[PA_TYPE] & self.PA_TYPE_FREE: x[PA_SIZE] = val[0] x[PA_FS] = val[1] x[PA_END] = x[PA_START] + x[PA_SIZE] x[PA_TYPE] = self.PA_TYPE_USE | self.PA_TYPE_LAST if x[PA_END] < self.__fullsize: self.__addFreePart(self.__new_part_list, x[PA_END]) break else: x[PA_TYPE]=self.PA_TYPE_USE self.__Filllist() def __addPart2Comlist(self, list, val, mkpart=True): partnr = val[PA_NR] if mkpart: fs=val[PA_FS] com = "parted -s -a none %s mkpart primary %s %s%s %s%s" %(self.__devpath, fs, val[PA_START], self.__unit, val[PA_END], self.__unit) list.append((com ,_("create partition %s") %partnr, None)) mountdev=None if val[PA_FS]=="linux-swap": mkfs = "/sbin/mkswap" elif val[PA_FS]=="fat": self.mbox = self.session.open(MessageBox,_("Verify a partition smaller than 4G has been created on the USB device. If it is higher, it appears as FAT32."), MessageBox.TYPE_INFO) mkfs = "/sbin/mkfs.fat" elif val[PA_FS]=="fat16": self.mbox = self.session.open(MessageBox,_("Verify a partition smaller than 4G has been created on the USB device. If it is higher, it will fail."), MessageBox.TYPE_INFO) mkfs = "/sbin/mkfs.msdos -F 16" elif val[PA_FS]=="fat32": mkfs = "/sbin/mkfs.vfat" else: mkfs = "/sbin/mkfs." + val[PA_FS] mountdev=self.__devpath+partnr if val[PA_FS]=="xfs": mkfs += " -f" com = "%s %s%s" %(mkfs,self.__devpath,partnr) list.append((com ,_("make filesystem '%s' on partition %s (%d %s)") %(val[PA_FS],partnr,val[PA_SIZE],self.__unit), mountdev)) def __delPart2Comlist(self, list, val): partnr = val[PA_NR] dev = "%s%s" %(self.__devpath,partnr) mp = ismounted(dev) if mp is not None: if myExecute("umount %s" %mp, self.session): return list.insert(0,("parted -s -a none %s rm %s" %(self.__devpath, partnr),_("delete partition %s") %partnr, None)) def __createCommandList(self): self.__comlist=[] for x in range(len(self.__old_part_list)): if self.__old_part_list[x][LIST_TYPE] == LIST_TYPE_PAR: if bool(self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE)==False: if len(self.__new_part_list) > x: if self.__old_part_list[x][PA_SIZE] != self.__new_part_list[x][PA_SIZE]: self.__delPart2Comlist(self.__comlist, self.__old_part_list[x]) else: self.__delPart2Comlist(self.__comlist, self.__old_part_list[x]) for x in range(len(self.__new_part_list)): if self.__new_part_list[x][LIST_TYPE] == LIST_TYPE_PAR: if bool(self.__new_part_list[x][PA_TYPE] & self.PA_TYPE_FREE)==False: if len(self.__old_part_list) > x and bool(self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE)==False: if self.__new_part_list[x][PA_SIZE] != self.__old_part_list[x][PA_SIZE]: self.__addPart2Comlist(self.__comlist,self.__new_part_list[x]) else: if self.__new_part_list[x][PA_FS] != self.__old_part_list[x][PA_FS]: self.__addPart2Comlist(self.__comlist,self.__new_part_list[x],False) else: self.__addPart2Comlist(self.__comlist,self.__new_part_list[x]) if len(self.__comlist): self["PixmapBlue"].setPixmapNum(1) self["LabelBlue"].setText(_("execute")) else: self["PixmapBlue"].setPixmapNum(0) self["LabelBlue"].setText("")