TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: DENNIS LEE BIEBER
date: 2018-06-16 08:59:00
subject: Re: ftp causing invalid s

On Sat, 16 Jun 2018 12:49:30 +0100, RobH  declaimed the
following:


>from os.path import join < I added this
>
 Why? Was typing os.path.join too much effort?

>src = ("RAMname")< and this
>dst = ("NASname")< this

 These lines do nothing useful since you never use the names src and dst
later (except to replace the contents and again not use them)


>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-%m-%d_%H.%M.%S.h264",
>time.localtime(triggerTime))
>
>     RAMname = os.path.join("/run/shm", fname)
>     NASname = os.path.join("/mnt/CCTV/PiZero" , fname)
>
>     camera.start_preview()
>
>     #capture video to RAM device first
>     camera.start_recording(RAMname)

 I suggested trying NASname in that call, to directly capture to the end
device rather than buffering in RAM first and then copying. If that fails,
then the problem is not inherent to the script but is something wrong in
the environment. RAMname (and later the shutil copyfile) was proposed to
let the RPi capture to RAM without the overhead of network traffic (given
that the network interface of an RPi is via the USB system)

>     camera.wait_recording(10)
>     camera.stop_recording()
>     camera.stop_preview()
>
>     #copy from RAM device to NAS device
>     #shutil.copyfile(RAMname, NASname) 
>     src = join('/', RAMname) #new lines here < I added this
>     dst = join('/', NASname) < and this

 Similarly, these do nothing useful since "src" and "dst" are never
referenced in the code... And what they are doing is just trying to add
another / to the front of the names generated earlier. But since / is the
path separator in Linux, and .join() puts the components together by
putting a path separator between them...

-=-=-=-=-
>>> import os.path
>>> import time
>>> fname = time.strftime("%Y-%m-%d_%H.%M.%S.h264", time.localtime())
>>> fname
'2018-06-16_08.45.24.h264'
>>> nname = os.path.join("/mnt/CCTV/PiZero", fname)
>>> nname
'/mnt/CCTV/PiZero/2018-06-16_08.45.24.h264'
>>> dst = os.path.join("/", nname)
>>> dst
'/mnt/CCTV/PiZero/2018-06-16_08.45.24.h264'
>>> dst == nname
True
>>>
-=-=-=-=-

... there is no effect

>
>
>     #delete file from RAM device
>     os.unlink(RAMname)      #os.remove() is same function

 I also asked you to comment that out... Since if the capture is going
to NASname, there is no file in RAMname to be deleted

>
>    #set up next check time
>     time.sleep((triggerTime + 20.0) - time.time())
>

 While picking up that beginners book on Linux, pick up a book on Python
also...


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

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.