示例#1
0
	def goDefaultfolder(self):
		bookmarks = config.plugins.filecommander.bookmarks.value
		if not bookmarks:
			if config.plugins.filecommander.path_default.value:
				bookmarks.append(config.plugins.filecommander.path_default.value)
			bookmarks.append('/home/root/')
			bookmarks.append(defaultMoviePath())
			config.plugins.filecommander.bookmarks.value = bookmarks
			config.plugins.filecommander.bookmarks.save()
		bookmarks = [(x, x) for x in bookmarks]
		bookmarks.append((_("Storage devices"), None))
		self.session.openWithCallback(self.locationCB, ChoiceBox, title=_("Select a path"), list=bookmarks, reorderConfig="fc_bookmarks_order")
示例#2
0
	def execButtonSetup(self, selected):
		if selected:
			selected = selected[1].split("/")
			if selected[0] == "Plugins":
				twinPlugins = []
				twinPaths = {}
				pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
						if plugin.path[24:] in twinPaths:
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
				pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path:
						if plugin.path[24:] in twinPaths:
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
			elif selected[0] == "MenuPlugin":
				for plugin in plugins.getPluginsForMenu(selected[1]):
					if plugin[2] == selected[2]:
						self.runPlugin(plugin[1])
						return
			elif selected[0] == "Infobar":
				if hasattr(self, selected[1]):
					exec "self." + ".".join(selected[1:]) + "()"
				else:
					return 0
			elif selected[0] == "Module":
				try:
					exec "from " + selected[1] + " import *"
					exec "self.session.open(" + ",".join(selected[2:]) + ")"
				except:
					print "[ButtonSetup] error during executing module %s, screen %s" % (selected[1], selected[2])
			elif selected[0] == "Setup":
				exec "from Screens.Setup import *"
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0].startswith("Zap"):
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
					self.pipShown() and self.showPiP()
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "Menu":
				from Screens.Menu import MainMenu, mdom
				root = mdom.getroot()
				for x in root.findall("menu"):
					y = x.find("id")
					if y is not None:
						id = y.get("val")
						if id and id == selected[1]:
							menu_screen = self.session.open(MainMenu, x)
							break
