1 from Screen import Screen
3 from enigma import eConsoleAppContainer
5 from Components.MenuList import MenuList
6 from Components.ActionMap import ActionMap
7 from Components.PluginComponent import plugins
8 from Components.PluginList import *
9 from Components.config import config
10 from Components.Label import Label
11 from Screens.MessageBox import MessageBox
12 from Screens.Console import Console
13 from Plugins.Plugin import PluginDescriptor
14 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
16 class PluginBrowser(Screen):
17 def __init__(self, session):
18 Screen.__init__(self, session)
20 self["red"] = Label(_("Remove Plugins"))
21 self["green"] = Label(_("Download Plugins"))
24 self["list"] = PluginList(self.list)
27 self["actions"] = ActionMap(["WizardActions", "ColorActions"],
32 "green": self.download
40 plugin = self["list"].l.getCurrentSelection()[0]
42 plugin(session=self.session)
46 self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
47 for plugin in self.pluginlist:
48 self.list.append(PluginEntryComponent(plugin))
50 self["list"].l.setList(self.list)
53 self.session.openWithCallback(self.updateList, PluginDownloadBrowser, PluginDownloadBrowser.REMOVE)
56 self.session.openWithCallback(self.updateList, PluginDownloadBrowser, PluginDownloadBrowser.DOWNLOAD)
58 class PluginDownloadBrowser(Screen):
62 def __init__(self, session, type):
63 Screen.__init__(self, session)
67 self.container = eConsoleAppContainer()
68 self.container.appClosed.get().append(self.runFinished)
69 self.container.dataAvail.get().append(self.dataAvail)
70 self.onLayoutFinish.append(self.startRun)
73 self["list"] = PluginList(self.list)
76 if self.type == self.DOWNLOAD:
77 self["text"] = Label(_("Downloading plugin information. Please wait..."))
78 elif self.type == self.REMOVE:
79 self["text"] = Label(_("Getting plugin information. Please wait..."))
83 self["actions"] = ActionMap(["WizardActions"],
90 print "plugin: installing:", self.pluginlist[self["list"].l.getCurrentSelectionIndex()]
91 if self.type == self.DOWNLOAD:
92 self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to download\nthe plugin \"" + self.pluginlist[self["list"].l.getCurrentSelectionIndex()][3] + "\"?"))
93 elif self.type == self.REMOVE:
94 self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to REMOVE\nthe plugin \"" + self.pluginlist[self["list"].l.getCurrentSelectionIndex()][3] + "\"?"))
96 def runInstall(self, val):
98 if self.type == self.DOWNLOAD:
99 self.session.openWithCallback(self.installFinished, Console, ["ipkg install " + self.pluginlist[self["list"].l.getCurrentSelectionIndex()][0]])
100 elif self.type == self.REMOVE:
101 self.session.openWithCallback(self.installFinished, Console, ["ipkg remove " + self.pluginlist[self["list"].l.getCurrentSelectionIndex()][0]])
104 #if self.type == self.DOWNLOAD:
105 # self.session.currentDialog.instance.setTitle(_("Downloadale new plugins"))
106 #elif self.type == self.REMOVE:
107 # self.session.currentDialog.instance.setTitle(_("Remove plugins"))
108 self["list"].instance.hide()
109 self.container.execute("ipkg update")
111 def installFinished(self):
112 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
114 def runFinished(self, retval):
117 if self.type == self.DOWNLOAD:
118 self.container.execute("ipkg list enigma2-plugin-*")
119 elif self.type == self.REMOVE:
120 self.container.execute("ipkg list_installed enigma2-plugin-*")
122 if len(self.pluginlist) > 0:
124 self["list"].instance.show()
126 self["text"].setText("No plugins found")
128 def dataAvail(self, str):
129 for x in str.split('\n'):
130 plugin = x.split(" - ")
132 plugin.append(plugin[0][15:])
134 self.pluginlist.append(plugin)
136 def updateList(self):
137 for x in self.pluginlist:
138 plugin = PluginDescriptor(name = x[3], description = x[2])
139 self.list.append(PluginEntryComponent(plugin))
141 self["list"].l.setList(self.list)