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=unused-argument | 9 # pylint: disable=unused-argument |
10 | 10 |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 def _GetChangedFilesImpl(self, host_path, device_path): | 811 def _GetChangedFilesImpl(self, host_path, device_path): |
812 real_host_path = os.path.realpath(host_path) | 812 real_host_path = os.path.realpath(host_path) |
813 try: | 813 try: |
814 real_device_path = self.RunShellCommand( | 814 real_device_path = self.RunShellCommand( |
815 ['realpath', device_path], single_line=True, check_return=True) | 815 ['realpath', device_path], single_line=True, check_return=True) |
816 except device_errors.CommandFailedError: | 816 except device_errors.CommandFailedError: |
817 real_device_path = None | 817 real_device_path = None |
818 if not real_device_path: | 818 if not real_device_path: |
819 return [(host_path, device_path)] | 819 return [(host_path, device_path)] |
820 | 820 |
821 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path]) | 821 try: |
822 device_paths_to_md5 = ( | 822 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path]) |
823 real_device_path if os.path.isfile(real_host_path) | 823 device_paths_to_md5 = ( |
824 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) | 824 real_device_path if os.path.isfile(real_host_path) |
825 for _, p in host_hash_tuples)) | 825 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) |
826 device_hash_tuples = md5sum.CalculateDeviceMd5Sums( | 826 for _, p in host_hash_tuples)) |
827 device_paths_to_md5, self) | 827 device_hash_tuples = md5sum.CalculateDeviceMd5Sums( |
828 device_paths_to_md5, self) | |
829 except EnvironmentError as e: | |
830 logging.warning('Error calculating md5: %s' % e) | |
perezju
2015/04/15 09:36:18
nit: should be logging.warning('Error calculating
mikecase (-- gone --)
2015/04/21 16:54:33
Done.
| |
831 return [(host_path, device_path)] | |
828 | 832 |
829 if os.path.isfile(host_path): | 833 if os.path.isfile(host_path): |
830 if (not device_hash_tuples | 834 if (not device_hash_tuples |
831 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): | 835 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): |
832 return [(host_path, device_path)] | 836 return [(host_path, device_path)] |
833 else: | 837 else: |
834 return [] | 838 return [] |
835 else: | 839 else: |
836 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) | 840 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) |
837 to_push = [] | 841 to_push = [] |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1531 """Returns client cache.""" | 1535 """Returns client cache.""" |
1532 if client_name not in self._client_caches: | 1536 if client_name not in self._client_caches: |
1533 self._client_caches[client_name] = {} | 1537 self._client_caches[client_name] = {} |
1534 return self._client_caches[client_name] | 1538 return self._client_caches[client_name] |
1535 | 1539 |
1536 def _ClearCache(self): | 1540 def _ClearCache(self): |
1537 """Clears all caches.""" | 1541 """Clears all caches.""" |
1538 for client in self._client_caches: | 1542 for client in self._client_caches: |
1539 self._client_caches[client].clear() | 1543 self._client_caches[client].clear() |
1540 self._cache.clear() | 1544 self._cache.clear() |
OLD | NEW |