Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Unified Diff: server/base_utils.py

Issue 6124004: Revert "Merge remote branch 'cros/upstream' into autotest-rebase" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « server/autotest_unittest.py ('k') | server/base_utils_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: server/base_utils.py
diff --git a/server/base_utils.py b/server/base_utils.py
index 1c58609a0fbe0dd6a2d0c90729bd3c2306227502..6d683b26deb49d8126b34a421e8539280dc0c958 100644
--- a/server/base_utils.py
+++ b/server/base_utils.py
@@ -244,27 +244,45 @@ def form_ntuples_from_machines(machines, n=2, mapping_func=default_mappings):
return (ntuples, failures)
-def parse_machine(machine, user='root', password='', port=22):
+def parse_machine(machine, user = 'root', port = 22, password = ''):
"""
Parse the machine string user:pass@host:port and return it separately,
if the machine string is not complete, use the default parameters
when appropriate.
"""
- if '@' in machine:
- user, machine = machine.split('@', 1)
+ user = user
+ port = port
+ password = password
- if ':' in user:
- user, password = user.split(':', 1)
+ if re.search('@', machine):
+ machine = machine.split('@')
- if ':' in machine:
- machine, port = machine.split(':', 1)
- port = int(port)
+ if re.search(':', machine[0]):
+ machine[0] = machine[0].split(':')
+ user = machine[0][0]
+ password = machine[0][1]
- if not machine or not user:
- raise ValueError
+ else:
+ user = machine[0]
+
+ if re.search(':', machine[1]):
+ machine[1] = machine[1].split(':')
+ hostname = machine[1][0]
+ port = int(machine[1][1])
+
+ else:
+ hostname = machine[1]
+
+ elif re.search(':', machine):
+ machine = machine.split(':')
+ hostname = machine[0]
+ port = int(machine[1])
+
+ else:
+ hostname = machine
- return machine, user, password, port
+ return hostname, user, password, port
def get_public_key():
« no previous file with comments | « server/autotest_unittest.py ('k') | server/base_utils_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698