commit 00f193bfbfed1d304c03cec2c44dd177cdb6f8dd
Author: David Sorber <dsorber@prometheus-wired.home>
Date:   Mon Apr 11 18:34:18 2016 -0400

    Adding client-side security cam script.

diff --git a/software/security_cam/client/security_cam.py b/software/security_cam/client/security_cam.py
new file mode 100644
index 0000000..c0ed91a
--- /dev/null
+++ b/software/security_cam/client/security_cam.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python3
+import datetime
+from multiprocessing import Process
+import os
+import subprocess
+import sys
+import time
+
+# Globals
+DELAY_DURATION = 15 # delay between taking pictures in seconds
+IMAGE_PATH = '/mnt/images' # path where images will be stored
+MAX_IMAGES = 4 # maximum number of images to keep
+
+# Security webcam daemon
+
+
+class ImageCapturer(Process):
+    
+    def __init__(self):
+        Process.__init__(self)
+        
+    def run(self):
+        self.running = True
+        
+        while (self.running):
+            date_str = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
+            filename = os.path.join(IMAGE_PATH, 'image_{:s}.jpg'.format(date_str))
+            cmd = 'fswebcam -r 1080x720 --jpeg 85 -S 5  {:s}'.format(filename)
+            subprocess.call(cmd, shell=True)
+            time.sleep(DELAY_DURATION)
+
+def main():
+    print('Image Capture\n')
+    
+    ImageCapturer().start()
+    
+    while True:
+        time.sleep(DELAY_DURATION - 5)
+        dir_contents = os.listdir(IMAGE_PATH)
+        if len(dir_contents) > MAX_IMAGES:
+            to_remove = sorted(dir_contents, reverse=True)[MAX_IMAGES:]
+            for filename in to_remove:
+                full_fname = os.path.join(IMAGE_PATH, filename)
+                os.remove(full_fname)
+
+
+if __name__ == '__main__':
+    sys.exit(main())
