def refreshMP(self, uirefresh=True): self.mdisks = Disks() self.mountpoints = MountPoints() self.mountpoints.read() self.disks = list() self.mounts = list() for disk in self.mdisks.disks: if disk[2] == True: diskname = disk[3] for partition in disk[5]: mp = "" rmp = "" try: mp = self.mountpoints.get(partition[0][:3], int(partition[0][3:])) rmp = self.mountpoints.getRealMount( partition[0][:3], int(partition[0][3:])) except Exception, e: pass if len(mp) > 0: self.disks.append( MountEntry( disk[3], "P.%s (Fixed: %s)" % (partition[0][3:], mp))) self.mounts.append(mp) elif len(rmp) > 0: self.disks.append( MountEntry( disk[3], "P.%s (Fast: %s)" % (partition[0][3:], rmp))) self.mounts.append(rmp)
def refreshMP(self, uirefresh=True): self.partitions = [] self.mountpoints = MountPoints() self.mountpoints.read() count = 1 for part in self.disk[5]: capacity = "%d MB" % (part[1] / (1024 * 1024)) mp = self.mountpoints.get(self.disk[0], count) rmp = self.mountpoints.getRealMount(self.disk[0], count) if len(mp) > 0: self.partitions.append( PartitionEntry( "P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity)) elif len(rmp) > 0: self.partitions.append( PartitionEntry( "P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity)) else: self.partitions.append( PartitionEntry("P. %d - %s" % (count, part[2]), capacity)) count += 1 if uirefresh: self["menu"].setList(self.partitions) self.selectionChanged()
def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_('Mount as /universe')) self.list.append(_('Mount as /media/usb')) self.list.append(_('Mount as /media/hdd')) self.list.append('Mount as /media/cf') self.list.append('Mount as /media/mmc1') self.list.append('Mount on custom path') self['menu'] = MenuList(self.list) self['key_red'] = Button(_('Fixed mount')) self['key_green'] = Button('Fast mount') self['key_blue'] = Button(_('Exit')) self['key_yellow'] = Button('') self['actions'] = ActionMap( ['OkCancelActions', 'ColorActions'], { 'blue': self.quit, 'green': self.green, 'ok': self.ok, 'red': self.ok, 'cancel': self.quit }, -2) self.onShown.append(self.setWindowTitle)
def checkDefault(self): mp = MountPoints() mp.read() if not mp.exist('/hdd'): mp.add(self.mdisks.disks[self.sindex][0], 1, '/hdd') mp.write() mp.mount(self.mdisks.disks[self.sindex][0], 1, '/hdd') os.system('/bin/mkdir /hdd/movie') os.system('/bin/mkdir /hdd/music') os.system('/bin/mkdir /hdd/picture')
def checkDefault(self): mp = MountPoints() mp.read() if self.asHDD and not mp.exist("/media/hdd"): mp.add(self.mdisks.disks[self.sindex][0], 1, "/media/hdd") mp.write() mp.mount(self.mdisks.disks[self.sindex][0], 1, "/media/hdd") os.system("mkdir -p /media/hdd/movie") message = _("Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?") mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO) mbox.setTitle(_("Restart STB"))
def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_('Mount as /universe')) self.list.append(_('Mount as /media/usb')) self.list.append(_('Mount as /media/hdd')) self.list.append('Mount as /media/cf') self.list.append('Mount as /media/mmc1') self.list.append('Mount on custom path') self['menu'] = MenuList(self.list) self['key_red'] = Button(_('Fixed mount')) self['key_green'] = Button('Fast mount') self['key_blue'] = Button(_('Exit')) self['key_yellow'] = Button('') self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'blue': self.quit, 'green': self.green, 'ok': self.ok, 'red': self.ok, 'cancel': self.quit}, -2) self.onShown.append(self.setWindowTitle)
def initialaze(self, result): if result != 5: self.result = result self.formatted = 0 mp = MountPoints() mp.read() mp.deleteDisk(self.mdisks.disks[self.sindex][0]) mp.write() self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, _('Partitioning...'), _('Initialize disk'), self.fdisk)
def _begin_scan(self, location): #---------------------------------------------------------------------- #Initiating device version scanning #---------------------------------------------------------------------- #XXX should remove this and add it in HttpServe when loading case self.print_queue.put("** Determining Device/Apps versions **") mounts = MountPoints() mounts.set_mountpoint(MountPoints.MOUNT_DATA, location) versions = AndroidDeviceVersion(self.print_queue, mounts) versions.populate_info() versions.print_debug() #---------------------------------------------------------------------- #Initiating file system scanning and populating of data #---------------------------------------------------------------------- self.print_queue.put("** Running Application Parser **") app_parser = ApplicationParser(self.print_queue, self.extract_store, location, settings=self.settings, versions=versions) #XXX note that this is hard-coded. If for some reason Android app store # location changes, this would need to reflect it app_parser.scan_directory(os.path.join(location, "data")) self.print_queue.put("** Running Configuration Parser **") misc_parser = MiscParser(self.print_queue, self.extract_store, settings=self.settings, versions=versions) misc_parser.scan_directory(location) #---------------------------------------------------------------------- # Initiating auxiliary modules #---------------------------------------------------------------------- self.print_queue.put("** Running Auxiliary Modules **") auxmods = Importer().get_package_modules( "AndroidAuxiliary", IAuxiliary(), (self.extract_store, self.print_queue)) auxmods.sort(key=lambda d: d.index) for mod in auxmods: mod.begin() #Finished, sending FIN signal self.print_queue.put("FIN") return
def initialaze(self, result): if not self.isExt4Supported(): result += 1 if result != 4: self.fsresult = result self.formatted = 0 mp = MountPoints() mp.read() mp.deleteDisk(self.mdisks.disks[self.sindex][0]) mp.write() self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, _("Partitioning..."), _("Initialize disk"), self.fdisk)
def _begin_scan(self, location): #---------------------------------------------------------------------- #Initiating device version scanning #---------------------------------------------------------------------- #XXX should remove this and add it in HttpServe when loading case self.print_queue.put("** Determining Device/Apps versions **") mounts = MountPoints() mounts.set_mountpoint(MountPoints.MOUNT_DATA, location) versions = AndroidDeviceVersion(self.print_queue,mounts) versions.populate_info() versions.print_debug() #---------------------------------------------------------------------- #Initiating file system scanning and populating of data #---------------------------------------------------------------------- self.print_queue.put("** Running Application Parser **") app_parser = ApplicationParser( self.print_queue, self.extract_store, location, settings=self.settings, versions=versions ) #XXX note that this is hard-coded. If for some reason Android app store # location changes, this would need to reflect it app_parser.scan_directory( os.path.join( location, "data" ) ) self.print_queue.put("** Running Configuration Parser **") misc_parser = MiscParser( self.print_queue, self.extract_store, settings=self.settings, versions=versions ) misc_parser.scan_directory(location) #---------------------------------------------------------------------- # Initiating auxiliary modules #---------------------------------------------------------------------- self.print_queue.put("** Running Auxiliary Modules **") auxmods = Importer().get_package_modules( "AndroidAuxiliary", IAuxiliary(), ( self.extract_store, self.print_queue ) ) for mod in auxmods: mod.begin() #Finished, sending FIN signal self.print_queue.put("FIN") return
def initialaze(self, result): if not self.isExt4Supported(): result += 1 if result != 6: self.fsresult = result self.formatted = 0 mp = MountPoints() mp.read() mp.deleteDisk(self.mdisks.disks[self.sindex][0]) mp.write() self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, _("Partitioning..."), _("Initialize disk"), self.fdisk)
def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_("Mount as main hdd")) self.list.append(_("Mount as /media/hdd1")) self.list.append(_("Mount as /media/hdd2")) self.list.append(_("Mount as /media/hdd3")) self.list.append(_("Mount as /media/hdd4")) self.list.append(_("Mount as /media/hdd5")) self.list.append(_("Mount as /media/usb")) self.list.append(_("Mount as /media/usb1")) self.list.append(_("Mount as /media/usb2")) self.list.append(_("Mount as /media/usb3")) self.list.append(_("Mount as /media/usb4")) self.list.append(_("Mount as /media/usb5")) self.list.append(_("Mount on custom path")) self["menu"] = MenuList(self.list) self["key_red"] = Button(_("Fixed mount")) self["key_green"] = Button(_("Fast mount")) self["key_blue"] = Button(_("Exit")) self["key_yellow"] = Button("") self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "green": self.green, "red": self.ok, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle)
def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_("Mount /universe")) self.list.append(_("Mount as /media/hdd")) self.list.append(_("Mount as /media/music")) self.list.append(_("Mount as /media/download")) self.list.append(_("Mount as /media/net")) self.list.append(_("Mount as /media/personal")) self.list.append(_("Mount as /media/usb")) self.list.append(_("Mount as /media/video")) self.list.append(_("Mount as /media/sda1")) self.list.append(_("Mount as /media/sdb1")) self.list.append(_("Mount as /media/meoboot")) self.list.append(_("Mount on custom path")) self["menu"] = MenuList(self.list) self["key_red"] = Button(_("Fixed mount")) self["key_green"] = Button(_("Fast mount")) self["key_blue"] = Button(_("Exit")) self["key_yellow"] = Button("") self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], { "blue": self.quit, "green": self.green, "red": self.ok, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle)
def refreshMP(self, uirefresh = True): self.partitions = [] self.mountpoints = MountPoints() self.mountpoints.read() count = 1 for part in self.disk[5]: capacity = "%d MB" % (part[1] / (1024 * 1024)) mp = self.mountpoints.get(self.disk[0], count) rmp = self.mountpoints.getRealMount(self.disk[0], count) if len(mp) > 0: self.partitions.append(PartitionEntry("P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity)) elif len(rmp) > 0: self.partitions.append(PartitionEntry("P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity)) else: self.partitions.append(PartitionEntry("P. %d - %s" % (count, part[2]), capacity)) count += 1 if uirefresh: self["menu"].setList(self.partitions) self.selectionChanged()
def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_("Mount /universe")) self.list.append(_("Mount as /media/hdd")) self.list.append(_("Mount as /media/music")) self.list.append(_("Mount as /media/download")) self.list.append(_("Mount as /media/net")) self.list.append(_("Mount as /media/personal")) self.list.append(_("Mount as /media/usb")) self.list.append(_("Mount as /media/video")) self.list.append(_("Mount as /media/sda1")) self.list.append(_("Mount as /media/sdb1")) self.list.append(_("Mount as /media/meoboot")) self.list.append(_("Mount on custom path")) self["menu"] = MenuList(self.list) self["key_red"] = Button(_("Fixed mount")) self["key_green"] = Button(_("Fast mount")) self["key_blue"] = Button(_("Exit")) self["key_yellow"] = Button("") self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "green": self.green, "red": self.ok, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle)
def refreshMP(self, uirefresh = True): self.mdisks = Disks() self.mountpoints = MountPoints() self.mountpoints.read() self.disks = list () self.mounts = list () for disk in self.mdisks.disks: if disk[2] == True: diskname = disk[3] for partition in disk[5]: mp = "" rmp = "" try: mp = self.mountpoints.get(partition[0][:3], int(partition[0][3:])) rmp = self.mountpoints.getRealMount(partition[0][:3], int(partition[0][3:])) except Exception, e: pass if len(mp) > 0: self.disks.append(MountEntry(disk[3], "P.%s (Fixed: %s)" % (partition[0][3:], mp))) self.mounts.append(mp) elif len(rmp) > 0: self.disks.append(MountEntry(disk[3], "P.%s (Fast: %s)" % (partition[0][3:], rmp))) self.mounts.append(rmp)
def checkDefault(self): mp = MountPoints() mp.read() if self.asHDD and not mp.exist("/media/hdd"): mp.add(self.mdisks.disks[self.sindex][0], 1, "/media/hdd") mp.write() mp.mount(self.mdisks.disks[self.sindex][0], 1, "/media/hdd") os.system("mkdir -p /media/hdd/movie") message = _( "Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?" ) mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO) mbox.setTitle(_("Restart STB"))
class HddMount(Screen): skin = '\n\t<screen name="HddMount" position="center,center" size="560,430" title="Hard Drive Mount">\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />\n\t\t<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t<widget name="menu" position="20,45" scrollbarMode="showOnDemand" size="520,380" transparent="1" />\n\t</screen>' def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_('Mount as /universe')) self.list.append(_('Mount as /media/usb')) self.list.append(_('Mount as /media/hdd')) self.list.append('Mount as /media/cf') self.list.append('Mount as /media/mmc1') self.list.append('Mount on custom path') self['menu'] = MenuList(self.list) self['key_red'] = Button(_('Fixed mount')) self['key_green'] = Button('Fast mount') self['key_blue'] = Button(_('Exit')) self['key_yellow'] = Button('') self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'blue': self.quit, 'green': self.green, 'ok': self.ok, 'red': self.ok, 'cancel': self.quit}, -2) self.onShown.append(self.setWindowTitle) def setWindowTitle(self): self.setTitle(_('Mountpoints')) def ok(self): self.fast = False selected = self['menu'].getSelectedIndex() if selected == 0: self.setMountPoint('/universe') elif selected == 1: self.setMountPoint('/media/usb') elif selected == 2: self.setMountPoint('/media/hdd') elif selected == 3: self.setMountPoint('/media/cf') elif selected == 4: self.setMountPoint('/media/mmc1') elif selected == 5: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom') def green(self): self.fast = True selected = self['menu'].getSelectedIndex() if selected == 0: self.setMountPoint('/universe') elif selected == 1: self.setMountPoint('/media/usb') elif selected == 2: self.setMountPoint('/media/hdd') elif selected == 3: self.setMountPoint('/media/cf') elif selected == 4: self.setMountPoint('/media/mmc1') elif selected == 5: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom') def customPath(self, result): if result and len(result) > 0: result = result.rstrip('/') os.system('mkdir -p %s' % result) self.setMountPoint(result) def setMountPoint(self, path): self.cpath = path if self.mountpoints.exist(path): self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, 'Selected mount point is already used by another drive.', 'Mount point exist!', [['Change old drive with this new drive', 'ok.png'], ['Mantain old drive', 'cancel.png']]) else: self.setMountPointCb(0) def setMountPointCb(self, result): if result == 0: if not self.mountpoints.isMounted(self.cpath) and self.mountpoints.umount(self.cpath): self.session.open(MessageBox, _('Cannot umount current drive.\nA record in progress, timeshit or some external tools (like samba and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR) self.close() return None self.mountpoints.delete(self.cpath) if not self.fast: self.mountpoints.add(self.device, self.partition, self.cpath) self.mountpoints.write() if not self.mountpoints.mount(self.device, self.partition, self.cpath): self.session.open(MessageBox, _('Cannot mount new drive.\nPlease check filesystem or format it and try again'), MessageBox.TYPE_ERROR) elif self.cpath == '/media/hdd': os.system('/bin/mkdir /hdd/movie') os.system('/bin/mkdir /hdd/music') os.system('/bin/mkdir /hdd/picture') self.close() def restartBox(self, answer): if answer is True: self.session.open(TryQuitMainloop, 2) else: self.close() def quit(self): self.close()
class HddMount(Screen): skin = """ <screen name="HddMount" position="center,center" size="560,430" title="Hard Drive Mount"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" /> <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" /> <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> <widget name="menu" position="20,45" scrollbarMode="showOnDemand" size="520,380" transparent="1" /> </screen>""" def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_("Mount as main hdd")) self.list.append(_("Mount as /media/hdd1")) self.list.append(_("Mount as /media/hdd2")) self.list.append(_("Mount as /media/hdd3")) self.list.append(_("Mount as /media/hdd4")) self.list.append(_("Mount as /media/hdd5")) self.list.append(_("Mount as /media/usb")) self.list.append(_("Mount as /media/usb1")) self.list.append(_("Mount as /media/usb2")) self.list.append(_("Mount as /media/usb3")) self.list.append(_("Mount as /media/usb4")) self.list.append(_("Mount as /media/usb5")) self.list.append(_("Mount on custom path")) self["menu"] = MenuList(self.list) self["key_red"] = Button(_("Fixed mount")) self["key_green"] = Button(_("Fast mount")) self["key_blue"] = Button(_("Exit")) self["key_yellow"] = Button("") self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "green": self.green, "red": self.ok, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle) def setWindowTitle(self): self.setTitle(_("Mountpoints")) def ok(self): self.fast = False selected = self["menu"].getSelectedIndex() if selected == 0: self.setMountPoint("/media/hdd") elif selected == 1: self.setMountPoint("/media/hdd1") elif selected == 2: self.setMountPoint("/media/hdd2") elif selected == 3: self.setMountPoint("/media/hdd3") elif selected == 4: self.setMountPoint("/media/hdd4") elif selected == 5: self.setMountPoint("/media/hdd5") elif selected == 6: self.setMountPoint("/media/usb") elif selected == 7: self.setMountPoint("/media/usb1") elif selected == 8: self.setMountPoint("/media/usb2") elif selected == 9: self.setMountPoint("/media/usb3") elif selected == 10: self.setMountPoint("/media/usb4") elif selected == 11: self.setMountPoint("/media/usb5") elif selected == 12: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = _("/media/custom")) def green(self): self.fast = True selected = self["menu"].getSelectedIndex() if selected == 0: self.setMountPoint("/media/hdd") elif selected == 1: self.setMountPoint("/media/hdd1") elif selected == 2: self.setMountPoint("/media/hdd2") elif selected == 3: self.setMountPoint("/media/hdd3") elif selected == 4: self.setMountPoint("/media/hdd4") elif selected == 5: self.setMountPoint("/media/hdd5") elif selected == 6: self.setMountPoint("/media/usb") elif selected == 7: self.setMountPoint("/media/usb1") elif selected == 8: self.setMountPoint("/media/usb2") elif selected == 9: self.setMountPoint("/media/usb3") elif selected == 10: self.setMountPoint("/media/usb4") elif selected == 11: self.setMountPoint("/media/usb5") elif selected == 12: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = _("/media/custom")) def customPath(self, result): if result and len(result) > 0: result = result.rstrip("/") os.system("mkdir -p %s" % result) self.setMountPoint(result) def setMountPoint(self, path): self.cpath = path if self.mountpoints.exist(path): self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, _("Selected mount point is already used by another drive."), _("Mount point exist!"), [ [ _("Change old drive with this new drive"), "ok.png" ], [ _("Keep old drive"), "cancel.png" ], ]) else: self.setMountPointCb(0) def setMountPointCb(self, result): if result == 0: if self.mountpoints.isMounted(self.cpath): if not self.mountpoints.umount(self.cpath): self.session.open(MessageBox, _("Cannot umount current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) self.close() return self.mountpoints.delete(self.cpath) if not self.fast: self.mountpoints.add(self.device, self.partition, self.cpath) self.mountpoints.write() if not self.mountpoints.mount(self.device, self.partition, self.cpath): self.session.open(MessageBox, _("Cannot mount new drive.\nPlease check filesystem or format it and try again"), MessageBox.TYPE_ERROR) elif self.cpath == "/media/hdd": os.system("/bin/mkdir -p /media/hdd/movie") if not self.fast: message = _("Device Fixed Mount Point change needs a system restart in order to take effect.\nRestart your %s %s now?") % (getMachineBrand(), getMachineName()) mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO) mbox.setTitle(_("Restart %s %s") % (getMachineBrand(), getMachineName())) else: self.close() def restartBox(self, answer): if answer is True: self.session.open(TryQuitMainloop, 2) else: self.close() def quit(self): self.close()
def __init__(self, session, returnService=None, playerInstance=None): print("MVC: MovieSelection: __init__") global instance instance = self Screen.__init__(self, session) EventInfo.__init__(self) MountPoints.__init__(self) self.skinName = ["MVCSelection"] self.skin = Util.readFile(self.getSkin()) self.playerInstance = playerInstance self.multi_select_index = None self.lastservice = None self.cursorDir = 0 self.savedIndex = 0 self["wait"] = Label(_("Reading directory...")) self["wait"].hide() self["space_info"] = Label("") self["sort_mode"] = Label("") self["list"] = MovieCenter() if returnService: self.returnService = returnService set_current_path = True for entry in self["list"].list: if entry[MOVIE_IDX_SERVICE] == self.returnService: set_current_path = False break if set_current_path: self.current_path = os.path.dirname(returnService.getPath()) self["key_red"] = Button() self["key_green"] = Button() self["key_yellow"] = Button() self["key_blue"] = Button() self.cover = config.MVC.cover.value helptext = self.initButtons() self["actions"] = HelpableActionMap( self, "PluginMovieSelectionActions", { "MVCOK": (self.entrySelected, _("Play selected movie(s)")), "MVCEXIT": (self.abort, _("Close plugin")), # "MVCEXITpowerdown": (self.abortAndPowerDown, _("Close plugin and do power button action")), "MVCMENU": (self.openMenu, _("Open menu")), "MVCINFO": (self.showEventInformation, _("Show event info")), "MVCINFOL": (self.openInfoLong, _("IMDBSearch / MVC-TMDBInfo / TMDBInfo / TMBDInfo / CSFDInfo" )), "MVCRed": (self.redFunc, helptext[0]), # redhelptext), "MVCGREEN": (self.greenFuncShort, helptext[2]), # greenhelptext), "MVCYELLOW": (self.yellowFunc, helptext[4]), # yellowhelptext), "MVCBLUE": (self.blueFunc, helptext[6]), # bluehelptext), "MVCREDL": (self.redFuncLong, helptext[1]), # redlonghelptext), "MVCGREENL": (self.greenFuncLong, helptext[3]), # greenlonghelptext), "MVCYELLOWL": (self.yellowFuncLong, helptext[5]), # yellowlonghelptext), "MVCBlueL": (self.blueFuncLong, helptext[7]), # bluelonghelptext), "MVCLeft": (self.pageUp, _("Move cursor page up")), "MVCRight": (self.pageDown, _("Move cursor page down")), "MVCUp": (self.moveUp, _("Move cursor up")), "MVCDown": (self.moveDown, _("Move cursor down")), "MVCBqtPlus": (self.bqtPlus, _("Move cursor to the top / Move cursor x entries up / Switch Folders in Movie Home (up)" )), "MVCBqtMnus": (self.bqtMnus, _("Move cursor to the end / Move cursor x entries down / Switch Folders in Movie Home (down)" )), "MVCVIDEOB": (self.toggleSelectionList, _("Toggle service selection")), "MVCVIDEOL": (self.resetSelectionList, _("Remove service selection")), "MVCAUDIO": (self.openMenuPlugins, _("Available plugins menu")), "MVCTV": (self.openTimerList, _("Open Timer List")), "MVCRADIO": (self.resetProgress, _("Reset movie progress")), "MVCTEXT": (self.multiSelect, _("Start / end multiselection")), "0": (self.MVCKey0, _("Movie home")), }, prio= -3 # give them a little more priority to win over base class buttons ) self["actions"].csel = self HelpableScreen.__init__(self) if self.current_path is None: self.current_path = config.MVC.movie_homepath.value self.last_current_path = None self.selection_list = [] # Used for file operations self.hide_miniTV = False # Key press short long handling #TODO We have to rework this key press handling in order to allow different user defined color key functions self.toggle = True # Used for long / short key press detection: Toggle sort mode / order, Toggle selection / reset selection self.move = True self.delayTimer = eTimer() self.delayTimer_conn = self.delayTimer.timeout.connect( self.updateInfoDelayed) self.coverTimer = eTimer() self.coverTimer_conn = self.coverTimer.timeout.connect( self.showCoverDelayed) self.onShow.append(self.onDialogShow) self.onHide.append(self.onDialogHide) self["list"].onSelectionChanged.append(self.selectionChanged)
class HddFastRemove(Screen): skin = """ <screen name="HddFastRemove" position="center,center" size="560,430" title="Hard Drive Fast Umount"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="140,0" size="140,40" alphatest="on" /> <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="key_blue" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> <widget source="menu" render="Listbox" position="10,55" size="520,380" scrollbarMode="showOnDemand"> <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0), MultiContentEntryText(pos = (65, 3), size = (190, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1), MultiContentEntryText(pos = (165, 27), size = (290, 38), font=1, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2), ], "fonts": [gFont("Regular", 22), gFont("Regular", 18)], "itemHeight": 50 } </convert> </widget> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.refreshMP(False) self["menu"] = List(self.disks) self["key_red"] = Button(_("Unmount")) self["key_blue"] = Button(_("Exit")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "red": self.red, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle) def setWindowTitle(self): self.setTitle(_("Fast Mounted Remove")) def red(self): if len(self.mounts) > 0: self.sindex = self["menu"].getIndex() self.mountpoints.umount(self.mounts[self.sindex]) # actually umount device here - also check both cases possible - for instance error case also check with stay in /e.g. /media/usb folder on telnet self.session.open(MessageBox, _("Fast mounted Media unmounted.\nYou can safely remove the Device now, if no further Partitions (displayed as P.x on Devicelist - where x >=2) are mounted on the same Device.\nPlease unmount Fixed Mounted Devices with Device Manager Panel!"), MessageBox.TYPE_INFO) self.refreshMP(True) def refreshMP(self, uirefresh = True): self.mdisks = Disks() self.mountpoints = MountPoints() self.mountpoints.read() self.disks = list () self.mounts = list () for disk in self.mdisks.disks: if disk[2] == True: diskname = disk[3] for partition in disk[5]: mp = "" rmp = "" try: mp = self.mountpoints.get(partition[0][:3], int(partition[0][3:])) rmp = self.mountpoints.getRealMount(partition[0][:3], int(partition[0][3:])) except Exception, e: pass if len(mp) > 0: self.disks.append(MountEntry(disk[3], "P.%s (Fixed: %s)" % (partition[0][3:], mp))) self.mounts.append(mp) elif len(rmp) > 0: self.disks.append(MountEntry(disk[3], "P.%s (Fast: %s)" % (partition[0][3:], rmp))) self.mounts.append(rmp) if uirefresh: self["menu"].setList(self.disks)
class HddPartitions(Screen): skin = """ <screen name="HddPartitions" position="center,center" size="560,430" title="Hard Drive Partitions"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" /> <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" /> <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> <widget name="label_disk" position="20,45" font="Regular;20" halign="center" size="520,25" valign="center" /> <widget source="menu" render="Listbox" position="20,75" size="520,350" scrollbarMode="showOnDemand"> <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0), MultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1), MultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2), ], "fonts": [gFont("Regular", 18)], "itemHeight": 50 } </convert> </widget> </screen>""" def __init__(self, session, disk): self.session = session Screen.__init__(self, session) self.disk = disk self.refreshMP(False) self["menu"] = List(self.partitions) self["menu"].onSelectionChanged.append(self.selectionChanged) self["key_red"] = Button(_("Exit")) self["key_green"] = Button("") self["key_yellow"] = Button("") self["key_blue"] = Button("") self["label_disk"] = Label("%s - %s" % (self.disk[0], self.disk[3])) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "red": self.quit, "yellow": self.yellow, "green": self.green, "blue": self.blue, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle) if len(self.disk[5]) > 0: if self.disk[5][0][3] == "83" or self.disk[5][0][3] == "7" or self.disk[5][0][3] == "b": self["key_green"].setText(_("Check")) self["key_yellow"].setText(_("Format")) mp = self.mountpoints.get(self.disk[0], 1) rmp = self.mountpoints.getRealMount(self.disk[0], 1) if len(mp) > 0 or len(rmp) > 0: self.mounted = True self["key_blue"].setText(_("Unmount")) else: self.mounted = False self["key_blue"].setText(_("Mount")) def setWindowTitle(self): self.setTitle(_("Partitions")) def selectionChanged(self): self["key_green"].setText("") self["key_yellow"].setText("") self["key_blue"].setText("") if len(self.disk[5]) > 0: index = self["menu"].getIndex() if self.disk[5][index][3] == "83" or self.disk[5][index][3] == "7" or self.disk[5][index][3] == "b": self["key_blue"].setText(_("Check")) self["key_yellow"].setText(_("Format")) mp = self.mountpoints.get(self.disk[0], index+1) rmp = self.mountpoints.getRealMount(self.disk[0], index+1) if len(mp) > 0 or len(rmp) > 0: self.mounted = True self["key_blue"].setText(_("Unmount")) else: self.mounted = False self["key_blue"].setText(_("Mount")) def chkfs(self): disks = Disks() ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index+1, self.fstype) if ret == 0: self.session.open(MessageBox, _("Check disk terminated with success"), MessageBox.TYPE_INFO) elif ret == -1: self.session.open(MessageBox, _("Cannot umount current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) else: self.session.open(MessageBox, _("Error checking disk. The disk may be damaged"), MessageBox.TYPE_ERROR) def mkfs(self): disks = Disks() ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index+1, self.fstype) if ret == 0: self.session.open(MessageBox, _("Format terminated with success"), MessageBox.TYPE_INFO) elif ret == -2: self.session.open(MessageBox, _("Cannot format current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) else: self.session.open(MessageBox, _("Error formatting disk. The disk may be damaged"), MessageBox.TYPE_ERROR) def isExt4Supported(self): return "ext4" in open("/proc/filesystems").read() def domkfs(self, result): if self.disk[5][self.index][3] == "83": if self.isExt4Supported(): if result < 2: self.fstype = result self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) else: if result < 1: self.fstype = 1 self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) elif self.disk[5][self.index][3] == "7": if result < 1: self.fstype = 2 self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) elif self.disk[5][self.index][3] == "b": if result < 1: self.fstype = 3 self.session.open(ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) def green(self): if len(self.disk[5]) > 0: index = self["menu"].getIndex() if self.disk[5][index][3] == "83" or self.disk[5][index][3] == "7" or self.disk[5][index][3] == "b": self.index = index if self.disk[5][index][3] == "83": self.fstype = 0 elif self.disk[5][index][3] == "7": self.fstype = 2 elif self.disk[5][index][3] == "b": self.fstype = 3 self.session.open(ExtraActionBox, _("Checking disk %s") % self.disk[5][index][0], _("Checking disk"), self.chkfs) def yellow(self): if len(self.disk[5]) > 0: self.index = self["menu"].getIndex() if self.disk[5][self.index][3] == "83": if self.isExt4Supported(): self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ [ "Ext4", "partitionmanager.png" ], [ "Ext3", "partitionmanager.png" ], [ _("Cancel"), "cancel.png" ], ], 1, 2) else: self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ [ "Ext3", "partitionmanager.png" ], [ _("Cancel"), "cancel.png" ], ], 1, 1) elif self.disk[5][self.index][3] == "7": self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ [ "NTFS", "partitionmanager.png" ], [ _("Cancel"), "cancel.png" ], ], 1, 1) elif self.disk[5][self.index][3] == "b": self.session.openWithCallback(self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ [ "Fat32", "partitionmanager.png" ], [ _("Cancel"), "cancel.png" ], ], 1, 1) def refreshMP(self, uirefresh = True): self.partitions = [] self.mountpoints = MountPoints() self.mountpoints.read() count = 1 for part in self.disk[5]: capacity = "%d MB" % (part[1] / (1024 * 1024)) mp = self.mountpoints.get(self.disk[0], count) rmp = self.mountpoints.getRealMount(self.disk[0], count) if len(mp) > 0: self.partitions.append(PartitionEntry("P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity)) elif len(rmp) > 0: self.partitions.append(PartitionEntry("P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity)) else: self.partitions.append(PartitionEntry("P. %d - %s" % (count, part[2]), capacity)) count += 1 if uirefresh: self["menu"].setList(self.partitions) self.selectionChanged() def blue(self): if len(self.disk[5]) > 0: index = self["menu"].getIndex() if self.disk[5][index][3] != "83" and self.disk[5][index][3] != "7" and self.disk[5][index][3] != "b": return if len(self.partitions) > 0: self.sindex = self['menu'].getIndex() if self.mounted: mp = self.mountpoints.get(self.disk[0], self.sindex+1) rmp = self.mountpoints.getRealMount(self.disk[0], self.sindex+1) if len(mp) > 0: if self.mountpoints.isMounted(mp): if self.mountpoints.umount(mp): self.mountpoints.delete(mp) self.mountpoints.write() else: self.session.open(MessageBox, _("Cannot umount current device.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) else: self.mountpoints.delete(mp) self.mountpoints.write() elif len(rmp) > 0: self.mountpoints.umount(rmp) self.refreshMP() else: self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex+1) def quit(self): self.close()
class HddPartitions(Screen): skin = '\n\t<screen name="HddPartitions" position="center,center" size="560,430" title="Hard Drive Partitions">\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />\n\t\t<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t<widget name="label_disk" position="20,45" font="Regular;20" halign="center" size="520,25" valign="center" />\n\t\t<widget source="menu" render="Listbox" position="20,75" size="520,350" scrollbarMode="showOnDemand">\n\t\t\t<convert type="TemplatedMultiContent">\n\t\t\t\t{"template": [\n\t\t\t\t\tMultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),\n\t\t\t\t\tMultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),\n\t\t\t\t\tMultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),\n\t\t\t\t\t],\n\t\t\t\t\t"fonts": [gFont("Regular", 18)],\n\t\t\t\t\t"itemHeight": 50\n\t\t\t\t}\n\t\t\t</convert>\n\t\t</widget>\n\t</screen>' def __init__(self, session, disk): self.session = session Screen.__init__(self, session) self.disk = disk self.refreshMP(False) self['menu'] = List(self.partitions) self['menu'].onSelectionChanged.append(self.selectionChanged) self['key_red'] = Button('') self['key_green'] = Button('') self['key_yellow'] = Button('') self['key_blue'] = Button(_('Exit')) self['label_disk'] = Label('%s - %s' % (self.disk[0], self.disk[3])) self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'blue': self.quit, 'yellow': self.yellow, 'green': self.green, 'red': self.red, 'cancel': self.quit}, -2) self.onShown.append(self.setWindowTitle) if len(self.disk[5]) > 0: if self.disk[5][0][3] == '83' or self.disk[5][0][3] == '7' or self.disk[5][0][3] == 'b': self['key_green'].setText(_('Check')) self['key_yellow'].setText(_('Format')) mp = self.mountpoints.get(self.disk[0], 1) rmp = self.mountpoints.getRealMount(self.disk[0], 1) if len(mp) > 0 or len(rmp) > 0: self.mounted = True self['key_red'].setText(_('Unmount')) else: self.mounted = False self['key_red'].setText(_('Mount')) def setWindowTitle(self): self.setTitle(_('Partitions')) def selectionChanged(self): self['key_green'].setText('') self['key_yellow'].setText('') self['key_red'].setText('') if len(self.disk[5]) > 0: index = self['menu'].getIndex() if self.disk[5][index][3] == '83' or self.disk[5][index][3] == '7' or self.disk[5][index][3] == 'b': self['key_green'].setText(_('Check')) self['key_yellow'].setText(_('Format')) mp = self.mountpoints.get(self.disk[0], index + 1) rmp = self.mountpoints.getRealMount(self.disk[0], index + 1) if len(mp) > 0 or len(rmp) > 0: self.mounted = True self['key_red'].setText(_('Unmount')) else: self.mounted = False self['key_red'].setText(_('Mount')) def chkfs(self): disks = Disks() ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index + 1, self.fstype) if ret == 0: self.session.open(MessageBox, _('Check disk terminated with success'), MessageBox.TYPE_INFO) elif ret == -1: self.session.open(MessageBox, _('Cannot umount current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR) else: self.session.open(MessageBox, _('Error checking disk. The disk may be damaged'), MessageBox.TYPE_ERROR) def mkfs(self): disks = Disks() ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index + 1, self.fstype) if ret == 0: self.session.open(MessageBox, _('Format terminated with success'), MessageBox.TYPE_INFO) elif ret == -2: self.session.open(MessageBox, _('Cannot format current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR) else: self.session.open(MessageBox, _('Error formatting disk. The disk may be damaged'), MessageBox.TYPE_ERROR) def isExt4Supported(self): return 'ext4' in open('/proc/filesystems').read() def domkfs(self, result): if self.disk[5][self.index][3] == '83': if self.isExt4Supported(): if result < 2: self.fstype = result self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs) elif result < 1: self.fstype = 1 self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs) elif self.disk[5][self.index][3] == '7': if result < 1: self.fstype = 2 self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs) elif self.disk[5][self.index][3] == 'b': if result < 1: self.fstype = 3 self.session.open(ExtraActionBox, _('Formatting disk %s') % self.disk[5][self.index][0], _('Formatting disk'), self.mkfs) def green(self): if len(self.disk[5]) > 0: index = self['menu'].getIndex() if self.disk[5][index][3] == '83' or self.disk[5][index][3] == '7' or self.disk[5][index][3] == 'b': self.index = index if self.disk[5][index][3] == '83': self.fstype = 0 elif self.disk[5][index][3] == '7': self.fstype = 2 elif self.disk[5][index][3] == 'b': self.fstype = 3 self.session.open(ExtraActionBox, _('Checking disk %s') % self.disk[5][index][0], _('Checking disk'), self.chkfs) def yellow(self): if len(self.disk[5]) > 0: self.index = self['menu'].getIndex() if self.disk[5][self.index][3] == '83': if self.isExt4Supported(): self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Ext4', 'partitionmanager.png'], ['Ext3', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 2) else: self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Ext3', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 1) elif self.disk[5][self.index][3] == '7': self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['NTFS', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 1) elif self.disk[5][self.index][3] == 'b': self.session.openWithCallback(self.domkfs, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Fat32', 'partitionmanager.png'], [_('Cancel'), 'cancel.png']], 1, 1) def refreshMP(self, uirefresh = True): self.partitions = [] self.mountpoints = MountPoints() self.mountpoints.read() count = 1 for part in self.disk[5]: capacity = '%d MB' % (part[1] / 1048576) mp = self.mountpoints.get(self.disk[0], count) rmp = self.mountpoints.getRealMount(self.disk[0], count) if len(mp) > 0: self.partitions.append(PartitionEntry('P. %d - %s (Fixed: %s)' % (count, part[2], mp), capacity)) elif len(rmp) > 0: self.partitions.append(PartitionEntry('P. %d - %s (Fast: %s)' % (count, part[2], rmp), capacity)) else: self.partitions.append(PartitionEntry('P. %d - %s' % (count, part[2]), capacity)) count += 1 if uirefresh: self['menu'].setList(self.partitions) self.selectionChanged() def red(self): if len(self.disk[5]) > 0: index = self['menu'].getIndex() if self.disk[5][index][3] != '83' and self.disk[5][index][3] != '7' and self.disk[5][index][3] != 'b': return if len(self.partitions) > 0: self.sindex = self['menu'].getIndex() if self.mounted: mp = self.mountpoints.get(self.disk[0], self.sindex + 1) rmp = self.mountpoints.getRealMount(self.disk[0], self.sindex + 1) if len(mp) > 0: if self.mountpoints.isMounted(mp): if self.mountpoints.umount(mp): self.mountpoints.delete(mp) self.mountpoints.write() else: self.session.open(MessageBox, _('Cannot umount current device.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR) else: self.mountpoints.delete(mp) self.mountpoints.write() elif len(rmp) > 0: self.mountpoints.umount(rmp) self.refreshMP() else: self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex + 1) def quit(self): self.close()
class HddFastRemove(Screen): skin = """ <screen name="HddFastRemove" position="center,center" size="560,430" title="Hard Drive Fast Umount"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="140,0" size="140,40" alphatest="on" /> <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="key_blue" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> <widget source="menu" render="Listbox" position="10,55" size="520,380" scrollbarMode="showOnDemand"> <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0), MultiContentEntryText(pos = (65, 3), size = (190, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1), MultiContentEntryText(pos = (165, 27), size = (290, 38), font=1, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2), ], "fonts": [gFont("Regular", 22), gFont("Regular", 18)], "itemHeight": 50 } </convert> </widget> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.refreshMP(False) self["menu"] = List(self.disks) self["key_red"] = Button(_("Unmount")) self["key_blue"] = Button(_("Exit")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "red": self.red, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle) def setWindowTitle(self): self.setTitle(_("Fast Mounted Remove")) def red(self): if len(self.mounts) > 0: self.sindex = self["menu"].getIndex() self.mountpoints.umount(self.mounts[self.sindex]) # actually umount device here - also check both cases possible - for instance error case also check with stay in /e.g. /media/usb folder on telnet self.session.open(MessageBox, _("Fast mounted Media unmounted.\nYou can safely remove the Device now, if no further Partitions (displayed as P.x on Devicelist - where x >=2) are mounted on the same Device.\nPlease unmount Fixed Mounted Devices with Device Manager Panel!"), MessageBox.TYPE_INFO) self.refreshMP(True) def refreshMP(self, uirefresh=True): self.mdisks = Disks() self.mountpoints = MountPoints() self.mountpoints.read() self.disks = list() self.mounts = list() for disk in self.mdisks.disks: if disk[2] == True: diskname = disk[3] for partition in disk[5]: mp = "" rmp = "" try: mp = self.mountpoints.get(partition[0][:3], int(partition[0][3:])) rmp = self.mountpoints.getRealMount(partition[0][:3], int(partition[0][3:])) except Exception, e: pass if len(mp) > 0: self.disks.append(MountEntry(disk[3], "P.%s (Fixed: %s)" % (partition[0][3:], mp))) self.mounts.append(mp) elif len(rmp) > 0: self.disks.append(MountEntry(disk[3], "P.%s (Fast: %s)" % (partition[0][3:], rmp))) self.mounts.append(rmp) if uirefresh: self["menu"].setList(self.disks)
class HddPartitions(Screen): skin = """ <screen name="HddPartitions" position="center,center" size="560,430" title="Hard Drive Partitions"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" /> <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" /> <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> <widget name="label_disk" position="20,45" font="Regular;20" halign="center" size="520,25" valign="center" /> <widget source="menu" render="Listbox" position="20,75" size="520,350" scrollbarMode="showOnDemand"> <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0), MultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1), MultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2), ], "fonts": [gFont("Regular", 18)], "itemHeight": 50 } </convert> </widget> </screen>""" def __init__(self, session, disk): self.session = session Screen.__init__(self, session) self.disk = disk self.refreshMP(False) self["menu"] = List(self.partitions) self["menu"].onSelectionChanged.append(self.selectionChanged) self["key_red"] = Button("") self["key_green"] = Button("") self["key_yellow"] = Button("") self["key_blue"] = Button(_("Exit")) self["label_disk"] = Label("%s - %s" % (self.disk[0], self.disk[3])) self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], { "blue": self.quit, "yellow": self.yellow, "green": self.green, "red": self.red, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle) if len(self.disk[5]) > 0: if self.disk[5][0][3] == "83" or self.disk[5][0][ 3] == "7" or self.disk[5][0][3] == "b": self["key_green"].setText(_("Check")) self["key_yellow"].setText(_("Format")) mp = self.mountpoints.get(self.disk[0], 1) rmp = self.mountpoints.getRealMount(self.disk[0], 1) if len(mp) > 0 or len(rmp) > 0: self.mounted = True self["key_red"].setText(_("Unmount")) else: self.mounted = False self["key_red"].setText(_("Mount")) def setWindowTitle(self): self.setTitle(_("Partitions")) def selectionChanged(self): self["key_green"].setText("") self["key_yellow"].setText("") self["key_red"].setText("") if len(self.disk[5]) > 0: index = self["menu"].getIndex() if self.disk[5][index][3] == "83" or self.disk[5][index][ 3] == "7" or self.disk[5][index][3] == "b": self["key_green"].setText(_("Check")) self["key_yellow"].setText(_("Format")) mp = self.mountpoints.get(self.disk[0], index + 1) rmp = self.mountpoints.getRealMount(self.disk[0], index + 1) if len(mp) > 0 or len(rmp) > 0: self.mounted = True self["key_red"].setText(_("Unmount")) else: self.mounted = False self["key_red"].setText(_("Mount")) def chkfs(self): disks = Disks() ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index + 1, self.fstype) if ret == 0: self.session.open(MessageBox, _("Check disk terminated with success"), MessageBox.TYPE_INFO) elif ret == -1: self.session.open( MessageBox, _("Cannot umount current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again" ), MessageBox.TYPE_ERROR) else: self.session.open( MessageBox, _("Error checking disk. The disk may be damaged"), MessageBox.TYPE_ERROR) def mkfs(self): disks = Disks() ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index + 1, self.fstype) if ret == 0: self.session.open(MessageBox, _("Format terminated with success"), MessageBox.TYPE_INFO) elif ret == -2: self.session.open( MessageBox, _("Cannot format current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again" ), MessageBox.TYPE_ERROR) else: self.session.open( MessageBox, _("Error formatting disk. The disk may be damaged"), MessageBox.TYPE_ERROR) def isExt4Supported(self): return "ext4" in open("/proc/filesystems").read() def domkfs(self, result): if self.disk[5][self.index][3] == "83": if self.isExt4Supported(): if result < 2: self.fstype = result self.session.open( ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) else: if result < 1: self.fstype = 1 self.session.open( ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) elif self.disk[5][self.index][3] == "7": if result < 1: self.fstype = 2 self.session.open( ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) elif self.disk[5][self.index][3] == "b": if result < 1: self.fstype = 3 self.session.open( ExtraActionBox, _("Formatting disk %s") % self.disk[5][self.index][0], _("Formatting disk"), self.mkfs) def green(self): if len(self.disk[5]) > 0: index = self["menu"].getIndex() if self.disk[5][index][3] == "83" or self.disk[5][index][ 3] == "7" or self.disk[5][index][3] == "b": self.index = index if self.disk[5][index][3] == "83": self.fstype = 0 elif self.disk[5][index][3] == "7": self.fstype = 2 elif self.disk[5][index][3] == "b": self.fstype = 3 self.session.open( ExtraActionBox, _("Checking disk %s") % self.disk[5][index][0], _("Checking disk"), self.chkfs) def yellow(self): if len(self.disk[5]) > 0: self.index = self["menu"].getIndex() if self.disk[5][self.index][3] == "83": if self.isExt4Supported(): self.session.openWithCallback( self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ ["Ext4", "partitionmanager.png"], ["Ext3", "partitionmanager.png"], [_("Cancel"), "cancel.png"], ], 1, 2) else: self.session.openWithCallback( self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ ["Ext3", "partitionmanager.png"], [_("Cancel"), "cancel.png"], ], 1, 1) elif self.disk[5][self.index][3] == "7": self.session.openWithCallback( self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ ["NTFS", "partitionmanager.png"], [_("Cancel"), "cancel.png"], ], 1, 1) elif self.disk[5][self.index][3] == "b": self.session.openWithCallback( self.domkfs, ExtraMessageBox, _("Format as"), _("Partitioner"), [ ["Fat32", "partitionmanager.png"], [_("Cancel"), "cancel.png"], ], 1, 1) def refreshMP(self, uirefresh=True): self.partitions = [] self.mountpoints = MountPoints() self.mountpoints.read() count = 1 for part in self.disk[5]: capacity = "%d MB" % (part[1] / (1024 * 1024)) mp = self.mountpoints.get(self.disk[0], count) rmp = self.mountpoints.getRealMount(self.disk[0], count) if len(mp) > 0: self.partitions.append( PartitionEntry( "P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity)) elif len(rmp) > 0: self.partitions.append( PartitionEntry( "P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity)) else: self.partitions.append( PartitionEntry("P. %d - %s" % (count, part[2]), capacity)) count += 1 if uirefresh: self["menu"].setList(self.partitions) self.selectionChanged() def red(self): if len(self.disk[5]) > 0: index = self["menu"].getIndex() if self.disk[5][index][3] != "83" and self.disk[5][index][ 3] != "7" and self.disk[5][index][3] != "b": return if len(self.partitions) > 0: self.sindex = self['menu'].getIndex() if self.mounted: mp = self.mountpoints.get(self.disk[0], self.sindex + 1) rmp = self.mountpoints.getRealMount(self.disk[0], self.sindex + 1) if len(mp) > 0: if self.mountpoints.isMounted(mp): if self.mountpoints.umount(mp): self.mountpoints.delete(mp) self.mountpoints.write() else: self.session.open( MessageBox, _("Cannot umount current device.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again" ), MessageBox.TYPE_ERROR) else: self.mountpoints.delete(mp) self.mountpoints.write() elif len(rmp) > 0: self.mountpoints.umount(rmp) self.refreshMP() else: self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex + 1) def quit(self): self.close()
class HddMount(Screen): skin = """ <screen name="HddMount" position="center,center" size="560,430" title="Hard Drive Mount"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" /> <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" /> <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" /> <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" /> <widget name="menu" position="20,45" scrollbarMode="showOnDemand" size="520,380" transparent="1" /> </screen>""" def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_("Mount as main hdd")) self.list.append(_("Mount as /media/hdd1")) self.list.append(_("Mount as /media/hdd2")) self.list.append(_("Mount as /media/hdd3")) self.list.append(_("Mount as /media/hdd4")) self.list.append(_("Mount as /media/hdd5")) self.list.append(_("Mount as /media/usb")) self.list.append(_("Mount as /media/usb1")) self.list.append(_("Mount as /media/usb2")) self.list.append(_("Mount as /media/usb3")) self.list.append(_("Mount as /media/usb4")) self.list.append(_("Mount as /media/usb5")) self.list.append(_("Mount on custom path")) self["menu"] = MenuList(self.list) self["key_red"] = Button(_("Fixed mount")) self["key_green"] = Button(_("Fast mount")) self["key_blue"] = Button(_("Exit")) self["key_yellow"] = Button("") self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "green": self.green, "red": self.ok, "cancel": self.quit, }, -2) self.onShown.append(self.setWindowTitle) def setWindowTitle(self): self.setTitle(_("Mountpoints")) def ok(self): self.fast = False selected = self["menu"].getSelectedIndex() if selected == 0: self.setMountPoint("/media/hdd") elif selected == 1: self.setMountPoint("/media/hdd1") elif selected == 2: self.setMountPoint("/media/hdd2") elif selected == 3: self.setMountPoint("/media/hdd3") elif selected == 4: self.setMountPoint("/media/hdd4") elif selected == 5: self.setMountPoint("/media/hdd5") elif selected == 6: self.setMountPoint("/media/usb") elif selected == 7: self.setMountPoint("/media/usb1") elif selected == 8: self.setMountPoint("/media/usb2") elif selected == 9: self.setMountPoint("/media/usb3") elif selected == 10: self.setMountPoint("/media/usb4") elif selected == 11: self.setMountPoint("/media/usb5") elif selected == 12: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=(_("Insert mount point:")), text=_("/media/custom")) def green(self): self.fast = True selected = self["menu"].getSelectedIndex() if selected == 0: self.setMountPoint("/media/hdd") elif selected == 1: self.setMountPoint("/media/hdd1") elif selected == 2: self.setMountPoint("/media/hdd2") elif selected == 3: self.setMountPoint("/media/hdd3") elif selected == 4: self.setMountPoint("/media/hdd4") elif selected == 5: self.setMountPoint("/media/hdd5") elif selected == 6: self.setMountPoint("/media/usb") elif selected == 7: self.setMountPoint("/media/usb1") elif selected == 8: self.setMountPoint("/media/usb2") elif selected == 9: self.setMountPoint("/media/usb3") elif selected == 10: self.setMountPoint("/media/usb4") elif selected == 11: self.setMountPoint("/media/usb5") elif selected == 12: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=(_("Insert mount point:")), text=_("/media/custom")) def customPath(self, result): if result and len(result) > 0: result = result.rstrip("/") os.system("mkdir -p %s" % result) self.setMountPoint(result) def setMountPoint(self, path): self.cpath = path if self.mountpoints.exist(path): self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, _("Selected mount point is already used by another drive."), _("Mount point exist!"), [[_("Change old drive with this new drive"), "ok.png"], [_("Keep old drive"), "cancel.png"], ]) else: self.setMountPointCb(0) def setMountPointCb(self, result): if result == 0: if self.mountpoints.isMounted(self.cpath): if not self.mountpoints.umount(self.cpath): self.session.open(MessageBox, _("Cannot umount current drive.\nA record in progress, timeshift or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) self.close() return self.mountpoints.delete(self.cpath) if not self.fast: self.mountpoints.add(self.device, self.partition, self.cpath) self.mountpoints.write() if not self.mountpoints.mount(self.device, self.partition, self.cpath): self.session.open(MessageBox, _("Cannot mount new drive.\nPlease check filesystem or format it and try again"), MessageBox.TYPE_ERROR) elif self.cpath == "/media/hdd": os.system("/bin/mkdir -p /media/hdd/movie") if not self.fast: message = _("Device Fixed Mount Point change needs a system restart in order to take effect.\nRestart your %s %s now?") % (getMachineBrand(), getMachineName()) mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO) mbox.setTitle(_("Restart %s %s") % (getMachineBrand(), getMachineName())) else: self.close() def restartBox(self, answer): if answer is True: self.session.open(TryQuitMainloop, 2) else: self.close() def quit(self): self.close()
class HddMount(Screen): skin = '\n\t<screen name="HddMount" position="center,center" size="560,430" title="Hard Drive Mount">\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />\n\t\t<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t<widget name="menu" position="20,45" scrollbarMode="showOnDemand" size="520,380" transparent="1" />\n\t</screen>' def __init__(self, session, device, partition): Screen.__init__(self, session) self.device = device self.partition = partition self.mountpoints = MountPoints() self.mountpoints.read() self.fast = False self.list = [] self.list.append(_('Mount as /universe')) self.list.append(_('Mount as /media/usb')) self.list.append(_('Mount as /media/hdd')) self.list.append('Mount as /media/cf') self.list.append('Mount as /media/mmc1') self.list.append('Mount on custom path') self['menu'] = MenuList(self.list) self['key_red'] = Button(_('Fixed mount')) self['key_green'] = Button('Fast mount') self['key_blue'] = Button(_('Exit')) self['key_yellow'] = Button('') self['actions'] = ActionMap( ['OkCancelActions', 'ColorActions'], { 'blue': self.quit, 'green': self.green, 'ok': self.ok, 'red': self.ok, 'cancel': self.quit }, -2) self.onShown.append(self.setWindowTitle) def setWindowTitle(self): self.setTitle(_('Mountpoints')) def ok(self): self.fast = False selected = self['menu'].getSelectedIndex() if selected == 0: self.setMountPoint('/universe') elif selected == 1: self.setMountPoint('/media/usb') elif selected == 2: self.setMountPoint('/media/hdd') elif selected == 3: self.setMountPoint('/media/cf') elif selected == 4: self.setMountPoint('/media/mmc1') elif selected == 5: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom') def green(self): self.fast = True selected = self['menu'].getSelectedIndex() if selected == 0: self.setMountPoint('/universe') elif selected == 1: self.setMountPoint('/media/usb') elif selected == 2: self.setMountPoint('/media/hdd') elif selected == 3: self.setMountPoint('/media/cf') elif selected == 4: self.setMountPoint('/media/mmc1') elif selected == 5: self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom') def customPath(self, result): if result and len(result) > 0: result = result.rstrip('/') os.system('mkdir -p %s' % result) self.setMountPoint(result) def setMountPoint(self, path): self.cpath = path if self.mountpoints.exist(path): self.session.openWithCallback( self.setMountPointCb, ExtraMessageBox, 'Selected mount point is already used by another drive.', 'Mount point exist!', [['Change old drive with this new drive', 'ok.png'], ['Mantain old drive', 'cancel.png']]) else: self.setMountPointCb(0) def setMountPointCb(self, result): if result == 0: if not self.mountpoints.isMounted( self.cpath) and self.mountpoints.umount(self.cpath): self.session.open( MessageBox, _('Cannot umount current drive.\nA record in progress, timeshit or some external tools (like samba and nfsd) may cause this problem.\nPlease stop this actions/applications and try again' ), MessageBox.TYPE_ERROR) self.close() return None self.mountpoints.delete(self.cpath) if not self.fast: self.mountpoints.add(self.device, self.partition, self.cpath) self.mountpoints.write() if not self.mountpoints.mount(self.device, self.partition, self.cpath): self.session.open( MessageBox, _('Cannot mount new drive.\nPlease check filesystem or format it and try again' ), MessageBox.TYPE_ERROR) elif self.cpath == '/media/hdd': os.system('/bin/mkdir /hdd/movie') os.system('/bin/mkdir /hdd/music') os.system('/bin/mkdir /hdd/picture') self.close() def restartBox(self, answer): if answer is True: self.session.open(TryQuitMainloop, 2) else: self.close() def quit(self): self.close()