[clug] MTP and Python - any ideas?

Bob Edwards bob at cs.anu.edu.au
Mon May 2 10:50:08 UTC 2016


On 02/05/16 20:41, Paul Wayper wrote:
> Hi all,
>
> Is anyone familiar with using libmtp to interface with MTP devices?  I'm
> trying to write a program to get some information from my phone, but while the
> kernel's usbfs module seems quiet happy to see the phone's file systems and
> MATE's file manager can browse the device, my simple "get the device name and
> free space" program doesn't get much further than the attempting to connect.
>
> The program is:
>
> #!/usr/bin/python
>
> import pymtp
>
> # Connect to MTP
> mtp = pymtp.MTP()
> mtp.connect()
>
> # Show a bit of data about the connection
> print "Device name:", mtp.get_devicename()
> print "Space:", mtp.get_freespace(), "of", mtp.get_totalspace(), "bytes free"
>
> But I get either:
>
> $ python phontosync.py
> Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
> ignoring libusb_claim_interface() = -6PTP_ERROR_IO: failed to open session,
> trying again after resetting USB interface
> LIBMTP libusb: Attempt to reset device
> inep: usb_get_endpoint_status(): Resource temporarily unavailable
> outep: usb_get_endpoint_status(): Device or resource busy
> ignoring libusb_claim_interface() = -6LIBMTP PANIC: failed to open session on
> second attempt
> Traceback (most recent call last):
>    File "phontosync.py", line 7, in <module>
>      mtp.connect()
>    File "/usr/lib64/python2.7/site-packages/pymtp.py", line 514, in connect
>      raise NoDeviceConnected
> pymtp.NoDeviceConnected
>
> or:
>
> $ python phontosync.py
> Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
> ignoring libusb_claim_interface() = -6PTP_ERROR_IO: failed to open session,
> trying again after resetting USB interface
> LIBMTP libusb: Attempt to reset device
> LIBMTP PANIC: failed to open session on second attempt
> Traceback (most recent call last):
>    File "phontosync.py", line 7, in <module>
>      mtp.connect()
>    File "/usr/lib64/python2.7/site-packages/pymtp.py", line 514, in connect
>      raise NoDeviceConnected
> pymtp.NoDeviceConnected
>
> (Not sure why I get the two different messages.)
>
> Any ideas?

No, but did you try sudo?

Bob Edwards.

>
> Thanks in advance,
>
> Paul
>




More information about the linux mailing list