obexftp python help

Help
2007-02-23
2013-05-01
  • I am writing a little tool to help me pull images and such off my cell phone.  Using obexftp directly works great, but I wanted to use the python bindings instead of parsing obexftp output.  My problem is that when using the bindings, the 'get' command doesn't return the whole file.  It only returns the first 10 bytes.  I checked, and those 10 bytes match the real image file.  Any ideas why it only grabs 10 bytes?  am I doing something wrong?  And let me just restate, using obexftp with --get retrieves the file just fine.

    Thanks
    richard

    My test code...

    #!/usr/bin/python

    import obexftp

    cl = obexftp.client(4)
    cl.connect(BTADDRESS, BTCHANNEL)
    file = open("test.jpg", "wb")
    data = cl.get("/SdPictures/0222071524.jpg")
    file.write(data)
    file.close
    cl.disconnect()

     
    • Can you check if the byte at 10 (or 11) is perhaps zero? Might be a problem with zero-terminated strings, which version of obexftp are you using?

       
    • Christian,

      Your right, the 11 byte is indeed a '00'. What can we do about it?  I am thinking it may be easiest to just create a 'get_file' method that would pair with 'put_file', where you would just specify were to store the file locally instead of trying to pass the data to python.  Thoughts?  I don't think I know the proper way to do this.  How do I generate the python bindings from the client.i swig file?  Never used swig before.

      Thanks

      richard

       
      • No problem there, I can do the SWIG coding. Maybe you can send me your python test/example by mail.

         
    • Ok,  I figured out SWIG, its pretty easy to run.  Here is a code snippet of what I added to make it work for me..  Would you consider adding this to your repos?

      richard

      int get_file(char *path, char *localname) {
          return obexftp_get_type(self, NULL, localname, path);
      }

       
      • Thank you for your suggestion. That is indeed a nice addition to the API.