From eaa8bc374ff5eca1bb3caf9517dc6772cae34dd6 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Tue, 19 Dec 2006 07:19:55 +0000 Subject: add IpkgInstaller Media Scanner plugin --- lib/python/Components/Ipkg.py | 39 ++++++------ lib/python/Components/Makefile.am | 2 +- lib/python/Components/SelectionList.py | 43 ++++++++++++++ .../Plugins/Extensions/IpkgInstaller/Makefile.am | 5 ++ .../Plugins/Extensions/IpkgInstaller/__init__.py | 0 .../Plugins/Extensions/IpkgInstaller/plugin.py | 69 ++++++++++++++++++++++ lib/python/Plugins/Extensions/Makefile.am | 2 +- .../Plugins/SystemPlugins/SoftwareUpdate/plugin.py | 42 ++++++------- lib/python/Screens/Makefile.am | 2 +- 9 files changed, 160 insertions(+), 44 deletions(-) create mode 100644 lib/python/Components/SelectionList.py create mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am create mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/__init__.py create mode 100644 lib/python/Plugins/Extensions/IpkgInstaller/plugin.py (limited to 'lib/python') diff --git a/lib/python/Components/Ipkg.py b/lib/python/Components/Ipkg.py index df700d6b..dbc99653 100644 --- a/lib/python/Components/Ipkg.py +++ b/lib/python/Components/Ipkg.py @@ -1,6 +1,6 @@ from enigma import eConsoleAppContainer -class Ipkg: +class IpkgComponent: EVENT_INSTALL = 0 EVENT_DOWNLOAD = 1 EVENT_INFLATING = 2 @@ -35,25 +35,24 @@ class Ipkg: print "executing", self.ipkg, cmd self.cmd.execute(self.ipkg + " " + cmd) - def cmdFetchList(self, installed_only = False): - self.fetchedList = [] - if installed_only: - self.runCmd("list_installed") - else: - self.runCmd("list") - self.setCurrentCommand(self.CMD_LIST) - - def cmdUpgrade(self, test_only = False): - append = "" - if test_only: - append = " -test" - self.runCmd("upgrade" + append) - self.setCurrentCommand(self.CMD_UPGRADE) - - def cmdUpdate(self): - self.runCmd("update") - self.setCurrentCommand(self.CMD_UPDATE) - + def startCmd(self, cmd, args = None): + if cmd == self.CMD_UPDATE: + self.runCmd("update") + elif cmd == self.CMD_UPGRADE: + append = "" + if args["test_only"]: + append = " -test" + self.runCmd("upgrade" + append) + elif cmd == self.CMD_LIST: + self.fetchedList = [] + if args['installed_only']: + self.runCmd("list_installed") + else: + self.runCmd("list") + elif cmd == self.CMD_INSTALL: + self.runCmd("install " + args['package']) + self.setCurrentCommand(cmd) + def cmdFinished(self, retval): self.callCallbacks(self.EVENT_DONE) diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index b51d53fd..9de7984a 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -17,4 +17,4 @@ install_PYTHON = \ FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \ MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \ Element.py Playlist.py ParentalControl.py ParentalControlList.py \ - Ipkg.py + Ipkg.py SelectionList.py diff --git a/lib/python/Components/SelectionList.py b/lib/python/Components/SelectionList.py new file mode 100644 index 00000000..1500254a --- /dev/null +++ b/lib/python/Components/SelectionList.py @@ -0,0 +1,43 @@ +from GUIComponent import GUIComponent +from MenuList import MenuList +from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE +from enigma import eListboxPythonMultiContent, loadPNG, eListbox, gFont, RT_HALIGN_LEFT + +selectionpng = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "selectioncross-fs8.png")) + +def SelectionEntryComponent(description, value, index, selected): + res = [ (description, value, index, selected) ] + res.append((eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description)) + if selected: + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 30, selectionpng)) + return res + +class SelectionList(MenuList, GUIComponent): + def __init__(self, list = []): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + self.list = list + self.setList(list) + self.l.setFont(0, gFont("Regular", 20)) + + GUI_WIDGET = eListbox + + def postWidgetCreate(self, instance): + instance.setContent(self.l) + instance.setItemHeight(30) + + def addSelection(self, description, value, index, selected = True): + self.list.append(SelectionEntryComponent(description, value, index, selected)) + self.setList(self.list) + + def toggleSelection(self): + item = self.list[self.getSelectedIndex()][0] + self.list[self.getSelectedIndex()] = SelectionEntryComponent(item[0], item[1], item[2], not item[3]) + self.setList(self.list) + + def getSelectionsList(self): + list = [] + for item in self.list: + if item[0][3]: + list.append((item[0][0], item[0][1], item[0][2])) + return list \ No newline at end of file diff --git a/lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am b/lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am new file mode 100644 index 00000000..ece0698f --- /dev/null +++ b/lib/python/Plugins/Extensions/IpkgInstaller/Makefile.am @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/Extensions/IpkgInstaller/plugin.py b/lib/python/Plugins/Extensions/IpkgInstaller/plugin.py new file mode 100644 index 00000000..f6dfc965 --- /dev/null +++ b/lib/python/Plugins/Extensions/IpkgInstaller/plugin.py @@ -0,0 +1,69 @@ +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): + session.open(IpkgInstaller, list) # list + +def filescan(): + # we expect not to be called if the MediaScanner plugin is not available, + # thus we don't catch an ImportError exception here + from Plugins.Extensions.MediaScanner.plugin import Scanner, ScanPath + return \ + Scanner(extensions = ["ipk"], + 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) ] \ No newline at end of file diff --git a/lib/python/Plugins/Extensions/Makefile.am b/lib/python/Plugins/Extensions/Makefile.am index 92251841..86834701 100644 --- a/lib/python/Plugins/Extensions/Makefile.am +++ b/lib/python/Plugins/Extensions/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = TuxboxPlugins WebInterface FileManager CutListEditor FritzCall PicturePlayer MediaScanner +SUBDIRS = TuxboxPlugins WebInterface FileManager CutListEditor FritzCall PicturePlayer MediaScanner IpkgInstaller # SimpleRSS is still not finished diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py index b5034b63..2a7bf655 100644 --- a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py @@ -1,21 +1,21 @@ -from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont -from Screens.Screen import Screen -from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap, NumberActionMap -from Components.ScrollLabel import ScrollLabel -from Components.GUIComponent import * -from Components.MenuList import MenuList +from Components.GUIComponent import GUIComponent from Components.Input import Input -from Screens.Console import Console -from Screens.MessageBox import MessageBox +from Components.Ipkg import IpkgComponent +from Components.Label import Label +from Components.MenuList import MenuList +from Components.ScrollLabel import ScrollLabel +from Components.Slider import Slider from Plugins.Plugin import PluginDescriptor +from Screens.Console import Console from Screens.ImageWizard import ImageWizard -from Components.Ipkg import Ipkg -from Components.Slider import Slider -from Components.Label import Label - +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 = """ @@ -256,12 +256,12 @@ class UpdatePlugin(Screen): self.activityTimer.timeout.get().append(self.doActivityTimer) self.activityTimer.start(100, False) - self.ipkg = Ipkg() + self.ipkg = IpkgComponent() self.ipkg.addCallback(self.ipkgCallback) self.updating = True self.package.setText(_("Package list update")) - self.ipkg.cmdUpdate() + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) self["actions"] = ActionMap(["WizardActions"], { @@ -276,27 +276,27 @@ class UpdatePlugin(Screen): self.activityslider.setValue(self.activity) def ipkgCallback(self, event, param): - if event == Ipkg.EVENT_DOWNLOAD: + if event == IpkgComponent.EVENT_DOWNLOAD: self.status.setText(_("Downloading")) - elif event == Ipkg.EVENT_UPGRADE: + 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 == Ipkg.EVENT_INSTALL: + elif event == IpkgComponent.EVENT_INSTALL: self.package.setText(param) self.status.setText(_("Installing")) self.packages += 1 - elif event == Ipkg.EVENT_CONFIGURING: + elif event == IpkgComponent.EVENT_CONFIGURING: self.package.setText(param) self.status.setText(_("Configuring")) - elif event == Ipkg.EVENT_ERROR: + elif event == IpkgComponent.EVENT_ERROR: self.error += 1 - elif event == Ipkg.EVENT_DONE: + elif event == IpkgComponent.EVENT_DONE: if self.updating: self.updating = False - self.ipkg.cmdUpgrade(test_only = False) + self.ipkg.startCmd(Ipkg.CMD_UPGRADE, args = {'test_only': False}) elif self.error == 0: self.slider.setValue(4) diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index b4e28e3c..d5512e7e 100644 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -12,4 +12,4 @@ install_PYTHON = \ Console.py InputBox.py ChoiceBox.py SimpleSummary.py ImageWizard.py \ MediaPlayer.py TimerSelection.py PictureInPicture.py TimeDateInput.py \ SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \ - SleepTimerEdit.py + SleepTimerEdit.py Ipkg.py -- cgit v1.2.3