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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2008 Google Inc, Martin J. Bligh <mbligh@google.com>, 1 # Copyright 2008 Google Inc, Martin J. Bligh <mbligh@google.com>,
2 # Benjamin Poirier, Ryan Stutsman 2 # Benjamin Poirier, Ryan Stutsman
3 # Released under the GPL v2 3 # Released under the GPL v2
4 """ 4 """
5 Miscellaneous small functions. 5 Miscellaneous small functions.
6 6
7 DO NOT import this file directly - it is mixed in by server/utils.py, 7 DO NOT import this file directly - it is mixed in by server/utils.py,
8 import that instead 8 import that instead
9 """ 9 """
10 10
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 while len(key_machines) >= n: 237 while len(key_machines) >= n:
238 ntuples.append(key_machines[0:n]) 238 ntuples.append(key_machines[0:n])
239 key_machines = key_machines[n:] 239 key_machines = key_machines[n:]
240 240
241 for mach in key_machines: 241 for mach in key_machines:
242 failures.append((mach, "machine can not be tupled")) 242 failures.append((mach, "machine can not be tupled"))
243 243
244 return (ntuples, failures) 244 return (ntuples, failures)
245 245
246 246
247 def parse_machine(machine, user = 'root', port = 22, password = ''): 247 def parse_machine(machine, user='root', password='', port=22):
248 """ 248 """
249 Parse the machine string user:pass@host:port and return it separately, 249 Parse the machine string user:pass@host:port and return it separately,
250 if the machine string is not complete, use the default parameters 250 if the machine string is not complete, use the default parameters
251 when appropriate. 251 when appropriate.
252 """ 252 """
253 253
254 user = user 254 if '@' in machine:
255 port = port 255 user, machine = machine.split('@', 1)
256 password = password
257 256
258 if re.search('@', machine): 257 if ':' in user:
259 machine = machine.split('@') 258 user, password = user.split(':', 1)
260 259
261 if re.search(':', machine[0]): 260 if ':' in machine:
262 machine[0] = machine[0].split(':') 261 machine, port = machine.split(':', 1)
263 user = machine[0][0] 262 port = int(port)
264 password = machine[0][1]
265 263
266 else: 264 if not machine or not user:
267 user = machine[0] 265 raise ValueError
268 266
269 if re.search(':', machine[1]): 267 return machine, user, password, port
270 machine[1] = machine[1].split(':')
271 hostname = machine[1][0]
272 port = int(machine[1][1])
273
274 else:
275 hostname = machine[1]
276
277 elif re.search(':', machine):
278 machine = machine.split(':')
279 hostname = machine[0]
280 port = int(machine[1])
281
282 else:
283 hostname = machine
284
285 return hostname, user, password, port
286 268
287 269
288 def get_public_key(): 270 def get_public_key():
289 """ 271 """
290 Return a valid string ssh public key for the user executing autoserv or 272 Return a valid string ssh public key for the user executing autoserv or
291 autotest. If there's no DSA or RSA public key, create a DSA keypair with 273 autotest. If there's no DSA or RSA public key, create a DSA keypair with
292 ssh-keygen and return it. 274 ssh-keygen and return it.
293 """ 275 """
294 276
295 ssh_conf_path = os.path.expanduser('~/.ssh') 277 ssh_conf_path = os.path.expanduser('~/.ssh')
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 401
420 # Client side barrier for all the tests to start at the same time 402 # Client side barrier for all the tests to start at the same time
421 control_new.append('b1 = job.barrier("%s", "c_bar", %d, port=%d)' 403 control_new.append('b1 = job.barrier("%s", "c_bar", %d, port=%d)'
422 % (jobid, c_bar_timeout, c_bar_port)) 404 % (jobid, c_bar_timeout, c_bar_port))
423 control_new.append("b1.rendezvous(%s)" % rendvstr) 405 control_new.append("b1.rendezvous(%s)" % rendvstr)
424 406
425 # Stick in the rest of the control file 407 # Stick in the rest of the control file
426 control_new.append(control) 408 control_new.append(control)
427 409
428 return "\n".join(control_new) 410 return "\n".join(control_new)
OLDNEW
« 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