| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
| 6 | 6 |
| 7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 # Column 0 is the executable name | 977 # Column 0 is the executable name |
| 978 # Column 1 is the pid | 978 # Column 1 is the pid |
| 979 # Column 8 is the Inode in use | 979 # Column 8 is the Inode in use |
| 980 if process_results[8] == socket_name: | 980 if process_results[8] == socket_name: |
| 981 pids.append((int(process_results[1]), process_results[0])) | 981 pids.append((int(process_results[1]), process_results[0])) |
| 982 break | 982 break |
| 983 logging.info('PidsUsingDevicePort: %s', pids) | 983 logging.info('PidsUsingDevicePort: %s', pids) |
| 984 return pids | 984 return pids |
| 985 | 985 |
| 986 def FileExistsOnDevice(self, file_name): | 986 def FileExistsOnDevice(self, file_name): |
| 987 """Checks whether the given (regular) file exists on the device. | 987 """Checks whether the given file exists on the device. |
| 988 | 988 |
| 989 Args: | 989 Args: |
| 990 file_name: Full path of file to check. | 990 file_name: Full path of file to check. |
| 991 | 991 |
| 992 Returns: | 992 Returns: |
| 993 True if the file exists, False otherwise. | 993 True if the file exists, False otherwise. |
| 994 """ | 994 """ |
| 995 assert '"' not in file_name, 'file_name cannot contain double quotes' | 995 assert '"' not in file_name, 'file_name cannot contain double quotes' |
| 996 status = self._adb.SendShellCommand( | 996 status = self._adb.SendShellCommand( |
| 997 '\'test -f "%s"; echo $?\'' % (file_name)) | 997 '\'test -e "%s"; echo $?\'' % (file_name)) |
| 998 if 'test: not found' not in status: | 998 if 'test: not found' not in status: |
| 999 return int(status) == 0 | 999 return int(status) == 0 |
| 1000 | 1000 |
| 1001 status = self._adb.SendShellCommand( | 1001 status = self._adb.SendShellCommand( |
| 1002 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) | 1002 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) |
| 1003 return int(status) == 0 | 1003 return int(status) == 0 |
| OLD | NEW |