Ejemplo n.º 1
0
 def post(self):
     try:
         upload = request.files['logs']
         if upload and self.allowed_file(upload.filename):
             filename = os.path.basename(upload.filename)
             upload.save(os.path.join(db.get('CAM_LOG_FOLDER'), filename))
             log_processor.process(os.path.join(db.get('CAM_LOG_FOLDER'), filename))
             return 201
         else:
             abort(400)
     except exceptions.HTTPException:
         raise
     except Exception as ex:
         logger.exception("An error occurred while attempting to receive logs")
         abort(500)
Ejemplo n.º 2
0
    def process_video(self, event, upload):
        filename = None

        try:
            filename = "%s-%s" % (event,  os.path.basename(upload.filename))
            logger.info("Processing %s event for video %s" % (event, filename))
            recording = os.path.join(db.get('UPLOAD_FOLDER'), filename)
            upload.save(recording)

            if db.get(constants.ENABLE_GDRIVE):
                drive.upload(recording, event, db.get(constants.GDRIVE_FOLDER))
                os.remove(recording)

        except:
            logger.exception("An exception occurred during processing video upload for %s" % filename)

        if event == constants.EVENT_MOTION:
            motion_log.add_motion_event(datetime.datetime.now().isoformat())

        return filename
Ejemplo n.º 3
0
    def process_image(self, event, upload):
        filename = None

        try:
            filename = "%s-%s" % (event,  os.path.basename(upload.filename))
            logger.info("Processing %s event for image %s" % (event, filename))
            capture = os.path.join(db.get('UPLOAD_FOLDER'), filename)
            upload.save(capture)
            shutil.copy(capture, os.path.join(db.get('UPLOAD_FOLDER'),"current.jpg"))

            if db.get(constants.ENABLE_GDRIVE):
                drive.upload(capture, event, db.get(constants.GDRIVE_FOLDER))
                os.remove(capture)
        except:
            logger.exception("An exception occurred during processing image upload for %s" % filename)

        if event == constants.EVENT_MOTION:
            motion_log.add_motion_event(datetime.datetime.now().isoformat())

        return filename
Ejemplo n.º 4
0
 def allowed_file(self,filename):
     return '.' in filename and filename.rsplit('.', 1)[1] in db.get('ALLOWED_EXTENSIONS')