Ejemplo n.º 1
0
	def updateList(self):
		self.sub_menu_sort = NoSave(ConfigDictionarySet())
		self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(self.menuID, "submenu") or None
		idx = 0
		for x in self.list:
			entry = list(self.list.pop(idx))
			m_weight = self.sub_menu_sort.getConfigValue(entry[2], "sort") or entry[3]
			entry.append(m_weight)
			self.list.insert(idx, tuple(entry))
			self.sub_menu_sort.changeConfigValue(entry[2], "sort", m_weight)
			if not self.sort_mode and self.sub_menu_sort.getConfigValue(entry[2], "hidden"):
				self.list.remove(x)
			idx += 1
Ejemplo n.º 2
0
    def createMenuList(self, showNumericHelp=False):
        self["key_blue"].text = _(
            "Edit menu") if config.usage.menu_sort_mode.value == "user" else ""
        self.list = []
        self.menuID = None
        for x in self.parentmenu:  # walk through the actual nodelist
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get("level", 0))
                if item_level <= config.usage.setup_level.index:
                    self.addItem(self.list, x)
                    count += 1
            elif x.tag == 'menu':
                item_level = int(x.get("level", 0))
                if item_level <= config.usage.setup_level.index:
                    self.addMenu(self.list, x)
                    count += 1
            elif x.tag == "id":
                self.menuID = x.get("val")
                count = 0

            if self.menuID:
                # menuupdater?
                if menuupdater.updatedMenuAvailable(self.menuID):
                    for x in menuupdater.getUpdatedMenu(self.menuID):
                        if x[1] == count:
                            self.list.append(
                                (x[0],
                                 boundFunction(self.runScreen,
                                               (x[2], x[3] + ", ")), x[4]))
                            count += 1
        if self.menuID:
            # plugins
            for l in plugins.getPluginsForMenu(self.menuID):
                # check if a plugin overrides an existing menu
                plugin_menuid = l[2]
                for x in self.list:
                    if x[2] == plugin_menuid:
                        self.list.remove(x)
                        break
                self.list.append(
                    (l[0], boundFunction(l[1], self.session,
                                         close=self.close), l[2], l[3] or 50))

        if "user" in config.usage.menu_sort_mode.value and self.menuID == "mainmenu":
            plugin_list = []
            id_list = []
            for l in plugins.getPlugins([
                    PluginDescriptor.WHERE_PLUGINMENU,
                    PluginDescriptor.WHERE_EXTENSIONSMENU,
                    PluginDescriptor.WHERE_EVENTINFO
            ]):
                l.id = (l.name.lower()).replace(' ', '_')
                if l.id not in id_list:
                    id_list.append(l.id)
                    plugin_list.append(
                        (l.name, boundFunction(l.__call__,
                                               self.session), l.id, 200))

        if self.menuID is not None and "user" in config.usage.menu_sort_mode.value:
            self.sub_menu_sort = NoSave(ConfigDictionarySet())
            self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(
                self.menuID, "submenu") or {}
            idx = 0
            for x in self.list:
                entry = list(self.list.pop(idx))
                m_weight = self.sub_menu_sort.getConfigValue(
                    entry[2], "sort") or entry[3]
                entry.append(m_weight)
                self.list.insert(idx, tuple(entry))
                self.sub_menu_sort.changeConfigValue(entry[2], "sort",
                                                     m_weight)
                idx += 1
            self.full_list = list(self.list)

        if config.usage.menu_sort_mode.value == "a_z":
            # Sort by Name
            self.list.sort(key=self.sortByName)
        elif "user" in config.usage.menu_sort_mode.value:
            self.hide_show_entries()
        else:
            # Sort by Weight
            self.list.sort(key=lambda x: int(x[3]))

        if config.usage.menu_show_numbers.value in ("menu&plugins",
                                                    "menu") or showNumericHelp:
            self.list = [(str(x[0] + 1) + " " + x[1][0], x[1][1], x[1][2])
                         for x in enumerate(self.list)]

        self["menu"].setList(self.list)
