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

Fix using file instead of io.IOBase #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, file):
elif hasattr(dest_file, 'write'):
pass
else:
raise ValueError("destfile is of unknown type")
Expand Down
2 changes: 1 addition & 1 deletion adb/filesync_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,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, file) 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