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

Side by Side Diff: build/android/devil/android/device_utils.py

Issue 1371563002: device_utils: Compute host and device md5s concurrently in PushChangedFiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on dependent patch Created 5 years, 2 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 | 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 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 else: 739 else:
740 return exc.output 740 return exc.output
741 741
742 def handle_large_command(cmd): 742 def handle_large_command(cmd):
743 if len(cmd) < self._MAX_ADB_COMMAND_LENGTH: 743 if len(cmd) < self._MAX_ADB_COMMAND_LENGTH:
744 return handle_check_return(cmd) 744 return handle_check_return(cmd)
745 else: 745 else:
746 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: 746 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script:
747 self._WriteFileWithPush(script.name, cmd) 747 self._WriteFileWithPush(script.name, cmd)
748 logging.info('Large shell command will be run from file: %s ...', 748 logging.info('Large shell command will be run from file: %s ...',
749 cmd[:100]) 749 cmd[:self._MAX_ADB_COMMAND_LENGTH])
750 return handle_check_return('sh %s' % script.name_quoted) 750 return handle_check_return('sh %s' % script.name_quoted)
751 751
752 def handle_large_output(cmd, large_output_mode): 752 def handle_large_output(cmd, large_output_mode):
753 if large_output_mode: 753 if large_output_mode:
754 with device_temp_file.DeviceTempFile(self.adb) as large_output_file: 754 with device_temp_file.DeviceTempFile(self.adb) as large_output_file:
755 cmd = '( %s )>%s' % (cmd, large_output_file.name) 755 cmd = '( %s )>%s' % (cmd, large_output_file.name)
756 logging.debug('Large output mode enabled. Will write output to ' 756 logging.debug('Large output mode enabled. Will write output to '
757 'device and read results from file.') 757 'device and read results from file.')
758 handle_large_command(cmd) 758 handle_large_command(cmd)
759 return self.ReadFile(large_output_file.name, force_pull=True) 759 return self.ReadFile(large_output_file.name, force_pull=True)
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 track_stale: whether to bother looking for stale files (slower) 1095 track_stale: whether to bother looking for stale files (slower)
1096 1096
1097 Returns: 1097 Returns:
1098 a three-element tuple 1098 a three-element tuple
1099 1st element: a list of (host_files_path, device_files_path) tuples to push 1099 1st element: a list of (host_files_path, device_files_path) tuples to push
1100 2nd element: a list of host_files_path that are up-to-date 1100 2nd element: a list of host_files_path that are up-to-date
1101 3rd element: a list of stale files under device_path, or [] when 1101 3rd element: a list of stale files under device_path, or [] when
1102 track_stale == False 1102 track_stale == False
1103 """ 1103 """
1104 try: 1104 try:
1105 host_checksums = md5sum.CalculateHostMd5Sums([host_path]) 1105 specific_device_paths = [device_path]
1106 interesting_device_paths = [device_path]
1107 if not track_stale and os.path.isdir(host_path): 1106 if not track_stale and os.path.isdir(host_path):
1108 interesting_device_paths = [ 1107 specific_device_paths = []
1109 posixpath.join(device_path, os.path.relpath(p, host_path)) 1108 for root, _, filenames in os.walk(host_path):
1110 for p in host_checksums.keys()] 1109 relative_dir = root[len(host_path) + 1:]
1111 device_checksums = md5sum.CalculateDeviceMd5Sums( 1110 specific_device_paths.extend(
1112 interesting_device_paths, self) 1111 posixpath.join(device_path, relative_dir, f) for f in filenames)
1112
1113 host_checksums, device_checksums = reraiser_thread.RunAsync((
1114 lambda: md5sum.CalculateHostMd5Sums([host_path]),
1115 lambda: md5sum.CalculateDeviceMd5Sums(specific_device_paths, self)))
1113 except EnvironmentError as e: 1116 except EnvironmentError as e:
1114 logging.warning('Error calculating md5: %s', e) 1117 logging.warning('Error calculating md5: %s', e)
1115 return ([(host_path, device_path)], [], []) 1118 return ([(host_path, device_path)], [], [])
1116 1119
1117 to_push = [] 1120 to_push = []
1118 up_to_date = [] 1121 up_to_date = []
1119 to_delete = [] 1122 to_delete = []
1120 if os.path.isfile(host_path): 1123 if os.path.isfile(host_path):
1121 host_checksum = host_checksums.get(host_path) 1124 host_checksum = host_checksums.get(host_path)
1122 device_checksum = device_checksums.get(device_path) 1125 device_checksum = device_checksums.get(device_path)
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions 1982 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions
1980 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): 1983 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions):
1981 permissions.append('android.permission.READ_EXTERNAL_STORAGE') 1984 permissions.append('android.permission.READ_EXTERNAL_STORAGE')
1982 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions) 1985 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions)
1983 if cmd: 1986 if cmd:
1984 output = self.RunShellCommand(cmd) 1987 output = self.RunShellCommand(cmd)
1985 if output: 1988 if output:
1986 logging.warning('Possible problem when granting permissions. Blacklist ' 1989 logging.warning('Possible problem when granting permissions. Blacklist '
1987 'may need to be updated.') 1990 'may need to be updated.')
1988 logging.warning(output) 1991 logging.warning(output)
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