OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Provides an interface to communicate with the device via the adb command. | 6 """Provides an interface to communicate with the device via the adb command. |
7 | 7 |
8 Assumes adb binary is currently on system path. | 8 Assumes adb binary is currently on system path. |
9 | 9 |
10 Usage: | 10 Usage: |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 416 |
417 # They don't match, so remove everything first and then create it. | 417 # They don't match, so remove everything first and then create it. |
418 if os.path.isdir(local_path): | 418 if os.path.isdir(local_path): |
419 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2*60) | 419 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2*60) |
420 self.RunShellCommand('mkdir -p %s' % device_path) | 420 self.RunShellCommand('mkdir -p %s' % device_path) |
421 | 421 |
422 # NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of | 422 # NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of |
423 # 60 seconds which isn't sufficient for a lot of users of this method. | 423 # 60 seconds which isn't sufficient for a lot of users of this method. |
424 push_command = 'push %s %s' % (local_path, device_path) | 424 push_command = 'push %s %s' % (local_path, device_path) |
425 logging.info('>>> $' + push_command) | 425 logging.info('>>> $' + push_command) |
426 self._adb.SendCommand(push_command, timeout_time=30*60) | 426 output = self._adb.SendCommand(push_command, timeout_time=30*60) |
| 427 # Success looks like this: "3035 KB/s (12512056 bytes in 4.025s)" |
| 428 # Errors look like this: "failed to copy ... " |
| 429 if not re.search('^[0-9]', output): |
| 430 logging.critical('PUSH FAILED: ' + output) |
427 | 431 |
428 def GetFileContents(self, filename): | 432 def GetFileContents(self, filename): |
429 """Gets contents from the file specified by |filename|.""" | 433 """Gets contents from the file specified by |filename|.""" |
430 return self.RunShellCommand('if [ -f "' + filename + '" ]; then cat "' + | 434 return self.RunShellCommand('if [ -f "' + filename + '" ]; then cat "' + |
431 filename + '"; fi') | 435 filename + '"; fi') |
432 | 436 |
433 def SetFileContents(self, filename, contents): | 437 def SetFileContents(self, filename, contents): |
434 """Writes |contents| to the file specified by |filename|.""" | 438 """Writes |contents| to the file specified by |filename|.""" |
435 with tempfile.NamedTemporaryFile() as f: | 439 with tempfile.NamedTemporaryFile() as f: |
436 f.write(contents) | 440 f.write(contents) |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 options, args = option_parser.parse_args(argv) | 771 options, args = option_parser.parse_args(argv) |
768 | 772 |
769 commands = AndroidCommands(wait_for_pm=options.wait_for_pm) | 773 commands = AndroidCommands(wait_for_pm=options.wait_for_pm) |
770 if options.set_asserts != None: | 774 if options.set_asserts != None: |
771 if commands.SetJavaAssertsEnabled(options.set_asserts): | 775 if commands.SetJavaAssertsEnabled(options.set_asserts): |
772 commands.Reboot(full_reboot=False) | 776 commands.Reboot(full_reboot=False) |
773 | 777 |
774 | 778 |
775 if __name__ == '__main__': | 779 if __name__ == '__main__': |
776 main(sys.argv) | 780 main(sys.argv) |
OLD | NEW |