Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Restore Python2/3 compatibility of Push+Pull methods
Browse files Browse the repository at this point in the history
  • Loading branch information
martin2250 committed Dec 8, 2018
1 parent 02d88c9 commit 2ead78a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion adb/adb_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callba
dest_file = io.BytesIO()
elif isinstance(dest_file, str):
dest_file = open(dest_file, 'wb')
elif isinstance(dest_file, io.IOBase):
elif hasattr(dest_file, 'write'):
pass
else:
raise ValueError("destfile is of unknown type")
Expand Down
3 changes: 1 addition & 2 deletions adb/filesync_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""

import collections
import io
import os
import stat
import struct
Expand Down Expand Up @@ -140,7 +139,7 @@ def Push(cls, connection, datafile, filename,
cnxn.Send(b'SEND', fileinfo)

if progress_callback:
total_bytes = os.fstat(datafile.fileno()).st_size if isinstance(datafile, io.IOBase) else -1
total_bytes = os.fstat(datafile.fileno()).st_size if hasattr(datafile, 'fileno') else -1
progress = cls._HandleProgress(lambda current: progress_callback(filename, current, total_bytes))
next(progress)

Expand Down

0 comments on commit 2ead78a

Please sign in to comment.