Several months ago I posted about ftp problem with a PiZero, and it was eventually solved by using a python script which was posted for me to use. The said script worked well for a short while, until I stopped it running for some reason.
Yesterday I booted up the PiZero, but it failed with some journal error message. I copied the python script to my desktop before I re imaged the sdcard, then copied the script back to the sdcard, insterted it into the Pi and booted up.
After running the python script it failed with: python intruder.py Traceback (most recent call last): File "intruder.py", line 37, in shutil.copyfile(RAMname, NASname) File "/usr/lib/python2.7/shutil.py", line 83, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 2] No such file or directory: '//192.168.0.22/mnt/CCTV/PiZero/2018-06-06_17.26.37.h264'
Line 37 relates to shutil.copyfile(RAMname, NASname)
I don't know about the shutil.py error and where it gets that old file from which obviously doesn't exist
from picamera import PiCamera import time import os import os.path import shutil
from gpiozero import MotionSensor #According to google motionsensor is in gpio$
# Create object for PIR Sensor # PIR Sensor is on GPIO-4 (Pin 7) pir = MotionSensor(4)
# Create Object for Camera camera = PiCamera()
while True: # Wait for motion being detected pir.wait_for_motion() triggerTime = time.time()
#create base filename at time of motion trigger fname = time.strftime("%Y-%d-%d_%H.%M.%S.h264", time.localtime(triggerTime))
RAMname = os.path.join("/run/shm", fname) NASname = os.path.join("//192.168.0.22/mnt/CCTV/PiZero" , fname)
camera.start_preview()
#capture video to RAM device first camera.start_recording(RAMname) camera.wait_recording(10) camera.stop_recording() camera.stop_preview()
#copy from RAM device to NAS device shutil.copyfile(RAMname, NASname)
#delete file from RAM device os.unlink(RAMname) #os.remove() is same function
#set up next check time time.sleep((triggerTime + 30.0)