PiZero and python project error

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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 <module>
     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:  

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
     triggerTime = time.time()

     #create base filename at time of motion trigger
     fname = time.strftime("%Y-%d-%d_%H.%M.%S.h264",  

     RAMname = os.path.join("/run/shm", fname)
     NASname = os.path.join("//" , fname)


     #capture video to RAM device first

     #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)

Re: PiZero and python project error

Quoted text here. Click to load it
    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
     snipped-for-privacy@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Re: PiZero and python project error
On 07/11/2018 02:08, Dennis Lee Bieber wrote:
Quoted text here. Click to load it
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  
// /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
//  899G  106G  794G  12% /mnt/CCTV/PiZero

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

Re: PiZero and python project error
On 07/11/2018 09:49, RobH wrote:
Quoted text here. Click to load it

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.


Re: PiZero and python project error
On Thu, 08 Nov 2018 22:08:32 +0000, druck wrote:

Quoted text here. Click to load it

Quoted text here. Click to load it

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.

Re: PiZero and python project error
On Fri, 09 Nov 2018 12:48:54 +0000, Alister wrote:

Quoted text here. Click to load it

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

Site Timeline