From 622cc7785802f23534ae5473a202476618e10fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 31 Oct 2008 15:06:54 +0000 Subject: [PATCH] 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 --- product/ERP5Type/tests/utils.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/product/ERP5Type/tests/utils.py b/product/ERP5Type/tests/utils.py index a682d69018..94ae969a3d 100644 --- a/product/ERP5Type/tests/utils.py +++ b/product/ERP5Type/tests/utils.py @@ -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): -- 2.30.9