Ejemplo n.º 3
0
    def __init__(self, session, parent):
        Screen.__init__(self, session)

        self.sort_mode = False
        self.selected_entry = None
        self.sub_menu_sort = None

        self["green"] = Label()
        self["yellow"] = Label()
        self["blue"] = Label()

        m_list = []

        menuID = None
        for x in parent:  #walk through the actual nodelist
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get("level", 0))
                if item_level <= config.usage.setup_level.index:
                    self.addItem(m_list, x)
                    count += 1
            elif x.tag == 'menu':
                item_level = int(x.get("level", 0))
                if item_level <= config.usage.setup_level.index:
                    self.addMenu(m_list, x)
                    count += 1
            elif x.tag == "id":
                menuID = x.get("val")
                count = 0

            if menuID is not None:
                # menuupdater?
                if menuupdater.updatedMenuAvailable(menuID):
                    for x in menuupdater.getUpdatedMenu(menuID):
                        if x[1] == count:
                            m_list.append(
                                (x[0],
                                 boundFunction(self.runScreen,
                                               (x[2], x[3] + ", ")), x[4]))
                            count += 1
        self.menuID = menuID

        if menuID is not None:
            # plugins
            for l in plugins.getPluginsForMenu(menuID):
                # check if a plugin overrides an existing menu
                plugin_menuid = l[2]
                for x in m_list:
                    if x[2] == plugin_menuid:
                        m_list.remove(x)
                        break
                if len(l) > 4 and l[4]:
                    m_list.append(
                        (l[0], boundFunction(l[1], self.session,
                                             self.close), l[2], l[3] or 50))
                else:
                    m_list.append(
                        (l[0], boundFunction(l[1], self.session), l[2], l[3]
                         or 50))

        # for the skin: first try a menu_<menuID>, then Menu
        self.skinName = []
        if menuID is not None:
            self.skinName.append("menu_" + menuID)
        self.skinName.append("Menu")
        self.menuID = menuID
        ProtectedScreen.__init__(self)

        if config.plugins.infopanel_usermenus is not None and menuID == "mainmenu":
            plugin_list = []
            id_list = []
            for l in plugins.getPlugins([
                    PluginDescriptor.WHERE_PLUGINMENU,
                    PluginDescriptor.WHERE_EXTENSIONSMENU,
                    PluginDescriptor.WHERE_EVENTINFO
            ]):
                l.id = (l.name.lower()).replace(' ', '_')
                if l.id not in id_list:
                    id_list.append(l.id)
                    plugin_list.append(
                        (l.name, boundFunction(l.__call__,
                                               session), l.id, 200))
            addlist = config.plugins.infopanel_usermenus.value
            addlist = addlist.split(',')
            for entry in plugin_list:
                if entry[2] in addlist:
                    list.append(entry)

        self.list = list

        # Sort by Weight
        #if config.usage.sort_menus.value:
        #	list.sort()
        #else:
        if config.usage.menu_sort_mode.value == "user" and menuID == "mainmenu":
            plugin_list = []
            id_list = []
            for l in plugins.getPlugins([
                    PluginDescriptor.WHERE_PLUGINMENU,
                    PluginDescriptor.WHERE_EXTENSIONSMENU,
                    PluginDescriptor.WHERE_EVENTINFO
            ]):
                l.id = (l.name.lower()).replace(' ', '_')
                if l.id not in id_list:
                    id_list.append(l.id)
                    plugin_list.append(
                        (l.name, boundFunction(l.__call__,
                                               session), l.id, 200))

        self.list = m_list

        if menuID is not None and config.usage.menu_sort_mode.value == "user":
            self.sub_menu_sort = NoSave(ConfigDictionarySet())
            self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(
                self.menuID, "submenu") or {}
            idx = 0
            for x in self.list:
                entry = list(self.list.pop(idx))
                m_weight = self.sub_menu_sort.getConfigValue(
                    entry[2], "sort") or entry[3]
                entry.append(m_weight)
                self.list.insert(idx, tuple(entry))
                self.sub_menu_sort.changeConfigValue(entry[2], "sort",
                                                     m_weight)
                idx += 1
            self.full_list = list(m_list)

        if config.usage.menu_sort_mode.value == "a_z":
            # Sort by Name
            m_list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == "user":
            self["blue"].setText(_("Edit mode on"))
            self.hide_show_entries()
            m_list = self.list
        else:
            # Sort by Weight
            m_list.sort(key=lambda x: int(x[3]))

        self["menu"] = List(m_list)
        self["menu"].enableWrapAround = True
        if config.usage.menu_sort_mode.value == "user":
            self["menu"].onSelectionChanged.append(self.selectionChanged)

        self["actions"] = NumberActionMap(
            ["OkCancelActions", "MenuActions", "NumberActions"], {
                "ok": self.okbuttonClick,
                "cancel": self.closeNonRecursive,
                "menu": self.closeRecursive,
                "0": self.resetSortOrder,
                "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
            })
        if config.usage.menu_sort_mode.value == "user":
            self["MoveActions"] = ActionMap(
                ["WizardActions"], {
                    "left": self.keyLeft,
                    "right": self.keyRight,
                    "up": self.keyUp,
                    "down": self.keyDown,
                }, -1)

            self["EditActions"] = ActionMap(
                ["ColorActions"], {
                    "green": self.keyGreen,
                    "yellow": self.keyYellow,
                    "blue": self.keyBlue,
                })

        a = six.ensure_str(parent.get("title", "")) or None
        a = a and _(a)
        if a is None:
            a = _(six.ensure_str(parent.get("text", "")))
        else:
            t_history.reset()
        self["title"] = StaticText(a)
        Screen.setTitle(self, a)
        self.menu_title = a
        self["thistory"] = StaticText(t_history.thistory)
        history_len = len(t_history.thistory)
        self["title0"] = StaticText('')
        self["title1"] = StaticText('')
        self["title2"] = StaticText('')
        if history_len < 13:
            self["title0"] = StaticText(a)
        elif history_len < 21:
            self["title0"] = StaticText('')
            self["title1"] = StaticText(a)
        else:
            self["title0"] = StaticText('')
            self["title1"] = StaticText('')
            self["title2"] = StaticText(a)

        if (t_history.thistory == ''):
            t_history.thistory = str(a) + ' > '
        else:
            t_history.thistory = t_history.thistory + str(a) + ' > '
