diff --git a/adb/adb_commands.py b/adb/adb_commands.py index f3667c8..bdf315b 100644 --- a/adb/adb_commands.py +++ b/adb/adb_commands.py @@ -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") diff --git a/adb/filesync_protocol.py b/adb/filesync_protocol.py index d0547f4..3b36af3 100644 --- a/adb/filesync_protocol.py +++ b/adb/filesync_protocol.py @@ -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)