From 7a3f64d4d76049ce7179d9526e9a6dc8d337249a Mon Sep 17 00:00:00 2001 From: Mark Theunissen Date: Thu, 26 Jul 2012 11:30:22 -0500 Subject: [PATCH] Check file exists instead of relying on the exception. Leave the exception catch in, in case the file is deleted or some other issue crops up --- mysql_db | 2 ++ mysql_user | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql_db b/mysql_db index 3a620f84941..85b25cb99d6 100755 --- a/mysql_db +++ b/mysql_db @@ -47,6 +47,8 @@ def db_create(cursor, db): def load_mycnf(): config = ConfigParser.RawConfigParser() mycnf = os.path.expanduser('~/.my.cnf') + if not os.path.exists(mycnf): + return False try: config.readfp(open(mycnf)) creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass')) diff --git a/mysql_user b/mysql_user index 6734961a749..1cba17e9a91 100755 --- a/mysql_user +++ b/mysql_user @@ -145,6 +145,8 @@ def privileges_grant(cursor, user,host,db_table,priv): def load_mycnf(): config = ConfigParser.RawConfigParser() mycnf = os.path.expanduser('~/.my.cnf') + if not os.path.exists(mycnf): + return False try: config.readfp(open(mycnf)) creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass'))