Ejemplo n.º 4
0
 def createMenuList(self, showNumericHelp=False):
     self.menuID = self.parentMenu.get("key")
     self.menuList = []
     for menu in self.parentMenu:  # Walk through the menu node list.
         if not menu.tag:
             continue
         if menu.tag == "item":
             itemLevel = int(menu.get("level", 0))
             if itemLevel <= config.usage.setup_level.index:
                 data = self.addItem(menu)
                 if data:
                     self.menuList.append(data)
         elif menu.tag == "menu":
             itemLevel = int(menu.get("level", 0))
             if itemLevel <= config.usage.setup_level.index:
                 data = self.addMenu(menu)
                 if data:
                     self.menuList.append(data)
     if self.menuID:
         for plugin in plugins.getPluginsForMenu(self.menuID):  # Plugins.
             # print("[Menu] DEBUG 1: Plugin data=%s." % str(plugin))
             pluginKey = plugin[
                 PLUGIN_KEY]  # Check if a plugin overrides an existing menu.
             for entry in self.menuList:
                 if entry[PLUGIN_KEY] == pluginKey:
                     self.menuList.remove(entry)
                     break
             description = plugins.getDescriptionForMenuEntryID(
                 self.menuID, pluginKey
             )  # It is assumed that description is already translated by the plugin!
             if "%s %s" in description:
                 description = description % (DISPLAY_BRAND, DISPLAY_MODEL)
             image = self.getMenuEntryImage(plugin[PLUGIN_KEY], lastKey)
             if len(plugin) > PLUGIN_CLOSEALL and plugin[
                     PLUGIN_CLOSEALL]:  # Was "len(plugin) > 4".
                 self.menuList.append(
                     (plugin[PLUGIN_TEXT],
                      boundFunction(plugin[PLUGIN_MODULE], self.session,
                                    self.close), plugin[PLUGIN_KEY],
                      plugin[PLUGIN_WEIGHT] or 50, description, image))
             else:
                 self.menuList.append(
                     (plugin[PLUGIN_TEXT],
                      boundFunction(plugin[PLUGIN_MODULE],
                                    self.session), plugin[PLUGIN_KEY],
                      plugin[PLUGIN_WEIGHT] or 50, description, image))
     if config.usage.menuSortOrder.value == "user" and self.menuID == "mainmenu":
         idList = []
         for plugin in plugins.getPlugins([
                 PluginDescriptor.WHERE_PLUGINMENU,
                 PluginDescriptor.WHERE_EXTENSIONSMENU,
                 PluginDescriptor.WHERE_EVENTINFO
         ]):
             # print("[Menu] DEBUG 2: Plugin data=%s." % str(plugin))
             plugin.id = (plugin.name.lower()).replace(" ", "_")
             if plugin.id not in idList:
                 idList.append(plugin.id)
     if self.menuID is not None and config.usage.menuSortOrder.value == "user":
         self.subMenuSort = NoSave(ConfigDictionarySet())
         self.subMenuSort.value = config.usage.menu_sort_weight.getConfigValue(
             self.menuID, "submenu") or {}
         for index, entry in enumerate(self.menuList):
             data = list(self.menuList.pop(index))
             sort = self.subMenuSort.getConfigValue(
                 data[MENU_KEY], "sort") or data[MENU_WEIGHT]
             data.append(sort)
             self.menuList.insert(index, tuple(data))
             self.subMenuSort.changeConfigValue(data[MENU_KEY], "sort",
                                                sort)
         self.fullMenuList = list(self.menuList)
     if config.usage.menuSortOrder.value == "alpha":  # Sort by menu item text.
         self.menuList.sort(key=lambda x: x[MENU_TEXT].lower())
     elif config.usage.menuSortOrder.value == "user":  # Sort by user defined sequence.
         self["key_blue"].setText(_("Edit Mode On"))
         self.hideShowEntries()
     else:  # Sort by menu item weight.
         self.menuList.sort(key=lambda x: int(x[MENU_WEIGHT]))
     self.setMenuList(self.menuList)
Ejemplo n.º 5
0
    def createMenuList(self):
        self.list = []
        self.menuID = None
        for x in self.parentmenu:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get('level', 0))
                if item_level <= config.usage.setup_level.index:
                    self.addItem(self.list, x)
                    count += 1
            elif x.tag == 'menu':
                item_level = int(x.get('level', 0))
                if item_level <= config.usage.setup_level.index:
                    self.addMenu(self.list, x)
                    count += 1
            elif x.tag == 'id':
                self.menuID = x.get('val')
                count = 0
            if self.menuID:
                if menuupdater.updatedMenuAvailable(self.menuID):
                    for x in menuupdater.getUpdatedMenu(self.menuID):
                        if x[1] == count:
                            self.list.append((x[0], boundFunction(self.runScreen, (x[2], x[3] + ', ')), x[4]))
                            count += 1

        if self.menuID:
            for l in plugins.getPluginsForMenu(self.menuID):
                plugin_menuid = l[2]
                for x in self.list:
                    if x[2] == plugin_menuid:
                        self.list.remove(x)
                        break

                self.list.append((l[0],
                 boundFunction(l[1], self.session, close=self.close),
                 l[2],
                 l[3] or 50))

        if config.usage.menu_sort_mode.value == 'user' and self.menuID == 'mainmenu':
            plugin_list = []
            id_list = []
            for l in plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU, PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
                l.id = l.name.lower().replace(' ', '_')
                if l.id not in id_list:
                    id_list.append(l.id)
                    plugin_list.append((l.name,
                     boundFunction(l.__call__, self.session),
                     l.id,
                     200))

        if self.menuID is not None and config.usage.menu_sort_mode.value == 'user':
            self.sub_menu_sort = NoSave(ConfigDictionarySet())
            self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(self.menuID, 'submenu') or {}
            idx = 0
            for x in self.list:
                entry = list(self.list.pop(idx))
                m_weight = self.sub_menu_sort.getConfigValue(entry[2], 'sort') or entry[3]
                entry.append(m_weight)
                self.list.insert(idx, tuple(entry))
                self.sub_menu_sort.changeConfigValue(entry[2], 'sort', m_weight)
                idx += 1

            self.full_list = list(self.list)
        if config.usage.menu_sort_mode.value == 'a_z':
            self.list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == 'user':
            self.hide_show_entries()
        else:
            self.list.sort(key=lambda x: int(x[3]))
        self['menu'].updateList(self.list)
