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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 | 828 |
829 def HostHas(fname): | 829 def HostHas(fname): |
830 return any(path in fname for path in host_files) | 830 return any(path in fname for path in host_files) |
831 | 831 |
832 device_hash_tuples = [h for h in device_hash_tuples if HostHas(h.path)] | 832 device_hash_tuples = [h for h in device_hash_tuples if HostHas(h.path)] |
833 | 833 |
834 # Constructs the target device path from a given host path. Don't use when | 834 # Constructs the target device path from a given host path. Don't use when |
835 # only a single file is given as the base name given in device_path may | 835 # only a single file is given as the base name given in device_path may |
836 # differ from that in host_path. | 836 # differ from that in host_path. |
837 def HostToDevicePath(host_file_path): | 837 def HostToDevicePath(host_file_path): |
838 return os.path.join(os.path.dirname(device_path), os.path.relpath( | 838 return os.path.join(device_path, os.path.relpath( |
839 host_file_path, os.path.dirname(os.path.normpath(host_path)))) | 839 host_file_path, os.path.normpath(host_path))) |
840 | 840 |
841 device_hashes = [h.hash for h in device_hash_tuples] | 841 device_hashes = [h.hash for h in device_hash_tuples] |
842 return [(t.path, HostToDevicePath(t.path) if os.path.isdir(host_path) else | 842 return [(t.path, HostToDevicePath(t.path) if os.path.isdir(host_path) else |
843 device_path) | 843 device_path) |
844 for t in host_hash_tuples if t.hash not in device_hashes] | 844 for t in host_hash_tuples if t.hash not in device_hashes] |
845 | 845 |
846 def PushIfNeeded(self, host_path, device_path): | 846 def PushIfNeeded(self, host_path, device_path): |
847 """Pushes |host_path| to |device_path|. | 847 """Pushes |host_path| to |device_path|. |
848 | 848 |
849 Works for files and directories. This method skips copying any paths in | 849 Works for files and directories. This method skips copying any paths in |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 """ | 1545 """ |
1546 def __init__(self, output): | 1546 def __init__(self, output): |
1547 self._output = output | 1547 self._output = output |
1548 | 1548 |
1549 def write(self, data): | 1549 def write(self, data): |
1550 data = data.replace('\r\r\n', '\n') | 1550 data = data.replace('\r\r\n', '\n') |
1551 self._output.write(data) | 1551 self._output.write(data) |
1552 | 1552 |
1553 def flush(self): | 1553 def flush(self): |
1554 self._output.flush() | 1554 self._output.flush() |
OLD | NEW |