示例#3
0
 def execButtonSetup(self, selected):
     if selected:
         selected = selected[1].split("/")
         if selected[0] == "Plugins":
             twinPlugins = []
             twinPaths = {}
             pluginlist = plugins.getPlugins(
                 PluginDescriptor.WHERE_EVENTINFO)
             pluginlist.sort(key=lambda p: p.name)
             for plugin in pluginlist:
                 if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
                     if twinPaths.has_key(
                             plugin.path[plugin.path.rfind("Plugins"):]):
                         twinPaths[plugin.path[plugin.path.rfind("Plugins"
                                                                 ):]] += 1
                     else:
                         twinPaths[
                             plugin.path[plugin.path.rfind("Plugins"):]] = 1
                     if plugin.path[
                             plugin.path.rfind("Plugins"):] + "/" + str(
                                 twinPaths[plugin.path[plugin.path.rfind(
                                     "Plugins"):]]) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
             pluginlist = plugins.getPlugins([
                 PluginDescriptor.WHERE_PLUGINMENU,
                 PluginDescriptor.WHERE_EXTENSIONSMENU
             ])
             pluginlist.sort(key=lambda p: p.name)
             for plugin in pluginlist:
                 if plugin.name not in twinPlugins and plugin.path:
                     if twinPaths.has_key(
                             plugin.path[plugin.path.rfind("Plugins"):]):
                         twinPaths[plugin.path[plugin.path.rfind("Plugins"
                                                                 ):]] += 1
                     else:
                         twinPaths[
                             plugin.path[plugin.path.rfind("Plugins"):]] = 1
                     if plugin.path[
                             plugin.path.rfind("Plugins"):] + "/" + str(
                                 twinPaths[plugin.path[plugin.path.rfind(
                                     "Plugins"):]]) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
         elif selected[0] == "MenuPlugin":
             for plugin in plugins.getPluginsForMenu(selected[1]):
                 if plugin[2] == selected[2]:
                     self.runPlugin(plugin[1])
                     return
         elif selected[0] == "Infobar":
             if hasattr(self, selected[1]):
                 exec "self." + ".".join(selected[1:]) + "()"
             else:
                 return 0
         elif selected[0] == "Module":
             try:
                 exec "from " + selected[1] + " import *"
                 exec "self.session.open(" + ",".join(selected[2:]) + ")"
             except:
                 print "[ButtonSetup] error during executing module %s, screen %s" % (
                     selected[1], selected[2])
         elif selected[0] == "Setup":
             exec "from Screens.Setup import *"
             exec "self.session.open(Setup, \"" + selected[1] + "\")"
         elif selected[0].startswith("Zap"):
             if selected[0] == "ZapPanic":
                 self.servicelist.history = []
                 self.pipShown() and self.showPiP()
             self.servicelist.servicelist.setCurrent(
                 eServiceReference("/".join(selected[1:])))
             self.servicelist.zap(enable_pipzap=True)
             if hasattr(self, "lastservice"):
                 self.lastservice = eServiceReference("/".join(
                     selected[1:]))
                 self.close()
             else:
                 self.show()
             from Screens.MovieSelection import defaultMoviePath
             moviepath = defaultMoviePath()
             if moviepath:
                 config.movielist.last_videodir.value = moviepath
         elif selected[0] == "PPanel":
             ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
             if os.path.isfile(ppanelFileName) and os.path.isdir(
                     '/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                 from Plugins.Extensions.PPanel.ppanel import PPanel
                 self.session.open(PPanel,
                                   name=selected[1] + ' PPanel',
                                   node=None,
                                   filename=ppanelFileName,
                                   deletenode=None)
         elif selected[0] == "Shellscript":
             command = '/usr/script/' + selected[1] + ".sh"
             if os.path.isfile(command) and os.path.isdir(
                     '/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                 from Plugins.Extensions.PPanel.ppanel import Execute
                 self.session.open(Execute, selected[1] + " shellscript",
                                   None, command)
             else:
                 from Screens.Console import Console
                 exec "self.session.open(Console,_(selected[1]),[command])"
         elif selected[0] == "EMC":
             try:
                 from Plugins.Extensions.EnhancedMovieCenter.plugin import showMoviesNew
                 from Screens.InfoBar import InfoBar
                 open(showMoviesNew(InfoBar.instance))
             except Exception as e:
                 print('[EMCPlayer] showMovies exception:\n' + str(e))
         elif selected[0] == "Kodi":
             if os.path.isfile(
                     "/usr/lib/enigma2/python/Plugins/Extensions/Kodi/plugin.pyo"
             ):
                 from Plugins.Extensions.Kodi.plugin import KodiMainScreen
                 self.session.open(KodiMainScreen)
         elif selected[0] == "Bluetooth":
             if os.path.isfile(
                     "/usr/lib/enigma2/python/Plugins/SystemPlugins/BluetoothSetup/plugin.pyo"
             ):
                 from Plugins.SystemPlugins.BluetoothSetup.plugin import BluetoothSetup
                 self.session.open(BluetoothSetup)
         elif selected[0] == "YoutubeTV":
             if os.path.isfile(
                     "/usr/lib/enigma2/python/Plugins/Extensions/Chromium/plugin.pyo"
             ):
                 from Plugins.Extensions.Chromium.youtube import YoutubeTVWindow
                 self.session.open(YoutubeTVWindow)
示例#4
0
	def execButtonSetup(self, selected):
		if selected:
			selected = selected[1].split("/")
			if selected[0] == "Plugins":
				twinPlugins = []
				twinPaths = {}
				pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
						if twinPaths.has_key(plugin.path[plugin.path.rfind("Plugins"):]):
							twinPaths[plugin.path[plugin.path.rfind("Plugins"):]] += 1
						else:
							twinPaths[plugin.path[plugin.path.rfind("Plugins"):]] = 1
						if plugin.path[plugin.path.rfind("Plugins"):] + "/" + str(twinPaths[plugin.path[plugin.path.rfind("Plugins"):]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
				pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path:
						if twinPaths.has_key(plugin.path[plugin.path.rfind("Plugins"):]):
							twinPaths[plugin.path[plugin.path.rfind("Plugins"):]] += 1
						else:
							twinPaths[plugin.path[plugin.path.rfind("Plugins"):]] = 1
						if plugin.path[plugin.path.rfind("Plugins"):] + "/" + str(twinPaths[plugin.path[plugin.path.rfind("Plugins"):]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
			elif selected[0] == "MenuPlugin":
				for plugin in plugins.getPluginsForMenu(selected[1]):
					if plugin[2] == selected[2]:
						self.runPlugin(plugin[1])
						return
			elif selected[0] == "Infobar":
				if hasattr(self, selected[1]):
					exec "self." + ".".join(selected[1:]) + "()"
				else:
					return 0
			elif selected[0] == "Module":
				try:
					exec "from " + selected[1] + " import *"
					exec "self.session.open(" + ",".join(selected[2:]) + ")"
				except Exception as e:
					print "[ButtonSetup] error during executing module %s, screen %s, %s" % (selected[1], selected[2], e)
					import traceback
					traceback.print_exc()
			elif selected[0] == "Setup":
				exec "from Screens.Setup import *"
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0].startswith("Zap"):
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
					self.pipShown() and self.showPiP()
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "Menu":
				from Screens.Menu import MainMenu, mdom
				root = mdom.getroot()
				for x in root.findall("menu"):
					y = x.find("id")
					if y is not None:
						id = y.get("val")
						if id and id == selected[1]:
							menu_screen = self.session.open(MainMenu, x)
							break
示例#5
0
    def execButtonSetup(self, selected):
        if selected:
            selected = selected[1].split('/')
            if selected[0] == 'Plugins':
                twinPlugins = []
                twinPaths = {}
                pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
                pluginlist.sort(key=lambda p: p.name)
                for plugin in pluginlist:
                    if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
                        if twinPaths.has_key(plugin.path[24:]):
                            twinPaths[plugin.path[24:]] += 1
                        else:
                            twinPaths[plugin.path[24:]] = 1
                        if plugin.path[24:] + '/' + str(twinPaths[plugin.path[24:]]) == '/'.join(selected):
                            self.runPlugin(plugin)
                            return
                        twinPlugins.append(plugin.name)

                pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
                pluginlist.sort(key=lambda p: p.name)
                for plugin in pluginlist:
                    if plugin.name not in twinPlugins and plugin.path:
                        if twinPaths.has_key(plugin.path[24:]):
                            twinPaths[plugin.path[24:]] += 1
                        else:
                            twinPaths[plugin.path[24:]] = 1
                        if plugin.path[24:] + '/' + str(twinPaths[plugin.path[24:]]) == '/'.join(selected):
                            self.runPlugin(plugin)
                            return
                        twinPlugins.append(plugin.name)

            elif selected[0] == 'MenuPlugin':
                for plugin in plugins.getPluginsForMenu(selected[1]):
                    if plugin[2] == selected[2]:
                        self.runPlugin(plugin[1])
                        return

            elif selected[0] == 'Infobar':
                if hasattr(self, selected[1]):
                    exec 'self.' + '.'.join(selected[1:]) + '()'
                else:
                    return 0
            elif selected[0] == 'Module':
                try:
                    exec 'from ' + selected[1] + ' import *'
                    exec 'self.session.open(' + ','.join(selected[2:]) + ')'
                except:
                    print '[ButtonSetup] error during executing module %s, screen %s' % (selected[1], selected[2])

            elif selected[0] == 'Setup':
                exec 'from Screens.Setup import *'
                exec 'self.session.open(Setup, "' + selected[1] + '")'
            elif selected[0].startswith('Zap'):
                if selected[0] == 'ZapPanic':
                    self.servicelist.history = []
                    self.pipShown() and self.showPiP()
                self.servicelist.servicelist.setCurrent(eServiceReference('/'.join(selected[1:])))
                self.servicelist.zap(enable_pipzap=True)
                if hasattr(self, 'lastservice'):
                    self.lastservice = eServiceReference('/'.join(selected[1:]))
                    self.close()
                else:
                    self.show()
                from Screens.MovieSelection import defaultMoviePath
                moviepath = defaultMoviePath()
                if moviepath:
                    config.movielist.last_videodir.value = moviepath
            elif selected[0] == 'PPanel':
                ppanelFileName = '/etc/ppanels/' + selected[1] + '.xml'
                if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                    from Plugins.Extensions.PPanel.ppanel import PPanel
                    self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None)
            elif selected[0] == 'Shellscript':
                command = '/usr/script/' + selected[1] + '.sh'
                if os.path.isfile(command) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                    from Plugins.Extensions.PPanel.ppanel import Execute
                    self.session.open(Execute, selected[1] + ' shellscript', None, command)
            elif selected[0] == 'EMC':
                try:
                    from Plugins.Extensions.EnhancedMovieCenter.plugin import showMoviesNew
                    from Screens.InfoBar import InfoBar
                    open(showMoviesNew(InfoBar.instance))
                except Exception as e:
                    print '[EMCPlayer] showMovies exception:\n' + str(e)

        return
示例#6
0
文件: Hotkey.py 项目: Akki01/enigma2
	def execHotkey(self, selected):
		if selected:
			selected = selected[1].split("/")
			if selected[0] == "Plugins":
				twinPlugins = []
				twinPaths = {}
				pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
				pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
			elif selected[0] == "MenuPlugin":
				for plugin in plugins.getPluginsForMenu(selected[1]):
					if plugin[2] == selected[2]:
						self.runPlugin(plugin[1])
						return
			elif selected[0] == "Infobar":
				if hasattr(self, selected[1]):
					exec "self." + ".".join(selected[1:]) + "()"
				else:
					return 0
			elif selected[0] == "Module":
				try:
					exec "from " + selected[1] + " import *"
					exec "self.session.open(" + ",".join(selected[2:]) + ")"
				except:
					print "[Hotkey] error during executing module %s, screen %s" % (selected[1], selected[2])
			elif selected[0] == "Setup":
				exec "from Screens.Setup import *"
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0].startswith("Zap"):
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
					self.pipShown() and self.showPiP()
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "PPanel":
				ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
				if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
					from Plugins.Extensions.PPanel.ppanel import PPanel
					self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None)
			elif selected[0] == "Shellscript":
				command = '/usr/script/' + selected[1] + ".sh"
				if os.path.isfile(command) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
					from Plugins.Extensions.PPanel.ppanel import Execute
					self.session.open(Execute, selected[1] + " shellscript", None, command)
			elif selected[0] == "Menu":
				from Screens.Menu import MainMenu, mdom
				root = mdom.getroot()
				for x in root.findall("menu"):
					y = x.find("id")
					if y is not None:
						id = y.get("val")
						if id and id == selected[1]:
							menu_screen = self.session.open(MainMenu, x)
							break
示例#7
0
 def execHotkey(self, selected):
     if selected:
         selected = selected[1].split("/")
         if selected[0] == "Plugins":
             twinPlugins = []
             twinPaths = {}
             pluginlist = plugins.getPlugins(
                 PluginDescriptor.WHERE_EVENTINFO)
             pluginlist.sort(key=lambda p: p.name)
             for plugin in pluginlist:
                 if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
                     if plugin.path[24:] in twinPaths:
                         twinPaths[plugin.path[24:]] += 1
                     else:
                         twinPaths[plugin.path[24:]] = 1
                     if plugin.path[24:] + "/" + str(twinPaths[
                             plugin.path[24:]]) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
             pluginlist = plugins.getPlugins([
                 PluginDescriptor.WHERE_PLUGINMENU,
                 PluginDescriptor.WHERE_EXTENSIONSMENU
             ])
             pluginlist.sort(key=lambda p: p.name)
             for plugin in pluginlist:
                 if plugin.name not in twinPlugins and plugin.path:
                     if plugin.path[24:] in twinPaths:
                         twinPaths[plugin.path[24:]] += 1
                     else:
                         twinPaths[plugin.path[24:]] = 1
                     if plugin.path[24:] + "/" + str(twinPaths[
                             plugin.path[24:]]) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
         elif selected[0] == "MenuPlugin":
             for plugin in plugins.getPluginsForMenu(selected[1]):
                 if plugin[2] == selected[2]:
                     self.runPlugin(plugin[1])
                     return
         elif selected[0] == "Infobar":
             if hasattr(self, selected[1]):
                 exec "self." + ".".join(selected[1:]) + "()"
             else:
                 return 0
         elif selected[0] == "Module":
             try:
                 exec "from " + selected[1] + " import *"
                 exec "self.session.open(" + ",".join(selected[2:]) + ")"
             except:
                 print "[Hotkey] error during executing module %s, screen %s" % (
                     selected[1], selected[2])
         elif selected[0] == "SoftcamSetup" and SystemInfo[
                 "HasSoftcamInstalled"]:
             from Screens.SoftcamSetup import SoftcamSetup
             self.session.open(SoftcamSetup)
         elif selected[0] == "Setup":
             from Screens.Setup import *
             exec "self.session.open(Setup, \"" + selected[1] + "\")"
         elif selected[0].startswith("Zap"):
             if selected[0] == "ZapPanic":
                 self.servicelist.history = []
                 self.pipShown() and self.showPiP()
             self.servicelist.servicelist.setCurrent(
                 eServiceReference("/".join(selected[1:])))
             self.servicelist.zap(enable_pipzap=True)
             if hasattr(self, "lastservice"):
                 self.lastservice = eServiceReference("/".join(
                     selected[1:]))
                 self.close()
             else:
                 self.show()
             from Screens.MovieSelection import defaultMoviePath
             moviepath = defaultMoviePath()
             if moviepath:
                 config.movielist.last_videodir.value = moviepath
         elif selected[0] == "PPanel":
             ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
             if os.path.isfile(ppanelFileName) and os.path.isdir(
                     '/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                 from Plugins.Extensions.PPanel.ppanel import PPanel
                 self.session.open(PPanel,
                                   name=selected[1] + ' PPanel',
                                   node=None,
                                   filename=ppanelFileName,
                                   deletenode=None)
         elif selected[0] == "Shellscript":
             command = '/usr/script/' + selected[1] + ".sh"
             if os.path.isfile(command):
                 if ".hidden." in command:
                     from enigma import eConsoleAppContainer
                     eConsoleAppContainer().execute(command)
                 else:
                     from Screens.Console import Console
                     self.session.open(
                         Console,
                         selected[1] + " shellscript",
                         command,
                         closeOnSuccess=selected[1].startswith('!'),
                         showStartStopText=False)
         elif selected[0] == "Menu":
             from Screens.Menu import MainMenu, mdom
             root = mdom.getroot()
             for x in root.findall("menu"):
                 y = x.find("id")
                 if y is not None:
                     id = y.get("val")
                     if id and id == selected[1]:
                         menu_screen = self.session.open(MainMenu, x)
                         break
示例#8
0
	def execButtonSetup(self, selected):
		if selected:
			selected = selected[1].split("/")
			if selected[0] == "Plugins":
				twinPlugins = []
				twinPaths = {}
				pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:	
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
				pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
			elif selected[0] == "MenuPlugin":
				for plugin in plugins.getPluginsForMenu(selected[1]):
					if plugin[2] == selected[2]:
						self.runPlugin(plugin[1])
						return
			elif selected[0] == "Infobar":
				if hasattr(self, selected[1]):
					exec "self." + ".".join(selected[1:]) + "()"
				else:
					return 0
			elif selected[0] == "Module":
				try:
					exec "from " + selected[1] + " import *"
					exec "self.session.open(" + ",".join(selected[2:]) + ")"
				except:
					print "[ButtonSetup] error during executing module %s, screen %s" % (selected[1], selected[2])
			elif selected[0] == "Setup":
				exec "from Screens.Setup import *"
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0].startswith("Zap"):
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
					self.pipShown() and self.showPiP()
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "PPanel":
				ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
				if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
					from Plugins.Extensions.PPanel.ppanel import PPanel
					self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None)
			elif selected[0] == "Shellscript":
				command = '/usr/script/' + selected[1] + ".sh"
				if os.path.isfile(command) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
					from Plugins.Extensions.PPanel.ppanel import Execute
					self.session.open(Execute, selected[1] + " shellscript", None, command)
				else:
					from Screens.Console import Console
					exec "self.session.open(Console,_(selected[1]),[command])"
			elif selected[0] == "EMC":
				try:
					from Plugins.Extensions.EnhancedMovieCenter.plugin import showMoviesNew
					from Screens.InfoBar import InfoBar
					open(showMoviesNew(InfoBar.instance))
				except Exception as e:
					print('[EMCPlayer] showMovies exception:\n' + str(e))
			elif selected[0] == "ScriptRunner":
				if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/ScriptRunner.pyo"):
					from Plugins.Extensions.Infopanel.ScriptRunner import ScriptRunner
					self.session.open (ScriptRunner)
			elif selected[0] == "QuickMenu":
				if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/QuickMenu.pyo"):
					from Plugins.Extensions.Infopanel.QuickMenu import QuickMenu
					self.session.open (QuickMenu)
			elif selected[0] == "Kodi":
				if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/Kodi/plugin.pyo"):
					from Plugins.Extensions.Kodi.plugin import KodiMainScreen
					self.session.open(KodiMainScreen)
示例#9
0
 def execHotkey(self, selected):
     if selected:
         selected = selected[1].split("/")
         if selected[0] == "Plugins":
             twinPlugins = []
             twinPaths = {}
             pluginlist = plugins.getPlugins(
                 PluginDescriptor.WHERE_EVENTINFO)
             pluginlist.sort(key=lambda p: p.name)
             for plugin in pluginlist:
                 if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
                     if twinPaths.has_key(plugin.path[24:]):
                         twinPaths[plugin.path[24:]] += 1
                     else:
                         twinPaths[plugin.path[24:]] = 1
                     if plugin.path[24:] + "/" + str(twinPaths[
                             plugin.path[24:]]) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
             pluginlist = plugins.getPlugins([
                 PluginDescriptor.WHERE_PLUGINMENU,
                 PluginDescriptor.WHERE_EXTENSIONSMENU
             ])
             pluginlist.sort(key=lambda p: p.name)
             for plugin in pluginlist:
                 if plugin.name not in twinPlugins and plugin.path:
                     if twinPaths.has_key(plugin.path[24:]):
                         twinPaths[plugin.path[24:]] += 1
                     else:
                         twinPaths[plugin.path[24:]] = 1
                     if plugin.path[24:] + "/" + str(twinPaths[
                             plugin.path[24:]]) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
         elif selected[0] == "MenuPlugin":
             for plugin in plugins.getPluginsForMenu(selected[1]):
                 if plugin[2] == selected[2]:
                     self.runPlugin(plugin[1])
                     return
         elif selected[0] == "Infobar":
             if hasattr(self, selected[1]):
                 exec "self." + ".".join(selected[1:]) + "()"
             else:
                 return 0
         elif selected[0] == "Module":
             try:
                 exec "from " + selected[1] + " import *"
                 exec "self.session.open(" + ",".join(selected[2:]) + ")"
             except:
                 print "[Hotkey] error during executing module %s, screen %s" % (
                     selected[1], selected[2])
         elif selected[0] == "Setup":
             exec "from Screens.Setup import *"
             exec "self.session.open(Setup, \"" + selected[1] + "\")"
         elif selected[0].startswith("Zap"):
             if selected[0] == "ZapPanic":
                 self.servicelist.history = []
                 self.pipShown() and self.showPiP()
             self.servicelist.servicelist.setCurrent(
                 eServiceReference("/".join(selected[1:])))
             self.servicelist.zap(enable_pipzap=True)
             if hasattr(self, "lastservice"):
                 self.lastservice = eServiceReference("/".join(
                     selected[1:]))
                 self.close()
             else:
                 self.show()
             from Screens.MovieSelection import defaultMoviePath
             moviepath = defaultMoviePath()
             if moviepath:
                 config.movielist.last_videodir.value = moviepath
         elif selected[0] == "PPanel":
             ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
             if os.path.isfile(ppanelFileName) and os.path.isdir(
                     '/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                 from Plugins.Extensions.PPanel.ppanel import PPanel
                 self.session.open(PPanel,
                                   name=selected[1] + ' PPanel',
                                   node=None,
                                   filename=ppanelFileName,
                                   deletenode=None)
         elif selected[0] == "Shellscript":
             command = '/usr/script/' + selected[1] + ".sh"
             if os.path.isfile(command) and os.path.isdir(
                     '/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                 from Plugins.Extensions.PPanel.ppanel import Execute
                 self.session.open(Execute, selected[1] + " shellscript",
                                   None, command)
示例#10
0
    def execButtonSetup(self, selected):
        if selected:
            selected = selected[1].split('/')
            if selected[0] == 'Plugins':
                twinPlugins = []
                twinPaths = {}
                pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
                pluginlist.sort(key=lambda p: p.name)
                for plugin in pluginlist:
                    if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
                        if twinPaths.has_key(plugin.path[24:]):
                            twinPaths[plugin.path[24:]] += 1
                        else:
                            twinPaths[plugin.path[24:]] = 1
                        if plugin.path[24:] + '/' + str(twinPaths[plugin.path[24:]]) == '/'.join(selected):
                            self.runPlugin(plugin)
                            return
                        twinPlugins.append(plugin.name)

                pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
                pluginlist.sort(key=lambda p: p.name)
                for plugin in pluginlist:
                    if plugin.name not in twinPlugins and plugin.path:
                        if twinPaths.has_key(plugin.path[24:]):
                            twinPaths[plugin.path[24:]] += 1
                        else:
                            twinPaths[plugin.path[24:]] = 1
                        if plugin.path[24:] + '/' + str(twinPaths[plugin.path[24:]]) == '/'.join(selected):
                            self.runPlugin(plugin)
                            return
                        twinPlugins.append(plugin.name)

            elif selected[0] == 'MenuPlugin':
                for plugin in plugins.getPluginsForMenu(selected[1]):
                    if plugin[2] == selected[2]:
                        self.runPlugin(plugin[1])
                        return

            elif selected[0] == 'Infobar':
                if hasattr(self, selected[1]):
                    exec 'self.' + '.'.join(selected[1:]) + '()'
                else:
                    return 0
            elif selected[0] == 'Module':
                try:
                    exec 'from ' + selected[1] + ' import *'
                    exec 'self.session.open(' + ','.join(selected[2:]) + ')'
                except:
                    print '[ButtonSetup] error during executing module %s, screen %s' % (selected[1], selected[2])

            elif selected[0] == 'Setup':
                exec 'from Screens.Setup import *'
                exec 'self.session.open(Setup, "' + selected[1] + '")'
            elif selected[0].startswith('Zap'):
                if selected[0] == 'ZapPanic':
                    self.servicelist.history = []
                    self.pipShown() and self.showPiP()
                self.servicelist.servicelist.setCurrent(eServiceReference('/'.join(selected[1:])))
                self.servicelist.zap(enable_pipzap=True)
                if hasattr(self, 'lastservice'):
                    self.lastservice = eServiceReference('/'.join(selected[1:]))
                    self.close()
                else:
                    self.show()
                from Screens.MovieSelection import defaultMoviePath
                moviepath = defaultMoviePath()
                if moviepath:
                    config.movielist.last_videodir.value = moviepath
示例#11
0
def getMovieList(rargs=None, locations=None):
    movieliste = []
    tag = None
    directory = None
    fields = None
    bookmarklist = []

    if rargs:
        tag = getUrlArg2(rargs, "tag")
        directory = getUrlArg2(rargs, "dirname")
        fields = getUrlArg2(rargs, "fields")

    if directory is None:
        directory = defaultMoviePath()
    else:
        if not PY3:
            try:
                directory.decode('utf-8')
            except UnicodeDecodeError:
                try:
                    directory = directory.decode("cp1252").encode("utf-8")
                except UnicodeDecodeError:
                    directory = directory.decode("iso-8859-1").encode("utf-8")

    if not directory:
        directory = MOVIE_LIST_ROOT_FALLBACK

    if directory[-1] != "/":
        directory += "/"

    if not os.path.isdir(directory):
        return {
            "movies": [],
            "locations": [],
            "bookmarks": [],
            "directory": [],
        }

    root = eServiceReference(MOVIE_LIST_SREF_ROOT + directory)

    for item in sorted(os.listdir(directory)):
        abs_p = os.path.join(directory, item)
        if os.path.isdir(abs_p):
            bookmarklist.append(item)

    folders = [root]
    brecursive = False
    if rargs and b"recursive" in list(rargs.keys()):
        brecursive = True
        dirs = []
        locations = []
        if PY3:
            from glob import glob
            for subdirpath in glob(directory + "**/", recursive=True):
                locations.append(subdirpath)
                subdirpath = subdirpath[len(directory):]
                dirs.append(subdirpath)
        else:
            # FIXME SLOW!!!
            for subdirpath in [x[0] for x in os.walk(directory)]:
                locations.append(subdirpath)
                subdirpath = subdirpath[len(directory):]
                dirs.append(subdirpath)

        for f in sorted(dirs):
            if f != '':
                if f[-1] != "/":
                    f += "/"
                ff = eServiceReference(MOVIE_LIST_SREF_ROOT + directory + f)
                folders.append(ff)
    else:
        # get all locations
        if locations is not None:
            folders = []

            for f in locations:
                if f[-1] != "/":
                    f += "/"
                ff = eServiceReference(MOVIE_LIST_SREF_ROOT + f)
                folders.append(ff)

    if config.OpenWebif.parentalenabled.value:
        dir_is_protected = checkParentalProtection(directory)
    else:
        dir_is_protected = False

    if not dir_is_protected:
        movielist = MovieList(None)
        for root in folders:
            if tag is not None:
                movielist.load(root=root, filter_tags=[tag])
            else:
                movielist.load(root=root, filter_tags=None)

            for (serviceref, info, begin, unknown) in movielist.list:
                if serviceref.flags & eServiceReference.mustDescent:
                    continue

                # BAD fix
                _serviceref = serviceref.toString().replace('%25', '%')
                length_minutes = 0
                txtdesc = ""
                filename = '/'.join(_serviceref.split("/")[1:])
                filename = '/' + filename
                name, ext = os.path.splitext(filename)

                sourceRef = ServiceReference(
                    info.getInfoString(serviceref,
                                       iServiceInformation.sServiceref))
                rtime = info.getInfo(serviceref,
                                     iServiceInformation.sTimeCreate)

                movie = {
                    'filename':
                    filename,
                    'filename_stripped':
                    filename.split("/")[-1],
                    'serviceref':
                    _serviceref,
                    'length':
                    "?:??",
                    'lastseen':
                    0,
                    'filesize_readable':
                    '',
                    'recordingtime':
                    rtime,
                    'begintime':
                    'undefined',
                    'eventname':
                    ServiceReference(serviceref).getServiceName().replace(
                        '\xc2\x86', '').replace('\xc2\x87', ''),
                    'servicename':
                    sourceRef.getServiceName().replace('\xc2\x86', '').replace(
                        '\xc2\x87', ''),
                    'tags':
                    info.getInfoString(serviceref, iServiceInformation.sTags),
                    'fullname':
                    _serviceref,
                }

                if rtime > 0:
                    movie['begintime'] = FuzzyTime2(rtime)

                try:
                    length_minutes = info.getLength(serviceref)
                except:  # noqa: E722
                    pass

                if length_minutes:
                    movie['length'] = "%d:%02d" % (length_minutes / 60,
                                                   length_minutes % 60)
                    if fields is None or 'pos' in fields:
                        movie['lastseen'] = _moviePlayState(
                            filename + '.cuts', serviceref,
                            length_minutes) or 0

                if fields is None or 'desc' in fields:
                    txtfile = name + '.txt'
                    if ext.lower() != '.ts' and os.path.isfile(txtfile):
                        with open(txtfile, "rb") as handle:
                            txtdesc = six.ensure_str(b''.join(
                                handle.readlines()))

                    event = info.getEvent(serviceref)
                    extended_description = event and event.getExtendedDescription(
                    ) or ""
                    if extended_description == '' and txtdesc != '':
                        extended_description = txtdesc
                    movie['descriptionExtended'] = ConvertDesc(
                        extended_description)

                    desc = info.getInfoString(serviceref,
                                              iServiceInformation.sDescription)
                    movie['description'] = ConvertDesc(desc)

                if fields is None or 'size' in fields:
                    size = 0
                    sz = ''

                    try:
                        size = os.stat(filename).st_size
                        if size > 1073741824:
                            sz = "%.2f %s" % ((size / 1073741824.), _("GB"))
                        elif size > 1048576:
                            sz = "%.2f %s" % ((size / 1048576.), _("MB"))
                        elif size > 1024:
                            sz = "%.2f %s" % ((size / 1024.), _("kB"))
                    except:  # noqa: E722
                        pass

                    movie['filesize'] = size
                    movie['filesize_readable'] = sz

                movieliste.append(movie)


#		del movielist

    if locations is None:
        return {
            "movies": movieliste,
            "bookmarks": bookmarklist,
            "directory": directory,
            "recursive": brecursive
        }

    if brecursive:
        return {
            "movies": movieliste,
            "locations": locations,
            "directory": directory,
            "bookmarks": bookmarklist,
            "recursive": brecursive
        }
    else:
        return {
            "movies": movieliste,
            "locations": locations,
            "recursive": brecursive
        }
示例#12
0
			elif selected[0] == "Setup":
				exec "from Screens.Setup import *"
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0].startswith("Zap"):
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
					self.pipShown() and self.showPiP()
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "Menu":
				from Screens.Menu import MainMenu, mdom
				root = mdom.getroot()
				for x in root.findall("menu"):
					y = x.find("id")
					if y is not None:
						id = y.get("val")
						if id and id == selected[1]:
							menu_screen = self.session.open(MainMenu, x)
							break

	def showServiceListOrMovies(self):
		if hasattr(self, "openServiceList"):
示例#13
0
	def execHotkey(self, selected):
		if selected:
			selected = selected[1].split("/")
			if selected[0] == "Plugins":
				twinPlugins = []
				twinPaths = {}
				pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
				pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
			elif selected[0] == "MenuPlugin":
				for plugin in plugins.getPluginsForMenu(selected[1]):
					if plugin[2] == selected[2]:
						self.runPlugin(plugin[1])
						return
			elif selected[0] == "Infobar":
				if hasattr(self, selected[1]):
					exec "self." + ".".join(selected[1:]) + "()"
				else:
					return 0
			elif selected[0] == "Module":
				try:
					exec "from " + selected[1] + " import " + selected[2]
					exec "self.session.open(" + ",".join(selected[2:]) + ")"
				except:
					print "[Hotkey] error during executing module %s, screen %s" % (selected[1], selected[2])
			elif selected[0] == "Setup":
				from Screens.Setup import Setup
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0][:3] == "Zap":
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "PPanel":
				ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
				if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
					from Plugins.Extensions.PPanel.ppanel import PPanel
					self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None)
			elif selected[0][-6:] == "script":
				command = '/usr/script/' + selected[1] + ".sh"
				if os.path.isfile(command):
					if selected[0] == "Backgroundscript":
						from Components.Console import Console as eConsole					
						message = _("Execute %s") % (selected[1] + ".sh")
						self.session.open(MessageBox, message, type = MessageBox.TYPE_INFO, timeout = 2)
						eConsole().ePopen(command)
					elif os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
						from Plugins.Extensions.PPanel.ppanel import Execute
						self.session.open(Execute, selected[1] + " shellscript", None, command)
					else:
						from Screens.Console import Console as sConsole
						self.session.open(sConsole, cmdlist = [command])
			elif selected[0] == "Menu":
				from Screens.Menu import MainMenu, mdom
				root = mdom.getroot()
				for x in root.findall("menu"):
					y = x.find("id")
					if y is not None:
						id = y.get("val")
						if id and id == selected[1]:
							menu_screen = self.session.open(MainMenu, x)
							break
