2

I have written a python code to mount my android physical device with the notebook (ubuntu 14.04).

I referred this http://www.anythingbutipod.com/forum/showthread.php?t=32817

$ sudo apt-get install libmtp mtptools mtpfs
#Once all of that is installed, you will need to create a mountpoint for your device.

$ sudo mkdir /media/MyZen
$ sudo chmod 775 /media/MyZen

#Next, plug in your player and mount it:

$ sudo mtpfs -o allow_other /media/MyZen
#Your player should appear on your desktop as a regular drive. Be aware that, depending on the device, access might be slow.

#IMPORTANT: DO NOT DISCONNECT YOUR DEVICE WITHOUT UNMOUNTING IT FIRST!

$ sudo umount /media/MyZen

This is the code what I have written : specificfolder.py

import os
import pymtp

os.getcwd()
print ('AT FOLDER :')
print os.getcwd()
os.chdir("/media/")
os.getcwd()
print ('AT FOLDER :')
print os.getcwd()
print ('')

#killall gvfs-gphoto2-volume-monitor

#killall gvfs-mtp-volume-monitor

if not os.path.exists("/media/karthik"):
    os.makedirs("/media/karthik")

os.chmod('karthik', 0755)    

oMTP = pymtp.MTP()
oMTP.connect()

os.listdir("/media/karthik/Int*/Maverick")

os.listdir("/media/karthik/Int*/Maverick | wc -l")

When I run the file specificfolder.py, I get this error

karthik@dkarnik2-Vostro-3558:~/appiumworkspace/appium-1.4.13/submodules/sample-code/examples/python$ python specificfolder.py 

AT FOLDER :
/home/karthik/appiumworkspace/appium-1.4.13/submodules/sample-code/examples/python

AT FOLDER :
/media

Traceback (most recent call last):
  File "specificfolder.py", line 20, in <module>
    os.chmod('/media/karthik', 0755)
OSError: [Errno 1] Operation not permitted: '/media/karthik'
karthik@dkarnik2-Vostro-3558:~/appiumworkspace/appium-1.4.13/submodules/sample-code/examples/python$ 

How can I resolve it ?

Karthik
  • 315
  • 1
  • 4
  • 16

0 Answers0