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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 else: | 892 else: |
893 raise Exception('Push failed: %s' % output) | 893 raise Exception('Push failed: %s' % output) |
894 | 894 |
895 diff_size = 0 | 895 diff_size = 0 |
896 if len(changed_files) <= MAX_INDIVIDUAL_PUSHES: | 896 if len(changed_files) <= MAX_INDIVIDUAL_PUSHES: |
897 diff_size = sum(GetHostSize(f[0]) for f in changed_files) | 897 diff_size = sum(GetHostSize(f[0]) for f in changed_files) |
898 | 898 |
899 # TODO(craigdh): Replace this educated guess with a heuristic that | 899 # TODO(craigdh): Replace this educated guess with a heuristic that |
900 # approximates the push time for each method. | 900 # approximates the push time for each method. |
901 if len(changed_files) > MAX_INDIVIDUAL_PUSHES or diff_size > 0.5 * size: | 901 if len(changed_files) > MAX_INDIVIDUAL_PUSHES or diff_size > 0.5 * size: |
902 # We're pushing everything, remove everything first and then create it. | |
903 self._actual_push_size += size | 902 self._actual_push_size += size |
904 if os.path.isdir(host_path): | 903 if os.path.isdir(host_path): |
905 self.RunShellCommand('rm -r %s' % device_path, timeout_time=2 * 60) | |
906 self.RunShellCommand('mkdir -p %s' % device_path) | 904 self.RunShellCommand('mkdir -p %s' % device_path) |
907 Push(host_path, device_path) | 905 Push(host_path, device_path) |
908 else: | 906 else: |
909 for f in changed_files: | 907 for f in changed_files: |
910 Push(f[0], f[1]) | 908 Push(f[0], f[1]) |
911 self._actual_push_size += diff_size | 909 self._actual_push_size += diff_size |
912 | 910 |
913 def GetPushSizeInfo(self): | 911 def GetPushSizeInfo(self): |
914 """Get total size of pushes to the device done via PushIfNeeded() | 912 """Get total size of pushes to the device done via PushIfNeeded() |
915 | 913 |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 """ | 1578 """ |
1581 def __init__(self, output): | 1579 def __init__(self, output): |
1582 self._output = output | 1580 self._output = output |
1583 | 1581 |
1584 def write(self, data): | 1582 def write(self, data): |
1585 data = data.replace('\r\r\n', '\n') | 1583 data = data.replace('\r\r\n', '\n') |
1586 self._output.write(data) | 1584 self._output.write(data) |
1587 | 1585 |
1588 def flush(self): | 1586 def flush(self): |
1589 self._output.flush() | 1587 self._output.flush() |
OLD | NEW |