import picamera
from picamera import PiCamera
import time
from datetime import datetime
import os.path

camera = PiCamera()
counter = 0

camera.rotation = 180
camera.resolution = (640, 480)

print "\nSecurity Camera Logger v3 | Ben Broce & William Hampton\n\n"
print "Streams video to vids/vidstream.h264 | Captures to pics/[timestamp].jpg"
print "Ctrl-C quits.\n\n"  if stream == "y":
    camera.stop_recording()
  camera.stop_preview()

stream = raw_input("Should I stream video (y/n)? ")
length = float(raw_input("How long should I run (in minutes): "))*60
interval = float(raw_input("How often should I take a picture (in seconds): "))

print "Running..."

camera.annotate_background = picamera.Color('black')

try:
  camera.start_preview()
  if stream == "y":
    camera.start_recording('/var/www/vids/vidstream.h264')
  while (counter <= length):
    timestamp = datetime.now().strftime("%m-%d-%Y_%H:%M:%S")
    camera.annotate_text = timestamp
    path = '/var/www/PiCamServer/pics/' + timestamp + '.jpg'
    camera.capture(path, use_video_port=True)
    time.sleep(interval)
    counter += interval
finally:
  print "Exiting..."
  if stream == "y":
    camera.stop_recording()
  camera.stop_preview()

@@ -363,79 +363,8 @@
 n%5Cn%22
-  if stream == %22y%22:%0A    camera.stop_recording()%0A  camera.stop_preview()
 %0A%0Ast
@@ -642,18 +642,17 @@
 )%0A%0Atry:%0A
-  
+%09
 camera.s
@@ -666,18 +666,17 @@
 eview()%0A
-  
+%09
 if strea
@@ -677,36 +677,34 @@
  stream == %22y%22:%0A
-    
+%09%09
 camera.start_rec
@@ -742,18 +742,17 @@
 .h264')%0A
-  
+%09
 while (c
@@ -770,20 +770,18 @@
 ength):%0A
-    
+%09%09
 timestam
@@ -829,20 +829,18 @@
 %25M:%25S%22)%0A
-    
+%09%09
 camera.a
@@ -864,20 +864,18 @@
 mestamp%0A
-    
+%09%09
 path = '
@@ -923,20 +923,18 @@
  '.jpg'%0A
-    
+%09%09
 camera.c
@@ -967,20 +967,18 @@
 t=True)%0A
-    
+%09%09
 time.sle
@@ -990,20 +990,18 @@
 terval)%0A
-    
+%09%09
 counter 
@@ -1021,18 +1021,17 @@
 inally:%0A
-  
+%09
 print %22E
@@ -1041,18 +1041,17 @@
 ing...%22%0A
-  
+%09
 if strea
@@ -1064,12 +1064,10 @@
 y%22:%0A
-    
+%09%09
 came
@@ -1090,10 +1090,9 @@
 g()%0A
-  
+%09
 came

Fix Up