OLD | NEW |
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 host_utils | 27 from pylib.utils import host_utils |
| 28 from pylib.utils import md5sum |
28 from pylib.utils import parallelizer | 29 from pylib.utils import parallelizer |
29 from pylib.utils import timeout_retry | 30 from pylib.utils import timeout_retry |
30 | 31 |
31 _DEFAULT_TIMEOUT = 30 | 32 _DEFAULT_TIMEOUT = 30 |
32 _DEFAULT_RETRIES = 3 | 33 _DEFAULT_RETRIES = 3 |
33 | 34 |
34 | 35 |
35 @decorators.WithExplicitTimeoutAndRetries( | 36 @decorators.WithExplicitTimeoutAndRetries( |
36 _DEFAULT_TIMEOUT, _DEFAULT_RETRIES) | 37 _DEFAULT_TIMEOUT, _DEFAULT_RETRIES) |
37 def GetAVDs(): | 38 def GetAVDs(): |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 def _GetChangedFilesImpl(self, host_path, device_path): | 693 def _GetChangedFilesImpl(self, host_path, device_path): |
693 real_host_path = os.path.realpath(host_path) | 694 real_host_path = os.path.realpath(host_path) |
694 try: | 695 try: |
695 real_device_path = self.RunShellCommand( | 696 real_device_path = self.RunShellCommand( |
696 ['realpath', device_path], single_line=True, check_return=True) | 697 ['realpath', device_path], single_line=True, check_return=True) |
697 except device_errors.CommandFailedError: | 698 except device_errors.CommandFailedError: |
698 real_device_path = None | 699 real_device_path = None |
699 if not real_device_path: | 700 if not real_device_path: |
700 return [(host_path, device_path)] | 701 return [(host_path, device_path)] |
701 | 702 |
702 # TODO(jbudorick): Move the md5 logic up into DeviceUtils or base | 703 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path]) |
703 # this function on mtime. | 704 device_paths_to_md5 = ( |
704 # pylint: disable=protected-access | 705 real_device_path if os.path.isfile(real_host_path) |
705 host_hash_tuples, device_hash_tuples = self.old_interface._RunMd5Sum( | 706 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) |
706 real_host_path, real_device_path) | 707 for _, p in host_hash_tuples)) |
707 # pylint: enable=protected-access | 708 device_hash_tuples = md5sum.CalculateDeviceMd5Sums( |
| 709 device_paths_to_md5, self) |
708 | 710 |
709 if os.path.isfile(host_path): | 711 if os.path.isfile(host_path): |
710 if (not device_hash_tuples | 712 if (not device_hash_tuples |
711 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): | 713 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): |
712 return [(host_path, device_path)] | 714 return [(host_path, device_path)] |
713 else: | 715 else: |
714 return [] | 716 return [] |
715 else: | 717 else: |
716 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) | 718 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) |
717 to_push = [] | 719 to_push = [] |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 Returns: | 1168 Returns: |
1167 A Parallelizer operating over |devices|. | 1169 A Parallelizer operating over |devices|. |
1168 """ | 1170 """ |
1169 if not devices or len(devices) == 0: | 1171 if not devices or len(devices) == 0: |
1170 devices = pylib.android_commands.GetAttachedDevices() | 1172 devices = pylib.android_commands.GetAttachedDevices() |
1171 parallelizer_type = (parallelizer.Parallelizer if async | 1173 parallelizer_type = (parallelizer.Parallelizer if async |
1172 else parallelizer.SyncParallelizer) | 1174 else parallelizer.SyncParallelizer) |
1173 return parallelizer_type([ | 1175 return parallelizer_type([ |
1174 d if isinstance(d, DeviceUtils) else DeviceUtils(d) | 1176 d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
1175 for d in devices]) | 1177 for d in devices]) |
OLD | NEW |