Commit 622cc778 authored by Jérome Perrin's avatar Jérome Perrin

support password in getMySQLArguments (used by runUnitTest --erp5_sql_connection_string=)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24438 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b3f92b07
......@@ -195,16 +195,24 @@ def _recreateMemcachedTool(portal):
def getMySQLArguments():
"""Returns arguments to pass to mysql by heuristically converting the
connection string.
Only simple cases are coverred for now.
"""
connection_string = os.environ.get('erp5_sql_connection_string')
if not connection_string:
return '-u test test'
db, user = connection_string.split()
if "@" in db:
password = ''
host = ''
db, user = connection_string.split(' ', 1)
if ' ' in user: # look for user password
user, password = user.split()
password = '-p%s' % password
if "@" in db: # look for hostname
db, host = db.split('@')
return "-u %s -h %s %s" % (user, host, db)
return '-u %s %s' % (user, db)
host = '-h %s' % host
return '-u %s %s %s %s' % (user, password, host, db)
# decorators
class reindex(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment