aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-02-22 19:21:16 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-02-22 19:21:16 +0000
commit3ad1f5540aa20e5b8132ededc367d8f319b2d5dd (patch)
treee286735b63a3a5024b084d0fad5d93c6a8a20cd8 /lib/python
parentab32bd33272b73f046cdfbe744ca9517f91d653d (diff)
downloadenigma2-3ad1f5540aa20e5b8132ededc367d8f319b2d5dd.tar.gz
enigma2-3ad1f5540aa20e5b8132ededc367d8f319b2d5dd.zip
add ability to download e2-plugins via PluginBrowser
naming conventions for plugin packets: enigma2-plugin-<category>-<pluginname> (category is not yet supported by the GUI)
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Plugins/Plugin.py1
-rw-r--r--lib/python/Plugins/update/plugin.py211
-rw-r--r--lib/python/Screens/Console.py2
-rw-r--r--lib/python/Screens/PluginBrowser.py80
4 files changed, 81 insertions, 213 deletions
diff --git a/lib/python/Plugins/Plugin.py b/lib/python/Plugins/Plugin.py
index bfa8509a..0378ce4c 100644
--- a/lib/python/Plugins/Plugin.py
+++ b/lib/python/Plugins/Plugin.py
@@ -35,6 +35,7 @@ class PluginDescriptor:
self.description = description
self.iconstr = icon
+ self.icon = None
self.__call__ = fnc
diff --git a/lib/python/Plugins/update/plugin.py b/lib/python/Plugins/update/plugin.py
index 6b094f30..e69de29b 100644
--- a/lib/python/Plugins/update/plugin.py
+++ b/lib/python/Plugins/update/plugin.py
@@ -1,211 +0,0 @@
-from enigma import *
-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.Input import Input
-from Screens.Console import Console
-from Plugins.Plugin import PluginDescriptor
-
-import os
-
-class UpdatePluginMenu(Screen):
- skin = """
- <screen position="200,100" size="300,250" title="Update..." >
- <widget name="menu" position="10,10" size="290,175" scrollbarMode="showOnDemand" />
- </screen>"""
-
- def __init__(self, session, args = None):
- self.skin = UpdatePluginMenu.skin
- Screen.__init__(self, session)
-
- list = []
- list.append((_("Upgrade"), "upgrade"))
- list.append((_("Choose source"), "source"))
- list.append((_("Packet management"), "ipkg"))
-
- self["menu"] = MenuList(list)
-
- self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
- {
- "ok": self.go,
- "back": self.close,
- }, -1)
-
- def go(self):
- 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!"))
- elif (self["menu"].l.getCurrentSelection()[1] == "source"):
- self.session.open(IPKGSource)
- elif (self["menu"].l.getCurrentSelection()[1] == "ipkg"):
- self.session.open(Ipkg)
-
- def runUpgrade(self, result):
- if result:
- self.session.open(Console, ["ipkg update", "ipkg upgrade -force-defaults -force-overwrite"])
-
-class IPKGSource(Screen):
- skin = """
- <screen position="100,100" size="550,60" title="IPKG source" >
- <widget name="text" position="0,0" size="550,25" font="Regular;20" />
- </screen>"""
-
- 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"],
- {
- "ok": self.go,
- "back": self.close,
- "left": self.keyLeft,
- "right": self.keyRight,
- "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 keyNumberGlobal(self, number):
- print "pressed", number
- self["text"].number(number)
-
-RT_HALIGN_LEFT = 0
-RT_HALIGN_RIGHT = 1
-RT_HALIGN_CENTER = 2
-RT_HALIGN_BLOCK = 4
-
-RT_VALIGN_TOP = 0
-RT_VALIGN_CENTER = 8
-RT_VALIGN_BOTTOM = 16
-
-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 Ipkg(Screen):
- skin = """
- <screen position="100,100" size="550,400" title="IPKG upgrade..." >
- <widget name="list" position="0,0" size="550,400" scrollbarMode="showOnDemand" />
- </screen>"""
-
- 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 = os.popen("ipkg list", "r").readlines()
- packetlist = []
- for x in lines:
- split = x.split(' - ')
- packetlist.append([split[0].strip(), split[1].strip()])
-
- lines = os.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 = os.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()
-
-def UpgradeMain(session):
- session.open(UpdatePluginMenu)
-
-def Plugins():
- return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain)
diff --git a/lib/python/Screens/Console.py b/lib/python/Screens/Console.py
index 17d706f5..dbe2fe9e 100644
--- a/lib/python/Screens/Console.py
+++ b/lib/python/Screens/Console.py
@@ -33,7 +33,7 @@ class Console(Screen):
def startRun(self):
self["text"].setText(_("Execution Progress:") + "\n\n")
- self.container.execute("ipkg update")
+ self.container.execute(self.cmdlist[self.run])
def runFinished(self, retval):
self.run += 1
diff --git a/lib/python/Screens/PluginBrowser.py b/lib/python/Screens/PluginBrowser.py
index 1c909746..67aac076 100644
--- a/lib/python/Screens/PluginBrowser.py
+++ b/lib/python/Screens/PluginBrowser.py
@@ -1,24 +1,34 @@
from Screen import Screen
+from enigma import eConsoleAppContainer
+
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Components.PluginComponent import plugins
from Components.PluginList import *
from Components.config import config
+from Components.Label import Label
+from Screens.MessageBox import MessageBox
+from Screens.Console import Console
from Plugins.Plugin import PluginDescriptor
class PluginBrowser(Screen):
def __init__(self, session):
Screen.__init__(self, session)
+ self["red"] = Label(_("Delete"))
+ self["green"] = Label(_("Download Plugins"))
+
self.list = []
self["list"] = PluginList(self.list)
self.updateList()
- self["actions"] = ActionMap(["WizardActions"],
+ self["actions"] = ActionMap(["WizardActions", "ColorActions"],
{
"ok": self.save,
"back": self.close,
+ "red": self.delete,
+ "green": self.download
})
def save(self):
@@ -37,3 +47,71 @@ class PluginBrowser(Screen):
self.list.append(PluginEntryComponent(plugin))
self["list"].l.setList(self.list)
+
+ def delete(self):
+ pass
+
+ def download(self):
+ self.session.open(PluginDownloadBrowser)
+
+class PluginDownloadBrowser(Screen):
+ def __init__(self, session):
+ Screen.__init__(self, session)
+
+ self.container = eConsoleAppContainer()
+ self.container.appClosed.get().append(self.runFinished)
+ self.container.dataAvail.get().append(self.dataAvail)
+ self.onLayoutFinish.append(self.startRun)
+
+ self.list = []
+ self["list"] = PluginList(self.list)
+ self.pluginlist = []
+
+ self["text"] = Label(_("Downloading plugin information. Please wait..."))
+
+ self.run = 0
+
+ self["actions"] = ActionMap(["WizardActions"],
+ {
+ "ok": self.go,
+ "back": self.close,
+ })
+
+ def go(self):
+ print "plugin: installing:", self.pluginlist[self["list"].l.getCurrentSelectionIndex()]
+ self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to download\nthe plugin \"" + self.pluginlist[self["list"].l.getCurrentSelectionIndex()][3] + "\"?"))
+
+ def runInstall(self, val):
+ if val:
+ self.session.open(Console, ["ipkg install " + self.pluginlist[self["list"].l.getCurrentSelectionIndex()][0]])
+
+ def startRun(self):
+ self["list"].instance.hide()
+ self.container.execute("ipkg update")
+
+ def runFinished(self, retval):
+ if self.run == 0:
+ self.run = 1
+ self.container.execute("ipkg list enigma2-plugin-*")
+ else:
+ if len(self.pluginlist) > 0:
+ self.updateList()
+ self["list"].instance.show()
+ else:
+ self["text"].setText("No plugins found")
+
+ def dataAvail(self, str):
+ for x in str.split('\n'):
+ plugin = x.split(" - ")
+ if len(plugin) == 3:
+ plugin.append(plugin[0][15:])
+
+ self.pluginlist.append(plugin)
+
+ def updateList(self):
+ for x in self.pluginlist:
+ plugin = PluginDescriptor(name = x[3], description = x[2])
+ self.list.append(PluginEntryComponent(plugin))
+
+ self["list"].l.setList(self.list)
+