JeffLIrion / adb_shell

A Python implementation of ADB with shell and FileSync functionality.
Apache License 2.0
530 stars 60 forks source link

Add support for pulling directories #211

Open wimmatthijs opened 1 year ago

wimmatthijs commented 1 year ago

Description

Was trying to automate a command where i pull a complete directory from the device. Just like adb pull /sdcard/someDirectory

Log

Traceback (most recent call last):
  File "C:\Artland_script\Artland_logscript.py", line 52, in <module>
    device.pull("/sdcard/someDirectory",os.getcwd()+"\someDirectory")
  File "C:\Users\Wim.Matthijs\AppData\Local\Programs\Python\Python310\lib\site-packages\adb_shell\adb_device.py", line 944, in pull
    self._pull(device_path, stream, progress_callback, adb_info, filesync_info)
  File "C:\Users\Wim.Matthijs\AppData\Local\Programs\Python\Python310\lib\site-packages\adb_shell\adb_device.py", line 969, in _pull
    for cmd_id, _, data in self._filesync_read_until([constants.DATA], [constants.DONE], adb_info, filesync_info):
  File "C:\Users\Wim.Matthijs\AppData\Local\Programs\Python\Python310\lib\site-packages\adb_shell\adb_device.py", line 1433, in _filesync_read_until
    cmd_id, header, data = self._filesync_read(expected_ids + finish_ids, adb_info, filesync_info)
  File "C:\Users\Wim.Matthijs\AppData\Local\Programs\Python\Python310\lib\site-packages\adb_shell\adb_device.py", line 1372, in _filesync_read
    raise exceptions.AdbCommandFailureException('Command failed: {}'.format(reason))
adb_shell.exceptions.AdbCommandFailureException: Command failed: read failed: Is a directory
JeffLIrion commented 1 year ago

It should be possible to accomplish this by using shell with ls to see the directory's contents and then pulling the files individually. If someone would like to submit this functionality in a pull request, that would be welcome.

wimmatthijs commented 1 year ago

Yeah that's what I did in my script, Subfolders should be handled recursively. I just figured it would make sense that the pull command works the same way as in ADB.

On Sat, Jan 14, 2023, 5:51 PM Jeff Irion @.***> wrote:

It should be possible to accomplish this by using shell with ls to see the directory's contents and then pulling the files individually. If someone would like to submit this functionality in a pull request, that would be welcome.

— Reply to this email directly, view it on GitHub https://github.com/JeffLIrion/adb_shell/issues/211#issuecomment-1382852973, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKIAQ4U2H6RBL2DSY4WSIUDWSLKRLANCNFSM6AAAAAATZBDD7A . You are receiving this because you authored the thread.Message ID: @.***>