OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 """A wrapper around ssh for common operations on a CrOS-based device""" | 4 """A wrapper around ssh for common operations on a CrOS-based device""" |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import re | 7 import re |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import time | 10 import time |
11 import tempfile | 11 import tempfile |
12 | 12 |
13 from telemetry import util | 13 from telemetry.core import util |
14 | 14 |
15 # TODO(nduca): This whole file is built up around making individual ssh calls | 15 # TODO(nduca): This whole file is built up around making individual ssh calls |
16 # for each operation. It really could get away with a single ssh session built | 16 # for each operation. It really could get away with a single ssh session built |
17 # around pexpect, I suspect, if we wanted it to be faster. But, this was | 17 # around pexpect, I suspect, if we wanted it to be faster. But, this was |
18 # convenient. | 18 # convenient. |
19 | 19 |
20 def RunCmd(args, cwd=None, quiet=False): | 20 def RunCmd(args, cwd=None, quiet=False): |
21 """Opens a subprocess to execute a program and returns its return value. | 21 """Opens a subprocess to execute a program and returns its return value. |
22 | 22 |
23 Args: | 23 Args: |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 return new_port | 401 return new_port |
402 | 402 |
403 def IsHTTPServerRunningOnPort(self, port): | 403 def IsHTTPServerRunningOnPort(self, port): |
404 wget_output = self.GetAllCmdOutput( | 404 wget_output = self.GetAllCmdOutput( |
405 ['wget', 'localhost:%i' % (port), '-T1', '-t1']) | 405 ['wget', 'localhost:%i' % (port), '-T1', '-t1']) |
406 | 406 |
407 if 'Connection refused' in wget_output[1]: | 407 if 'Connection refused' in wget_output[1]: |
408 return False | 408 return False |
409 | 409 |
410 return True | 410 return True |
OLD | NEW |