From 1a9635e73d3725af360b3246f041771a84f53dbe Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 08:03:12 +0100 Subject: remove Imagewizard --- lib/python/Screens/ImageWizard.py | 38 -------------------------------------- lib/python/Screens/Makefile.am | 2 +- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 lib/python/Screens/ImageWizard.py (limited to 'lib/python') diff --git a/lib/python/Screens/ImageWizard.py b/lib/python/Screens/ImageWizard.py deleted file mode 100644 index faf6120b..00000000 --- a/lib/python/Screens/ImageWizard.py +++ /dev/null @@ -1,38 +0,0 @@ -from Wizard import Wizard, wizardManager - -from Tools.Directories import fileExists - -import os - -backupfile = "backupenigma2settings.tar" - -def checkConfigBackup(): - paths = ['/media/hdd/', '/media/cf/'] - for x in paths: - if fileExists(x + backupfile): - return x - return None - -if checkConfigBackup() is None: - backupAvailable = 0 -else: - backupAvailable = 1 - -class ImageWizard(Wizard): - def __init__(self, session): - self.xmlfile = "imagewizard.xml" - Wizard.__init__(self, session, showSteps=False, showStepSlider=False, showList=True, showConfig=True) - - def markDone(self): - pass - -wizardManager.registerWizard(ImageWizard, backupAvailable, priority = 10) - -def doBackup(path): - os.system('tar cvpf ' + path + backupfile + ' /etc/enigma2') - -def doRestore(path): - os.system('cd / && /bin/tar xvpf ' + path + backupfile) - - - \ No newline at end of file diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index cde2d6c3..00204a94 100755 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -9,7 +9,7 @@ install_PYTHON = \ InfoBarGenerics.py HelpMenu.py Wizard.py __init__.py \ Dish.py LanguageSelection.py StartWizard.py PiPSetup.py Subtitles.py \ TutorialWizard.py PluginBrowser.py MinuteInput.py Scart.py PVRState.py \ - Console.py InputBox.py ChoiceBox.py SimpleSummary.py ImageWizard.py \ + Console.py InputBox.py ChoiceBox.py SimpleSummary.py \ TimerSelection.py PictureInPicture.py TimeDateInput.py \ SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \ SleepTimerEdit.py Ipkg.py RdsDisplay.py Globals.py DefaultWizard.py \ -- cgit v1.2.3 From 9015ce354743d7a3a73400c8b91cd85a6ceaeb96 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 08:13:40 +0100 Subject: remove IPKGInstaller and ConfigurationBackup start working on Softwaremanager --- configure.ac | 2 - .../Plugins/Extensions/IpkgInstaller/.cvsignore | 4 - .../Plugins/Extensions/IpkgInstaller/Makefile.am | 5 - .../Plugins/Extensions/IpkgInstaller/__init__.py | 0 .../Plugins/Extensions/IpkgInstaller/plugin.py | 67 ------- lib/python/Plugins/Extensions/Makefile.am | 2 +- .../SystemPlugins/ConfigurationBackup/.cvsignore | 4 - .../SystemPlugins/ConfigurationBackup/LICENSE | 12 -- .../SystemPlugins/ConfigurationBackup/Makefile.am | 8 - .../SystemPlugins/ConfigurationBackup/__init__.py | 0 .../SystemPlugins/ConfigurationBackup/backup.png | Bin 3711 -> 0 bytes .../SystemPlugins/ConfigurationBackup/blue.png | Bin 3495 -> 0 bytes .../SystemPlugins/ConfigurationBackup/green.png | Bin 3454 -> 0 bytes .../SystemPlugins/ConfigurationBackup/plugin.py | 221 --------------------- .../SystemPlugins/ConfigurationBackup/red.png | Bin 3742 -> 0 bytes .../SystemPlugins/ConfigurationBackup/yellow.png | Bin 3732 -> 0 bytes lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- 17 files changed, 2 insertions(+), 325 deletions(-) mode change 100644 => 100755 configure.ac delete mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/.cvsignore delete mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am delete mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/__init__.py delete mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/plugin.py mode change 100644 => 100755 lib/python/Plugins/Extensions/Makefile.am delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/.cvsignore delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/LICENSE delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile.am delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/__init__.py delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/backup.png delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/blue.png delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/green.png delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/red.png delete mode 100644 lib/python/Plugins/SystemPlugins/ConfigurationBackup/yellow.png mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/Makefile.am (limited to 'lib/python') diff --git a/configure.ac b/configure.ac old mode 100644 new mode 100755 index 719baa11..89ab3f06 --- a/configure.ac +++ b/configure.ac @@ -112,7 +112,6 @@ lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile lib/python/Plugins/SystemPlugins/PositionerSetup/Makefile lib/python/Plugins/SystemPlugins/Hotplug/Makefile -lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile lib/python/Plugins/SystemPlugins/DefaultServicesScanner/Makefile lib/python/Plugins/SystemPlugins/NFIFlash/Makefile lib/python/Plugins/SystemPlugins/Satfinder/Makefile @@ -124,7 +123,6 @@ lib/python/Plugins/SystemPlugins/DiseqcTester/Makefile lib/python/Plugins/DemoPlugins/Makefile lib/python/Plugins/DemoPlugins/TestPlugin/Makefile lib/python/Plugins/Extensions/Makefile -lib/python/Plugins/Extensions/IpkgInstaller/Makefile lib/python/Plugins/Extensions/TuxboxPlugins/Makefile lib/python/Plugins/Extensions/FileManager/Makefile lib/python/Plugins/Extensions/CutListEditor/Makefile diff --git a/lib/python/Plugins/Extensions/IpkgInstaller/.cvsignore b/lib/python/Plugins/Extensions/IpkgInstaller/.cvsignore deleted file mode 100644 index 138b9cc2..00000000 --- a/lib/python/Plugins/Extensions/IpkgInstaller/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*.pyc -*.pyo -Makefile -Makefile.in diff --git a/lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am b/lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am deleted file mode 100644 index ece0698f..00000000 --- a/lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/IpkgInstaller - -install_PYTHON = \ - __init__.py \ - plugin.py diff --git a/lib/python/Plugins/Extensions/IpkgInstaller/__init__.py b/lib/python/Plugins/Extensions/IpkgInstaller/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/python/Plugins/Extensions/IpkgInstaller/plugin.py b/lib/python/Plugins/Extensions/IpkgInstaller/plugin.py deleted file mode 100644 index 4893dc47..00000000 --- a/lib/python/Plugins/Extensions/IpkgInstaller/plugin.py +++ /dev/null @@ -1,67 +0,0 @@ -from Components.ActionMap import ActionMap -from Components.Ipkg import IpkgComponent -from Components.Label import Label -from Components.SelectionList import SelectionList -from Plugins.Plugin import PluginDescriptor -from Screens.Ipkg import Ipkg -from Screens.Screen import Screen - -class IpkgInstaller(Screen): - skin = """ - - - - - - - - """ - - def __init__(self, session, list): - self.skin = IpkgInstaller.skin - Screen.__init__(self, session) - - self.list = SelectionList() - self["list"] = self.list - for listindex in range(len(list)): - self.list.addSelection(list[listindex], list[listindex], listindex, True) - - self["red"] = Label() - self["green"] = Label() - self["yellow"] = Label() - self["blue"] = Label() - - self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], - { - "ok": self.list.toggleSelection, - "cancel": self.close, - "green": self.install - }, -1) - - def install(self): - list = self.list.getSelectionsList() - cmdList = [] - for item in list: - cmdList.append((IpkgComponent.CMD_INSTALL, { "package": item[1] })) - print cmdList - self.session.open(Ipkg, cmdList = cmdList) - -def filescan_open(list, session, **kwargs): - filelist = [x.path for x in list] - session.open(IpkgInstaller, filelist) # list - -def filescan(**kwargs): - from Components.Scanner import Scanner, ScanPath - return \ - Scanner(mimetypes = ["application/x-debian-package"], - paths_to_scan = - [ - ScanPath(path = "ipk", with_subdirs = True), - ScanPath(path = "", with_subdirs = False), - ], - name = "Ipkg", - description = "Install software updates...", - openfnc = filescan_open, ) - -def Plugins(**kwargs): - return [ PluginDescriptor(name="Ipkg", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) ] diff --git a/lib/python/Plugins/Extensions/Makefile.am b/lib/python/Plugins/Extensions/Makefile.am old mode 100644 new mode 100755 index 9f3737aa..edbd2084 --- a/lib/python/Plugins/Extensions/Makefile.am +++ b/lib/python/Plugins/Extensions/Makefile.am @@ -1 +1 @@ -SUBDIRS = TuxboxPlugins FileManager CutListEditor PicturePlayer MediaScanner MediaPlayer IpkgInstaller GraphMultiEPG SocketMMI DVDPlayer DVDBurn +SUBDIRS = TuxboxPlugins FileManager CutListEditor PicturePlayer MediaScanner MediaPlayer GraphMultiEPG SocketMMI DVDPlayer DVDBurn diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/.cvsignore b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/.cvsignore deleted file mode 100644 index 138b9cc2..00000000 --- a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*.pyc -*.pyo -Makefile -Makefile.in diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/LICENSE b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/LICENSE deleted file mode 100644 index 99700593..00000000 --- a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ -This plugin is licensed under the Creative Commons -Attribution-NonCommercial-ShareAlike 3.0 Unported -License. To view a copy of this license, visit -http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative -Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. - -Alternatively, this plugin may be distributed and executed on hardware which -is licensed by Dream Multimedia GmbH. - -This plugin is NOT free software. It is open source, you are allowed to -modify it (if you keep the license), but it may not be commercially -distributed other than under the conditions noted above. diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile.am b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile.am deleted file mode 100644 index d50236d8..00000000 --- a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/ConfigurationBackup - -install_PYTHON = \ - __init__.py \ - plugin.py red.png yellow.png green.png blue.png backup.png - -install_DATA = LICENSE - diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/__init__.py b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/backup.png b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/backup.png deleted file mode 100644 index 4962a058..00000000 Binary files a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/backup.png and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/blue.png b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/blue.png deleted file mode 100644 index a392bbe6..00000000 Binary files a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/blue.png and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/green.png b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/green.png deleted file mode 100644 index f168e4d0..00000000 Binary files a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/green.png and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py deleted file mode 100644 index 7a918da6..00000000 --- a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py +++ /dev/null @@ -1,221 +0,0 @@ -from Screens.Screen import Screen -from Screens.MessageBox import MessageBox -from Screens.Console import Console -from Components.ActionMap import ActionMap, NumberActionMap -from Components.Pixmap import Pixmap -from Components.Label import Label -from Components.MenuList import MenuList -from Components.config import ConfigSelection, ConfigSubsection, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry -from Components.ConfigList import ConfigList -from Plugins.Plugin import PluginDescriptor - -from Tools.Directories import * -from os import path, makedirs, listdir -from time import localtime -from datetime import date - -plugin_path = "" - -# FIXME: harddiskmanager has a better overview about available mointpoints! -BackupPath = { - "hdd" : "/media/hdd/backup", - "usb" : "/media/usb/backup", - "cf" : "/media/cf/backup" - } - -MountPoints = { - "hdd" : "/media/hdd", - "usb" : "/media/usb", - "cf" : "/media/cf" - } - -class BackupSetup(Screen): - skin = """ - - - - - - - - - - - """ - - def keyLeft(self): - self["config"].handleKey(KEY_LEFT) - - def keyRight(self): - self["config"].handleKey(KEY_RIGHT) - - def keyNumberGlobal(self, number): - print "You pressed number", number - if (self["config"].getCurrent()[1].parent.enabled == True): - self["config"].handleKey(KEY_0+number) - - def keyCancel(self): - for x in self["config"].list: - x[1].cancel() - self.close() - - def keySave(self): - for x in self["config"].list: - x[1].save() - self.close() - - def __init__(self, session, args = None): - Screen.__init__(self, session) - self.skin_path = plugin_path - - self["oktext"] = Label(_("OK")) - self["canceltext"] = Label(_("Cancel")) - self["backuptext"] = Label(_("Backup")) - self["restoretext"] = Label(_("Restore")) - self["restore"] = Pixmap() - self["backup"] = Pixmap() - self["ok"] = Pixmap() - self["cancel"] = Pixmap() - - self.path = "" - self.list = [] - self["config"] = ConfigList(self.list) - self.createSetup() - - self["actions"] = NumberActionMap(["SetupActions"], - { - "ok": self.keySave, - "cancel": self.keyCancel, - "left": self.keyLeft, - "right": self.keyRight - }, -1) - - self["shortcuts"] = ActionMap(["ShortcutActions"], - { - "red": self.keyCancel, - "green": self.keySave, - "blue": self.Backup, - "yellow": self.Restore, - }) - - - def createSetup(self): - print "Creating BackupSetup" - self.list = [ ] - self["config"] = ConfigList(self.list) - self.backup = ConfigSubsection() - self.backup.type = ConfigSelection(choices = [("settings", _("enigma2 and network")), ("var", _("/var directory")), ("skin", _("/usr/share/enigma2 directory"))], default="settings") - self.backup.location = ConfigSelection(choices = [("hdd", _("Harddisk")), ("usb", _("USB Stick")), ("cf", _("CF Drive"))]) - self.list.append(getConfigListEntry(_("Backup Mode"), self.backup.type)) - self.list.append(getConfigListEntry(_("Backup Location"), self.backup.location)) - - def createBackupfolders(self): - self.path = BackupPath[self.backup.location.value] - print "Creating Backup Folder if not already there..." - if (path.exists(self.path) == False): - makedirs(self.path) - - def Backup(self): - print "this will start the backup now!" - self.session.openWithCallback(self.runBackup, MessageBox, _("Do you want to backup now?\nAfter pressing OK, please wait!")) - - def Restore(self): - print "this will start the restore now!" - self.session.open(RestoreMenu, self.backup) - - def runBackup(self, result): - if result: - if path.ismount(MountPoints[self.backup.location.value]): - self.createBackupfolders() - d = localtime() - dt = date(d.tm_year, d.tm_mon, d.tm_mday) - self.path = BackupPath[self.backup.location.value] - if self.backup.type.value == "settings": - print "Backup Mode: Settings" - self.session.open(Console, title = "Backup running", cmdlist = ["tar -czvf " + self.path + "/" + str(dt) + "_settings_backup.tar.gz /etc/enigma2/ /etc/network/interfaces /etc/wpa_supplicant.conf"]) - elif self.backup.type.value == "var": - print "Backup Mode: var" - self.session.open(Console, title = "Backup running", cmdlist = [ "tar -czvf " + self.path + "/" + str(dt) + "_var_backup.tar.gz /var/"]) - elif self.backup.type.value == "skin": - print "Backup Mode: skin" - self.session.open(Console, title ="Backup running", cmdlist = [ "tar -czvf " + self.path + "/" + str(dt) + "_skin_backup.tar.gz /usr/share/enigma2/"]) - else: - self.session.open(MessageBox, _("Sorry your Backup destination does not exist\n\nPlease choose an other one."), MessageBox.TYPE_INFO) - -class RestoreMenu(Screen): - skin = """ - - - - - - - """ - - def __init__(self, session, backup): - Screen.__init__(self, session) - self.skin_path = plugin_path - self.backup = backup - - self["canceltext"] = Label(_("Cancel")) - self["restoretext"] = Label(_("Restore")) - self["restore"] = Pixmap() - self["cancel"] = Pixmap() - - self.sel = [] - self.val = [] - self.entry = False - self.exe = False - - self.path = "" - - self["actions"] = NumberActionMap(["SetupActions"], - { - "ok": self.KeyOk, - "cancel": self.keyCancel - }, -1) - - self["shortcuts"] = ActionMap(["ShortcutActions"], - { - "red": self.keyCancel, - "yellow": self.KeyOk, - }) - self.flist = [] - self["filelist"] = MenuList(self.flist) - self.fill_list() - - def fill_list(self): - self.flist = [] - self.path = BackupPath[self.backup.location.value] - if (path.exists(self.path) == False): - makedirs(self.path) - for file in listdir(self.path): - if (file.endswith(".tar.gz")): - self.flist.append((file)) - self.entry = True - self["filelist"].l.setList(self.flist) - - def KeyOk(self): - if (self.exe == False) and (self.entry == True): - self.sel = self["filelist"].getCurrent() - self.val = self.path + self.sel - self.session.openWithCallback(self.startRestore, MessageBox, _("are you sure you want to restore\nfollowing backup:\n" + self.sel + "\nEnigma2 will restart after the restore")) - - def keyCancel(self): - self.close() - - def startRestore(self, ret = False): - if (ret == True): - self.exe = True - self.session.open(Console, title = "Restore running", cmdlist = ["tar -xzvf " + self.path + "/" + self.sel + " -C /", "killall -9 enigma2"]) - - def Exit(self): - self.close() - -def BackupMain(session, **kwargs): - session.open(BackupSetup) - -def Plugins(path, **kwargs): - global plugin_path - plugin_path = path - return PluginDescriptor(name="Backup/Restore", description="Backup and Restore your Settings", icon="backup.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=BackupMain) diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/red.png b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/red.png deleted file mode 100644 index 8096045f..00000000 Binary files a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/red.png and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/yellow.png b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/yellow.png deleted file mode 100644 index dacb80e6..00000000 Binary files a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/yellow.png and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am old mode 100644 new mode 100755 index 4491eafc..be12378c --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -1 +1 @@ -SUBDIRS = SoftwareUpdate FrontprocessorUpgrade PositionerSetup ConfigurationBackup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug DefaultServicesScanner NFIFlash DiseqcTester +SUBDIRS = SoftwareUpdate FrontprocessorUpgrade PositionerSetup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug DefaultServicesScanner NFIFlash DiseqcTester -- cgit v1.2.3 From 60881a22938560d1b583797ddf74b62d24926517 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 08:17:55 +0100 Subject: do not show inaccessible devices in deviceselection --- lib/python/Plugins/Extensions/MediaScanner/plugin.py | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 lib/python/Plugins/Extensions/MediaScanner/plugin.py (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/MediaScanner/plugin.py b/lib/python/Plugins/Extensions/MediaScanner/plugin.py old mode 100644 new mode 100755 index 88b917ee..2c31197d --- a/lib/python/Plugins/Extensions/MediaScanner/plugin.py +++ b/lib/python/Plugins/Extensions/MediaScanner/plugin.py @@ -42,6 +42,9 @@ def scan(session): parts = [ (r.description, r.mountpoint, session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] if len(parts): + for x in parts: + if not access(x[1], F_OK|R_OK): + parts.remove(x) session.openWithCallback(mountpoint_choosen, ChoiceBox, title = _("Please Select Medium to be Scanned"), list = parts) def main(session, **kwargs): -- cgit v1.2.3 From a1b97a6ac06f120114cb12c4e4667230edb8d7df Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 08:21:01 +0100 Subject: add remove/add partition interface for external applications not using autofs --- lib/python/Components/Harddisk.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) mode change 100644 => 100755 lib/python/Components/Harddisk.py (limited to 'lib/python') diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py old mode 100644 new mode 100755 index d165e26c..75d68fad --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -519,4 +519,18 @@ class HarddiskManager: description += " (Partition %d)" % part return description + def addMountedPartition(self, device, desc): + already_mounted = False + for x in self.partitions[:]: + if x.mountpoint == device: + already_mounted = True + if not already_mounted: + self.partitions.append(Partition(mountpoint = device, description = desc)) + + def removeMountedPartition(self, mountpoint): + for x in self.partitions[:]: + if x.mountpoint == mountpoint: + self.partitions.remove(x) + self.on_partition_list_change("remove", x) + harddiskmanager = HarddiskManager() -- cgit v1.2.3 From 2cfd7bf526965a11394275b6d3b28b87c6c76875 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 08:24:46 +0100 Subject: add MultiFileSelectList --- lib/python/Components/FileList.py | 186 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) mode change 100644 => 100755 lib/python/Components/FileList.py (limited to 'lib/python') diff --git a/lib/python/Components/FileList.py b/lib/python/Components/FileList.py old mode 100644 new mode 100755 index 84abf328..f9697094 --- a/lib/python/Components/FileList.py +++ b/lib/python/Components/FileList.py @@ -248,3 +248,189 @@ class FileList(MenuList): self.refreshMountpoints() if self.current_directory is None: self.refresh() + + +def MultiFileSelectEntryComponent(name, absolute = None, isDir = False, selected = False): + res = [ (absolute, isDir, selected, name) ] + res.append((eListboxPythonMultiContent.TYPE_TEXT, 55, 1, 470, 20, 0, RT_HALIGN_LEFT, name)) + if isDir: + png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "extensions/directory.png")) + else: + extension = name.split('.') + extension = extension[-1].lower() + if EXTENSIONS.has_key(extension): + png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "extensions/" + EXTENSIONS[extension] + ".png")) + else: + png = None + if png is not None: + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 30, 2, 20, 20, png)) + + if not name.startswith('<'): + if selected is False: + icon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_off.png")) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 2, 0, 25, 25, icon)) + else: + icon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png")) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 2, 0, 25, 25, icon)) + + return res + + +class MultiFileSelectList(FileList): + def __init__(self, preselectedFiles, directory, showMountpoints = False, matchingPattern = None, showDirectories = True, showFiles = True, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None): + self.selectedFiles = preselectedFiles + if self.selectedFiles is None: + self.selectedFiles = [] + FileList.__init__(self, directory, showMountpoints = showMountpoints, matchingPattern = matchingPattern, showDirectories = showDirectories, showFiles = showFiles, useServiceRef = useServiceRef, inhibitDirs = inhibitDirs, inhibitMounts = inhibitMounts, isTop = isTop, enableWrapAround = enableWrapAround, additionalExtensions = additionalExtensions) + self.changeDir(directory) + self.l.setItemHeight(25) + self.l.setFont(0, gFont("Regular", 20)) + self.onSelectionChanged = [ ] + + def selectionChanged(self): + for f in self.onSelectionChanged: + f() + + def changeSelectionState(self): + idx = self.l.getCurrentSelectionIndex() + count = 0 + newList = [] + for x in self.list: + if idx == count: + if x[0][3].startswith('<'): + newList.append(x) + else: + if x[0][1] is True: + realPathname = x[0][0] + else: + realPathname = self.current_directory + x[0][0] + if x[0][2] == True: + SelectState = False + for entry in self.selectedFiles: + if entry == realPathname: + self.selectedFiles.remove(entry) + + else: + SelectState = True + alreadyinList = False + for entry in self.selectedFiles: + if entry == realPathname: + alreadyinList = True + if not alreadyinList: + self.selectedFiles.append(realPathname) + newList.append(MultiFileSelectEntryComponent(name = x[0][3], absolute = x[0][0], isDir = x[0][1], selected = SelectState )) + else: + newList.append(x) + + count += 1 + + self.list = newList + self.l.setList(self.list) + + def getSelectedList(self): + return self.selectedFiles + + def changeDir(self, directory, select = None): + self.list = [] + + # if we are just entering from the list of mount points: + if self.current_directory is None: + if directory and self.showMountpoints: + self.current_mountpoint = self.getMountpointLink(directory) + else: + self.current_mountpoint = None + self.current_directory = directory + directories = [] + files = [] + + if directory is None and self.showMountpoints: # present available mountpoints + for p in harddiskmanager.getMountedPartitions(): + path = os_path.join(p.mountpoint, "") + if path not in self.inhibitMounts and not self.inParentDirs(path, self.inhibitDirs): + self.list.append(MultiFileSelectEntryComponent(name = p.description, absolute = path, isDir = True)) + files = [ ] + directories = [ ] + elif directory is None: + files = [ ] + directories = [ ] + elif self.useServiceRef: + root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + directory) + if self.additional_extensions: + root.setName(self.additional_extensions) + serviceHandler = eServiceCenter.getInstance() + list = serviceHandler.list(root) + + while 1: + s = list.getNext() + if not s.valid(): + del list + break + if s.flags & s.mustDescent: + directories.append(s.getPath()) + else: + files.append(s) + directories.sort() + files.sort() + else: + if os_path.exists(directory): + files = listdir(directory) + files.sort() + tmpfiles = files[:] + for x in tmpfiles: + if os_path.isdir(directory + x): + directories.append(directory + x + "/") + files.remove(x) + + if directory is not None and self.showDirectories and not self.isTop: + if directory == self.current_mountpoint and self.showMountpoints: + self.list.append(MultiFileSelectEntryComponent(name = "<" +_("List of Storage Devices") + ">", absolute = None, isDir = True)) + elif (directory != "/") and not (self.inhibitMounts and self.getMountpoint(directory) in self.inhibitMounts): + self.list.append(MultiFileSelectEntryComponent(name = "<" +_("Parent Directory") + ">", absolute = '/'.join(directory.split('/')[:-2]) + '/', isDir = True)) + + if self.showDirectories: + for x in directories: + if not (self.inhibitMounts and self.getMountpoint(x) in self.inhibitMounts) and not self.inParentDirs(x, self.inhibitDirs): + name = x.split('/')[-2] + alreadySelected = False + for entry in self.selectedFiles: + if entry == x: + alreadySelected = True + if alreadySelected: + self.list.append(MultiFileSelectEntryComponent(name = name, absolute = x, isDir = True, selected = True)) + else: + self.list.append(MultiFileSelectEntryComponent(name = name, absolute = x, isDir = True, selected = False)) + + if self.showFiles: + for x in files: + if self.useServiceRef: + path = x.getPath() + name = path.split('/')[-1] + else: + path = directory + x + name = x + + if (self.matchingPattern is None) or re_compile(self.matchingPattern).search(path): + alreadySelected = False + for entry in self.selectedFiles: + if os_path.basename(entry) == x: + alreadySelected = True + if alreadySelected: + self.list.append(MultiFileSelectEntryComponent(name = name, absolute = x , isDir = False, selected = True)) + else: + self.list.append(MultiFileSelectEntryComponent(name = name, absolute = x , isDir = False, selected = False)) + + self.l.setList(self.list) + + if select is not None: + i = 0 + self.moveToIndex(0) + for x in self.list: + p = x[0][0] + + if isinstance(p, eServiceReference): + p = p.getPath() + + if p == select: + self.moveToIndex(i) + i += 1 + -- cgit v1.2.3 From cd3cd96e2ff4c6e6a9a38393e4d93167d30f74ea Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 08:27:58 +0100 Subject: add remove to ipkg component and screen --- lib/python/Components/Ipkg.py | 4 ++++ lib/python/Screens/Ipkg.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib/python/Components/Ipkg.py mode change 100644 => 100755 lib/python/Screens/Ipkg.py (limited to 'lib/python') diff --git a/lib/python/Components/Ipkg.py b/lib/python/Components/Ipkg.py old mode 100644 new mode 100755 index 31889bcf..0ba1165c --- a/lib/python/Components/Ipkg.py +++ b/lib/python/Components/Ipkg.py @@ -52,6 +52,8 @@ class IpkgComponent: self.runCmd("list") elif cmd == self.CMD_INSTALL: self.runCmd("install " + args['package']) + elif cmd == self.CMD_REMOVE: + self.runCmd("remove " + args['package']) self.setCurrentCommand(cmd) def cmdFinished(self, retval): @@ -90,6 +92,8 @@ class IpkgComponent: self.callCallbacks(self.EVENT_UPGRADE, data.split(' ', 1)[1].split(' ')[0]) elif data.find('Installing') == 0: self.callCallbacks(self.EVENT_INSTALL, data.split(' ', 1)[1].split(' ')[0]) + elif data.find('Removing') == 0: + self.callCallbacks(self.EVENT_REMOVE, data.split(' ', 1)[1].split(' ')[1]) elif data.find('Configuring') == 0: self.callCallbacks(self.EVENT_CONFIGURING, data.split(' ', 1)[1].split(' ')[0]) elif data.find('An error occurred') == 0: diff --git a/lib/python/Screens/Ipkg.py b/lib/python/Screens/Ipkg.py old mode 100644 new mode 100755 index eac03479..96876336 --- a/lib/python/Screens/Ipkg.py +++ b/lib/python/Screens/Ipkg.py @@ -54,7 +54,7 @@ class Ipkg(Screen): self.slider.setValue(len(self.cmdList)) self.package.setText("") - self.status.setText(_("Done - Installed or upgraded %d packages with %d errors") % (self.packages, self.error)) + self.status.setText(_("Done - Installed, upgraded or removed %d packages with %d errors") % (self.packages, self.error)) return False else: cmd = self.cmdList[self.runningCmd] @@ -90,6 +90,10 @@ class Ipkg(Screen): self.package.setText(param) self.status.setText(_("Installing")) self.packages += 1 + elif event == IpkgComponent.EVENT_REMOVE: + self.package.setText(param) + self.status.setText(_("Removing")) + self.packages += 1 elif event == IpkgComponent.EVENT_CONFIGURING: self.package.setText(param) self.status.setText(_("Configuring")) -- cgit v1.2.3 From 8530482b1d58468eade8ae2cfd618c694bef75d2 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 10:51:23 +0100 Subject: really only show accessible devices --- lib/python/Plugins/Extensions/MediaScanner/plugin.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/MediaScanner/plugin.py b/lib/python/Plugins/Extensions/MediaScanner/plugin.py index 2c31197d..b43662ef 100755 --- a/lib/python/Plugins/Extensions/MediaScanner/plugin.py +++ b/lib/python/Plugins/Extensions/MediaScanner/plugin.py @@ -45,6 +45,9 @@ def scan(session): for x in parts: if not access(x[1], F_OK|R_OK): parts.remove(x) + for x in parts: # first run sometimes skips an entry + if not access(x[1], F_OK|R_OK): + parts.remove(x) session.openWithCallback(mountpoint_choosen, ChoiceBox, title = _("Please Select Medium to be Scanned"), list = parts) def main(session, **kwargs): -- cgit v1.2.3 From 954ca139746278ae94ba5a5b0aaccbf5a2dcd13b Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 10:55:43 +0100 Subject: Revert "really only show accessible devices" This reverts commit 8530482b1d58468eade8ae2cfd618c694bef75d2. --- lib/python/Plugins/Extensions/MediaScanner/plugin.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/Extensions/MediaScanner/plugin.py b/lib/python/Plugins/Extensions/MediaScanner/plugin.py index b43662ef..2c31197d 100755 --- a/lib/python/Plugins/Extensions/MediaScanner/plugin.py +++ b/lib/python/Plugins/Extensions/MediaScanner/plugin.py @@ -45,9 +45,6 @@ def scan(session): for x in parts: if not access(x[1], F_OK|R_OK): parts.remove(x) - for x in parts: # first run sometimes skips an entry - if not access(x[1], F_OK|R_OK): - parts.remove(x) session.openWithCallback(mountpoint_choosen, ChoiceBox, title = _("Please Select Medium to be Scanned"), list = parts) def main(session, **kwargs): -- cgit v1.2.3 From 7da4f25976773b0e1f8a06c13f2455c4bdb88349 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 11:44:58 +0100 Subject: Revert "really only show accessible devices" This reverts commit 8530482b1d58468eade8ae2cfd618c694bef75d2. --- configure.ac | 2 +- lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- .../SystemPlugins/SoftwareUpdate/.cvsignore | 4 - .../SystemPlugins/SoftwareUpdate/Makefile.am | 8 - .../SystemPlugins/SoftwareUpdate/__init__.py | 0 .../Plugins/SystemPlugins/SoftwareUpdate/plugin.py | 360 --------------------- .../SystemPlugins/SoftwareUpdate/update.png | Bin 3630 -> 0 bytes po/Makefile.am | 1 + 8 files changed, 3 insertions(+), 374 deletions(-) delete mode 100644 lib/python/Plugins/SystemPlugins/SoftwareUpdate/.cvsignore delete mode 100644 lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am delete mode 100644 lib/python/Plugins/SystemPlugins/SoftwareUpdate/__init__.py delete mode 100644 lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py delete mode 100644 lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png mode change 100644 => 100755 po/Makefile.am (limited to 'lib/python') diff --git a/configure.ac b/configure.ac index 89ab3f06..b94272d9 100755 --- a/configure.ac +++ b/configure.ac @@ -108,7 +108,7 @@ lib/python/Components/Sources/Makefile lib/python/Screens/Makefile lib/python/Plugins/Makefile lib/python/Plugins/SystemPlugins/Makefile -lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile +lib/python/Plugins/SystemPlugins/SoftwareManager/Makefile lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile lib/python/Plugins/SystemPlugins/PositionerSetup/Makefile lib/python/Plugins/SystemPlugins/Hotplug/Makefile diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index be12378c..10151f2c 100755 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -1 +1 @@ -SUBDIRS = SoftwareUpdate FrontprocessorUpgrade PositionerSetup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug DefaultServicesScanner NFIFlash DiseqcTester +SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug DefaultServicesScanner NFIFlash DiseqcTester diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/.cvsignore b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/.cvsignore deleted file mode 100644 index 138b9cc2..00000000 --- a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*.pyc -*.pyo -Makefile -Makefile.in diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am deleted file mode 100644 index 9848f3df..00000000 --- a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/SoftwareUpdate - -install_PYTHON = \ - __init__.py \ - plugin.py \ - update.png - - diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/__init__.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py deleted file mode 100644 index 8127514c..00000000 --- a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py +++ /dev/null @@ -1,360 +0,0 @@ -from Components.ActionMap import ActionMap, NumberActionMap -from Components.GUIComponent import GUIComponent -from Components.Input import Input -from Components.Ipkg import IpkgComponent -from Components.Label import Label -from Components.MenuList import MenuList -from Components.Slider import Slider -from Plugins.Plugin import PluginDescriptor -from Screens.Console import Console -from Screens.ImageWizard import ImageWizard -from Screens.MessageBox import MessageBox -from Screens.MessageBox import MessageBox -from Screens.Screen import Screen -from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont -from os import popen - - -class UpdatePluginMenu(Screen): - skin = """ - - - """ - - def __init__(self, session, args = 0): - self.skin = UpdatePluginMenu.skin - Screen.__init__(self, session) - - self.menu = args - - list = [] - if self.menu == 0: - list.append((_("Image-Upgrade"), "image")) - list.append((_("Online-Upgrade"), "upgrade")) - list.append((_("Advanced"), "advanced")) - elif self.menu == 1: - list.append((_("Choose source"), "source")) - list.append((_("Packet management"), "ipkg")) - list.append((_("Settings"), "setup")) - - self["menu"] = MenuList(list) - - self["actions"] = ActionMap(["WizardActions", "DirectionActions"], - { - "ok": self.go, - "back": self.close, - }, -1) - - def go(self): - if self.menu == 0: - if (self["menu"].l.getCurrentSelection()[1] == "image"): - self.session.open(ImageWizard) - if (self["menu"].l.getCurrentSelection()[1] == "upgrade"): - self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!")) - if (self["menu"].l.getCurrentSelection()[1] == "advanced"): - self.session.open(UpdatePluginMenu, 1) - if self.menu == 1: - if (self["menu"].l.getCurrentSelection()[1] == "source"): - self.session.open(IPKGSource) - elif (self["menu"].l.getCurrentSelection()[1] == "ipkg"): - self.session.open(Ipkg) - elif (self["menu"].l.getCurrentSelection()[1] == "setup"): - self.session.open(MessageBox, _("Function not yet implemented"), MessageBox.TYPE_ERROR) - - def runUpgrade(self, result): - if result: - self.session.open(Console, title = "Upgrade running...", cmdlist = ["ipkg update", "ipkg upgrade -force-defaults -force-overwrite"], finishedCallback = self.runFinished) - - def runFinished(self): - self.session.openWithCallback(self.reboot, MessageBox, _("Upgrade finished. Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) - - def reboot(self, result): - if result is None: - return - if result: - quitMainloop(3) - -class IPKGSource(Screen): - skin = """ - - - """ - - def __init__(self, session, args = None): - self.skin = IPKGSource.skin - Screen.__init__(self, session) - - fp = file('/etc/ipkg/official-feed.conf', 'r') - sources = fp.readlines() - fp.close() - - self["text"] = Input(sources[0], maxSize=False, type=Input.TEXT) - - self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions"], - { - "ok": self.go, - "back": self.close, - "left": self.keyLeft, - "right": self.keyRight, - "home": self.keyHome, - "end": self.keyEnd, - "deleteForward": self.deleteForward, - "deleteBackward": self.deleteBackward, - "1": self.keyNumberGlobal, - "2": self.keyNumberGlobal, - "3": self.keyNumberGlobal, - "4": self.keyNumberGlobal, - "5": self.keyNumberGlobal, - "6": self.keyNumberGlobal, - "7": self.keyNumberGlobal, - "8": self.keyNumberGlobal, - "9": self.keyNumberGlobal, - "0": self.keyNumberGlobal - }, -1) - - def go(self): - fp = file('/etc/ipkg/official-feed.conf', 'w') - fp.write(self["text"].getText()) - fp.close() - self.close() - - def keyLeft(self): - self["text"].left() - - def keyRight(self): - self["text"].right() - - def keyHome(self): - self["text"].home() - - def keyEnd(self): - self["text"].end() - - def keyDeleteForward(self): - self["text"].delete() - - def keyDeleteBackward(self): - self["text"].deleteBackward() - - def keyNumberGlobal(self, number): - print "pressed", number - self["text"].number(number) - -def PacketEntryComponent(packet): - res = [ packet ] - - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[0])) - res.append((eListboxPythonMultiContent.TYPE_TEXT, 250, 0, 200, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[1])) - res.append((eListboxPythonMultiContent.TYPE_TEXT, 450, 0, 100, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[2])) - return res - -class PacketList(GUIComponent): - def __init__(self, list): - GUIComponent.__init__(self) - self.l = eListboxPythonMultiContent() - self.l.setList(list) - self.l.setFont(0, gFont("Regular", 20)) - self.l.setFont(1, gFont("Regular", 18)) - - def getCurrent(self): - return self.l.getCurrentSelection() - - def GUIcreate(self, parent): - self.instance = eListbox(parent) - self.instance.setContent(self.l) - self.instance.setItemHeight(30) - - def GUIdelete(self): - self.instance.setContent(None) - self.instance = None - - def invalidate(self): - self.l.invalidate() - -class Ipkg2(Screen): - skin = """ - - - """ - - def __init__(self, session, args = None): - self.skin = Ipkg.skin - Screen.__init__(self, session) - - list = [] - self.list = list - self.fillPacketList() - - self["list"] = PacketList(self.list) - - self["actions"] = ActionMap(["WizardActions"], - { - "ok": self.close, - "back": self.close - }, -1) - - - def fillPacketList(self): - lines = popen("ipkg list", "r").readlines() - packetlist = [] - for x in lines: - split = x.split(' - ') - packetlist.append([split[0].strip(), split[1].strip()]) - - lines = popen("ipkg list_installed", "r").readlines() - - installedlist = {} - for x in lines: - split = x.split(' - ') - installedlist[split[0].strip()] = split[1].strip() - - for x in packetlist: - status = "" - if installedlist.has_key(x[0]): - if installedlist[x[0]] == x[1]: - status = "installed" - else: - status = "upgradable" - self.list.append(PacketEntryComponent([x[0], x[1], status])) - - def go(self): - if self.update: - self.session.openWithCallback(self.doUpdate, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!")) - else: - self.close() - - def doUpdateDelay(self): - lines = popen("ipkg update && ipkg upgrade", "r").readlines() - string = "" - for x in lines: - string += x - self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string) - self.update = False - - - def doUpdate(self, val = False): - if val == True: - self["text"].setText(_("Updating... Please wait... This can take some minutes...")) - self.delayTimer.start(0, 1) - else: - self.close() - -class UpdatePlugin(Screen): - skin = """ - - - - - - """ - - def __init__(self, session, args = None): - self.skin = UpdatePlugin.skin - Screen.__init__(self, session) - - self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 } - - self.slider = Slider(0, 4) - self["slider"] = self.slider - self.activityslider = Slider(0, 100) - self["activityslider"] = self.activityslider - self.status = Label(_("Upgrading Dreambox... Please wait")) - self["status"] = self.status - self.package = Label() - self["package"] = self.package - - self.packages = 0 - self.error = 0 - - self.activity = 0 - self.activityTimer = eTimer() - self.activityTimer.callback.append(self.doActivityTimer) - self.activityTimer.start(100, False) - - self.ipkg = IpkgComponent() - self.ipkg.addCallback(self.ipkgCallback) - - self.updating = True - self.package.setText(_("Package list update")) - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - - self["actions"] = ActionMap(["WizardActions"], - { - "ok": self.exit, - "back": self.exit - }, -1) - - def doActivityTimer(self): - self.activity += 1 - if self.activity == 100: - self.activity = 0 - self.activityslider.setValue(self.activity) - - def ipkgCallback(self, event, param): - if event == IpkgComponent.EVENT_DOWNLOAD: - self.status.setText(_("Downloading")) - elif event == IpkgComponent.EVENT_UPGRADE: - if self.sliderPackages.has_key(param): - self.slider.setValue(self.sliderPackages[param]) - self.package.setText(param) - self.status.setText(_("Upgrading")) - self.packages += 1 - elif event == IpkgComponent.EVENT_INSTALL: - self.package.setText(param) - self.status.setText(_("Installing")) - self.packages += 1 - elif event == IpkgComponent.EVENT_CONFIGURING: - self.package.setText(param) - self.status.setText(_("Configuring")) - elif event == IpkgComponent.EVENT_MODIFIED: - self.session.openWithCallback( - self.modificationCallback, - MessageBox, - _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param) - ) - elif event == IpkgComponent.EVENT_ERROR: - self.error += 1 - elif event == IpkgComponent.EVENT_DONE: - if self.updating: - self.updating = False - self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False}) - elif self.error == 0: - self.slider.setValue(4) - - self.activityTimer.stop() - self.activityslider.setValue(0) - - self.package.setText("") - self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages) - else: - self.activityTimer.stop() - self.activityslider.setValue(0) - error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.") - if self.packages == 0: - error = _("No packages were upgraded yet. So you can check your network and try again.") - if self.updating: - error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.") - self.status.setText(_("Error") + " - " + error) - #print event, "-", param - pass - - def modificationCallback(self, res): - self.ipkg.write(res and "N" or "Y") - - def exit(self): - if not self.ipkg.isRunning(): - if self.packages != 0 and self.error == 0: - self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished. Do you want to reboot your Dreambox?")) - else: - self.close() - - def exitAnswer(self, result): - if result is not None and result: - quitMainloop(2) - self.close() - -def UpgradeMain(session, **kwargs): - session.open(UpdatePlugin) - -def Plugins(**kwargs): - return PluginDescriptor(name="Softwareupdate", description=_("Updates your receiver's software"), icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain) diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png deleted file mode 100644 index 0ece6c76..00000000 Binary files a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png and /dev/null differ diff --git a/po/Makefile.am b/po/Makefile.am old mode 100644 new mode 100755 index 26518b56..986f0ae4 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -30,6 +30,7 @@ enigma2.pot: ./xml2po.py ../data/ >> enigma2.pot ./xml2po.py ../lib/python/Plugins/SystemPlugins/Videomode/ >> enigma2.pot + ./xml2po.py ../lib/python/Plugins/SystemPlugins/SoftwareManager/ >> enigma2.pot msguniq -o enigma2uniq.pot enigma2.pot $(RM) enigma2.pot mv enigma2uniq.pot enigma2.pot -- cgit v1.2.3 From 95fa0e8c06f26bc2c4d3b5ab6afc772cd991e9dc Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 11:47:46 +0100 Subject: add SoftwareManager and show it inside Setup Menu --- .../SystemPlugins/SoftwareManager/.cvsignore | 4 + .../SystemPlugins/SoftwareManager/BackupRestore.py | 313 +++++++++ .../SystemPlugins/SoftwareManager/ImageWizard.py | 120 ++++ .../Plugins/SystemPlugins/SoftwareManager/LICENSE | 17 + .../SystemPlugins/SoftwareManager/Makefile.am | 12 + .../SystemPlugins/SoftwareManager/__init__.py | 0 .../Plugins/SystemPlugins/SoftwareManager/blue.png | Bin 0 -> 3495 bytes .../SystemPlugins/SoftwareManager/green.png | Bin 0 -> 3454 bytes .../SystemPlugins/SoftwareManager/imagewizard.xml | 100 +++ .../SystemPlugins/SoftwareManager/installable.png | Bin 0 -> 2272 bytes .../SystemPlugins/SoftwareManager/installed.png | Bin 0 -> 2225 bytes .../SystemPlugins/SoftwareManager/plugin.py | 728 +++++++++++++++++++++ .../Plugins/SystemPlugins/SoftwareManager/red.png | Bin 0 -> 3742 bytes .../SystemPlugins/SoftwareManager/update.png | Bin 0 -> 3630 bytes .../SystemPlugins/SoftwareManager/upgradeable.png | Bin 0 -> 2094 bytes .../SystemPlugins/SoftwareManager/yellow.png | Bin 0 -> 3732 bytes 16 files changed, 1294 insertions(+) create mode 100644 lib/python/Plugins/SystemPlugins/SoftwareManager/.cvsignore create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/LICENSE create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/Makefile.am create mode 100644 lib/python/Plugins/SystemPlugins/SoftwareManager/__init__.py create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/blue.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/green.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/imagewizard.xml create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/installable.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/installed.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/red.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/update.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/upgradeable.png create mode 100755 lib/python/Plugins/SystemPlugins/SoftwareManager/yellow.png (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/.cvsignore b/lib/python/Plugins/SystemPlugins/SoftwareManager/.cvsignore new file mode 100644 index 00000000..138b9cc2 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/.cvsignore @@ -0,0 +1,4 @@ +*.pyc +*.pyo +Makefile +Makefile.in diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py new file mode 100755 index 00000000..f92472d3 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -0,0 +1,313 @@ +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Screens.Console import Console +from Components.ActionMap import ActionMap, NumberActionMap +from Components.Pixmap import Pixmap +from Components.Label import Label +from Components.MenuList import MenuList +from Components.config import getConfigListEntry, configfile, ConfigSelection, ConfigSubsection, ConfigText, ConfigLocations +from Components.config import config +from Components.ConfigList import ConfigList,ConfigListScreen +from Components.FileList import MultiFileSelectList +from Plugins.Plugin import PluginDescriptor +from enigma import eTimer +from Tools.Directories import * +from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK +from time import gmtime, strftime, localtime +from datetime import date + + +config.plugins.configurationbackup = ConfigSubsection() +config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf']) + +def getBackupPath(): + backuppath = config.plugins.configurationbackup.backuplocation.value + if backuppath.endswith('/'): + return backuppath + 'backup' + else: + return backuppath + '/backup' + +def getBackupFilename(): + return "enigma2settingsbackup.tar.gz" + + +class BackupScreen(Screen, ConfigListScreen): + skin = """ + + + """ + + def __init__(self, session, runBackup = False): + Screen.__init__(self, session) + self.session = session + self.runBackup = runBackup + self["actions"] = ActionMap(["WizardActions", "DirectionActions"], + { + "ok": self.close, + "back": self.close, + "cancel": self.close, + }, -1) + self.finished_cb = None + self.backuppath = getBackupPath() + self.backupfile = getBackupFilename() + self.fullbackupfilename = self.backuppath + "/" + self.backupfile + self.list = [] + ConfigListScreen.__init__(self, self.list) + self.onLayoutFinish.append(self.layoutFinished) + if self.runBackup: + self.onShown.append(self.doBackup) + + def layoutFinished(self): + self.setWindowTitle() + + def setWindowTitle(self): + self.setTitle(_("Backup running...")) + + def doBackup(self): + try: + if (path.exists(self.backuppath) == False): + makedirs(self.backuppath) + self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) + if path.exists(self.fullbackupfilename): + dt = str(date.fromtimestamp(stat(self.fullbackupfilename).st_ctime)) + self.newfilename = self.backuppath + "/" + dt + '-' + self.backupfile + if path.exists(self.newfilename): + remove(self.newfilename) + rename(self.fullbackupfilename,self.newfilename) + if self.finished_cb: + self.session.openWithCallback(self.finished_cb, Console, title = _("Backup running"), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB,closeOnSuccess = True) + else: + self.session.open(Console, title = _("Backup running"), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB, closeOnSuccess = True) + except OSError: + if self.finished_cb: + self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry your backup destination is not writeable.\nPlease choose an other one."), MessageBox.TYPE_INFO) + else: + self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry your backup destination is not writeable.\nPlease choose an other one."), MessageBox.TYPE_INFO) + + def backupFinishedCB(self,retval = None): + self.close(True) + + def backupErrorCB(self,retval = None): + self.close(False) + + def runAsync(self, finished_cb): + self.finished_cb = finished_cb + self.doBackup() + + +class BackupSelection(Screen): + skin = """ + + + + + + + + + """ + + def __init__(self, session): + Screen.__init__(self, session) + self.skin_path = plugin_path + self["key_red"] = Label(_("Cancel")) + self["key_green"] = Label(_("Save")) + self["key_yellow"] = Label() + + self.selectedFiles = config.plugins.configurationbackup.backupdirs.value + defaultDir = '/' + inhibitDirs = ["/bin", "/boot", "/dev", "/autofs", "/lib", "/proc", "/sbin", "/sys", "/hdd", "/tmp", "/mnt", "/media"] + self.filelist = MultiFileSelectList(self.selectedFiles, defaultDir, inhibitDirs = inhibitDirs ) + self["checkList"] = self.filelist + + self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ShortcutActions"], + { + "cancel": self.exit, + "red": self.exit, + "yellow": self.changeSelectionState, + "green": self.saveSelection, + "ok": self.okClicked, + "left": self.left, + "right": self.right, + "down": self.down, + "up": self.up + }, -1) + if not self.selectionChanged in self["checkList"].onSelectionChanged: + self["checkList"].onSelectionChanged.append(self.selectionChanged) + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + idx = 0 + self["checkList"].moveToIndex(idx) + self.setWindowTitle() + self.selectionChanged() + + def setWindowTitle(self): + self.setTitle(_("Select files/folders to backup...")) + + def selectionChanged(self): + current = self["checkList"].getCurrent()[0] + if current[2] is True: + self["key_yellow"].setText(_("Deselect")) + else: + self["key_yellow"].setText(_("Select")) + + def up(self): + self["checkList"].up() + + def down(self): + self["checkList"].down() + + def left(self): + self["checkList"].pageUp() + + def right(self): + self["checkList"].pageDown() + + def changeSelectionState(self): + self["checkList"].changeSelectionState() + self.selectedFiles = self["checkList"].getSelectedList() + + def saveSelection(self): + self.selectedFiles = self["checkList"].getSelectedList() + config.plugins.configurationbackup.backupdirs.value = self.selectedFiles + config.plugins.configurationbackup.backupdirs.save() + config.plugins.configurationbackup.save() + config.save() + self.close(None) + + def exit(self): + self.close(None) + + def okClicked(self): + if self.filelist.canDescent(): + self.filelist.descent() + + +class RestoreMenu(Screen): + skin = """ + + + + + + + """ + + def __init__(self, session, plugin_path): + Screen.__init__(self, session) + self.skin_path = plugin_path + + self["canceltext"] = Label(_("Cancel")) + self["restoretext"] = Label(_("Restore")) + self["restore"] = Pixmap() + self["cancel"] = Pixmap() + + self.sel = [] + self.val = [] + self.entry = False + self.exe = False + + self.path = "" + + self["actions"] = NumberActionMap(["SetupActions"], + { + "ok": self.KeyOk, + "cancel": self.keyCancel + }, -1) + + self["shortcuts"] = ActionMap(["ShortcutActions"], + { + "red": self.keyCancel, + "yellow": self.KeyOk, + }) + self.flist = [] + self["filelist"] = MenuList(self.flist) + self.fill_list() + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setWindowTitle() + + def setWindowTitle(self): + self.setTitle(_("Restore backups...")) + + + def fill_list(self): + self.flist = [] + self.path = getBackupPath() + if (path.exists(self.path) == False): + makedirs(self.path) + for file in listdir(self.path): + if (file.endswith(".tar.gz")): + self.flist.append((file)) + self.entry = True + self["filelist"].l.setList(self.flist) + + def KeyOk(self): + if (self.exe == False) and (self.entry == True): + self.sel = self["filelist"].getCurrent() + self.val = self.path + self.sel + self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n" + self.sel + "\nSystem will restart after the restore!")) + + def keyCancel(self): + self.close() + + def startRestore(self, ret = False): + if (ret == True): + self.exe = True + self.session.open(Console, title = _("Restore running"), cmdlist = ["tar -xzvf " + self.path + "/" + self.sel + " -C /", "killall -9 enigma2"]) + + def Exit(self): + self.close() + +class RestoreScreen(Screen, ConfigListScreen): + skin = """ + + + """ + + def __init__(self, session, runRestore = False): + Screen.__init__(self, session) + self.session = session + self.runRestore = runRestore + self["actions"] = ActionMap(["WizardActions", "DirectionActions"], + { + "ok": self.close, + "back": self.close, + "cancel": self.close, + }, -1) + self.finished_cb = None + self.backuppath = getBackupPath() + self.backupfile = getBackupFilename() + self.fullbackupfilename = self.backuppath + "/" + self.backupfile + self.list = [] + ConfigListScreen.__init__(self, self.list) + self.onLayoutFinish.append(self.layoutFinished) + if self.runRestore: + self.onShown.append(self.doRestore) + + def layoutFinished(self): + self.setWindowTitle() + + def setWindowTitle(self): + self.setTitle(_("Restore running...")) + + def doRestore(self): + if self.finished_cb: + self.session.openWithCallback(self.finished_cb, Console, title = _("Restore running"), cmdlist = ["tar -xzvf " + self.fullbackupfilename + " -C /", "killall -9 enigma2"]) + else: + self.session.open(Console, title = _("Restore running"), cmdlist = ["tar -xzvf " + self.fullbackupfilename + " -C /", "killall -9 enigma2"]) + + def backupFinishedCB(self,retval = None): + self.close(True) + + def backupErrorCB(self,retval = None): + self.close(False) + + def runAsync(self, finished_cb): + self.finished_cb = finished_cb + self.doRestore() + + \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py new file mode 100755 index 00000000..1797e4fe --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py @@ -0,0 +1,120 @@ +from Screens.Wizard import WizardSummary +from Screens.WizardLanguage import WizardLanguage +from Screens.Wizard import wizardManager +from Screens.Rc import Rc +from Components.Label import Label +from Components.MenuList import MenuList +from Components.PluginComponent import plugins +from Plugins.Plugin import PluginDescriptor +from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE +from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap +from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK + +from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations, ConfigBoolean +from Components.Harddisk import harddiskmanager +config.misc.firstrun = ConfigBoolean(default = True) +config.plugins.configurationbackup = ConfigSubsection() +config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf']) + + +backupfile = "enigma2settingsbackup.tar.gz" + +def checkConfigBackup(): + parts = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] + for x in parts: + if x[1] == '/': + parts.remove(x) + if len(parts): + for x in parts: + if x[1].endswith('/'): + fullbackupfile = x[1] + 'backup/' + backupfile + if fileExists(fullbackupfile): + config.plugins.configurationbackup.backuplocation.value = str(x[1]) + config.plugins.configurationbackup.backuplocation.save() + config.plugins.configurationbackup.save() + return x + else: + fullbackupfile = x[1] + '/backup/' + backupfile + if fileExists(fullbackupfile): + config.plugins.configurationbackup.backuplocation.value = str(x[1]) + config.plugins.configurationbackup.backuplocation.save() + config.plugins.configurationbackup.save() + return x + return None + +def checkBackupFile(): + backuplocation = config.plugins.configurationbackup.backuplocation.value + if backuplocation.endswith('/'): + fullbackupfile = backuplocation + 'backup/' + backupfile + if fileExists(fullbackupfile): + return True + else: + return False + else: + fullbackupfile = backuplocation + '/backup/' + backupfile + if fileExists(fullbackupfile): + return True + else: + return False + +if checkConfigBackup() is None: + backupAvailable = 0 +else: + backupAvailable = 1 + +class ImageWizard(WizardLanguage, Rc): + skin = """ + + + + + + + + + + + + + + + """ + def __init__(self, session): + self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/imagewizard.xml") + WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False) + Rc.__init__(self) + self.session = session + self["wizard"] = Pixmap() + self.selectedDevice = None + + def markDone(self): + pass + + def listDevices(self): + list = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] + for x in list: + result = access(x[1], W_OK) and access(x[1], R_OK) + if result is False or x[1] == '/': + list.remove(x) + for x in list: + if x[1].startswith('/autofs/'): + list.remove(x) + return list + + def deviceSelectionMade(self, index): + self.deviceSelect(index) + + def deviceSelectionMoved(self): + self.deviceSelect(self.selection) + + def deviceSelect(self, device): + self.selectedDevice = device + config.plugins.configurationbackup.backuplocation.value = self.selectedDevice + config.plugins.configurationbackup.backuplocation.save() + config.plugins.configurationbackup.save() + + +if config.misc.firstrun.value: + wizardManager.registerWizard(ImageWizard, backupAvailable, priority = 10) + diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/LICENSE b/lib/python/Plugins/SystemPlugins/SoftwareManager/LICENSE new file mode 100755 index 00000000..835b9dc6 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/LICENSE @@ -0,0 +1,17 @@ +This plugin is licensed under the Creative Commons +Attribution-NonCommercial-ShareAlike 3.0 Unported +License. To view a copy of this license, visit +http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative +Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + +Alternatively, this plugin may be distributed and executed on hardware which +is licensed by Dream Multimedia GmbH. + +This plugin is NOT free software. It is open source, you are allowed to +modify it (if you keep the license), but it may not be commercially +distributed other than under the conditions noted above. + +Some Icons used are taken from NX10 icons by Mazenl77 +(http://www.iconspedia.com/pack/nx10-1-6/) +licensed under Creative Commons Attribution 3.0 Unported +http://creativecommons.org/licenses/by/3.0/ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/Makefile.am b/lib/python/Plugins/SystemPlugins/SoftwareManager/Makefile.am new file mode 100755 index 00000000..f94498f5 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/Makefile.am @@ -0,0 +1,12 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/SoftwareManager + +install_PYTHON = \ + __init__.py \ + plugin.py \ + BackupRestore.py \ + ImageWizard.py \ + imagewizard.xml \ + *.png + +install_DATA = LICENSE + diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/__init__.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/blue.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/blue.png new file mode 100755 index 00000000..a392bbe6 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/blue.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/green.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/green.png new file mode 100755 index 00000000..f168e4d0 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/green.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/imagewizard.xml b/lib/python/Plugins/SystemPlugins/SoftwareManager/imagewizard.xml new file mode 100755 index 00000000..98658b7d --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/imagewizard.xml @@ -0,0 +1,100 @@ + + + +from Plugins.SystemPlugins.SoftwareManager.ImageWizard import checkConfigBackup +self.backuppath = checkConfigBackup() +self.condition = (self.backuppath is not None and config.misc.firstrun.value) + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") + + + + + + + + + + + + + + + + + + + + + + + + + + + + +self.currStep = self.getStepWithID('backupresult') +self.afterAsyncCode() + + + + + +from Plugins.SystemPlugins.SoftwareManager.ImageWizard import checkBackupFile +self.backuppath = checkBackupFile() +self.condition = (self.backuppath is True) + + + + + + +from Plugins.SystemPlugins.SoftwareManager.ImageWizard import checkBackupFile +self.backuppath = checkBackupFile() +self.condition = (self.backuppath is False) + + + + + + + + + + + + + + + + + + + + + + + + + + + + +from enigma import quitMainloop +quitMainloop(1) + + + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/installable.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/installable.png new file mode 100755 index 00000000..710f4201 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/installable.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/installed.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/installed.png new file mode 100755 index 00000000..d6a1bc10 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/installed.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py new file mode 100755 index 00000000..1835a2ed --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -0,0 +1,728 @@ +from Plugins.Plugin import PluginDescriptor +from Screens.Console import Console +from Screens.ChoiceBox import ChoiceBox +from Screens.MessageBox import MessageBox +from Screens.Screen import Screen +from Screens.Ipkg import Ipkg +from Components.ActionMap import ActionMap, NumberActionMap +from Components.Input import Input +from Components.Ipkg import IpkgComponent +from Components.Label import Label +from Components.MenuList import MenuList +from Components.Sources.List import List +from Components.Slider import Slider +from Components.Harddisk import harddiskmanager +from Components.config import config,getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations +from Components.Console import Console +from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest +from Components.SelectionList import SelectionList +from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE +from Tools.LoadPixmap import LoadPixmap +from enigma import eTimer, loadPNG, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont +from cPickle import dump, load + +from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK +from time import time, gmtime, strftime, localtime +from stat import ST_MTIME +from datetime import date + +from ImageWizard import ImageWizard +from BackupRestore import BackupSelection, RestoreMenu, BackupScreen, RestoreScreen, getBackupPath, getBackupFilename + +config.plugins.configurationbackup = ConfigSubsection() +config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf']) + + +def write_cache(cache_file, cache_data): + #Does a cPickle dump + if not os_path.isdir( os_path.dirname(cache_file) ): + try: + mkdir( os_path.dirname(cache_file) ) + except OSError: + print os_path.dirname(cache_file), 'is a file' + fd = open(cache_file, 'w') + dump(cache_data, fd, -1) + fd.close() + +def valid_cache(cache_file, cache_ttl): + #See if the cache file exists and is still living + try: + mtime = stat(cache_file)[ST_MTIME] + except: + return 0 + curr_time = time() + if (curr_time - mtime) > cache_ttl: + return 0 + else: + return 1 + +def load_cache(cache_file): + #Does a cPickle load + fd = open(cache_file) + cache_data = load(fd) + fd.close() + return cache_data + + +class UpdatePluginMenu(Screen): + skin = """ + + + + + {"template": [ + MultiContentEntryText(pos = (2, 2), size = (230, 22), flags = RT_HALIGN_LEFT, text = 1), # index 0 is the MenuText, + ], + "fonts": [gFont("Regular", 20)], + "itemHeight": 25 + } + + + + """ + + def __init__(self, session, args = 0): + Screen.__init__(self, session) + self.skin_path = plugin_path + self.menu = args + self.list = [] + self.oktext = _("\nPress OK on your remote control to continue.") + self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) + if self.menu == 0: + self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext) ) + self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext)) + self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext)) + self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext)) + if config.usage.setup_level.index >= 2: # expert+ + self.list.append(("advanced", _("Advanced Options"), _("\nAdvanced options and settings." ) + self.oktext)) + elif self.menu == 1: + self.list.append(("ipkg-manager", _("Packet management"), _("\nView, install and remove available or installed packages." ) + self.oktext)) + self.list.append(("ipkg-install", _("Install local IPKG"), _("\nScan for local packages and install them." ) + self.oktext)) + self.list.append(("advancedrestore", _("Advanced restore"), _("\nRestore your backups by date." ) + self.oktext)) + self.list.append(("backuplocation", _("Choose backup location"), _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext )) + self.list.append(("backupfiles", _("Choose backup files"), _("Select files for backup. Currently selected:\n" ) + self.backupdirs + self.oktext)) + self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext)) + + self["menu"] = List(self.list) + self["menu"].onSelectionChanged.append(self.selectionChanged) + self["description"] = Label() + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "ok": self.go, + "back": self.close, + "red": self.close, + }, -1) + + self.onLayoutFinish.append(self.layoutFinished) + self.backuppath = getBackupPath() + self.backupfile = getBackupFilename() + self.fullbackupfilename = self.backuppath + "/" + self.backupfile + self.onShown.append(self.setWindowTitle) + + def layoutFinished(self): + idx = 0 + self["menu"].index = idx + self.loadDescription() + + def setWindowTitle(self): + self.setTitle(_("Software manager...")) + + def loadDescription(self): + if self["menu"].getCurrent()[0] == 'software-update': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'software-restore': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'ipkg-install': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'system-backup': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'system-restore': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'advanced': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'ipkg-source': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'ipkg-manager': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'advancedrestore': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'backuplocation': + self["description"].setText(self["menu"].getCurrent()[2] ) + if self["menu"].getCurrent()[0] == 'backupfiles': + self["description"].setText(self["menu"].getCurrent()[2] ) + + def go(self): + if self.menu == 0: + if (self["menu"].getCurrent()[0] == "software-restore"): + self.session.open(ImageWizard) + if (self["menu"].getCurrent()[0] == "software-update"): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!")) + if (self["menu"].getCurrent()[0] == "advanced"): + self.session.open(UpdatePluginMenu, 1) + if (self["menu"].getCurrent()[0] == "system-backup"): + self.session.openWithCallback(self.backupDone,BackupScreen, runBackup = True) + if (self["menu"].getCurrent()[0] == "system-restore"): + if os_path.exists(self.fullbackupfilename): + self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore your Enigma2 backup?\nEnigma2 will restart after the restore")) + else: + self.session.open(MessageBox, _("Sorry no backups found!"), MessageBox.TYPE_INFO) + if self.menu == 1: + if (self["menu"].getCurrent()[0] == "ipkg-manager"): + self.session.open(PacketManager, self.skin_path) + if (self["menu"].getCurrent()[0] == "ipkg-source"): + self.session.open(IPKGSource) + if (self["menu"].getCurrent()[0] == "ipkg-install"): + try: + from Plugins.Extensions.MediaScanner.plugin import main + main(self.session) + except: + self.session.open(MessageBox, _("Sorry MediaScanner is not installed!"), MessageBox.TYPE_INFO) + if (self["menu"].getCurrent()[0] == "backuplocation"): + parts = [ (r.description, r.mountpoint, self.session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] + for x in parts: + if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/': + parts.remove(x) + for x in parts: + if x[1].startswith('/autofs/'): + parts.remove(x) + if len(parts): + self.session.openWithCallback(self.backuplocation_choosen, ChoiceBox, title = _("Please select medium to use as backup location"), list = parts) + if (self["menu"].getCurrent()[0] == "backupfiles"): + self.session.openWithCallback(self.backupfiles_choosen,BackupSelection) + if (self["menu"].getCurrent()[0] == "advancedrestore"): + self.session.open(RestoreMenu, self.skin_path) + + def selectionChanged(self): + self.loadDescription() + + def backupfiles_choosen(self, ret): + self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) + self.loadDescription() + + def backuplocation_choosen(self, option): + if option is not None: + config.plugins.configurationbackup.backuplocation.value = str(option[1]) + config.plugins.configurationbackup.backuplocation.save() + config.plugins.configurationbackup.save() + config.save() + self.createBackupfolders() + self.loadDescription() + + def runUpgrade(self, result): + if result: + self.session.openWithCallback(self.runFinished,UpdatePlugin, self.skin_path) + + def runFinished(self): + self.session.openWithCallback(self.reboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def reboot(self, result): + if result is None: + return + if result: + quitMainloop(3) + + def createBackupfolders(self): + print "Creating backup folder if not already there..." + self.backuppath = getBackupPath() + try: + if (os_path.exists(self.backuppath) == False): + makedirs(self.backuppath) + except OSError: + self.session.open(MessageBox, _("Sorry, your backup destination is not writeable.\n\nPlease choose another one."), MessageBox.TYPE_INFO) + + def backupDone(self,retval = None): + if retval is True: + self.session.open(MessageBox, _("Backup done."), MessageBox.TYPE_INFO) + else: + self.session.open(MessageBox, _("Backup failed."), MessageBox.TYPE_INFO) + + def startRestore(self, ret = False): + if (ret == True): + self.exe = True + self.session.open(RestoreScreen, runRestore = True) + + +class IPKGSource(Screen): + skin = """ + + + """ + + def __init__(self, session, args = None): + Screen.__init__(self, session) + self.session = session + + fp = file('/etc/ipkg/official-feed.conf', 'r') + sources = fp.readlines() + fp.close() + + self["text"] = Input(sources[0], maxSize=False, type=Input.TEXT) + + self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions"], + { + "ok": self.go, + "back": self.close, + "left": self.keyLeft, + "right": self.keyRight, + "home": self.keyHome, + "end": self.keyEnd, + "deleteForward": self.keyDeleteForward, + "deleteBackward": self.keyDeleteBackward, + "1": self.keyNumberGlobal, + "2": self.keyNumberGlobal, + "3": self.keyNumberGlobal, + "4": self.keyNumberGlobal, + "5": self.keyNumberGlobal, + "6": self.keyNumberGlobal, + "7": self.keyNumberGlobal, + "8": self.keyNumberGlobal, + "9": self.keyNumberGlobal, + "0": self.keyNumberGlobal + }, -1) + + def go(self): + fp = file('/etc/ipkg/official-feed.conf', 'w') + fp.write(self["text"].getText()) + fp.close() + self.close() + + def keyLeft(self): + self["text"].left() + + def keyRight(self): + self["text"].right() + + def keyHome(self): + self["text"].home() + + def keyEnd(self): + self["text"].end() + + def keyDeleteForward(self): + self["text"].delete() + + def keyDeleteBackward(self): + self["text"].deleteBackward() + + def keyNumberGlobal(self, number): + print "pressed", number + self["text"].number(number) + + +class PacketList(MenuList): + def __init__(self, list, enableWrapAround=True): + MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent) + self.l.setFont(0, gFont("Regular", 22)) + self.l.setFont(1, gFont("Regular", 14)) + self.l.setItemHeight(52) + +class PacketManager(Screen): + skin = """ + + + + + + + + """ + + def __init__(self, session, plugin_path, args = None): + Screen.__init__(self, session) + self.session = session + self.skin_path = plugin_path + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "ok": self.go, + "back": self.close, + "red": self.close, + "green": self.reload, + }, -1) + + self.list = [] + self["list"] = PacketList(self.list) + self.status = Label() + self["closetext"] = Label(_("Close")) + self["reloadtext"] = Label(_("Reload")) + self["status"] = self.status + + self.list_updating = True + self.packetlist = [] + self.installed_packetlist = {} + self.Console = Console() + self.cmdList = [] + self.cachelist = [] + self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid (24h should be ok for caching ipkgs) + self.cache_file = '/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache' #Path to cache directory + self.oktext = _("\nAfter pressing OK, please wait!") + + self.ipkg = IpkgComponent() + self.ipkg.addCallback(self.ipkgCallback) + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) + self.onClose.append(self.cleanup) + + def cleanup(self): + self.ipkg.stop() + if self.Console is not None: + del self.Console + + def reload(self): + if (os_path.exists(self.cache_file) == True): + remove(self.cache_file) + self.list_updating = True + self.rebuildList() + + def setWindowTitle(self): + self.setTitle(_("Packet manager")) + + def rebuildList(self): + self["list"].instance.hide() + self.status.setText(_("Package list update")) + self.status.show() + self.inv_cache = 0 + self.vc = valid_cache(self.cache_file, self.cache_ttl) + if self.cache_ttl > 0 and self.vc != 0: + try: + self.buildPacketList() + except: + self.inv_cache = 1 + if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0: + self.run = 0 + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + + def go(self, returnValue = None): + returnValue = self['list'].l.getCurrentSelection()[0] + self.cmdList = [] + if returnValue[3] == 'installed': + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": returnValue[0] })) + if len(self.cmdList): + self.session.openWithCallback(self.runRemove, MessageBox, _("Do you want to remove the package:\n" + returnValue[0] + "\n" + self.oktext)) + elif returnValue[3] == 'upgradeable': + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": returnValue[0] })) + if len(self.cmdList): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to upgrade the package:\n" + returnValue[0] + "\n" + self.oktext)) + else: + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": returnValue[0] })) + if len(self.cmdList): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to install the package:\n" + returnValue[0] + "\n" + self.oktext)) + + def runRemove(self, result): + if result: + self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList) + + def runRemoveFinished(self): + self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def RemoveReboot(self, result): + if result is None: + return + if result is False: + entry = self['list'].l.getCurrentSelection()[0] + item = self['list'].l.getCurrentSelectionIndex() + self.list[item] = PacketEntryComponent([entry[0], entry[1], entry[2], 'installable']) + self.cachelist[item] = [entry[0], entry[1], entry[2], 'installable'] + self['list'].l.setList(self.list) + write_cache(self.cache_file, self.cachelist) + if result: + quitMainloop(3) + + def runUpgrade(self, result): + if result: + self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList) + + def runUpgradeFinished(self): + self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def UpgradeReboot(self, result): + if result is None: + return + if result is False: + entry = self['list'].l.getCurrentSelection()[0] + item = self['list'].l.getCurrentSelectionIndex() + self.list[item] = PacketEntryComponent([entry[0], entry[1], entry[2], 'installed']) + self.cachelist[item] = [entry[0], entry[1], entry[2], 'installed'] + self['list'].l.setList(self.list) + write_cache(self.cache_file, self.cachelist) + if result: + quitMainloop(3) + + def ipkgCallback(self, event, param): + if event == IpkgComponent.EVENT_ERROR: + self.list_updating = False + self.status.setText(_("An error occured!")) + elif event == IpkgComponent.EVENT_DONE: + if self.list_updating: + self.list_updating = False + if not self.Console: + self.Console = Console() + cmd = "ipkg list" + self.Console.ePopen(cmd, self.IpkgList_Finished) + #print event, "-", param + pass + + def IpkgList_Finished(self, result, retval, extra_args = None): + if len(result): + self.packetlist = [] + for x in result.splitlines(): + split = x.split(' - ') + self.packetlist.append([split[0].strip(), split[1].strip(),split[2].strip()]) + cmd = "ipkg list_installed" + self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) + + def IpkgListInstalled_Finished(self, result, retval, extra_args = None): + if len(result): + self.installed_packetlist = {} + for x in result.splitlines(): + split = x.split(' - ') + self.installed_packetlist[split[0].strip()] = split[1].strip() + self.buildPacketList() + + def PacketEntryComponent(self,entry): + res = [ entry ] + res.append(MultiContentEntryText(pos=(5, 1), size=(440, 28), font=0, text= entry[0])) + res.append(MultiContentEntryText(pos=(5, 26), size=(440, 20), font=1, text=entry[2])) + res.append(MultiContentEntryPixmapAlphaTest(pos=(445, 2), size=(48, 48), png = entry[4])) + res.append(MultiContentEntryPixmapAlphaTest(pos=(5, 50), size=(510, 2), png = entry[5])) + + return res + + + def buildPacketList(self): + self.list = [] + self.cachelist = [] + installedpng = loadPNG(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installed.png")) + upgradeablepng = loadPNG(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/upgradeable.png")) + installablepng = loadPNG(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installable.png")) + divpng = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) + + if self.cache_ttl > 0 and self.vc != 0: + print 'Loading packagelist cache from ',self.cache_file + try: + self.cachelist = load_cache(self.cache_file) + if len(self.cachelist) > 0: + for x in self.cachelist: + if x[3] == 'installed': + self.list.append(self.PacketEntryComponent([x[0], x[1], x[2], x[3],installedpng,divpng])) + elif x[3] == 'upgradeable': + self.list.append(self.PacketEntryComponent([x[0], x[1], x[2], x[3],upgradeablepng,divpng])) + else: + self.list.append(self.PacketEntryComponent([x[0], x[1], x[2], x[3],installablepng,divpng])) + self['list'].l.setList(self.list) + self["list"].instance.show() + self.status.hide() + except: + self.inv_cache = 1 + + if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0: + print 'rebuilding fresh package list' + for x in self.packetlist: + status = "" + if self.installed_packetlist.has_key(x[0].strip()): + if self.installed_packetlist[x[0].strip()] == x[1].strip(): + status = "installed" + self.list.append(self.PacketEntryComponent([x[0].strip(), x[1].strip(), x[2].strip(), status,installedpng,divpng])) + else: + status = "upgradeable" + self.list.append(self.PacketEntryComponent([x[0].strip(), x[1].strip(), x[2].strip(), status,upgradeablepng,divpng])) + else: + status = "installable" + self.list.append(self.PacketEntryComponent([x[0].strip(), x[1].strip(), x[2].strip(), status,installablepng,divpng])) + self.cachelist.append([x[0].strip(), x[1].strip(), x[2].strip(), status]) + write_cache(self.cache_file, self.cachelist) + self['list'].l.setList(self.list) + self["list"].instance.show() + self.status.hide() + + +class UpdatePlugin(Screen): + skin = """ + + + + + + """ + + def __init__(self, session, args = None): + self.skin = UpdatePlugin.skin + Screen.__init__(self, session) + + self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 } + + self.slider = Slider(0, 4) + self["slider"] = self.slider + self.activityslider = Slider(0, 100) + self["activityslider"] = self.activityslider + self.status = Label(_("Upgrading Dreambox... Please wait")) + self["status"] = self.status + self.package = Label() + self["package"] = self.package + + self.packages = 0 + self.error = 0 + + self.activity = 0 + self.activityTimer = eTimer() + self.activityTimer.callback.append(self.doActivityTimer) + self.activityTimer.start(100, False) + + self.ipkg = IpkgComponent() + self.ipkg.addCallback(self.ipkgCallback) + + self.updating = True + self.package.setText(_("Package list update")) + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.exit, + "back": self.exit + }, -1) + + def doActivityTimer(self): + self.activity += 1 + if self.activity == 100: + self.activity = 0 + self.activityslider.setValue(self.activity) + + def ipkgCallback(self, event, param): + if event == IpkgComponent.EVENT_DOWNLOAD: + self.status.setText(_("Downloading")) + elif event == IpkgComponent.EVENT_UPGRADE: + if self.sliderPackages.has_key(param): + self.slider.setValue(self.sliderPackages[param]) + self.package.setText(param) + self.status.setText(_("Upgrading")) + self.packages += 1 + elif event == IpkgComponent.EVENT_INSTALL: + self.package.setText(param) + self.status.setText(_("Installing")) + self.packages += 1 + elif event == IpkgComponent.EVENT_CONFIGURING: + self.package.setText(param) + self.status.setText(_("Configuring")) + elif event == IpkgComponent.EVENT_MODIFIED: + self.session.openWithCallback( + self.modificationCallback, + MessageBox, + _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param) + ) + elif event == IpkgComponent.EVENT_ERROR: + self.error += 1 + elif event == IpkgComponent.EVENT_DONE: + if self.updating: + self.updating = False + self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False}) + elif self.error == 0: + self.slider.setValue(4) + + self.activityTimer.stop() + self.activityslider.setValue(0) + + self.package.setText("") + self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages) + else: + self.activityTimer.stop() + self.activityslider.setValue(0) + error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.") + if self.packages == 0: + error = _("No packages were upgraded yet. So you can check your network and try again.") + if self.updating: + error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.") + self.status.setText(_("Error") + " - " + error) + #print event, "-", param + pass + + def modificationCallback(self, res): + self.ipkg.write(res and "N" or "Y") + + def exit(self): + if not self.ipkg.isRunning(): + if self.packages != 0 and self.error == 0: + self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?")) + else: + self.close() + + def exitAnswer(self, result): + if result is not None and result: + quitMainloop(2) + self.close() + + + +class IpkgInstaller(Screen): + skin = """ + + + + + + + + """ + + def __init__(self, session, list): + self.skin = IpkgInstaller.skin + Screen.__init__(self, session) + + self.list = SelectionList() + self["list"] = self.list + for listindex in range(len(list)): + self.list.addSelection(list[listindex], list[listindex], listindex, True) + + self["red"] = Label() + self["green"] = Label() + self["yellow"] = Label() + self["blue"] = Label() + + self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], + { + "ok": self.list.toggleSelection, + "cancel": self.close, + "green": self.install + }, -1) + + def install(self): + list = self.list.getSelectionsList() + cmdList = [] + for item in list: + cmdList.append((IpkgComponent.CMD_INSTALL, { "package": item[1] })) + self.session.open(Ipkg, cmdList = cmdList) + +def filescan_open(list, session, **kwargs): + filelist = [x.path for x in list] + session.open(IpkgInstaller, filelist) # list + +def filescan(**kwargs): + from Components.Scanner import Scanner, ScanPath + return \ + Scanner(mimetypes = ["application/x-debian-package"], + paths_to_scan = + [ + ScanPath(path = "ipk", with_subdirs = True), + ScanPath(path = "", with_subdirs = False), + ], + name = "Ipkg", + description = "Install software updates...", + openfnc = filescan_open, ) + +def UpgradeMain(session, **kwargs): + session.open(UpdatePluginMenu) + +def startSetup(menuid): + if menuid != "setup": + return [ ] + return [(_("Software manager") + "...", UpgradeMain, "software_manager", 50)] + +def Plugins(path, **kwargs): + global plugin_path + plugin_path = path + return [ + PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), + #PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain), + PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) + ] diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/red.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/red.png new file mode 100755 index 00000000..8096045f Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/red.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/update.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/update.png new file mode 100755 index 00000000..0ece6c76 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/update.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/upgradeable.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/upgradeable.png new file mode 100755 index 00000000..edbbdee1 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/upgradeable.png differ diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/yellow.png b/lib/python/Plugins/SystemPlugins/SoftwareManager/yellow.png new file mode 100755 index 00000000..dacb80e6 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareManager/yellow.png differ -- cgit v1.2.3 From da0da334b1314329d7d1f294d8df59acf66ac0d0 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 13 Feb 2009 13:31:31 +0100 Subject: Remove double reboot question after upgrade small cleanups --- .../SystemPlugins/SoftwareManager/BackupRestore.py | 1 - .../SystemPlugins/SoftwareManager/plugin.py | 72 ++++++++-------------- 2 files changed, 25 insertions(+), 48 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index f92472d3..947452e9 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -110,7 +110,6 @@ class BackupSelection(Screen): def __init__(self, session): Screen.__init__(self, session) - self.skin_path = plugin_path self["key_red"] = Label(_("Cancel")) self["key_green"] = Label(_("Save")) self["key_yellow"] = Label() diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 1835a2ed..85d23284 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -79,7 +79,16 @@ class UpdatePluginMenu(Screen): } - + + + {"template": [ + MultiContentEntryText(pos = (2, 2), size = (230, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 0 is the MenuText, + ], + "fonts": [gFont("Regular", 20)], + "itemHeight": 230 + } + + """ def __init__(self, session, args = 0): @@ -105,8 +114,6 @@ class UpdatePluginMenu(Screen): self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext)) self["menu"] = List(self.list) - self["menu"].onSelectionChanged.append(self.selectionChanged) - self["description"] = Label() self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], { @@ -124,62 +131,38 @@ class UpdatePluginMenu(Screen): def layoutFinished(self): idx = 0 self["menu"].index = idx - self.loadDescription() def setWindowTitle(self): self.setTitle(_("Software manager...")) - def loadDescription(self): - if self["menu"].getCurrent()[0] == 'software-update': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'software-restore': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'ipkg-install': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'system-backup': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'system-restore': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'advanced': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'ipkg-source': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'ipkg-manager': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'advancedrestore': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'backuplocation': - self["description"].setText(self["menu"].getCurrent()[2] ) - if self["menu"].getCurrent()[0] == 'backupfiles': - self["description"].setText(self["menu"].getCurrent()[2] ) - def go(self): + current = self["menu"].getCurrent()[0] if self.menu == 0: - if (self["menu"].getCurrent()[0] == "software-restore"): + if (current == "software-restore"): self.session.open(ImageWizard) - if (self["menu"].getCurrent()[0] == "software-update"): + elif (current == "software-update"): self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!")) - if (self["menu"].getCurrent()[0] == "advanced"): + elif (current == "advanced"): self.session.open(UpdatePluginMenu, 1) - if (self["menu"].getCurrent()[0] == "system-backup"): + elif (current == "system-backup"): self.session.openWithCallback(self.backupDone,BackupScreen, runBackup = True) - if (self["menu"].getCurrent()[0] == "system-restore"): + elif (current == "system-restore"): if os_path.exists(self.fullbackupfilename): self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore your Enigma2 backup?\nEnigma2 will restart after the restore")) else: self.session.open(MessageBox, _("Sorry no backups found!"), MessageBox.TYPE_INFO) if self.menu == 1: - if (self["menu"].getCurrent()[0] == "ipkg-manager"): + if (current == "ipkg-manager"): self.session.open(PacketManager, self.skin_path) - if (self["menu"].getCurrent()[0] == "ipkg-source"): + elif (current == "ipkg-source"): self.session.open(IPKGSource) - if (self["menu"].getCurrent()[0] == "ipkg-install"): + elif (current == "ipkg-install"): try: from Plugins.Extensions.MediaScanner.plugin import main main(self.session) except: self.session.open(MessageBox, _("Sorry MediaScanner is not installed!"), MessageBox.TYPE_INFO) - if (self["menu"].getCurrent()[0] == "backuplocation"): + elif (current == "backuplocation"): parts = [ (r.description, r.mountpoint, self.session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] for x in parts: if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/': @@ -189,17 +172,13 @@ class UpdatePluginMenu(Screen): parts.remove(x) if len(parts): self.session.openWithCallback(self.backuplocation_choosen, ChoiceBox, title = _("Please select medium to use as backup location"), list = parts) - if (self["menu"].getCurrent()[0] == "backupfiles"): + elif (current == "backupfiles"): self.session.openWithCallback(self.backupfiles_choosen,BackupSelection) - if (self["menu"].getCurrent()[0] == "advancedrestore"): + elif (current == "advancedrestore"): self.session.open(RestoreMenu, self.skin_path) - def selectionChanged(self): - self.loadDescription() - def backupfiles_choosen(self, ret): self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) - self.loadDescription() def backuplocation_choosen(self, option): if option is not None: @@ -208,20 +187,19 @@ class UpdatePluginMenu(Screen): config.plugins.configurationbackup.save() config.save() self.createBackupfolders() - self.loadDescription() def runUpgrade(self, result): if result: - self.session.openWithCallback(self.runFinished,UpdatePlugin, self.skin_path) + self.session.open(UpdatePlugin, self.skin_path) - def runFinished(self): + """def runFinished(self): self.session.openWithCallback(self.reboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) def reboot(self, result): if result is None: return if result: - quitMainloop(3) + quitMainloop(3)""" def createBackupfolders(self): print "Creating backup folder if not already there..." -- cgit v1.2.3