Ejemplo n.º 1
0
 def get(self):
     unseen_count = db_session.query(Video.filename).filter(
         Video.is_archived.__eq__(False)).count()
     return render_template('index.html',
                            unseen_count=unseen_count,
                            notifications_enabled=get_db_setting(
                                'notifications', True))
Ejemplo n.º 2
0
 def get(self):
     filters = [
         MotionEvent.video.has(is_archived=False),
         MotionEvent.video.__ne__(None)
     ]
     dispo = None
     if 'dispo' in request.args:
         dispo = request.args['dispo']
         if dispo == 'none':
             filters.append(MotionEvent.disposition.__eq__(None))
         else:
             filters.append(
                 MotionEvent.disposition.__eq__(
                     EventDispositionEnum[dispo]))
     events = db_session.query(MotionEvent).filter(*filters).order_by(
         asc(MotionEvent.date)).all()
     unseen_count = db_session.query(Video.filename).filter(
         Video.is_archived.__eq__(False)).count()
     cams = cams_dict()
     return_to = '/simple/videos'
     if dispo is not None:
         return_to += '?dispo=%s' % dispo
     return render_template('videos.html',
                            events=events,
                            unseen_count=unseen_count,
                            cameras=cams,
                            cam_names=sorted(settings.CAMERAS.keys()),
                            notifications_enabled=get_db_setting(
                                'notifications', True),
                            dispo_enum=EventDispositionEnum,
                            dispo=dispo,
                            return_to=return_to)
Ejemplo n.º 3
0
def newvideo_ready(self, filename, event_text, notification_id=None):
    """
    Triggered when a new video has been added to the DB and the thumbnail
    has been generated. Entrypoint for notifications and other event handling
    for new videos.
    """
    logger.debug(
        'Running task newvideo_ready() id=%s retries=%d filename=%s '
        'event_text=%s notification_id=%s', self.request.id,
        self.request.retries, filename, event_text, notification_id)
    try:
        from motion_pipeline.database.dbsettings import get_db_setting
        if not get_db_setting('notifications', True):
            logger.info('Notifications disabled; not processing task.')
            return
        from motion_pipeline.celerytasks.notifications import \
            NotificationProcessor
        p = NotificationProcessor(filename,
                                  event_text,
                                  self.request,
                                  notification_id=notification_id,
                                  tasklogger=logger)
        notification_id = p.notification_id
        p.generate_and_send()
    except Exception as ex:
        logger.warning('Caught exception running newvideo_ready(%s, %s): %s',
                       filename,
                       event_text,
                       ex,
                       exc_info=True)
        self.retry((filename, event_text),
                   {'notification_id': notification_id},
                   countdown=2**self.request.retries)
Ejemplo n.º 4
0
 def get(self, video_filename):
     file = db_session.query(Video).get(video_filename)
     cams = cams_dict()
     return_to = request.args.get('return_to', '/simple/videos')
     return render_template('video.html',
                            video=file,
                            cameras=cams,
                            cam_names=sorted(settings.CAMERAS.keys()),
                            notifications_enabled=get_db_setting(
                                'notifications', True),
                            return_to=return_to)
Ejemplo n.º 5
0
 def get(self):
     unseen_counts = {
         x[0]: x[1]
         for x in db_session.query(Video.cam_name, func.count(
             Video.cam_name)).filter(Video.is_archived.__eq__(
                 False)).group_by(Video.cam_name).all()
     }
     cams = cams_dict()
     for camname in cams.keys():
         logger.info('cam %s latest_event: %s', camname,
                     cams[camname]['latest_event'])
     return render_template('live.html',
                            unseen_count=sum(unseen_counts.values()),
                            new_video_counts=unseen_counts,
                            cameras=cams,
                            cam_names=sorted(settings.CAMERAS.keys()),
                            notifications_enabled=get_db_setting(
                                'notifications', True))
Ejemplo n.º 6
0
 def get(self):
     return jsonify({'state': get_db_setting('notifications', True)})