|
|
@ -98,7 +98,17 @@ requirements: [ "ConfigParser", "MySQLdb" ]
|
|
|
|
author: Mark Theunissen
|
|
|
|
author: Mark Theunissen
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = """
|
|
|
|
|
|
|
|
# Example .my.cnf file for setting the root password
|
|
|
|
|
|
|
|
# Note: don't use quotes around the password, because the mysql_user module
|
|
|
|
|
|
|
|
# will include them in the password but the mysql client will not
|
|
|
|
|
|
|
|
[client]
|
|
|
|
|
|
|
|
user=root
|
|
|
|
|
|
|
|
password=n<_665{vS43y
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import ConfigParser
|
|
|
|
import ConfigParser
|
|
|
|
|
|
|
|
import getpass
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import MySQLdb
|
|
|
|
import MySQLdb
|
|
|
|
except ImportError:
|
|
|
|
except ImportError:
|
|
|
@ -260,10 +270,13 @@ def load_mycnf():
|
|
|
|
passwd = config.get('client', 'pass')
|
|
|
|
passwd = config.get('client', 'pass')
|
|
|
|
except (ConfigParser.NoOptionError):
|
|
|
|
except (ConfigParser.NoOptionError):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If .my.cnf doesn't specify a user, default to user login name
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
creds = dict(user=config.get('client', 'user'),passwd=passwd)
|
|
|
|
user = config.get('client', 'user')
|
|
|
|
except (ConfigParser.NoOptionError):
|
|
|
|
except (ConfigParser.NoOptionError):
|
|
|
|
return False
|
|
|
|
user = getpass.getuser()
|
|
|
|
|
|
|
|
creds = dict(user=user,passwd=passwd)
|
|
|
|
return creds
|
|
|
|
return creds
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================
|
|
|
|
# ===========================================
|
|
|
|