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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 1307393004: Reland of Don't bother running realpath in DeviceUtils._GetChangedAndStaleFiles() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@device5
Patch Set: with md5sum.cc changes Created 5 years, 3 months 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 | tools/android/md5sum/md5sum.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 device_path: an absolute path of a file or directory on the device 1032 device_path: an absolute path of a file or directory on the device
1033 track_stale: whether to bother looking for stale files (slower) 1033 track_stale: whether to bother looking for stale files (slower)
1034 1034
1035 Returns: 1035 Returns:
1036 a three-element tuple 1036 a three-element tuple
1037 1st element: a list of (host_files_path, device_files_path) tuples to push 1037 1st element: a list of (host_files_path, device_files_path) tuples to push
1038 2nd element: a list of host_files_path that are up-to-date 1038 2nd element: a list of host_files_path that are up-to-date
1039 3rd element: a list of stale files under device_path, or [] when 1039 3rd element: a list of stale files under device_path, or [] when
1040 track_stale == False 1040 track_stale == False
1041 """ 1041 """
1042 real_host_path = os.path.realpath(host_path)
1043 try: 1042 try:
1044 real_device_path = self.RunShellCommand( 1043 host_checksums = md5sum.CalculateHostMd5Sums([host_path])
1045 ['realpath', device_path], single_line=True, check_return=True) 1044 interesting_device_paths = [device_path]
1046 except device_errors.CommandFailedError: 1045 if not track_stale and os.path.isdir(host_path):
1047 real_device_path = None
1048 if not real_device_path:
1049 return ([(host_path, device_path)], [], [])
1050
1051 try:
1052 host_checksums = md5sum.CalculateHostMd5Sums([real_host_path])
1053 interesting_device_paths = [real_device_path]
1054 if not track_stale and os.path.isdir(real_host_path):
1055 interesting_device_paths = [ 1046 interesting_device_paths = [
1056 posixpath.join(real_device_path, os.path.relpath(p, real_host_path)) 1047 posixpath.join(device_path, os.path.relpath(p, host_path))
1057 for p in host_checksums.keys()] 1048 for p in host_checksums.keys()]
1058 device_checksums = md5sum.CalculateDeviceMd5Sums( 1049 device_checksums = md5sum.CalculateDeviceMd5Sums(
1059 interesting_device_paths, self) 1050 interesting_device_paths, self)
1060 except EnvironmentError as e: 1051 except EnvironmentError as e:
1061 logging.warning('Error calculating md5: %s', e) 1052 logging.warning('Error calculating md5: %s', e)
1062 return ([(host_path, device_path)], [], []) 1053 return ([(host_path, device_path)], [], [])
1063 1054
1064 to_push = [] 1055 to_push = []
1065 up_to_date = [] 1056 up_to_date = []
1066 to_delete = [] 1057 to_delete = []
1067 if os.path.isfile(host_path): 1058 if os.path.isfile(host_path):
1068 host_checksum = host_checksums.get(real_host_path) 1059 host_checksum = host_checksums.get(host_path)
1069 device_checksum = device_checksums.get(real_device_path) 1060 device_checksum = device_checksums.get(device_path)
1070 if host_checksum == device_checksum: 1061 if host_checksum == device_checksum:
1071 up_to_date.append(host_path) 1062 up_to_date.append(host_path)
1072 else: 1063 else:
1073 to_push.append((host_path, device_path)) 1064 to_push.append((host_path, device_path))
1074 else: 1065 else:
1075 for host_abs_path, host_checksum in host_checksums.iteritems(): 1066 for host_abs_path, host_checksum in host_checksums.iteritems():
1076 device_abs_path = posixpath.join( 1067 device_abs_path = posixpath.join(
1077 real_device_path, os.path.relpath(host_abs_path, real_host_path)) 1068 device_path, os.path.relpath(host_abs_path, host_path))
1078 device_checksum = device_checksums.pop(device_abs_path, None) 1069 device_checksum = device_checksums.pop(device_abs_path, None)
1079 if device_checksum == host_checksum: 1070 if device_checksum == host_checksum:
1080 up_to_date.append(host_abs_path) 1071 up_to_date.append(host_abs_path)
1081 else: 1072 else:
1082 to_push.append((host_abs_path, device_abs_path)) 1073 to_push.append((host_abs_path, device_abs_path))
1083 to_delete = device_checksums.keys() 1074 to_delete = device_checksums.keys()
1084 return (to_push, up_to_date, to_delete) 1075 return (to_push, up_to_date, to_delete)
1085 1076
1086 def _ComputeDeviceChecksumsForApks(self, package_name): 1077 def _ComputeDeviceChecksumsForApks(self, package_name):
1087 ret = self._cache['package_apk_checksums'].get(package_name) 1078 ret = self._cache['package_apk_checksums'].get(package_name)
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1882 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
1892 if not blacklisted(adb)] 1883 if not blacklisted(adb)]
1893 1884
1894 @decorators.WithTimeoutAndRetriesFromInstance() 1885 @decorators.WithTimeoutAndRetriesFromInstance()
1895 def RestartAdbd(self, timeout=None, retries=None): 1886 def RestartAdbd(self, timeout=None, retries=None):
1896 logging.info('Restarting adbd on device.') 1887 logging.info('Restarting adbd on device.')
1897 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: 1888 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script:
1898 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) 1889 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT)
1899 self.RunShellCommand(['source', script.name], as_root=True) 1890 self.RunShellCommand(['source', script.name], as_root=True)
1900 self.adb.WaitForDevice() 1891 self.adb.WaitForDevice()
OLDNEW
« no previous file with comments | « no previous file | tools/android/md5sum/md5sum.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698