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

Unified Diff: server/base_utils.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch 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
Index: server/base_utils.py
diff --git a/server/base_utils.py b/server/base_utils.py
index 6d683b26deb49d8126b34a421e8539280dc0c958..1c58609a0fbe0dd6a2d0c90729bd3c2306227502 100644
--- a/server/base_utils.py
+++ b/server/base_utils.py
@@ -244,45 +244,27 @@ def form_ntuples_from_machines(machines, n=2, mapping_func=default_mappings):
return (ntuples, failures)
-def parse_machine(machine, user = 'root', port = 22, password = ''):
+def parse_machine(machine, user='root', password='', port=22):
"""
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.
"""
- user = user
- port = port
- password = password
+ if '@' in machine:
+ user, machine = machine.split('@', 1)
- if re.search('@', machine):
- machine = machine.split('@')
+ if ':' in user:
+ user, password = user.split(':', 1)
- if re.search(':', machine[0]):
- machine[0] = machine[0].split(':')
- user = machine[0][0]
- password = machine[0][1]
+ if ':' in machine:
+ machine, port = machine.split(':', 1)
+ port = int(port)
- 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
+ if not machine or not user:
+ raise ValueError
- return hostname, user, password, port
+ return machine, user, password, port
def get_public_key():
« cli/job.py ('K') | « 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