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

device.Pull return {TypeError}coercing to Unicode: need string or buffer, file found #113

Open

Description

@evoup

use python2.7
device.Pull(file_name, dest_file)
return {TypeError}coercing to Unicode: need string or buffer, file found

And I must use follow way to get work around:

    file_bytes = device.Pull(file_name)
    output_file = open(dest_file, "wb")
    output_file.write(file_bytes)
    output_file.close()

Activity

  1. fahhem commented on Jun 20, 2018

    @fahhem
    Contributor

    Is this on Windows?

  2. evoup commented on Jun 20, 2018

    @evoup
    Author

    linuxmint

  3. fahhem commented on Jun 20, 2018

    @fahhem
    Contributor

    Try master as of now? Okay, then 'b' also affects the expected type in write() instead of just the way the file is opened on Windows

  4. evoup commented on Jun 20, 2018

    @evoup
    Author

    Sorry, I`ve changed code in /usr/local/lib/python2.7/dist-packages/adb/adb_commands.py 294 line then add a 'b', and regenrate the adb_commands.pyc file, but return same error after run code.

  5. fahhem commented on Jun 20, 2018

    @fahhem
    Contributor

    Hmm, what type is dest_file when you pass it into Pull? Is it the filename (a string) or an open file?

  6. evoup commented on Jun 20, 2018

    @evoup
    Author

    Sorry, it is my fault. May be lost object bug in my code, can pull picture now. And it does not matter with 'b'.Thanks for your help!

  7. fahhem commented on Jun 20, 2018

    @fahhem
    Contributor

    Does it work with 'b' though? I think it's necessary for Windows, so if it works in Linux then I'll leave that change

  8. evoup commented on Jun 20, 2018

    @evoup
    Author

    Yes, both add 'b' or without 'b' , can work in my linux

  9. evoup commented on Jun 20, 2018

    @evoup
    Author

    HI:
    I think I still find the problem after some debuging test, I assign dest_file param with '/tmp/1.png'.
    The reason is calling

    dest_file.close()
    return os.path.exists(dest_file)
    

    which dest_file is type:

    <closed file '/tmp/1.png', mode 'w' at 0x7f0b50528e40>
    <type 'file'>
    

    so if we call os.path.exists(dest_file) , the param dest_file type should be string or buffer, it is file so get the exception

  10. fahhem commented on Jun 20, 2018

    @fahhem
    Contributor

    How about with that commit? 82bfd52

  11. reopened this on Jun 20, 2018
  12. evoup commented on Jun 21, 2018

    @evoup
    Author

    Tested ok, even if remove

    elif isinstance(dest_file, file):
        pass
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions