From 894e4ff78a8bccf10bb55bbf493a7bdb08cc1cd8 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 --- mysql_db | 4 ++-- mysql_user | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql_db b/mysql_db index 07d4374546b..1e98c3676c0 100755 --- a/mysql_db +++ b/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/mysql_user b/mysql_user index 385f48faa94..7ae3cb6363c 100755 --- a/mysql_user +++ b/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