From 7395becf3ac4eedd0f63506e341d3b39b19dfb75 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 --- library/mysql_db | 2 ++ library/mysql_user | 2 ++ 2 files changed, 4 insertions(+) diff --git a/library/mysql_db b/library/mysql_db index 3a620f8494..85b25cb99d 100755 --- a/library/mysql_db +++ b/library/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/library/mysql_user b/library/mysql_user index 6734961a74..1cba17e9a9 100755 --- a/library/mysql_user +++ b/library/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'))