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 | 4 |
5 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 | 9 |
10 import collections | 10 import collections |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 assert os.path.exists(md5sum_path), 'Please build md5sum.' | 675 assert os.path.exists(md5sum_path), 'Please build md5sum.' |
676 command = 'push %s %s' % (md5sum_path, MD5SUM_DEVICE_PATH) | 676 command = 'push %s %s' % (md5sum_path, MD5SUM_DEVICE_PATH) |
677 assert _HasAdbPushSucceeded(self._adb.SendCommand(command)) | 677 assert _HasAdbPushSucceeded(self._adb.SendCommand(command)) |
678 self._md5sum_path = md5sum_path | 678 self._md5sum_path = md5sum_path |
679 | 679 |
680 self._pushed_files.append(device_path) | 680 self._pushed_files.append(device_path) |
681 hashes_on_device = _ComputeFileListHash( | 681 hashes_on_device = _ComputeFileListHash( |
682 self.RunShellCommand(self._util_wrapper + ' ' + MD5SUM_DEVICE_PATH + | 682 self.RunShellCommand(self._util_wrapper + ' ' + MD5SUM_DEVICE_PATH + |
683 ' ' + device_path)) | 683 ' ' + device_path)) |
684 assert os.path.exists(local_path), 'Local path not found %s' % local_path | 684 assert os.path.exists(local_path), 'Local path not found %s' % local_path |
685 hashes_on_host = _ComputeFileListHash( | 685 md5sum_output = cmd_helper.GetCmdOutput( |
686 subprocess.Popen( | 686 ['%s_host' % self._md5sum_path, local_path]) |
687 '%s_host %s' % (self._md5sum_path, local_path), | 687 hashes_on_host = _ComputeFileListHash(md5sum_output) |
688 stdout=subprocess.PIPE, shell=True).stdout) | |
689 if hashes_on_device == hashes_on_host: | 688 if hashes_on_device == hashes_on_host: |
690 return | 689 return |
691 | 690 |
692 # They don't match, so remove everything first and then create it. | 691 # They don't match, so remove everything first and then create it. |
693 if os.path.isdir(local_path): | 692 if os.path.isdir(local_path): |
694 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60) | 693 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60) |
695 self.RunShellCommand('mkdir -p %s' % device_path) | 694 self.RunShellCommand('mkdir -p %s' % device_path) |
696 | 695 |
697 # NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of | 696 # NOTE: We can't use adb_interface.Push() because it hardcodes a timeout of |
698 # 60 seconds which isn't sufficient for a lot of users of this method. | 697 # 60 seconds which isn't sufficient for a lot of users of this method. |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 """ | 1268 """ |
1270 def __init__(self, output): | 1269 def __init__(self, output): |
1271 self._output = output | 1270 self._output = output |
1272 | 1271 |
1273 def write(self, data): | 1272 def write(self, data): |
1274 data = data.replace('\r\r\n', '\n') | 1273 data = data.replace('\r\r\n', '\n') |
1275 self._output.write(data) | 1274 self._output.write(data) |
1276 | 1275 |
1277 def flush(self): | 1276 def flush(self): |
1278 self._output.flush() | 1277 self._output.flush() |
OLD | NEW |