Ejemplo n.º 6
0
def runScreenTest():
	config.misc.startCounter.value += 1

	profile("readPluginList")
	plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))

	profile("Init:Session")
	nav = Navigation(config.misc.nextWakeup.value)
	#nav = Navigation(config.misc.isNextRecordTimerAfterEventActionAuto.value, config.misc.isNextPowerTimerAfterEventActionAuto.value)
	session = Session(desktop = enigma.getDesktop(0), summary_desktop = enigma.getDesktop(1), navigation = nav)

	CiHandler.setSession(session)

	profile("wizards")
	screensToRun = []
	RestoreSettings = None
	import hashlib
	import os
	from os import path
	from pathlib import Path
	import fileinput, sys	
	def md5_update_from_file(filename, hash):
		assert Path(filename).is_file()
		with open(str(filename), "rb") as f:
			for chunk in iter(lambda: f.read(4096), b""):
				hash.update(chunk)
		return hash


	def md5_file(filename):
		return md5_update_from_file(filename, hashlib.md5()).hexdigest()

	def md5_update_from_dir(directory, hash):
		assert Path(directory).is_dir()
		for path in sorted(Path(directory).iterdir()):
			hash.update(path.name.encode())
			if path.is_file():
				hash = md5_update_from_file(path, hash)
			elif path.is_dir():
				hash = md5_update_from_dir(path, hash)
		return hash


	def md5_dir(directory):
		return md5_update_from_dir(directory, hashlib.md5()).hexdigest()	
	
	
	sha256hash = ()
	myfilecheck = "/usr/lib/enigma2/python/Plugins/Extensions/Infopanel"
	sha256save = "/var/lib/opkg/info/enigma2-plugin-extensions-infopanel.sha256"
	if config.misc.firstrun.value == True:
		myfile = Path(sha256save)
		if os.path.isfile(sha256save):
			os.remove(sha256save)
		myfile.touch(exist_ok=True)
		sha256hash = md5_dir(myfilecheck)
		sha_f = open(sha256save, "a")
		sha_f.write(sha256hash)
		sha_f.close()
	else:
		if os.path.isfile(sha256save): 
			sha256hash = md5_dir(myfilecheck)
			try:
				sha256read = open(sha256save,'r')
				sha256hash1 = sha256read.read()
				print("sha256hash1:", sha256hash1)
				print("sha256hash:", sha256hash)				
				if sha256hash == sha256hash1:
					print("all ok with Infopanel")
				else:
					print("Sorry, but you change our Infopanel so we had to disable it!!")
					sub_menu_sort = NoSave(ConfigDictionarySet())
					sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue("mainmenu", "submenu")
					m_weight = sub_menu_sort.getConfigValue('Infopanel', "sort")
					m_weight1 = sub_menu_sort.getConfigValue('Infopanel', "hidden")
					sub_menu_sort.changeConfigValue('Infopanel', "hidden", "1")				
					config.usage.menu_sort_weight.save()
					configfile.save()			
				
				sha256read.close()
			
			except:
				print("Sorry, but you change our Infopanel so we had to disable it!!")
				sub_menu_sort = NoSave(ConfigDictionarySet())
				sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue("mainmenu", "submenu")
				m_weight = sub_menu_sort.getConfigValue('Infopanel', "sort")
				m_weight1 = sub_menu_sort.getConfigValue('Infopanel', "hidden")
				sub_menu_sort.changeConfigValue('Infopanel', "hidden", "1")				
				config.usage.menu_sort_weight.save()
				configfile.save()                                        
		else:
			print("Sorry, but you change our Infopanel so we had to disable it!!")
			sub_menu_sort = NoSave(ConfigDictionarySet())
			sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue("mainmenu", "submenu")
			m_weight = sub_menu_sort.getConfigValue('Infopanel', "sort")
			m_weight1 = sub_menu_sort.getConfigValue('Infopanel', "hidden")
			sub_menu_sort.changeConfigValue('Infopanel', "hidden", "1")				
			config.usage.menu_sort_weight.save()
			configfile.save()                                                  
                                                                            	
	if os.path.exists("/media/hdd/images/config/settings") and config.misc.firstrun.value:
		if autorestoreLoop():
			RestoreSettings = True
			from Plugins.SystemPlugins.SoftwareManager.BackupRestore import RestoreScreen
			os.system("rm /media/hdd/images/config/settings")
			session.open(RestoreScreen, runRestore = True)
		else:
			os.system("rm /media/hdd/images/config/settings")
			screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
			screensToRun += wizardManager.getWizards()
	else:
		if os.path.exists("/media/hdd/images/config/autorestore"):
			os.system('rm -f /media/hdd/images/config/autorestore')
		screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
		screensToRun += wizardManager.getWizards()
	
	screensToRun.append((100, InfoBar.InfoBar))
	screensToRun.sort()
	print(screensToRun)

	enigma.ePythonConfigQuery.setQueryFunc(configfile.getResolvedKey)

	def runNextScreen(session, screensToRun, *result):
		config.easysetup = ConfigSubsection()
		config.easysetup.restart = ConfigBoolean(default = False)
		if config.easysetup.restart.value == True:
			print("restart after Wizard2")
			config.easysetup.restart.setValue(False)
			config.easysetup.restart.save()
			enigma.quitMainloop(3)
		if result:
			print("[mytest.py] quitMainloop #3")
			enigma.quitMainloop(*result)
			return

		screen = screensToRun[0][1]
		args = screensToRun[0][2:]
		if screensToRun:
			session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args)
		else:
			session.open(screen, *args)

	if not RestoreSettings:
		runNextScreen(session, screensToRun)

	profile("Init:VolumeControl")
	vol = VolumeControl(session)
	profile("Init:PowerKey")
	power = PowerKey(session)
	power.timerstdby()        
	if boxtype in ('alien5', 'osninopro', 'osnino', 'osninoplus', 'alphatriple', 'spycat4kmini', 'tmtwin4k', 'mbmicrov2', 'revo4k', 'force3uhd', 'wetekplay', 'wetekplay2', 'wetekhub', 'dm7020hd', 'dm7020hdv2', 'osminiplus', 'osmega', 'sf3038', 'spycat', 'e4hd', 'e4hdhybrid', 'mbmicro', 'et7500', 'mixosf5', 'mixosf7', 'mixoslumi', 'gi9196m', 'maram9', 'ixussone', 'ixusszero', 'uniboxhd1', 'uniboxhd2', 'uniboxhd3', 'sezam5000hd', 'mbtwin', 'sezam1000hd', 'mbmini', 'atemio5x00', 'beyonwizt3', '9910lx', '9911lx', '9920lx') or getBrandOEM() in ('fulan') or getMachineBuild() in ('u41', 'dags7362', 'dags73625', 'dags5', 'ustym4kpro', 'beyonwizv2', 'viper4k', 'sf8008', 'sf8008m', 'cc1', 'gbmv200'):
		profile("VFDSYMBOLS")
	import Components.VfdSymbols
	Components.VfdSymbols.SymbolsCheck(session)
		
	# we need session.scart to access it from within menu.xml
	session.scart = AutoScartControl(session)

	profile("Init:Trashcan")
	import Tools.Trashcan
	Tools.Trashcan.init(session)

	profile("Init:AutoVideoMode")
	import Screens.VideoMode
	Screens.VideoMode.autostart(session)

	profile("RunReactor")
	profile_final()

	if boxtype in ('sf8', 'classm', 'axodin', 'axodinc', 'starsatlx', 'genius', 'evo'):
		f = open("/dev/dbox/oled0", "w")
		f.write('-E2-')
		f.close()

	print("lastshutdown=%s		(True = last shutdown was OK)" % config.usage.shutdownOK.value)
	print("NOK shutdown action=%s" % config.usage.shutdownNOK_action.value)
	print("bootup action=%s" % config.usage.boot_action.value)
	
	if not config.usage.shutdownOK.value and not config.usage.shutdownNOK_action.value == 'normal' or not config.usage.boot_action.value == 'normal':
		print("last shutdown = %s" % config.usage.shutdownOK.value)
		import Screens.PowerLost
		Screens.PowerLost.PowerLost(session)

	config.usage.shutdownOK.setValue(False)
	config.usage.shutdownOK.save()
	if not RestoreSettings:
		configfile.save()
	
	# kill showiframe if it is running (sh4 hack...)
	if getMachineBuild() in ('spark', 'spark7162'):
		os.system("killall -9 showiframe")
	
	runReactor()
	print("[mytest.py] normal shutdown")
	
	config.misc.startCounter.save()
	config.usage.shutdownOK.setValue(True)
	config.usage.shutdownOK.save()	

	profile("wakeup")
	#get currentTime
	nowTime = time()
	if not config.misc.SyncTimeUsing.value == "0" or getBoxType().startswith('gb') or getMachineProcModel().startswith('ini'):
		print("dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime)))
		setRTCtime(nowTime)
		
	wakeupList = [
		x for x in ((session.nav.RecordTimer.getNextRecordingTime(), 0, session.nav.RecordTimer.isNextRecordAfterEventActionAuto()),
					(session.nav.RecordTimer.getNextZapTime(), 1),
					(plugins.getNextWakeupTime(), 2),
					(session.nav.PowerTimer.getNextPowerManagerTime(), 3, session.nav.PowerTimer.isNextPowerManagerAfterEventActionAuto()))
		if x[0] != -1
	]
	wakeupList.sort()
	recordTimerWakeupAuto = False
	if wakeupList and wakeupList[0][1] != 3:
		startTime = wakeupList[0]
		if (startTime[0] - nowTime) < 270: # no time to switch box back on
			wptime = nowTime + 30  # so switch back on in 30 seconds
		else:
			if getBoxType().startswith("gb"):
				wptime = startTime[0] - 120 # Gigaboxes already starts 2 min. before wakeup time
			else:
				wptime = startTime[0] - 240
		if startTime[1] == 3:
			nextPluginName = " (%s)" % nextPluginName				
		#if not config.misc.SyncTimeUsing.value == "0" or getBoxType().startswith('gb'):
		#	print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
		#	setRTCtime(nowTime)
		print("set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime)))
		setFPWakeuptime(wptime)
		recordTimerWakeupAuto = startTime[1] == 0 and startTime[2]
		print('recordTimerWakeupAuto',recordTimerWakeupAuto)
	config.misc.isNextRecordTimerAfterEventActionAuto.value = recordTimerWakeupAuto
	config.misc.isNextRecordTimerAfterEventActionAuto.save()


	PowerTimerWakeupAuto = False
	if wakeupList and wakeupList[0][1] == 3:
		startTime = wakeupList[0]
		if (startTime[0] - nowTime) < 60: # no time to switch box back on
			wptime = nowTime + 30  # so switch back on in 30 seconds
		else:
			if getBoxType().startswith("gb"):
				wptime = startTime[0] + 120 # Gigaboxes already starts 2 min. before wakeup time
			else:
				wptime = startTime[0]
		#if not config.misc.SyncTimeUsing.value == "0" or getBoxType().startswith('gb'):
		#	print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
		#	setRTCtime(nowTime)
		print("set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime+60)))
		setFPWakeuptime(wptime)
		PowerTimerWakeupAuto = startTime[1] == 3 and startTime[2]
		print('PowerTimerWakeupAuto',PowerTimerWakeupAuto)
	config.misc.isNextPowerTimerAfterEventActionAuto.value = PowerTimerWakeupAuto
	config.misc.isNextPowerTimerAfterEventActionAuto.save()

	profile("stopService")
	session.nav.stopService()
	profile("nav shutdown")
	session.nav.shutdown()

	profile("configfile.save")
	configfile.save()
	from Screens import InfoBarGenerics
	InfoBarGenerics.saveResumePoints()

	return 0
Ejemplo n.º 7
0
	def __init__(self, session, parent):
		Screen.__init__(self, session)

		self.sort_mode = False
		self.selected_entry = None
		self.sub_menu_sort = None

		self["green"] = Label()
		self["yellow"] = Label()
		self["blue"] = Label()

		m_list = []

		menuID = None
		for x in parent:						#walk through the actual nodelist
			if not x.tag:
				continue
			if x.tag == 'item':
				item_level = int(x.get("level", 0))
				if item_level <= config.usage.setup_level.index:
					self.addItem(m_list, x)
					count += 1
			elif x.tag == 'menu':
				item_level = int(x.get("level", 0))
				if item_level <= config.usage.setup_level.index:
					self.addMenu(m_list, x)
					count += 1
			elif x.tag == "id":
				menuID = x.get("val")
				count = 0

			if menuID is not None:
				# menuupdater?
				if menuupdater.updatedMenuAvailable(menuID):
					for x in menuupdater.getUpdatedMenu(menuID):
						if x[1] == count:
							description = x.get('description', '').encode('UTF-8') or None
							description = description and _(description)
							menupng = MenuEntryPixmap(menuID, self.png_cache, lastMenuID)
							m_list.append((x[0], boundFunction(self.runScreen, (x[2], x[3] + ", ")), x[4], description, menupng))
							count += 1

		self.menuID = menuID
		if config.ParentalControl.configured.value:
			ProtectedScreen.__init__(self)

		if menuID is not None:
			# plugins
			for l in plugins.getPluginsForMenu(menuID):
				# check if a plugin overrides an existing menu
				plugin_menuid = l[2]
				for x in m_list:
					if x[2] == plugin_menuid:
						m_list.remove(x)
						break
				description = plugins.getDescriptionForMenuEntryID(menuID, plugin_menuid)
				menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
				if len(l) > 4 and l[4]:
					m_list.append((l[0], boundFunction(l[1], self.session, self.close), l[2], l[3] or 50, description, menupng))
				else:
					m_list.append((l[0], boundFunction(l[1], self.session), l[2], l[3] or 50, description, menupng))

		# for the skin: first try a menu_<menuID>, then Menu
		self.skinName = [ ]
                skfile = '/usr/share/enigma2/' + config.skin.primary_skin.value
                f1 = open(skfile, 'r')
                self.sktxt = f1.read()
                f1.close()
                if menuID is not None:
                        if '<screen name="Animmain" ' in self.sktxt and config.usage.menutype.value == 'horzanim':
                                self.skinName.append('Animmain')
                        elif '<screen name="Iconmain" ' in self.sktxt and config.usage.menutype.value == 'horzicon':
                                if '<screen name="Iconmain" ' in self.sktxt:
                                        self.skinName.append('Iconmain')
                        else:
                                self.skinName.append('menu_' + menuID)
		self.skinName.append("Menu")
		self.menuID = menuID
		ProtectedScreen.__init__(self)

		if config.usage.menu_sort_mode.value == "user" and menuID == "mainmenu":
			plugin_list = []
			id_list = []
			for l in plugins.getPlugins([PluginDescriptor.WHERE_PLUGINMENU ,PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_EVENTINFO]):
				l.id = (l.name.lower()).replace(' ','_')
				if l.id not in id_list:
					id_list.append(l.id)
					plugin_list.append((l.name, boundFunction(l.__call__, session), l.id, 200))

		self.list = m_list

		if menuID is not None and config.usage.menu_sort_mode.value == "user":
			self.sub_menu_sort = NoSave(ConfigDictionarySet())
			self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(self.menuID, "submenu") or {}
			idx = 0
			for x in self.list:
				entry = list(self.list.pop(idx))
				m_weight = self.sub_menu_sort.getConfigValue(entry[2], "sort") or entry[3]
				entry.append(m_weight)
				self.list.insert(idx, tuple(entry))
				self.sub_menu_sort.changeConfigValue(entry[2], "sort", m_weight)
				idx += 1
			self.full_list = list(m_list)

		if config.usage.menu_sort_mode.value == "a_z":
			# Sort by Name
			m_list.sort(key=self.sortByName)
		elif config.usage.menu_sort_mode.value == "user":
			self["blue"].setText(_("Edit mode on"))
			self.hide_show_entries()
			m_list = self.list
		else:
			# Sort by Weight
			m_list.sort(key=lambda x: int(x[3]))
		
		if config.usage.menu_show_numbers.value:
			m_list = [(str(x[0] + 1) + " " +x[1][0], x[1][1], x[1][2]) for x in enumerate(m_list)]

		self["menu"] = List(m_list)
		self["menu"].enableWrapAround = True
		if config.usage.menu_sort_mode.value == "user":
			self["menu"].onSelectionChanged.append(self.selectionChanged)

		self["actions"] = NumberActionMap(["OkCancelActions", "MenuActions", "NumberActions"],
			{
				"ok": self.okbuttonClick,
				"cancel": self.closeNonRecursive,
				"menu": self.closeRecursive,
				#"0": self.resetSortOrder,
				"0": self.keyNumberGlobal,
				"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
			})

		if config.usage.menu_sort_mode.value == "user":
			self["MoveActions"] = ActionMap(["WizardActions"],
				{
					"left": self.keyLeft,
					"right": self.keyRight,
					"up": self.keyUp,
					"down": self.keyDown,
				}, -1
			)

			self["EditActions"] = ActionMap(["ColorActions"],
			{
				"green": self.keyGreen,
				"yellow": self.keyYellow,
				"blue": self.keyBlue,
			})

		a = parent.get("title", "").encode("UTF-8") or None
		a = a and _(a)
		if a is None:
			a = _(parent.get("text", "").encode("UTF-8"))
		else:
			t_history.reset()
		self["title"] = StaticText(a)
		Screen.setTitle(self, a)
		self.menu_title = a

		self["thistory"] = StaticText(t_history.thistory)
		history_len = len(t_history.thistory)
		self["title0"] = StaticText('')
		self["title1"] = StaticText('')
		self["title2"] = StaticText('')
		if history_len < 13 :
			self["title0"] = StaticText(a)
		elif history_len < 21 :
			self["title0"] = StaticText('')
			self["title1"] = StaticText(a)
		else:
			self["title0"] = StaticText('')
			self["title1"] = StaticText('')
			self["title2"] = StaticText(a)

		if(t_history.thistory ==''):
			t_history.thistory = str(a) + ' > '
		else:
			t_history.thistory = t_history.thistory + str(a) + ' > '

                if '<screen name="Animmain" ' in self.sktxt and config.usage.menutype.value == 'horzanim':
                        self.onShown.append(self.openTestA)
                elif '<screen name="Iconmain" ' in self.sktxt and config.usage.menutype.value == 'horzicon':
                        if '<screen name="Iconmain" ' in self.sktxt:
                                self.onShown.append(self.openTestB)

		self.number = 0
		self.nextNumberTimer = eTimer()
		self.nextNumberTimer.callback.append(self.okbuttonClick)
Ejemplo n.º 8
0
    def __init__(self, session, parent):
        Screen.__init__(self, session)
        self.sort_mode = False
        self.selected_entry = None
        self.sub_menu_sort = None
        self['key_green'] = Label()
        self['key_yellow'] = Label()
        self['key_blue'] = Label()
        m_list = []
        menuID = None
        for x in parent:
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get('level', 0))
                if item_level <= config.usage.setup_level.index:
                    self.addItem(m_list, x)
                    count += 1
            elif x.tag == 'menu':
                item_level = int(x.get('level', 0))
                if item_level <= config.usage.setup_level.index:
                    self.addMenu(m_list, x)
                    count += 1
            elif x.tag == 'id':
                menuID = x.get('val')
                count = 0
            if menuID is not None:
                if menuupdater.updatedMenuAvailable(menuID):
                    for x in menuupdater.getUpdatedMenu(menuID):
                        if x[1] == count:
                            description = x.get('description',
                                                '').encode('UTF-8') or None
                            description = description and _(description)
                            menupng = MenuEntryPixmap(menuID, self.png_cache,
                                                      lastMenuID)
                            m_list.append(
                                (x[0],
                                 boundFunction(self.runScreen,
                                               (x[2], x[3] + ', ')), x[4],
                                 description, menupng))
                            count += 1

        self.menuID = menuID
        if config.ParentalControl.configured.value:
            ProtectedScreen.__init__(self)
        if menuID is not None:
            for l in plugins.getPluginsForMenu(menuID):
                plugin_menuid = l[2]
                for x in m_list:
                    if x[2] == plugin_menuid:
                        m_list.remove(x)
                        break

                description = plugins.getDescriptionForMenuEntryID(
                    menuID, plugin_menuid)
                menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
                if len(l) > 4 and l[4]:
                    m_list.append(
                        (l[0], boundFunction(l[1], self.session,
                                             self.close), l[2], l[3]
                         or 50, description, menupng))
                else:
                    m_list.append(
                        (l[0], boundFunction(l[1], self.session), l[2], l[3]
                         or 50, description, menupng))

        self.skinName = []
        if menuID is not None:
            if config.usage.menutype.value == 'horzanim' and skin.dom_screens.has_key(
                    'Animmain'):
                self.skinName.append('Animmain')
            elif config.usage.menutype.value == 'horzicon' and skin.dom_screens.has_key(
                    'Iconmain'):
                self.skinName.append('Iconmain')
            else:
                self.skinName.append('menu_' + menuID)
        self.skinName.append('Menu')
        self.menuID = menuID
        ProtectedScreen.__init__(self)
        if config.usage.menu_sort_mode.value == 'user' and menuID == 'mainmenu':
            plugin_list = []
            id_list = []
            for l in plugins.getPlugins([
                    PluginDescriptor.WHERE_PLUGINMENU,
                    PluginDescriptor.WHERE_EXTENSIONSMENU,
                    PluginDescriptor.WHERE_EVENTINFO
            ]):
                l.id = l.name.lower().replace(' ', '_')
                if l.id not in id_list:
                    id_list.append(l.id)
                    plugin_list.append(
                        (l.name, boundFunction(l.__call__,
                                               session), l.id, 200))

        self.list = m_list
        if menuID is not None and config.usage.menu_sort_mode.value == 'user':
            self.sub_menu_sort = NoSave(ConfigDictionarySet())
            self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(
                self.menuID, 'submenu') or {}
            idx = 0
            for x in self.list:
                entry = list(self.list.pop(idx))
                m_weight = self.sub_menu_sort.getConfigValue(
                    entry[2], 'sort') or entry[3]
                entry.append(m_weight)
                self.list.insert(idx, tuple(entry))
                self.sub_menu_sort.changeConfigValue(entry[2], 'sort',
                                                     m_weight)
                idx += 1

            self.full_list = list(m_list)
        if config.usage.menu_sort_mode.value == 'a_z':
            m_list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == 'user':
            self['key_blue'].setText(_('Edit mode on'))
            self.hide_show_entries()
            m_list = self.list
        else:
            m_list.sort(key=lambda x: int(x[3]))
        if config.usage.menu_show_numbers.value:
            m_list = [(str(x[0] + 1) + ' ' + x[1][0], x[1][1], x[1][2])
                      for x in enumerate(m_list)]
        self['menu'] = List(m_list)
        self['menu'].enableWrapAround = True
        if config.usage.menu_sort_mode.value == 'user':
            self['menu'].onSelectionChanged.append(self.selectionChanged)
        self['actions'] = NumberActionMap(
            ['OkCancelActions', 'MenuActions', 'NumberActions'], {
                'ok': self.okbuttonClick,
                'cancel': self.closeNonRecursive,
                'menu': self.closeRecursive,
                '0': self.keyNumberGlobal,
                '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
            })
        if config.usage.menu_sort_mode.value == 'user':
            self['MoveActions'] = ActionMap(
                ['WizardActions'], {
                    'left': self.keyLeft,
                    'right': self.keyRight,
                    'up': self.keyUp,
                    'down': self.keyDown
                }, -1)
            self['EditActions'] = ActionMap(
                ['ColorActions'], {
                    'green': self.keyGreen,
                    'yellow': self.keyYellow,
                    'blue': self.keyBlue
                })
        a = parent.get('title', '').encode('UTF-8') or None
        a = a and _(a)
        if a is None:
            a = _(parent.get('text', '').encode('UTF-8'))
        else:
            t_history.reset()
        self['title'] = StaticText(a)
        Screen.setTitle(self, a)
        self.menu_title = a
        self['thistory'] = StaticText(t_history.thistory)
        history_len = len(t_history.thistory)
        self['title0'] = StaticText('')
        self['title1'] = StaticText('')
        self['title2'] = StaticText('')
        if history_len < 13:
            self['title0'] = StaticText(a)
        elif history_len < 21:
            self['title0'] = StaticText('')
            self['title1'] = StaticText(a)
        else:
            self['title0'] = StaticText('')
            self['title1'] = StaticText('')
            self['title2'] = StaticText(a)
        if t_history.thistory == '':
            t_history.thistory = str(a) + ' > '
        else:
            t_history.thistory = t_history.thistory + str(a) + ' > '
        if config.usage.menutype.value == 'horzanim' and skin.dom_screens.has_key(
                'Animmain'):
            self['label1'] = StaticText()
            self['label2'] = StaticText()
            self['label3'] = StaticText()
            self['label4'] = StaticText()
            self['label5'] = StaticText()
            self.onShown.append(self.openTestA)
        elif config.usage.menutype.value == 'horzicon' and skin.dom_screens.has_key(
                'Iconmain'):
            self['label1'] = StaticText()
            self['label2'] = StaticText()
            self['label3'] = StaticText()
            self['label4'] = StaticText()
            self['label5'] = StaticText()
            self['label6'] = StaticText()
            self['label1s'] = StaticText()
            self['label2s'] = StaticText()
            self['label3s'] = StaticText()
            self['label4s'] = StaticText()
            self['label5s'] = StaticText()
            self['label6s'] = StaticText()
            self['pointer'] = Pixmap()
            self['pixmap1'] = Pixmap()
            self['pixmap2'] = Pixmap()
            self['pixmap3'] = Pixmap()
            self['pixmap4'] = Pixmap()
            self['pixmap5'] = Pixmap()
            self['pixmap6'] = Pixmap()
            self.onShown.append(self.openTestB)
        self.number = 0
        self.nextNumberTimer = eTimer()
        self.nextNumberTimer.callback.append(self.okbuttonClick)
Ejemplo n.º 9
0
    def createMenuList(self):
        self.list = []
        self.menuID = None
        count = 0
        for x in self.parentmenu:  #walk through the actual nodelist
            if not x.tag:
                continue
            if x.tag == 'item':
                item_level = int(x.get('level', 0))
                if item_level <= config.usage.setup_level.index:
                    self.addItem(self.list, x)
                    count += 1
            elif x.tag == 'menu':
                item_level = int(x.get('level', 0))
                if item_level <= config.usage.setup_level.index:
                    self.addMenu(self.list, x)
                    count += 1
            elif x.tag == 'id':
                self.menuID = x.get('val')
                count = 0
            if self.menuID is not None:
                if menuupdater.updatedMenuAvailable(self.menuID):
                    for x in menuupdater.getUpdatedMenu(self.menuID):
                        if x[1] == count:
                            description = x.get('description',
                                                '').encode('UTF-8') or None
                            description = description and _(description)
                            menupng = MenuEntryPixmap(self.menuID,
                                                      self.png_cache,
                                                      lastMenuID)
                            self.list.append(
                                (x[0],
                                 boundFunction(self.runScreen,
                                               (x[2], x[3] + ', ')), x[4],
                                 description, menupng))
                            count += 1

        if self.menuID is not None:
            for l in plugins.getPluginsForMenu(self.menuID):
                plugin_menuid = l[2]
                for x in self.list:
                    if x[2] == plugin_menuid:
                        self.list.remove(x)
                        break

                description = plugins.getDescriptionForMenuEntryID(
                    self.menuID, plugin_menuid)
                menupng = MenuEntryPixmap(l[2], self.png_cache, lastMenuID)
                self.list.append((l[0], boundFunction(l[1],
                                                      self.session), l[2], l[3]
                                  or 50, description, menupng))

        if config.usage.menu_sort_mode.value == 'user' and self.menuID == 'mainmenu':
            plugin_list = []
            id_list = []
            for l in plugins.getPlugins([
                    PluginDescriptor.WHERE_PLUGINMENU,
                    PluginDescriptor.WHERE_EXTENSIONSMENU,
                    PluginDescriptor.WHERE_EVENTINFO
            ]):
                l.id = l.name.lower().replace(' ', '_')
                if l.id not in id_list:
                    id_list.append(l.id)
                    plugin_list.append(
                        (l.name, boundFunction(l.__call__,
                                               self.session), l.id, 200))

        if self.menuID is not None and config.usage.menu_sort_mode.value == 'user':
            self.sub_menu_sort = NoSave(ConfigDictionarySet())
            self.sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue(
                self.menuID, 'submenu') or {}
            idx = 0
            for x in self.list:
                entry = list(self.list.pop(idx))
                m_weight = self.sub_menu_sort.getConfigValue(
                    entry[2], 'sort') or entry[3]
                entry.append(m_weight)
                self.list.insert(idx, tuple(entry))
                self.sub_menu_sort.changeConfigValue(entry[2], 'sort',
                                                     m_weight)
                idx += 1

            self.full_list = list(self.list)
        if config.usage.menu_sort_mode.value == 'a_z':
            self.list.sort(key=self.sortByName)
        elif config.usage.menu_sort_mode.value == 'user':
            self.hide_show_entries()
        else:
            self.list.sort(key=lambda x: int(x[3]))

        if config.usage.menu_show_numbers.value:
            self.list = [(str(x[0] + 1) + " " + x[1][0], x[1][1], x[1][2])
                         for x in enumerate(self.list)]

        self['menu'].updateList(self.list)