0

I have a python script that copies files from one folder to another on my pi, but is no longer working and i don't know why.

1) I know it is running, because the script sends me an email. 2) I'm not sure if an update to python has happened, but i haven't chained anything on the script and it has been working for weeks.

3) if i manually copy the files on the PI i can see them on another computer via dropbox.

Could it be an auto update, if not how can i find out how to fix it?

Thanks in advance,

Reggie.

#!/usr/bin/env python

import smtplib
import time
import subprocess
import fcntl, sys


################################################### locking section


pid_file = '/run/lock/LOCKFILE-FOR-THIS-SCRIPT.pid'
fh = open(pid_file, 'w')
try:
    fcntl.lockf(fh, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
    # another instance is running
    print 'Error: Another instance is running...'
    sys.exit(0)

################################################## locking section end


from email.mime.text import MIMEText

USERNAME = "myemail"
PASSWORD = "mypw"
MAILTO  = "mailto"

msg = MIMEText('http://whatever.com:1953  http://whatever2.com:1972')
msg['Subject'] = 'from pi motion script'
msg['From'] = USERNAME
msg['To'] = MAILTO

server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo_or_helo_if_needed()
server.starttls()
server.ehlo_or_helo_if_needed()
server.login(USERNAME,PASSWORD)
server.sendmail(USERNAME, MAILTO, msg.as_string())
server.quit()


time.sleep(30)

subprocess.call("mv /mnt/*.jpg  /home/pi/box/pi_pictures", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  • 1
    Try running your subprocess.call command from the shell. Does that work? – nagyben Apr 6 '14 at 18:41
  • Thanks Exantas, I ran the command " mv /mnt/*.jpg /home/pi/box/pi_pictures" from shell, and it came back with "mv: target `/home/pi/box/pi_pictures' is not a directory"; so i added this directory, via shell, to the pi and BINGO! It appears to work now. Don't know how this dir. was lost from my pi, when it is still in the box folder, does anyone know? – reggie Apr 6 '14 at 22:59
  • Why not put this into a nice answer to help others who might find the thread (and get some questions of the "unanswered"-list)? – Ghanima Sep 4 '14 at 8:12
1

I ran the command mv /mnt/*.jpg /home/pi/box/pi_pictures from shell, and it came back with mv: target/home/pi/box/pi_pictures' is not a directory`.

I added this directory, via shell, to the pi, and BINGO!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.