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

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

Issue 738413002: [Android] Extract MD5sum logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « build/android/pylib/constants.py ('k') | build/android/pylib/instrumentation/test_jar.py » ('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=W0613 9 # pylint: disable=W0613
10 10
11 import logging 11 import logging
12 import multiprocessing 12 import multiprocessing
13 import os 13 import os
14 import re 14 import re
15 import sys 15 import sys
16 import tempfile 16 import tempfile
17 import time 17 import time
18 import zipfile 18 import zipfile
19 19
20 import pylib.android_commands 20 import pylib.android_commands
21 from pylib import cmd_helper 21 from pylib import cmd_helper
22 from pylib.device import adb_wrapper 22 from pylib.device import adb_wrapper
23 from pylib.device import decorators 23 from pylib.device import decorators
24 from pylib.device import device_errors 24 from pylib.device import device_errors
25 from pylib.device.commands import install_commands 25 from pylib.device.commands import install_commands
26 from pylib.utils import apk_helper 26 from pylib.utils import apk_helper
27 from pylib.utils import device_temp_file 27 from pylib.utils import device_temp_file
28 from pylib.utils import host_utils 28 from pylib.utils import host_utils
29 from pylib.utils import md5sum
29 from pylib.utils import parallelizer 30 from pylib.utils import parallelizer
30 from pylib.utils import timeout_retry 31 from pylib.utils import timeout_retry
31 32
32 _DEFAULT_TIMEOUT = 30 33 _DEFAULT_TIMEOUT = 30
33 _DEFAULT_RETRIES = 3 34 _DEFAULT_RETRIES = 3
34 35
35 36
36 @decorators.WithExplicitTimeoutAndRetries( 37 @decorators.WithExplicitTimeoutAndRetries(
37 _DEFAULT_TIMEOUT, _DEFAULT_RETRIES) 38 _DEFAULT_TIMEOUT, _DEFAULT_RETRIES)
38 def GetAVDs(): 39 def GetAVDs():
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 def _GetChangedFilesImpl(self, host_path, device_path): 695 def _GetChangedFilesImpl(self, host_path, device_path):
695 real_host_path = os.path.realpath(host_path) 696 real_host_path = os.path.realpath(host_path)
696 try: 697 try:
697 real_device_path = self.RunShellCommand( 698 real_device_path = self.RunShellCommand(
698 ['realpath', device_path], single_line=True, check_return=True) 699 ['realpath', device_path], single_line=True, check_return=True)
699 except device_errors.CommandFailedError: 700 except device_errors.CommandFailedError:
700 real_device_path = None 701 real_device_path = None
701 if not real_device_path: 702 if not real_device_path:
702 return [(host_path, device_path)] 703 return [(host_path, device_path)]
703 704
704 # TODO(jbudorick): Move the md5 logic up into DeviceUtils or base 705 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path])
705 # this function on mtime. 706 device_paths_to_md5 = (
706 # pylint: disable=protected-access 707 real_device_path if os.path.isfile(real_host_path)
707 host_hash_tuples, device_hash_tuples = self.old_interface._RunMd5Sum( 708 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path))
708 real_host_path, real_device_path) 709 for _, p in host_hash_tuples))
709 # pylint: enable=protected-access 710 device_hash_tuples = md5sum.CalculateDeviceMd5Sums(
711 device_paths_to_md5, self)
710 712
711 if os.path.isfile(host_path): 713 if os.path.isfile(host_path):
712 if (not device_hash_tuples 714 if (not device_hash_tuples
713 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): 715 or device_hash_tuples[0].hash != host_hash_tuples[0].hash):
714 return [(host_path, device_path)] 716 return [(host_path, device_path)]
715 else: 717 else:
716 return [] 718 return []
717 else: 719 else:
718 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) 720 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples)
719 to_push = [] 721 to_push = []
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 Returns: 1158 Returns:
1157 A Parallelizer operating over |devices|. 1159 A Parallelizer operating over |devices|.
1158 """ 1160 """
1159 if not devices or len(devices) == 0: 1161 if not devices or len(devices) == 0:
1160 devices = pylib.android_commands.GetAttachedDevices() 1162 devices = pylib.android_commands.GetAttachedDevices()
1161 parallelizer_type = (parallelizer.Parallelizer if async 1163 parallelizer_type = (parallelizer.Parallelizer if async
1162 else parallelizer.SyncParallelizer) 1164 else parallelizer.SyncParallelizer)
1163 return parallelizer_type([ 1165 return parallelizer_type([
1164 d if isinstance(d, DeviceUtils) else DeviceUtils(d) 1166 d if isinstance(d, DeviceUtils) else DeviceUtils(d)
1165 for d in devices]) 1167 for d in devices])
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/instrumentation/test_jar.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698