~aj00200/anonplus/trunk

« back to all changes in this revision

Viewing changes to src/libs/__init__.py

  • Committer: Aj00200
  • Date: 2012-01-13 02:36:22 UTC
  • Revision ID: aj00200@aj00200.org-20120113023622-837s2gn6asorozq0
Fixed bug lp:915767 which was caused by use of a variable which no longer exists. Also added better error catching to the save function for the config to handle a non-existant ~/.vomun/ directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
                values = json.loads(config_file.read())
33
33
        except IOError:
34
34
            self['vomundir'] = os.path.expanduser('~/.vomun/')
 
35
            self['keyfile'] = os.path.expanduser('~/.vomun/keys.json')
35
36
            self['nodekey'] = ''
36
37
            self.save()
37
38
        else:
39
40
                self[value] = values[value]
40
41
 
41
42
    def save(self):
42
 
        '''Save the configuration enteries in a json format to the location set
 
43
        '''Save the configuration enteries in a j4son format to the location set
43
44
        in self.path.
44
45
        '''
45
 
        with open(self.path, 'w') as config_file:
46
 
            config_file.write(json.dumps(self, indent=2))
 
46
        try:
 
47
            with open(self.path, 'w') as config_file:
 
48
                config_file.write(json.dumps(self, indent=2))
 
49
        except IOError: # ~/.vomun/ does not exist?
 
50
            pass # TODO: run setup.py
47
51
            
48
52
class Registrar(dict):
49
53
    '''Manages dynamic imports relative to a set start_path.'''