예제 #1
0
	def read_registry(cls):
		data = {}
		
		try:
			hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, cls.CONFIG_LOCATION, 0, win32con.KEY_ENUMERATE_SUB_KEYS|win32con.KEY_QUERY_VALUE|win32con.KEY_WOW64_64KEY)
		except pywintypes.error, err:
			ConfigModule.report_error("Unable to open '%s' from registry"%(cls.CONFIG_LOCATION))
			return data
예제 #2
0
    def read_registry(cls):
        data = {}

        try:
            hkey = win32api.RegOpenKey(
                win32con.HKEY_LOCAL_MACHINE, cls.CONFIG_LOCATION, 0,
                win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
                | win32con.KEY_WOW64_64KEY)
        except pywintypes.error, err:
            ConfigModule.report_error("Unable to open '%s' from registry" %
                                      (cls.CONFIG_LOCATION))
            return data
예제 #3
0
    def read_ini(cls, filename):
        if not os.path.isfile(filename):
            ConfigModule.report_error("No such file '%s'" % (filename))
            return False

        parser = ConfigParser.ConfigParser()
        parser.read(filename)

        data = {}

        for section in parser.sections():
            data[section] = {}
            for k, v in parser.items(section):
                data[section][k] = v

        return data
예제 #4
0
	def read_ini(cls, filename):
		if not os.path.isfile(filename):
			ConfigModule.report_error("No such file '%s'"%(filename))
			return False
		
		parser = ConfigParser.ConfigParser()
		parser.read(filename)
		
		data = {}
		
		for section in parser.sections():
			data[section] = {}
			for k,v in parser.items(section):
				data[section][k] = v
		
		return data
예제 #5
0
class ConfigReader(AbstractConfigReader):
    CONFIG_LOCATION = "Software\\ulteo\\OVD\\SlaveServer"

    @classmethod
    def process(cls, filename=None):
        if filename is not None:
            return cls.read_ini(filename)

        return cls.read_registry()

    @classmethod
    def read_registry(cls):
        data = {}

        try:
            hkey = win32api.RegOpenKey(
                win32con.HKEY_LOCAL_MACHINE, cls.CONFIG_LOCATION, 0,
                win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
                | win32con.KEY_WOW64_64KEY)
        except pywintypes.error, err:
            ConfigModule.report_error("Unable to open '%s' from registry" %
                                      (cls.CONFIG_LOCATION))
            return data

        data["main"] = cls.reg_enum_values(hkey)
        subkeys = cls.reg_enum_keys(hkey)

        win32api.RegCloseKey(hkey)

        for subkey in subkeys:
            location = os.path.join(cls.CONFIG_LOCATION, subkey)

            try:
                hkey = win32api.RegOpenKey(
                    win32con.HKEY_LOCAL_MACHINE, location, 0,
                    win32con.KEY_QUERY_VALUE | win32con.KEY_WOW64_64KEY)
            except pywintypes.error, err:
                ConfigModule.report_error("Unable to open '%s' from registry" %
                                          (location))
                return data

            data[subkey] = cls.reg_enum_values(hkey)

            win32api.RegCloseKey(hkey)