On Tue, 15 May 2018 20:35:09 +0100, RobH declaimed the
following:
>I found the said line or information here:
>https://www.newth.net/mars/how-to-set-up-a-raspberry-pi-zero-to-upload-images-
to-a-server-via-ftp/
>
>And I used the 2nd line first, then both lines, and still it returned
>the same error message: invalid syntax.
>
Read the paragraph above those lines "To run an automated process in
Linux you need a shell script"... Shell scripts are run in the command
line, they are NOT Python scripts (you /start/ Python from a command line,
but then /it/ runs the Python script).
You really need to look at a few introductions to Linux, BASH (shell),
and Python, because the impression you are presenting is that of someone
who thinks all of them work at the same level. Especially with the other
post where you were entering
import ftplib
at a shell prompt, when /that/ is a Python statement.
>In answer to the b) the ip address of the NAS server means I actually
>use an ip address to access my NAS server, 192.168.x.x as an example.
>There would not be any added spaces when it is used.
Show us an example of the command you would use to create or open a
file on that NAS... Normally, in Linux, the IP or hostname would appear in
the mount command, or in an fstab entry, and the mounted path would not use
the IP/hostname itself (this allows the IP/hostname to change in the future
while the mount point stays the same, and programs are not affected).
.
>
>When you say: Just create your filename with the full path to the NAS
>mount point/directory you want to use for saving videos.
>
>Do you then mean to use an exact file name to move or upload to the NAS
>mount point.
>This would be impractical I think because each picture has a date in the
>name, ie: 2018-05-07_22.40.54.jpg
And here again you are specifying a still-image JPEG, but your Python
script is making an H264 video... Different type of file, different
extension.
What difference does the file name make? You generated the name, you
can reuse the name in multiple statements.
{Obviously untested -- I don't have a picamera, and I don't have a NAS}
{Save as "CameraExample.py", run by enterings "python CameraExample.py" at
the command line}
{Watch out for line wrap on long comments; and don't mess up the
indentation}
-=-=-=-=-
from picamera import PiCamera
import time
import os
import os.path
import shutil
from gpiozero import MotionSensor #According to Google MotionSensor is in
gpiozero
pir = MotionSensor(4)
camera = PiCamera()
while True:
pir.wait_for_motion()
triggerTime = time.time()
#create base file name 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("/path/to/NAS/mount/point", 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) - time.time())
-=-=-=-=-
Obviously you'll have to replace "/path/to/NAS/mount/point" with the
correct specification for your system. A proper NAS should appear as just
part of the file system -- no use of FTP or other fancy protocols should be
needed to access it.
--
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)
|