diff --git a/library/mysql_db b/library/mysql_db index 07d4374546..1e98c3676c 100755 --- a/library/mysql_db +++ b/library/mysql_db @@ -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 diff --git a/library/mysql_user b/library/mysql_user index 385f48faa9..7ae3cb6363 100755 --- a/library/mysql_user +++ b/library/mysql_user @@ -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