示例#14
0
	def execHotkey(self, selected):
		if selected:
			selected = selected[1].split("/")
			if selected[0] == "Plugins":
				twinPlugins = []
				twinPaths = {}
				pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_EVENTINFO)
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
				pluginlist = plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU])
				pluginlist.sort(key=lambda p: p.name)
				for plugin in pluginlist:
					if plugin.name not in twinPlugins and plugin.path:
						if twinPaths.has_key(plugin.path[24:]):
							twinPaths[plugin.path[24:]] += 1
						else:
							twinPaths[plugin.path[24:]] = 1
						if plugin.path[24:] + "/" + str(twinPaths[plugin.path[24:]]) == "/".join(selected):
							self.runPlugin(plugin)
							return
						twinPlugins.append(plugin.name)
			elif selected[0] == "MenuPlugin":
				for plugin in plugins.getPluginsForMenu(selected[1]):
					if plugin[2] == selected[2]:
						self.runPlugin(plugin[1])
						return
			elif selected[0] == "Infobar":
				if hasattr(self, selected[1]):
					exec "self." + ".".join(selected[1:]) + "()"
				else:
					return 0
			elif selected[0] == "Module":
				try:
					exec "from " + selected[1] + " import " + selected[2]
					exec "self.session.open(" + ",".join(selected[2:]) + ")"
				except:
					print "[Hotkey] error during executing module %s, screen %s" % (selected[1], selected[2])
			elif selected[0] == "Setup":
				from Screens.Setup import Setup
				exec "self.session.open(Setup, \"" + selected[1] + "\")"
			elif selected[0][:3] == "Zap":
				if selected[0] == "ZapPanic":
					self.servicelist.history = []
				self.servicelist.servicelist.setCurrent(eServiceReference("/".join(selected[1:])))
				self.servicelist.zap(enable_pipzap = True)
				if hasattr(self, "lastservice"):
					self.lastservice = eServiceReference("/".join(selected[1:]))
					self.close()
				else:
					self.show()
				from Screens.MovieSelection import defaultMoviePath
				moviepath = defaultMoviePath()
				if moviepath:
					config.movielist.last_videodir.value = moviepath
			elif selected[0] == "PPanel":
				ppanelFileName = '/etc/ppanels/' + selected[1] + ".xml"
				if os.path.isfile(ppanelFileName) and os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
					from Plugins.Extensions.PPanel.ppanel import PPanel
					self.session.open(PPanel, name=selected[1] + ' PPanel', node=None, filename=ppanelFileName, deletenode=None)
			elif selected[0][-6:] == "script":
				command = '/usr/script/' + selected[1] + ".sh"
				if os.path.isfile(command):
					if selected[0] == "Backgroundscript":
						from Components.Console import Console as eConsole
						message = _("Execute %s") % (selected[1] + ".sh")
						self.session.open(MessageBox, message, type = MessageBox.TYPE_INFO, timeout = 2)
						eConsole().ePopen(command)
					elif os.path.isdir('/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
						from Plugins.Extensions.PPanel.ppanel import Execute
						self.session.open(Execute, selected[1] + " shellscript", None, command)
					else:
						from Screens.Console import Console as sConsole
						self.session.open(sConsole, cmdlist = [command])
示例#15
0
 def execButtonSetup(self, selected):
     if selected:
         selected = selected[1].split("/")
         if selected[0] == "Plugins":
             twinPlugins = []
             twinPaths = {}
             pluginList = plugins.getPlugins(
                 PluginDescriptor.WHERE_EVENTINFO)
             pluginList.sort(key=lambda x: x.name)
             for plugin in pluginList:
                 if plugin.name not in twinPlugins and plugin.path and "selectedevent" not in plugin.__call__.__code__.co_varnames:
                     if plugin.path[plugin.path.rfind("Plugins"
                                                      ):] in twinPaths:
                         twinPaths[plugin.path[plugin.path.rfind("Plugins"
                                                                 ):]] += 1
                     else:
                         twinPaths[
                             plugin.path[plugin.path.rfind("Plugins"):]] = 1
                     if "%s/%s" % (
                             plugin.path[plugin.path.rfind("Plugins"):],
                             str(twinPaths[plugin.path[plugin.path.rfind(
                                 "Plugins"):]])) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
             pluginList = plugins.getPlugins([
                 PluginDescriptor.WHERE_PLUGINMENU,
                 PluginDescriptor.WHERE_EXTENSIONSMENU
             ])
             pluginList.sort(key=lambda p: p.name)
             for plugin in pluginList:
                 if plugin.name not in twinPlugins and plugin.path:
                     if plugin.path[plugin.path.rfind("Plugins"
                                                      ):] in twinPaths:
                         twinPaths[plugin.path[plugin.path.rfind("Plugins"
                                                                 ):]] += 1
                     else:
                         twinPaths[
                             plugin.path[plugin.path.rfind("Plugins"):]] = 1
                     if "%s/%s" % (
                             plugin.path[plugin.path.rfind("Plugins"):],
                             str(twinPaths[plugin.path[plugin.path.rfind(
                                 "Plugins"):]])) == "/".join(selected):
                         self.runPlugin(plugin)
                         return
                     twinPlugins.append(plugin.name)
         elif selected[0] == "MenuPlugin":
             for plugin in plugins.getPluginsForMenu(selected[1]):
                 if plugin[2] == selected[2]:
                     self.runPlugin(plugin[1])
                     return
         elif selected[0] == "Infobar":
             if hasattr(self, selected[1]):
                 exec("self.%s()" % ".".join(selected[1:]))
             else:
                 return 0
         elif selected[0] == "Module":
             try:
                 exec("from %s import %s\nself.session.open(%s)" %
                      (selected[1], selected[2], ",".join(selected[2:])))
             except Exception as err:
                 print(
                     "[ButtonSetup] Error: Exception raised executing module '%s', screen '%s'!  (%s)"
                     % (selected[1], selected[2], str(err)))
                 import traceback
                 traceback.print_exc()
         elif selected[0] == "Setup":
             from Screens.Setup import Setup
             # exec("self.session.open(Setup, \"%s\")" % selected[1])  # DEBUG: What is this trying to do?
             self.session.open(Setup, selected[1])
         elif selected[0].startswith("Zap"):
             if selected[0] == "ZapPanic":
                 self.servicelist.history = []
                 self.pipShown() and self.showPiP()
             self.servicelist.servicelist.setCurrent(
                 eServiceReference("/".join(selected[1:])))
             self.servicelist.zap(enable_pipzap=True)
             if hasattr(self, "lastservice"):
                 self.lastservice = eServiceReference("/".join(
                     selected[1:]))
                 self.close()
             else:
                 self.show()
             from Screens.MovieSelection import defaultMoviePath
             moviepath = defaultMoviePath()
             if moviepath:
                 config.movielist.last_videodir.value = moviepath
         elif selected[0] == "PPanel":
             ppanelFileName = "/etc/ppanels/%s.xml" % selected[1]
             if isfile(ppanelFileName) and isdir(
                     "/usr/lib/enigma2/python/Plugins/Extensions/PPanel"):
                 from Plugins.Extensions.PPanel.ppanel import PPanel
                 self.session.open(PPanel,
                                   name="%s PPanel" % selected[1],
                                   node=None,
                                   filename=ppanelFileName,
                                   deletenode=None)
         elif selected[0] == "Shellscript":
             command = "/usr/script/%s.sh" % selected[1]
             if isfile(command) and isdir(
                     "/usr/lib/enigma2/python/Plugins/Extensions/PPanel"):
                 from Plugins.Extensions.PPanel.ppanel import Execute
                 self.session.open(Execute, "%s shellscript" % selected[1],
                                   None, command)
             else:
                 from Screens.Console import Console
                 # exec("self.session.open(Console, title=_(selected[1]), cmdlist=[command])")  # DEBUG: What is this trying to do?
                 self.session.open(Console, selected[1], [command])
         elif selected[0] == "EMC":
             try:
                 from Plugins.Extensions.EnhancedMovieCenter.plugin import showMoviesNew
                 from Screens.InfoBar import InfoBar
                 open(showMoviesNew(InfoBar.instance)
                      )  # DEBUG: Should this be self.session.open?
             except Exception as err:
                 print(
                     "[ButtonSetup] EMCPlayer: showMovies exception: %s!" %
                     str(err))
         elif selected[0] == "ScriptRunner":
             from Screens.ScriptRunner import ScriptRunner
             self.session.open(ScriptRunner)
         elif selected[0] == "QuickMenu":
             from Screens.QuickMenu import QuickMenu
             self.session.open(QuickMenu)
         elif selected[0] == "Kodi":
             if isPluginInstalled("Kodi"):
                 from Plugins.Extensions.Kodi.plugin import KodiMainScreen
                 self.session.open(KodiMainScreen)
         elif selected[0] == "Bluetooth":
             if isPluginInstalled("BluetoothSetup"):
                 from Plugins.SystemPlugins.BluetoothSetup.plugin import BluetoothSetup
                 self.session.open(BluetoothSetup)
         elif selected[0] == "YoutubeTV":
             if isPluginInstalled("Chromium"):
                 from Plugins.Extensions.Chromium.youtube import YoutubeTVWindow
                 self.session.open(YoutubeTVWindow)
示例#16
0
    def execButtonSetup(self, selected):
        if selected:
            selected = selected[1].split('/')
            if selected[0] == 'Plugins':
                twinPlugins = []
                twinPaths = {}
                pluginlist = plugins.getPlugins(
                    PluginDescriptor.WHERE_EVENTINFO)
                pluginlist.sort(key=lambda p: p.name)
                for plugin in pluginlist:
                    if plugin.name not in twinPlugins and plugin.path and 'selectedevent' not in plugin.__call__.func_code.co_varnames:
                        if twinPaths.has_key(plugin.path[24:]):
                            twinPaths[plugin.path[24:]] += 1
                        else:
                            twinPaths[plugin.path[24:]] = 1
                        if plugin.path[24:] + '/' + str(twinPaths[
                                plugin.path[24:]]) == '/'.join(selected):
                            self.runPlugin(plugin)
                            return
                        twinPlugins.append(plugin.name)

                pluginlist = plugins.getPlugins([
                    PluginDescriptor.WHERE_PLUGINMENU,
                    PluginDescriptor.WHERE_EXTENSIONSMENU
                ])
                pluginlist.sort(key=lambda p: p.name)
                for plugin in pluginlist:
                    if plugin.name not in twinPlugins and plugin.path:
                        if twinPaths.has_key(plugin.path[24:]):
                            twinPaths[plugin.path[24:]] += 1
                        else:
                            twinPaths[plugin.path[24:]] = 1
                        if plugin.path[24:] + '/' + str(twinPaths[
                                plugin.path[24:]]) == '/'.join(selected):
                            self.runPlugin(plugin)
                            return
                        twinPlugins.append(plugin.name)

            elif selected[0] == 'MenuPlugin':
                for plugin in plugins.getPluginsForMenu(selected[1]):
                    if plugin[2] == selected[2]:
                        self.runPlugin(plugin[1])
                        return

            elif selected[0] == 'Infobar':
                if hasattr(self, selected[1]):
                    exec 'self.' + '.'.join(selected[1:]) + '()'
                else:
                    return 0
            elif selected[0] == 'Module':
                try:
                    exec 'from ' + selected[1] + ' import *'
                    exec 'self.session.open(' + ','.join(selected[2:]) + ')'
                except:
                    print '[ButtonSetup] error during executing module %s, screen %s' % (
                        selected[1], selected[2])

            elif selected[0] == 'Setup':
                exec 'from Screens.Setup import *'
                exec 'self.session.open(Setup, "' + selected[1] + '")'
            elif selected[0].startswith('Zap'):
                if selected[0] == 'ZapPanic':
                    self.servicelist.history = []
                    self.pipShown() and self.showPiP()
                self.servicelist.servicelist.setCurrent(
                    eServiceReference('/'.join(selected[1:])))
                self.servicelist.zap(enable_pipzap=True)
                if hasattr(self, 'lastservice'):
                    self.lastservice = eServiceReference('/'.join(
                        selected[1:]))
                    self.close()
                else:
                    self.show()
                from Screens.MovieSelection import defaultMoviePath
                moviepath = defaultMoviePath()
                if moviepath:
                    config.movielist.last_videodir.value = moviepath
            elif selected[0] == 'PPanel':
                ppanelFileName = '/etc/ppanels/' + selected[1] + '.xml'
                if os.path.isfile(ppanelFileName) and os.path.isdir(
                        '/usr/lib/enigma2/python/Plugins/Extensions/PPanel'):
                    from Plugins.Extensions.PPanel.ppanel import PPanel
                    self.session.open(PPanel,
                                      name=selected[1] + ' PPanel',
                                      node=None,
                                      filename=ppanelFileName,
                                      deletenode=None)
            elif selected[0] == 'EMC':
                try:
                    from Plugins.Extensions.EnhancedMovieCenter.plugin import showMoviesNew
                    from Screens.InfoBar import InfoBar
                    open(showMoviesNew(InfoBar.instance))
                except Exception as e:
                    print '[EMCPlayer] showMovies exception:\n' + str(e)

            elif selected[0] == 'Kodi':
                if os.path.isfile(
                        '/usr/lib/enigma2/python/Plugins/Extensions/Kodi/plugin.pyo'
                ):
                    from Plugins.Extensions.Kodi.plugin import KodiMainScreen
                    self.session.open(KodiMainScreen)
            elif selected[0] == 'Bluetooth':
                if os.path.isfile(
                        '/usr/lib/enigma2/python/Plugins/SystemPlugins/BluetoothSetup/plugin.pyo'
                ):
                    from Plugins.SystemPlugins.BluetoothSetup.plugin import BluetoothSetup
                    self.session.open(BluetoothSetup)
        return