Changing to read from a file pointer instead so that an exception is thrown if the file doesn't exist

reviewable/pr18780/r1
Mark Theunissen 12 years ago
parent 5ab81692d7
commit 894e4ff78a

@ -47,10 +47,10 @@ def db_create(cursor, db):
def load_mycnf():
config = ConfigParser.RawConfigParser()
mycnf = os.path.expanduser('~/.my.cnf')
config.read(mycnf)
try:
config.readfp(open(mycnf))
creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass'))
except ConfigParser.NoOptionError:
except (ConfigParser.NoOptionError, IOError):
return False
return creds

@ -145,10 +145,10 @@ def privileges_grant(cursor, user,host,db_table,priv):
def load_mycnf():
config = ConfigParser.RawConfigParser()
mycnf = os.path.expanduser('~/.my.cnf')
config.read(mycnf)
try:
config.readfp(open(mycnf))
creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass'))
except ConfigParser.NoOptionError:
except (ConfigParser.NoOptionError, IOError):
return False
return creds

Loading…
Cancel
Save