Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: build/android/pylib/android_commands.py

Issue 57633003: Make PushIfNeeded do what is says. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary change to call of HostHas Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 host_path: Path (file or directory) on the host. 834 host_path: Path (file or directory) on the host.
835 device_path: Path on the device. 835 device_path: Path on the device.
836 ignore_filenames: If True only the file contents are considered when 836 ignore_filenames: If True only the file contents are considered when
837 checking whether a file has changed, otherwise the relative path 837 checking whether a file has changed, otherwise the relative path
838 must also match. 838 must also match.
839 839
840 Returns: 840 Returns:
841 A list of tuples of the form (host_path, device_path) for files whose 841 A list of tuples of the form (host_path, device_path) for files whose
842 md5sums do not match. 842 md5sums do not match.
843 """ 843 """
844
845 real_host_path = os.path.realpath(host_path)
craigdh 2013/11/05 19:10:08 add a comment here explaining why this is needed
aberent 2013/11/05 19:58:34 Done.
846 real_device_path = self.RunShellCommand('realpath "%s"' % device_path)[0]
847
844 host_hash_tuples, device_hash_tuples = self._RunMd5Sum( 848 host_hash_tuples, device_hash_tuples = self._RunMd5Sum(
845 host_path, device_path) 849 real_host_path, real_device_path)
846 850
847 # Ignore extra files on the device. 851 # Ignore extra files on the device.
848 if not ignore_filenames: 852 if not ignore_filenames:
849 host_files = [os.path.relpath(os.path.normpath(p.path), 853 host_files = [os.path.relpath(os.path.normpath(p.path),
850 os.path.normpath(host_path)) for p in host_hash_tuples] 854 real_host_path) for p in host_hash_tuples]
851 855
852 def HostHas(fname): 856 def HostHas(fname):
853 return any(path in fname for path in host_files) 857 return any(path in fname for path in host_files)
854 858
855 device_hash_tuples = [h for h in device_hash_tuples if HostHas(h.path)] 859 device_hash_tuples = [h for h in device_hash_tuples if HostHas(h.path)]
856 860
857 if len(host_hash_tuples) > len(device_hash_tuples): 861 if len(host_hash_tuples) > len(device_hash_tuples):
858 logging.info('%s files do not exist on the device' % 862 logging.info('%s files do not exist on the device' %
859 (len(host_hash_tuples) - len(device_hash_tuples))) 863 (len(host_hash_tuples) - len(device_hash_tuples)))
860 864
861 # Constructs the target device path from a given host path. Don't use when 865 # Constructs the target device path from a given host path. Don't use when
862 # only a single file is given as the base name given in device_path may 866 # only a single file is given as the base name given in device_path may
863 # differ from that in host_path. 867 # differ from that in host_path.
864 def HostToDevicePath(host_file_path): 868 def HostToDevicePath(host_file_path):
865 return os.path.join(device_path, os.path.relpath( 869 return os.path.join(device_path, os.path.relpath(host_file_path,
866 host_file_path, os.path.normpath(host_path))) 870 real_host_path))
867 871
868 device_hashes = [h.hash for h in device_hash_tuples] 872 device_hashes = [h.hash for h in device_hash_tuples]
869 return [(t.path, HostToDevicePath(t.path) if os.path.isdir(host_path) else 873 return [(t.path, HostToDevicePath(t.path) if
870 device_path) 874 os.path.isdir(real_host_path) else real_device_path)
871 for t in host_hash_tuples if t.hash not in device_hashes] 875 for t in host_hash_tuples if t.hash not in device_hashes]
872 876
873 def PushIfNeeded(self, host_path, device_path): 877 def PushIfNeeded(self, host_path, device_path):
874 """Pushes |host_path| to |device_path|. 878 """Pushes |host_path| to |device_path|.
875 879
876 Works for files and directories. This method skips copying any paths in 880 Works for files and directories. This method skips copying any paths in
877 |test_data_paths| that already exist on the device with the same hash. 881 |test_data_paths| that already exist on the device with the same hash.
878 882
879 All pushed files can be removed by calling RemovePushedFiles(). 883 All pushed files can be removed by calling RemovePushedFiles().
880 """ 884 """
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 """ 1658 """
1655 def __init__(self, output): 1659 def __init__(self, output):
1656 self._output = output 1660 self._output = output
1657 1661
1658 def write(self, data): 1662 def write(self, data):
1659 data = data.replace('\r\r\n', '\n') 1663 data = data.replace('\r\r\n', '\n')
1660 self._output.write(data) 1664 self._output.write(data)
1661 1665
1662 def flush(self): 1666 def flush(self):
1663 self._output.flush() 1667 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698