mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Changing to read from a file pointer instead so that an exception is thrown if the file doesn't exist
This commit is contained in:
parent
12979cf834
commit
6afe3fd497
2 changed files with 4 additions and 4 deletions
|
@ -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…
Reference in a new issue