示例#1
0
	def load(self):
		if not fileExists(XML_CONFIG):
			return

		try:
			config = cet_parse(XML_CONFIG).getroot()
		except ParseError as pe:
			from time import time
			print("[PluginSort] Parse Error occured in configuration, backing it up and starting from scratch!")
			try:
				copyfile(XML_CONFIG, "/etc/enigma2/pluginsort.xml.%d" % (int(time()),))
			except Error as she:
				print("[PluginSort] Uh oh, failed to create the backup... I hope you have one anyway :D")
			return

		for wheresection in config.findall('where'):
			where = wheresection.get('type')
			whereid = WHEREMAP.get(where, None)
			whereplugins = wheresection.findall('plugin')
			if whereid is None or not whereplugins:
				print("[PluginSort] Ignoring section %s because of invalid id (%s) or no plugins (%s)" % (where, repr(whereid), repr(whereplugins)))
				continue

			for plugin in whereplugins:
				name = plugin.get('name')
				try:
					weight = int(plugin.get('weight'))
				except ValueError as ve:
					print("[PluginSort] Invalid weight of %s received for plugin %s, ignoring" % (repr(plugin.get('weight')), repr(name)))
				else:
					self.plugins.setdefault(whereid, {})[name] = weight
示例#2
0
	def load(self):
		if not fileExists(XML_CONFIG):
			return

		try:
			config = cet_parse(XML_CONFIG).getroot()
		except ParseError as pe:
			from time import time
			print("[PluginSort] Parse Error occured in configuration, backing it up and starting from scratch!")
			try:
				copyfile(XML_CONFIG, "/etc/enigma2/pluginsort.xml.%d" % (int(time()),))
			except Error as she:
				print("[PluginSort] Uh oh, failed to create the backup... I hope you have one anyway :D")
			return

		for wheresection in config.findall('where'):
			where = wheresection.get('type')
			whereid = WHEREMAP.get(where, None)
			whereplugins = wheresection.findall('plugin')
			if whereid is None or not whereplugins:
				print("[PluginSort] Ignoring section %s because of invalid id (%s) or no plugins (%s)" % (where, repr(whereid), repr(whereplugins)))
				continue

			for plugin in whereplugins:
				name = plugin.get('name')
				try:
					weight = int(plugin.get('weight'))
				except ValueError as ve:
					print("[PluginSort] Invalid weight of %s received for plugin %s, ignoring" % (repr(plugin.get('weight')), repr(name)))
				else:
					self.plugins.setdefault(whereid, {})[name] = weight
示例#3
0
        if not fileExists(XML_CONFIG):
            return

        try:
            config = cet_parse(XML_CONFIG).getroot()
        except ParseError, pe:
            from time import time
            print "[PluginSort] Parse Error occured in configuration, backing it up and starting from scratch!"
            try:
                copyfile(XML_CONFIG,
                         "/etc/enigma2/pluginsort.xml.%d" % (int(time()), ))
            except Error, she:
                print "[PluginSort] Uh oh, failed to create the backup... I hope you have one anyway :D"
            return

        for wheresection in config.findall('where'):
            where = wheresection.get('type')
            whereid = WHEREMAP.get(where, None)
            whereplugins = wheresection.findall('plugin')
            if whereid is None or not whereplugins:
                print "[PluginSort] Ignoring section %s because of invalid id (%s) or no plugins (%s)" % (
                    where, repr(whereid), repr(whereplugins))
                continue

            for plugin in whereplugins:
                name = plugin.get('name')
                try:
                    weight = int(plugin.get('weight'))
                except ValueError, ve:
                    print "[PluginSort] Invalid weight of %s received for plugin %s, ignoring" % (
                        repr(plugin.get('weight')), repr(name))
示例#4
0
	def load(self):
		if not fileExists(XML_CONFIG):
			return

		try:
			config = cet_parse(XML_CONFIG).getroot()
		except ParseError, pe:
			from time import time
			print "[PluginSort] Parse Error occured in configuration, backing it up and starting from scratch!"
			try:
				copyfile(XML_CONFIG, "/etc/enigma2/pluginsort.xml.%d" % (int(time()),))
			except Error, she:
				print "[PluginSort] Uh oh, failed to create the backup... I hope you have one anyway :D"
			return

		for wheresection in config.findall('where'):
			where = wheresection.get('type')
			whereid = WHEREMAP.get(where, None)
			whereplugins = wheresection.findall('plugin')
			if whereid is None or not whereplugins:
				print "[PluginSort] Ignoring section %s because of invalid id (%s) or no plugins (%s)" % (where, repr(whereid), repr(whereplugins))
				continue

			for plugin in whereplugins:
				name = plugin.get('name')
				try:
					weight = int(plugin.get('weight'))
				except ValueError, ve:
					print "[PluginSort] Invalid weight of %s received for plugin %s, ignoring" % (repr(plugin.get('weight')), repr(name))
				else:
					self.plugins.setdefault(whereid, {})[name] = weight