def main(): """Run Main""" now = datetime.datetime.now() try: cursor = common.get_dbconn().cursor() except: # This is a NOOP at the moment, alerting will come from other # places when the webcams are stale return # Figure out how frequently we are to update cursor.execute(""" SELECT propvalue from properties WHERE propname = 'webcam.interval' """) row = cursor.fetchone() # assumption is either 60 or 300 is set if row[0] == "300" and now.minute % 5 != 0: sys.exit(0) cursor.execute(""" SELECT id from webcams WHERE online = 't' and network in ('KELO','KCCI','KCRG','ISUC', 'KCWI') """) for row in cursor: # async subprocess.call("python getStill4web.py %s &" % (row[0],), shell=True)
def run(network): """ Start a long term lapse for this network """ dbconn = common.get_dbconn() cursor = dbconn.cursor(cursor_factory=psycopg2.extras.DictCursor) cursor.execute(""" SELECT id from webcams where network = %s and online ORDER by id ASC """, (network,)) for row in cursor: pid = subprocess.Popen("python longLapse.py %s 2" % (row[0],), shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE).pid print "%s PID: %s" % (row[0], pid)
""" import time import sys import math import StringIO import os import ephem import datetime from PIL import Image from PIL import ImageDraw import psycopg2.extras import common import logging logging.basicConfig(level=logging.DEBUG) mesosite = common.get_dbconn() cursor = mesosite.cursor(cursor_factory=psycopg2.extras.DictCursor) os.chdir("../tmp") # Which webcam, establish existing lat/lon and pan0 cid = sys.argv[1] camera = common.get_vbcam(cid, loglevel=logging.DEBUG) clat = camera.d['lat'] clon = camera.d['lon'] newpan0 = camera.d['pan0'] + int(sys.argv[2]) if newpan0 < 0: newpan0 += 360. logging.info('Webcam %s initial pan0: %s attempting: %s' % (cid,
"""proctor the exec of daily auto lapse scripts""" import common import datetime import time import subprocess import psycopg2.extras dbconn = common.get_dbconn() cursor = dbconn.cursor(cursor_factory=psycopg2.extras.DictCursor) lookingfor = datetime.datetime.now().strftime("%Y%m%d%H") sql = """ SELECT s.*, s.oid from webcam_scheduler s JOIN webcams c on (s.cid = c.id) WHERE c.online is TRUE and (to_char(begints, 'YYYYMMDDHH24') = '%s' or (to_char(begints, 'HH24') = '%s' and is_daily IS TRUE)) """ % (lookingfor, lookingfor[8:]) cursor.execute(sql) for row in cursor: sts = row['begints'] ets = row['endts'] if ets < sts: ets += datetime.timedelta(days=1) movie_seconds = row['movie_seconds'] secs = (ets - sts).seconds init_delay = sts.minute * 60 # is the amphersand necessary? cmd = ("python do_auto_lapse.py %s %s %s %s %s &" ) % (init_delay,