Deal with wrong configuration file

This commit is contained in:
Alexandre Possebom 2014-09-26 17:30:05 -03:00
parent 53b0d71f6b
commit 33b694c2ac
1 changed files with 9 additions and 4 deletions

View File

@ -102,11 +102,13 @@ class Util(object):
else:
if self.chars == None and self.config.has_option(self.profile, 'chars'):
self.chars = self.config.getint(self.profile, 'chars')
else:
self.chars = 12
self.config.set(self.profile, config_key, self.chars)
self.writeconfig()
if self.chars < 4 or self.chars > 26:
print 'invalid password length value from configuration using default'
self.chars = 12
return self.chars
def get_passord_type(self):
@ -117,11 +119,14 @@ class Util(object):
else:
if self.pass_type == None and self.config.has_option(self.profile, 'password_type'):
self.pass_type = self.config.getint(self.profile, 'password_type')
else:
self.pass_type = 1
self.config.set(self.profile, config_key, self.pass_type)
self.writeconfig()
if self.pass_type < 1 or self.pass_type > 3:
print 'invalid password type value from configuration using default'
self.pass_type = 1
return self.pass_type
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4