| OLD | NEW |
| 1 # Copyright 2015 Google Inc. All rights reserved. | 1 # Copyright 2015 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 Only contains the low level commands. High level operations are built upon the | 78 Only contains the low level commands. High level operations are built upon the |
| 79 low level functionality provided by this class. | 79 low level functionality provided by this class. |
| 80 """ | 80 """ |
| 81 # - CommonUsbError means that device I/O failed, e.g. a write or a read call | 81 # - CommonUsbError means that device I/O failed, e.g. a write or a read call |
| 82 # returned an error. | 82 # returned an error. |
| 83 # - USBError means that a bus I/O failed, e.g. the device path is not present | 83 # - USBError means that a bus I/O failed, e.g. the device path is not present |
| 84 # anymore. It is sometimes thrown as USBErrorIO. | 84 # anymore. It is sometimes thrown as USBErrorIO. |
| 85 _ERRORS = ( | 85 _ERRORS = ( |
| 86 usb_exceptions.CommonUsbError, | 86 usb_exceptions.CommonUsbError, |
| 87 common.usb1.USBError, | 87 common.usb1.USBError, |
| 88 common.usb1.USBErrorIO, | 88 common.usb1.USBErrorIO) |
| 89 ) | |
| 90 | 89 |
| 91 _SHELL_SUFFIX = ' ;echo -e "\n$?"' | 90 _SHELL_SUFFIX = ' ;echo -e "\n$?"' |
| 92 | 91 |
| 93 def __init__( | 92 def __init__( |
| 94 self, handle, banner, rsa_keys, on_error, port_path=None, | 93 self, handle, banner, rsa_keys, on_error, port_path=None, |
| 95 default_timeout_ms=10000, auth_timeout_ms=10000, lost_timeout_ms=10000): | 94 default_timeout_ms=10000, auth_timeout_ms=10000, lost_timeout_ms=10000): |
| 96 """Constructs an AdbCommandsSafe. | 95 """Constructs an AdbCommandsSafe. |
| 97 | 96 |
| 98 Arguments: | 97 Arguments: |
| 99 - port_path: str addressing the device on the USB bus, e.g. '1/2'. | 98 - port_path: str addressing the device on the USB bus, e.g. '1/2'. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 self._handle = None | 212 self._handle = None |
| 214 elif self._handle: | 213 elif self._handle: |
| 215 self._handle.Close() | 214 self._handle.Close() |
| 216 self._handle = None | 215 self._handle = None |
| 217 | 216 |
| 218 def GetUptime(self): | 217 def GetUptime(self): |
| 219 """Returns the device's uptime in second.""" | 218 """Returns the device's uptime in second.""" |
| 220 # This is an high level functionality but is needed by self.Reboot(). | 219 # This is an high level functionality but is needed by self.Reboot(). |
| 221 out = self.PullContent('/proc/uptime') | 220 out = self.PullContent('/proc/uptime') |
| 222 if out: | 221 if out: |
| 223 return float(out.split()[1]) | 222 return float(out.split()[0]) |
| 224 return None | 223 return None |
| 225 | 224 |
| 226 def List(self, destdir): | 225 def List(self, destdir): |
| 227 """List a directory on the device. | 226 """List a directory on the device. |
| 228 | 227 |
| 229 Returns: | 228 Returns: |
| 230 list of file_sync_protocol.DeviceFile. | 229 list of file_sync_protocol.DeviceFile. |
| 231 """ | 230 """ |
| 232 assert destdir.startswith('/'), destdir | 231 assert destdir.startswith('/'), destdir |
| 233 if self._adb_cmd: | 232 if self._adb_cmd: |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 self.Close() | 882 self.Close() |
| 884 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): | 883 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): |
| 885 return False | 884 return False |
| 886 if not self._OpenHandle(): | 885 if not self._OpenHandle(): |
| 887 return False | 886 return False |
| 888 return self._Connect(use_serial=use_serial) | 887 return self._Connect(use_serial=use_serial) |
| 889 | 888 |
| 890 def __repr__(self): | 889 def __repr__(self): |
| 891 return '<Device %s %s>' % ( | 890 return '<Device %s %s>' % ( |
| 892 self.port_path, self.serial if self.is_valid else '(broken)') | 891 self.port_path, self.serial if self.is_valid else '(broken)') |
| OLD | NEW |