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

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

Issue 1286763002: device_utils.Install: Calculate host md5s at the same time as device md5s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix diffbase for realz Created 5 years, 4 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
11 import collections 11 import collections
12 import contextlib 12 import contextlib
13 import itertools 13 import itertools
14 import logging 14 import logging
15 import multiprocessing 15 import multiprocessing
16 import os 16 import os
17 import posixpath 17 import posixpath
18 import re 18 import re
19 import shutil 19 import shutil
20 import sys 20 import sys
21 import tempfile 21 import tempfile
22 import threading
22 import time 23 import time
23 import zipfile 24 import zipfile
24 25
25 import pylib.android_commands 26 import pylib.android_commands
26 from pylib import cmd_helper 27 from pylib import cmd_helper
27 from pylib import constants 28 from pylib import constants
28 from pylib import device_signal 29 from pylib import device_signal
29 from pylib.constants import keyevent 30 from pylib.constants import keyevent
30 from pylib.device import adb_wrapper 31 from pylib.device import adb_wrapper
31 from pylib.device import decorators 32 from pylib.device import decorators
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 def _ComputeDeviceChecksumsForApks(self, package_name): 1086 def _ComputeDeviceChecksumsForApks(self, package_name):
1086 ret = self._cache['package_apk_checksums'].get(package_name) 1087 ret = self._cache['package_apk_checksums'].get(package_name)
1087 if ret is None: 1088 if ret is None:
1088 device_paths = self._GetApplicationPathsInternal(package_name) 1089 device_paths = self._GetApplicationPathsInternal(package_name)
1089 file_to_checksums = md5sum.CalculateDeviceMd5Sums(device_paths, self) 1090 file_to_checksums = md5sum.CalculateDeviceMd5Sums(device_paths, self)
1090 ret = set(file_to_checksums.values()) 1091 ret = set(file_to_checksums.values())
1091 self._cache['package_apk_checksums'][package_name] = ret 1092 self._cache['package_apk_checksums'][package_name] = ret
1092 return ret 1093 return ret
1093 1094
1094 def _ComputeStaleApks(self, package_name, host_apk_paths): 1095 def _ComputeStaleApks(self, package_name, host_apk_paths):
1095 host_checksums = md5sum.CalculateHostMd5Sums(host_apk_paths) 1096 host_checksums_holder = [None]
1097 def DoComputeHostChecksums():
jbudorick 2015/08/11 18:06:40 nit: I've generally been trying to keep local func
agrieve 2015/08/11 18:15:00 Done.
1098 host_checksums_holder[0] = md5sum.CalculateHostMd5Sums(host_apk_paths)
jbudorick 2015/08/11 18:06:40 nit: line break after function definition
agrieve 2015/08/11 18:15:00 Done.
1099 host_thread = threading.Thread(target=DoComputeHostChecksums)
jbudorick 2015/08/11 18:06:40 I'd prefer it if you used a timeout_retry thread:
agrieve 2015/08/11 18:15:00 Since this is a private helper, and all public met
jbudorick 2015/08/11 18:16:54 ah, right.
1100 host_thread.start()
1096 device_checksums = self._ComputeDeviceChecksumsForApks(package_name) 1101 device_checksums = self._ComputeDeviceChecksumsForApks(package_name)
1097 stale_apks = [k for (k, v) in host_checksums.iteritems() 1102 host_thread.join()
1103 stale_apks = [k for (k, v) in host_checksums_holder[0].iteritems()
1098 if v not in device_checksums] 1104 if v not in device_checksums]
1099 return stale_apks, set(host_checksums.values()) 1105 return stale_apks, set(host_checksums_holder[0].values())
1100 1106
1101 def _PushFilesImpl(self, host_device_tuples, files): 1107 def _PushFilesImpl(self, host_device_tuples, files):
1102 size = sum(host_utils.GetRecursiveDiskUsage(h) for h, _ in files) 1108 size = sum(host_utils.GetRecursiveDiskUsage(h) for h, _ in files)
1103 file_count = len(files) 1109 file_count = len(files)
1104 dir_size = sum(host_utils.GetRecursiveDiskUsage(h) 1110 dir_size = sum(host_utils.GetRecursiveDiskUsage(h)
1105 for h, _ in host_device_tuples) 1111 for h, _ in host_device_tuples)
1106 dir_file_count = 0 1112 dir_file_count = 0
1107 for h, _ in host_device_tuples: 1113 for h, _ in host_device_tuples:
1108 if os.path.isdir(h): 1114 if os.path.isdir(h):
1109 dir_file_count += sum(len(f) for _r, _d, f in os.walk(h)) 1115 dir_file_count += sum(len(f) for _r, _d, f in os.walk(h))
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1886 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
1881 if not blacklisted(adb)] 1887 if not blacklisted(adb)]
1882 1888
1883 @decorators.WithTimeoutAndRetriesFromInstance() 1889 @decorators.WithTimeoutAndRetriesFromInstance()
1884 def RestartAdbd(self, timeout=None, retries=None): 1890 def RestartAdbd(self, timeout=None, retries=None):
1885 logging.info('Restarting adbd on device.') 1891 logging.info('Restarting adbd on device.')
1886 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: 1892 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script:
1887 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) 1893 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT)
1888 self.RunShellCommand(['source', script.name], as_root=True) 1894 self.RunShellCommand(['source', script.name], as_root=True)
1889 self.adb.WaitForDevice() 1895 self.adb.WaitForDevice()
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