From 6afe3fd4979572ced46124509d8288b423431204 Mon Sep 17 00:00:00 2001 From: Mark Theunissen Date: Thu, 26 Jul 2012 08:58:21 -0500 Subject: [PATCH] Changing to read from a file pointer instead so that an exception is thrown if the file doesn't exist --- library/mysql_db | 4 ++-- library/mysql_user | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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