Skip to content

Commit 3f68e2a

Browse files
authored
Merge pull request #141 from OpenTrafficCam/user-story/1152-as-a-user-i-want-to-automatically-download-the-videos-from-my-otcamera-upon-connecting-my-usb-stick
User story/1152 as a user i want to automatically download the videos from my otcamera upon connecting my usb stick
2 parents 774fbbd + 086947c commit 3f68e2a

File tree

7 files changed

+603
-3
lines changed

7 files changed

+603
-3
lines changed

OTCamera/config.py

+3
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ def read_text_file(text_file: Path) -> str:
341341
"""Path to the HTML to be displayed when OTCamera is offline"""
342342
NUM_LOG_FILES_HTML = 2
343343
"""Number of log files to be displayed on the status website"""
344+
USB_MOUNT_POINT = "~/mnt/usb"
345+
USB_DEVICE = "/dev/sda1"
344346

345347
# Microsoft Teams WebHook
346348
USE_MS_TEAMS_WEBHOOK = False
@@ -351,6 +353,7 @@ def read_text_file(text_file: Path) -> str:
351353
"""The number of max failed HTTP Requests send attempts."""
352354

353355
VIDEO_DIR = str(Path(VIDEO_DIR).expanduser().resolve())
356+
USB_MOUNT_POINT = str(Path(USB_MOUNT_POINT).expanduser().resolve())
354357
PREVIEW_PATH = str(Path(PREVIEW_PATH).expanduser().resolve())
355358
TEMPLATE_HTML_PATH = str(Path(TEMPLATE_HTML_PATH).expanduser().resolve())
356359
INDEX_HTML_PATH = str(Path(INDEX_HTML_PATH).expanduser().resolve())

raspi-files/install_otcamera.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,16 @@ apt install gldriver-test libgl1-mesa-dri -y
5454
sed $CONFIG -i -e "s/^dtoverlay=vc4-fkms-v3d/#dtoverlay=vc4-fkms-v3d/g"
5555
sed $CONFIG -i -e "s/^dtoverlay=vc4-kms-v3d/#dtoverlay=vc4-kms-v3d/g"
5656

57-
echo " Setting power safing variables"
57+
echo " Setting power saving variables"
5858
RCLOCAL="/etc/rc.local"
5959
cp $RCLOCAL $RCLOCAL.backup
6060
sed $RCLOCAL -i -e "/^exit 0/i /usr/bin/tvservice -o"
6161

62+
echo " Setting USB mount access permissions"
63+
FSTAB="/etc/fstab"
64+
cp $FSTAB $FSTAB.backup
65+
echo "/dev/sda1 /home/$SUDO_USER/mnt/usb auto noauto,uid=otc,gid=otc,umask=022 0 0" >> $FSTAB
66+
6267
echo "#### Setting up OTCamera"
6368

6469
echo " Installing packages"

run.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@ def parse_args() -> Path:
3939
config.parse_user_config("~/user_config.yaml")
4040

4141

42+
def usb_device_exists(usb_device: str) -> bool:
43+
"""Whether a usb device at `usb_device` exists."""
44+
45+
return Path(usb_device).exists()
46+
47+
4248
def main():
4349
parse_args()
4450

45-
import OTCamera.record as record
51+
if usb_device_exists(config.USB_DEVICE):
52+
import usb_flash_drive_copy
53+
54+
usb_flash_drive_copy.main(config.VIDEO_DIR, config.USB_MOUNT_POINT)
55+
else:
56+
import OTCamera.record as record
4657

47-
record.main()
58+
record.main()
4859

4960

5061
if __name__ == "__main__":
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ajlsdkfjalksdjfklajsdlkfjklasdjfkl
2+
laksdjflkasdjfklaj
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
alskdjfaklsjef
2+
alskdjfklasjdklf
3+
asldkfjlaksdjf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
filename,copied,delete
2+
otcamera-dev01_FR20_2022-11-03_15-26-27.h264,no,no
3+
otcamera-dev01_FR20_2022-11-10_17-13-22.h264,no,no
4+
otcamera-dev01_FR20_2022-11-10_17-31-16.h264,no,no

0 commit comments

Comments
 (0)