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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 | 856 |
857 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path]) | 857 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path]) |
858 device_paths_to_md5 = ( | 858 device_paths_to_md5 = ( |
859 real_device_path if os.path.isfile(real_host_path) | 859 real_device_path if os.path.isfile(real_host_path) |
860 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) | 860 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) |
861 for _, p in host_hash_tuples)) | 861 for _, p in host_hash_tuples)) |
862 device_hash_tuples = md5sum.CalculateDeviceMd5Sums( | 862 device_hash_tuples = md5sum.CalculateDeviceMd5Sums( |
863 device_paths_to_md5, self) | 863 device_paths_to_md5, self) |
864 | 864 |
865 if os.path.isfile(host_path): | 865 if os.path.isfile(host_path): |
866 if (not device_hash_tuples | 866 host_hash = None |
867 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): | 867 for h, p in host_hash_tuples or (): |
868 if p == real_host_path: | |
869 host_hash = h | |
870 | |
871 device_hash = None | |
872 for h, p in device_hash_tuples or (): | |
873 if p == real_device_path: | |
874 device_hash = h | |
perezju
2015/04/23 09:54:59
really sounds like md5sum functions should return
jbudorick
2015/04/23 16:20:14
I suppose so. Done.
| |
875 | |
876 if host_hash != device_hash: | |
868 return [(host_path, device_path)] | 877 return [(host_path, device_path)] |
869 else: | 878 else: |
870 return [] | 879 return [] |
871 else: | 880 else: |
872 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) | 881 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) |
873 to_push = [] | 882 to_push = [] |
874 for host_hash, host_abs_path in ( | 883 for host_hash, host_abs_path in ( |
875 (h.hash, h.path) for h in host_hash_tuples): | 884 (h.hash, h.path) for h in host_hash_tuples): |
876 device_abs_path = '%s/%s' % ( | 885 device_abs_path = '%s/%s' % ( |
877 real_device_path, os.path.relpath(host_abs_path, real_host_path)) | 886 real_device_path, os.path.relpath(host_abs_path, real_host_path)) |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1575 """Returns client cache.""" | 1584 """Returns client cache.""" |
1576 if client_name not in self._client_caches: | 1585 if client_name not in self._client_caches: |
1577 self._client_caches[client_name] = {} | 1586 self._client_caches[client_name] = {} |
1578 return self._client_caches[client_name] | 1587 return self._client_caches[client_name] |
1579 | 1588 |
1580 def _ClearCache(self): | 1589 def _ClearCache(self): |
1581 """Clears all caches.""" | 1590 """Clears all caches.""" |
1582 for client in self._client_caches: | 1591 for client in self._client_caches: |
1583 self._client_caches[client].clear() | 1592 self._client_caches[client].clear() |
1584 self._cache.clear() | 1593 self._cache.clear() |
OLD | NEW |