Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: adb/common.py

Issue 2177573003: Add option to send reboot command and not wait for device. (Closed) Base URL: https://github.com/luci/python-adb.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | adb/contrib/adb_commands_safe.py » ('j') | adb/contrib/adb_commands_safe.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 Google Inc. All rights reserved. 1 # Copyright 2014 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 raise 435 raise
436 436
437 def Close(self): 437 def Close(self):
438 if self._connection is None: 438 if self._connection is None:
439 return 439 return
440 try: 440 try:
441 self._connection.close() 441 self._connection.close()
442 finally: 442 finally:
443 self._connection = None 443 self._connection = None
444 444
445 def Reset(self, new_endpoint=None):
446 self.Close()
447 if new_endpoint:
448 if ':' in new_endpoint:
M-A Ruel 2016/07/23 00:58:43 I feel odd about this, shouldn't we create a new i
bpastene 2016/07/23 01:17:39 Yeah; I tried, but ran into a couple of problems:
M-A Ruel 2016/07/23 01:29:34 No, that's fine. Not worth reengineering.
449 (self._host, self._port) = new_endpoint.split(':')
450 else:
451 self._host = new_endpoint
452 self._port = 5555
453 self._serial_number = '%s:%s' % (self._host, self._port)
454 self.Open()
455
445 def BulkWrite(self, data, timeout_ms=None): 456 def BulkWrite(self, data, timeout_ms=None):
446 try: 457 try:
447 self._connection.settimeout(self.Timeout(timeout_ms) / 1000.0) 458 self._connection.settimeout(self.Timeout(timeout_ms) / 1000.0)
448 return self._connection.sendall(data) 459 return self._connection.sendall(data)
449 except socket.timeout as e: 460 except socket.timeout as e:
450 raise usb_exceptions.ReadFailedError( 461 raise usb_exceptions.ReadFailedError(
451 'Could not send data (timeout %sms)' % (self.Timeout(timeout_ms)), e) 462 'Could not send data (timeout %sms)' % (self.Timeout(timeout_ms)), e)
452 463
453 def BulkRead(self, length, timeout_ms=None): 464 def BulkRead(self, length, timeout_ms=None):
454 try: 465 try:
455 self._connection.settimeout(self.Timeout(timeout_ms) / 1000.0) 466 self._connection.settimeout(self.Timeout(timeout_ms) / 1000.0)
456 return self._connection.recv(length) 467 return self._connection.recv(length)
457 except socket.timeout as e: 468 except socket.timeout as e:
458 raise usb_exceptions.ReadFailedError( 469 raise usb_exceptions.ReadFailedError(
459 'Could not receive data (timeout %sms)' % ( 470 'Could not receive data (timeout %sms)' % (
460 self.Timeout(timeout_ms)), e) 471 self.Timeout(timeout_ms)), e)
OLDNEW
« no previous file with comments | « no previous file | adb/contrib/adb_commands_safe.py » ('j') | adb/contrib/adb_commands_safe.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698