PiZero and python project error

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)

Reply to
RobH
Loading thread data ...

On Tue, 6 Nov 2018 17:29:47 +0000, RobH declaimed the following:

You re-imaged the SD card... That means all the stuff we went through to get the NFS mount point working has been lost. You need to recreated the fstab entry for the NAS mount point, along with recreating the empty directory on the file system on which the NAS will be mounted.

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
Reply to
Dennis Lee Bieber

Thanks , but I had to re image the sdcard because I didn't know how to fix the error, and I forgot to mention that I re created the the CCTV/Pizero diretories, and mounted them :

sudo mount -t cifs -o username=root,password=*******,uid=pi,gid=pi //192.168.0.22/CCTV/PiZero/ /mnt/CCTV/PiZero

Then checked: df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 7.5G 2.7G 4.8G 37% /media/pi/Sandisk_CF //192.168.0.22/CCTV/PiZero/ 899G 106G 794G 12% /mnt/CCTV/PiZero

I'll look through the old thread to see if I can sort this out. Thanks

Reply to
RobH

Perhaps taking a moment to find out how to solve the problem, would be better than using the nuclear option of re-imaging the card.

You probably just needed add a few characters to /boot/cmdline.txt so the disc is checked and repaired on start up.

---druck

Reply to
druck

Or even put it into a linux PC with an SD card reader & run fsck on all of the partitions.

Has got me out of stook on a number of occasions

it is also worth creating an image file of a mission critical SD card once working so it can be recreated as needed.

--
When some people decide it's time for everyone to make big changes, 
it means that they want you to change first.
Reply to
Alister

Even better: make a backup copy of the SD card immediately before doing an update (you do keep your software up to date, don't you), or at least once a month. And keep a cycle of at least two backups offline: that means that one is always a known good copy.

FWIW, I do weekly backups and system updates on ALL my systems using a cycle of two USB HDDs which are kept in a fire safe.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.