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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 all_changed_files = [] | 1006 all_changed_files = [] |
1007 all_stale_files = [] | 1007 all_stale_files = [] |
1008 for h, d in host_device_tuples: | 1008 for h, d in host_device_tuples: |
1009 if os.path.isdir(h): | 1009 if os.path.isdir(h): |
1010 self.RunShellCommand(['mkdir', '-p', d], check_return=True) | 1010 self.RunShellCommand(['mkdir', '-p', d], check_return=True) |
1011 changed_files, stale_files = ( | 1011 changed_files, stale_files = ( |
1012 self._GetChangedAndStaleFiles(h, d, delete_device_stale)) | 1012 self._GetChangedAndStaleFiles(h, d, delete_device_stale)) |
1013 all_changed_files += changed_files | 1013 all_changed_files += changed_files |
1014 all_stale_files += stale_files | 1014 all_stale_files += stale_files |
1015 | 1015 |
1016 if delete_device_stale: | 1016 if delete_device_stale and all_stale_files: |
1017 self.RunShellCommand(['rm', '-f'] + all_stale_files, | 1017 self.RunShellCommand(['rm', '-f'] + all_stale_files, |
1018 check_return=True) | 1018 check_return=True) |
1019 | 1019 |
1020 if not all_changed_files: | 1020 if all_changed_files: |
1021 return | 1021 self._PushFilesImpl(host_device_tuples, all_changed_files) |
1022 | |
1023 self._PushFilesImpl(host_device_tuples, all_changed_files) | |
1024 | 1022 |
1025 def _GetChangedAndStaleFiles(self, host_path, device_path, track_stale=False): | 1023 def _GetChangedAndStaleFiles(self, host_path, device_path, track_stale=False): |
1026 """Get files to push and delete | 1024 """Get files to push and delete |
1027 | 1025 |
1028 Args: | 1026 Args: |
1029 host_path: an absolute path of a file or directory on the host | 1027 host_path: an absolute path of a file or directory on the host |
1030 device_path: an absolute path of a file or directory on the device | 1028 device_path: an absolute path of a file or directory on the device |
1031 track_stale: whether to bother looking for stale files (slower) | 1029 track_stale: whether to bother looking for stale files (slower) |
1032 | 1030 |
1033 Returns: | 1031 Returns: |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1880 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() |
1883 if not blacklisted(adb)] | 1881 if not blacklisted(adb)] |
1884 | 1882 |
1885 @decorators.WithTimeoutAndRetriesFromInstance() | 1883 @decorators.WithTimeoutAndRetriesFromInstance() |
1886 def RestartAdbd(self, timeout=None, retries=None): | 1884 def RestartAdbd(self, timeout=None, retries=None): |
1887 logging.info('Restarting adbd on device.') | 1885 logging.info('Restarting adbd on device.') |
1888 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: | 1886 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: |
1889 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) | 1887 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) |
1890 self.RunShellCommand(['source', script.name], as_root=True) | 1888 self.RunShellCommand(['source', script.name], as_root=True) |
1891 self.adb.WaitForDevice() | 1889 self.adb.WaitForDevice() |
OLD | NEW |