Beispiel #1
0
    def __readPermanentSortXmlFile(self):
        data = {}
        if os.path.exists(XML_FILE):
            f = None

            # Read from file
            try:
                f = open(XML_FILE, "rb")
                doc = xml.etree.cElementTree.parse(f)
                root = doc.getroot()
            except Exception as e:
                emcDebugOut(
                    "[EMC] Exception in __readPermanentSortXmlFile Load: " +
                    str(e))
            finally:
                if f is not None:
                    f.close()

            # Parse the data
            try:
                for entry in root.findall("entry"):
                    key = entry.get("key")
                    modestring = entry.get("modestring")
                    from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes
                    value = sort_modes.get(modestring)[1]
                    data[key] = value
            except Exception as e:
                emcDebugOut(
                    "[EMC] Exception in __readPermanentSortXmlFile Parse: " +
                    str(e))

        return data
Beispiel #2
0
    def __readPermanentSortCfgFile(self):
        data = {}
        if os.path.exists(CFG_FILE):
            f = None

            # Read from file
            try:
                f = open(CFG_FILE, "rb")
                data = pickle.load(f)
            except Exception as e:
                emcDebugOut(
                    "[EMC] Exception in readPermanentSortCfgFile Load: " +
                    str(e))
            finally:
                if f is not None:
                    f.close()

            # Parse the data
            try:
                for key, value in data.items():
                    if not isinstance(value, tuple):
                        # There is only the sorting stored, add the default order
                        #data[key] = (value, config.EMC.moviecenter_sort.value[1])
                        from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes
                        data[key] = (
                            value,
                            sort_modes.get(
                                config.EMC.moviecenter_sort.value)[1][1])
            except Exception as e:
                emcDebugOut(
                    "[EMC] Exception in readPermanentSortCfgFile Parse: " +
                    str(e))

        return data


#	def __writePermanentSortCfgFile(self, data):
#		f = None
#		try:
#			f = open(CFG_FILE, "wb")
#			pickle.dump(data, f)
#		except Exception as e:
#			emcDebugOut("[EMC] Exception in writePermanentSortCfgFile: " + str(e))
#		finally:
#			if f is not None:
#				f.close()
                data = pickle.load(f)
            except Exception, e:
                emcDebugOut("[EMC] Exception in readPermanentSortCfgFile Load: " + str(e))
            finally:
                if f is not None:
                    f.close()

                    # Parse the data
            try:
                for key, value in data.items():
                    if not isinstance(value, tuple):
                        # There is only the sorting stored, add the default order
                        # data[key] = (value, config.EMC.moviecenter_sort.value[1])
                        from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes

                        data[key] = (value, sort_modes.get(config.EMC.moviecenter_sort.value)[1][1])
            except Exception, e:
                emcDebugOut("[EMC] Exception in readPermanentSortCfgFile Parse: " + str(e))

        return data

    def __writePermanentSortCfgFile(self, data):
        f = None
        try:
            f = open(CFG_FILE, "wb")
            pickle.dump(data, f)
        except Exception, e:
            emcDebugOut("[EMC] Exception in writePermanentSortCfgFile: " + str(e))
        finally:
            if f is not None:
                f.close()
                    "[EMC] Exception in readPermanentSortCfgFile Load: " +
                    str(e))
            finally:
                if f is not None:
                    f.close()

            # Parse the data
            try:
                for key, value in data.items():
                    if not isinstance(value, tuple):
                        # There is only the sorting stored, add the default order
                        #data[key] = (value, config.EMC.moviecenter_sort.value[1])
                        from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes
                        data[key] = (
                            value,
                            sort_modes.get(
                                config.EMC.moviecenter_sort.value)[1][1])
            except Exception, e:
                emcDebugOut(
                    "[EMC] Exception in readPermanentSortCfgFile Parse: " +
                    str(e))

        return data

    def __writePermanentSortCfgFile(self, data):
        f = None
        try:
            f = open(CFG_FILE, "wb")
            pickle.dump(data, f)
        except Exception, e:
            emcDebugOut("[EMC] Exception in writePermanentSortCfgFile: " +
                        str(e))
Beispiel #5
0
                root = doc.getroot()
            except Exception, e:
                emcDebugOut(
                    "[EMC] Exception in __readPermanentSortXmlFile Load: " +
                    str(e))
            finally:
                if f is not None:
                    f.close()

            # Parse the data
            try:
                for entry in root.findall("entry"):
                    key = entry.get("key")
                    modestring = entry.get("modestring")
                    from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes
                    value = sort_modes.get(modestring)[1]
                    data[key] = value
            except Exception, e:
                emcDebugOut(
                    "[EMC] Exception in __readPermanentSortXmlFile Parse: " +
                    str(e))

        return data

    def __writePermanentSortXmlFile(self, data):
        f = None
        try:
            from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes
            list = ['<?xml version="1.0" ?>\n']
            list.append('<PermanentSort>\n')
            for key, value in data.items():
				f = open(CFG_FILE, "rb")
				data = pickle.load(f)
			except Exception, e:
				emcDebugOut("[EMC] Exception in readPermanentSortCfgFile Load: " + str(e))
			finally:
				if f is not None:
					f.close()

			# Parse the data
			try:
				for key, value in data.items():
					if not isinstance(value, tuple):
						# There is only the sorting stored, add the default order
						#data[key] = (value, config.EMC.moviecenter_sort.value[1])
						from Plugins.Extensions.EnhancedMovieCenter.plugin import sort_modes
						data[key] = (value, sort_modes.get( config.EMC.moviecenter_sort.value )[1][1])
			except Exception, e:
				emcDebugOut("[EMC] Exception in readPermanentSortCfgFile Parse: " + str(e))

		return data

	def __writePermanentSortCfgFile(self, data):
		f = None
		try:
			f = open(CFG_FILE, "wb")
			pickle.dump(data, f)
		except Exception, e:
			emcDebugOut("[EMC] Exception in writePermanentSortCfgFile: " + str(e))
		finally:
			if f is not None:
				f.close()