Louigi
Posts: 4
Joined: Wed Jan 15, 2014 11:35 am

Trouble with shutil python

Sat Feb 01, 2014 12:53 am

Hi,

I'm trying to get some python code to copy a video file from one location (on the pi's SD card) to another (a box sync cloud storage folder). I am trying to use the shutil.copy function but am have problems of which I'm not sure of. The internet seems to suggest some byte or unicode issue? Note: line 71 is the below, the file is an executable and I am using sudo before command.

Python code:
shutil.copy("/tmp/motion/Video-_1.avi", "/home/pi/box/Private/MotionVideos")

result from comms over putty:
Traceback (most recent call last):
File "/media/USBHDD1/PiCloud/movie_end.py", line 71, in <module>
shutil.copy("/tmp/motion/Video-_1.avi", "/home/pi/box/Private/MotionVideos")
File "/usr/lib/python2.7/shutil.py", line 120, in copy
copymode(src, dst)
File "/usr/lib/python2.7/shutil.py", line 91, in copymode
os.chmod(dst, mode)
OSError: [Errno 22] Invalid argument: '/home/pi/box/Private/MotionVideos/Video-_1.avi'


Does anyone know what this possibly might be. This is very frustrating!!!

gkreidl
Posts: 6335
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Trouble with shutil python

Sat Feb 01, 2014 9:34 am

This looks like a permission problem. Who's the user owning the files in "/tmp/motion"?

Perhaps
chmod +rw /home/pi/box/Private/MotionVideos
might help.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Louigi
Posts: 4
Joined: Wed Jan 15, 2014 11:35 am

Re: Trouble with shutil python

Tue Feb 04, 2014 8:39 pm

Hi gkreidl,

When I type:
ls -l /tmp/
I get
drwxr-xr-x 2 motion motion 24576 Feb 4 20:25 motion
drwx------ 2 pi pi 4096 Feb 1 10:34 ssh-np8bGhpl234Q

I am logged in as pi. I've tried changing the permission using what you said on /tmp/motion, all the videos in /tmp/motion and /home/pi/box/Private/MotionVideos. Yet I still get the same error. I am also running "sudo python script" etc. Any ideas?

Return to “Troubleshooting”