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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 md5sum_output = cmd_helper.GetCmdOutput( | 685 md5sum_output = cmd_helper.GetCmdOutput( |
686 ['%s_host' % self._md5sum_path, local_path]) | 686 ['%s_host' % self._md5sum_path, local_path]) |
687 hashes_on_host = _ComputeFileListHash(md5sum_output) | 687 hashes_on_host = _ComputeFileListHash(md5sum_output.splitlines()) |
688 if hashes_on_device == hashes_on_host: | 688 if hashes_on_device == hashes_on_host: |
689 return | 689 return |
690 | 690 |
691 # 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. |
692 if os.path.isdir(local_path): | 692 if os.path.isdir(local_path): |
693 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60) | 693 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60) |
694 self.RunShellCommand('mkdir -p %s' % device_path) | 694 self.RunShellCommand('mkdir -p %s' % device_path) |
695 | 695 |
696 # 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 |
697 # 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... |
1268 """ | 1268 """ |
1269 def __init__(self, output): | 1269 def __init__(self, output): |
1270 self._output = output | 1270 self._output = output |
1271 | 1271 |
1272 def write(self, data): | 1272 def write(self, data): |
1273 data = data.replace('\r\r\n', '\n') | 1273 data = data.replace('\r\r\n', '\n') |
1274 self._output.write(data) | 1274 self._output.write(data) |
1275 | 1275 |
1276 def flush(self): | 1276 def flush(self): |
1277 self._output.flush() | 1277 self._output.flush() |
OLD | NEW |