-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy
More file actions
executable file
·71 lines (56 loc) · 2.38 KB
/
deploy
File metadata and controls
executable file
·71 lines (56 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /usr/bin/env python
''' Deploy script for the PACMAR projects
'''
import logging, sys
from datetime import datetime
from pathlib import Path
from deepi import load_camera
# from deepi import load_config
#from deepi import make_recorder, make_socket_streamer
from deepi import VideoRecorder, SocketStreamer
from deepi import RecorderThread
from deepi import StillCamera
from deepi import DEEPiConfig
# from deepi import SocketStreamingThread
# Config
logpath = Path("/home/pi/log/")
loglevel = logging.INFO
logpath.mkdir(parents=True, exist_ok=True)
log_file = (logpath / datetime.utcnow().strftime('%Y%m%dT%H%M%S')).with_suffix('.txt')
logging.root.handlers = []
logging.basicConfig(format="%(asctime)s [%(levelname)s] %(message)s",
level=loglevel,
handlers=[logging.FileHandler(log_file),
logging.StreamHandler(sys.stdout)
]
)
logging.debug("Reading config file")
config = DEEPiConfig('deepi.conf')
# Make sure other folders exist
for sec in ['STILLCAM', 'RECORDER']:
save_path = Path(config.get(sec, 'outpath'))
logging.debug(f"Ensuring directory exists: {save_path}")
save_path.mkdir(parents=True, exist_ok=True)
# Set up camera
logging.info('Initializing camera')
picam = load_camera(config)
logging.info("Set up recorder thread")
recorder = VideoRecorder(picam,
splitter_port=config.getint('RECORDER','splitter'),
outpath=config.get('RECORDER','outpath'))
recorder_thread = RecorderThread(recorder,
interval=config.getint('RECORDER','split'))
# if config.getboolean('TIMELAPSE',''):
logging.info("Setting up still camera")
camera = StillCamera(picam, splitter_port=config.getint('STILLCAM','splitter'),
outpath=config.get('STILLCAM','outpath'),
fmt=config.get('STILLCAM','format'))
if config.getboolean('RECORDER','autostart'):
logging.info("Starting recording")
recorder_thread.start()
if config.getboolean('TIMELAPSE','autostart'):
logging.info("Starting timelapse")
camera.start_timelapse(interval=config.getint('TIMELAPSE','interval'))
# logging.info("Set up socket streaming thread")
# socket_streaming_thread = SocketStreamingThread(picam, port=8000, splitter_port=2)
logging.info("All set, it should be a never ending loop now.")