@@ -88,20 +88,24 @@ class FastbootProtocol(object):
8888
8989 .. image:: _static/adb.fastboot.FastbootProtocol.__init__.CALLER_GRAPH.svg
9090
91+ Parameters
92+ ----------
93+ usb : adb.common.UsbHandle
94+ :class:`adb.common.UsbHandle` instance.
95+ chunk_kb : int
96+ Packet size. For older devices, 4 may be required.
97+
98+ Attributes
99+ ----------
100+ chunk_kb : int
101+ Packet size. For older devices, 4 may be required.
102+ usb : adb.common.UsbHandle
103+ :class:`adb.common.UsbHandle` instance.
104+
91105 """
92106 FINAL_HEADERS = {b'OKAY' , b'DATA' }
93107
94108 def __init__ (self , usb , chunk_kb = 1024 ):
95- """Constructs a FastbootProtocol instance.
96-
97- Parameters
98- ----------
99- usb : TODO
100- UsbHandle instance.
101- chunk_kb : int
102- Packet size. For older devices, 4 may be required.
103-
104- """
105109 self .usb = usb
106110 self .chunk_kb = chunk_kb
107111
@@ -111,8 +115,8 @@ def usb_handle(self):
111115
112116 Returns
113117 -------
114- self.usb : TODO
115- TODO
118+ self.usb : adb.common.UsbHandle
119+ :class:`adb.common.UsbHandle` instance.
116120
117121 """
118122 return self .usb
@@ -204,9 +208,10 @@ def HandleDataSending(self, source_file, source_len,
204208 accepted_size = binascii .unhexlify (accepted_size [:8 ])
205209 accepted_size , = struct .unpack (b'>I' , accepted_size )
206210 if accepted_size != source_len :
207- raise FastbootTransferError (
208- 'Device refused to download {0} bytes of data (accepts {1} bytes)' . format ( source_len , accepted_size ))
211+ raise FastbootTransferError ('Device refused to download {0} bytes of data (accepts {1} bytes)' . format ( source_len , accepted_size ))
212+
209213 self ._Write (source_file , accepted_size , progress_callback )
214+
210215 return self ._AcceptResponses (b'OKAY' , info_cb , timeout_ms = timeout_ms )
211216
212217 def _AcceptResponses (self , expected_header , info_cb , timeout_ms = None ):
@@ -255,8 +260,7 @@ def _AcceptResponses(self, expected_header, info_cb, timeout_ms=None):
255260 info_cb (FastbootMessage (remaining , header ))
256261 raise FastbootRemoteFailure ('FAIL: {0}' .format (remaining ))
257262 else :
258- raise FastbootInvalidResponse (
259- 'Got unknown header {0} and response {1}' .format (header , remaining ))
263+ raise FastbootInvalidResponse ('Got unknown header {0} and response {1}' .format (header , remaining ))
260264
261265 @staticmethod
262266 def _HandleProgress (total , progress_callback ):
@@ -278,8 +282,7 @@ def _HandleProgress(total, progress_callback):
278282 try :
279283 progress_callback (current , total )
280284 except Exception : # pylint: disable=broad-except
281- _LOG .exception ('Progress callback raised an exception. %s' ,
282- progress_callback )
285+ _LOG .exception ('Progress callback raised an exception. %s' , progress_callback )
283286 continue
284287
285288 def _Write (self , data , length , progress_callback = None ):
@@ -316,23 +319,15 @@ class FastbootCommands(object):
316319
317320 .. image:: _static/adb.fastboot.FastbootCommands.__init__.CALLER_GRAPH.svg
318321
322+ Attributes
323+ ----------
324+ _handle : TODO, None
325+ TODO
326+ _protocol : TODO, None
327+ TODO
328+
319329 """
320330 def __init__ (self ):
321- """Constructs a FastbootCommands instance.
322-
323- Parameters
324- ----------
325- usb : TODO
326- UsbHandle instance.
327-
328- Attributes
329- ----------
330- _handle : TODO, None
331- TODO
332- _protocol : TODO, None
333- TODO
334-
335- """
336331 self ._handle = None
337332 self ._protocol = None
338333
@@ -350,7 +345,7 @@ def usb_handle(self):
350345
351346 Returns
352347 -------
353- self._handle
348+ self._handle : TODO
354349 TODO
355350
356351 """
@@ -376,7 +371,7 @@ def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, ch
376371 Amount of data, in kilobytes, to break fastboot packets up into
377372 **kwargs : dict
378373 Keyword arguments
379- handle : common.TcpHandle, common.UsbHandle
374+ handle : adb. common.TcpHandle, adb. common.UsbHandle
380375 Device handle to use
381376 banner : TODO
382377 Connection banner to pass to the remote device
@@ -482,6 +477,7 @@ def FlashFromFile(self, partition, source_file, source_len=0,
482477 source_file , source_len = source_len , info_cb = info_cb ,
483478 progress_callback = progress_callback )
484479 flash_response = self .Flash (partition , info_cb = info_cb )
480+
485481 return download_response + flash_response
486482
487483 def Download (self , source_file , source_len = 0 ,
@@ -521,8 +517,8 @@ def Download(self, source_file, source_len=0,
521517 source_len = len (data )
522518
523519 self ._protocol .SendCommand (b'download' , b'%08x' % source_len )
524- return self . _protocol . HandleDataSending (
525- source_file , source_len , info_cb , progress_callback = progress_callback )
520+
521+ return self . _protocol . HandleDataSending ( source_file , source_len , info_cb , progress_callback = progress_callback )
526522
527523 def Flash (self , partition , timeout_ms = 0 , info_cb = DEFAULT_MESSAGE_CALLBACK ):
528524 """Flashes the last downloaded file to the given partition.
@@ -538,15 +534,14 @@ def Flash(self, partition, timeout_ms=0, info_cb=DEFAULT_MESSAGE_CALLBACK):
538534 timeout_ms : int
539535 Optional timeout in milliseconds to wait for it to finish.
540536 info_cb : TODO
541- See Download. Usually no messages.
537+ See :meth:`FastbootCommands. Download` . Usually no messages.
542538
543539 Returns
544540 -------
545541 TODO
546542 Response to a download request, normally nothing.
547543 """
548- return self ._SimpleCommand (b'flash' , arg = partition , info_cb = info_cb ,
549- timeout_ms = timeout_ms )
544+ return self ._SimpleCommand (b'flash' , arg = partition , info_cb = info_cb , timeout_ms = timeout_ms )
550545
551546 def Erase (self , partition , timeout_ms = None ):
552547 """Erases the given partition.
@@ -573,12 +568,12 @@ def Getvar(self, var, info_cb=DEFAULT_MESSAGE_CALLBACK):
573568 var : TODO
574569 A variable the bootloader tracks. Use 'all' to get them all.
575570 info_cb : TODO
576- See Download. Usually no messages.
571+ See :meth:`FastbootCommands. Download` . Usually no messages.
577572
578573 Returns
579574 -------
580575 TODO
581- Value of var according to the current bootloader.
576+ Value of `` var`` according to the current bootloader.
582577
583578 """
584579 return self ._SimpleCommand (b'getvar' , arg = var , info_cb = info_cb )
@@ -595,16 +590,16 @@ def Oem(self, command, timeout_ms=None, info_cb=DEFAULT_MESSAGE_CALLBACK):
595590 timeout_ms : TODO, None
596591 Optional timeout in milliseconds to wait for a response.
597592 info_cb : TODO
598- See Download. Messages vary based on command.
593+ See :meth:`FastbootCommands. Download` . Messages vary based on command.
599594
600595 Returns
601596 -------
602597 The final response from the device.
603598 """
604599 if not isinstance (command , bytes ):
605600 command = command .encode ('utf8' )
606- return self . _SimpleCommand (
607- b'oem %s' % command , timeout_ms = timeout_ms , info_cb = info_cb )
601+
602+ return self . _SimpleCommand ( b'oem %s' % command , timeout_ms = timeout_ms , info_cb = info_cb )
608603
609604 def Continue (self ):
610605 """Continues execution past fastboot into the system.
@@ -637,8 +632,7 @@ def Reboot(self, target_mode=b'', timeout_ms=None):
637632 Usually the empty string. Depends on the bootloader and the target_mode.
638633
639634 """
640- return self ._SimpleCommand (
641- b'reboot' , arg = target_mode or None , timeout_ms = timeout_ms )
635+ return self ._SimpleCommand (b'reboot' , arg = target_mode or None , timeout_ms = timeout_ms )
642636
643637 def RebootBootloader (self , timeout_ms = None ):
644638 """Reboots into the bootloader, usually equiv to Reboot('bootloader').
0 commit comments