Subversion Repositories basico

Rev

Rev 341 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 341 Rev 401
Line 34... Line 34...
34
34
35
35
36
    def get(self, section, key):
36
    def get(self, section, key):
37
        config = self.load()
37
        config = self.load()
38
        try:
38
        try:
39
            return config[section][key]            
-
 
-
 
39
            return config[section][key]
40
        except Exception as error:
40
        except Exception as error:
41
            self.log.error(error)
41
            self.log.error(error)
42
            return None
42
            return None
43
43
44
44
45
    def set(self, section, key, value):
45
    def set(self, section, key, value):
46
        config = self.load()
46
        config = self.load()
47
        try:
47
        try:
48
            config[section][key] = value
48
            config[section][key] = value
49
            self.log.debug("[%s][%s] = %s" % (section, key, value))
49
            self.log.debug("[%s][%s] = %s" % (section, key, value))
50
            self.save(config)            
-
 
-
 
50
            self.save(config)
51
        except:
51
        except:
52
            self.log.error("Setting not saved")
52
            self.log.error("Setting not saved")
53
            self.log.error(self.get_traceback())
53
            self.log.error(self.get_traceback())
54
54
55
55
Line 69... Line 69...
69
        if config is None:
69
        if config is None:
70
            self.log.error("A dictionary with all settings must be provided")
70
            self.log.error("A dictionary with all settings must be provided")
71
            return
71
            return
72
        with open(FILE['CNF'], 'w') as fp:
72
        with open(FILE['CNF'], 'w') as fp:
73
            json.dump(config, fp)
73
            json.dump(config, fp)
74
        self.log.debug("Settings saved successfully")
-
 
-
 
74
        # ~ self.log.debug("Settings saved successfully")