Ejemplo n.º 1
0
def appFactory():
    logger.debug("creating flask server")
    app = Flask(get_env("SERVICE_NAME"))
    if get_env("ENV") == "development":
        logger.debug("Debug mode is on")

    load_extensions(app)
    app.register_error_handler(Exception, exception_handler)
    return app
Ejemplo n.º 2
0
def startServer():
    server = getServer()
    port = get_env("PORT")
    logger.info("server is listening on port " + port)
    server.run(host="0.0.0.0", port=port, load_dotenv=False, threaded=True)
    logger.error("server shutdown")
    return server
Ejemplo n.º 3
0
def get_logger(logger_name):
    logger = logging.getLogger(logger_name)

    if get_env("ENV") == "production":
        logger.setLevel(logging.INFO)
    else:
        logger.setLevel(logging.DEBUG)

    logger.addHandler(get_console_handler())

    logger.propagate = False
    return logger
Ejemplo n.º 4
0
def bootstrap():
    server = getServer()
    CORS(server)
    db = connect(server, get_env('DATBASE_URI'))
    load_controllers(server)

    db.create_all(app=server)
    server.debug = True

    # def dfdf():
    #     print('hello')
        
    # # with server.app_context():
    # #     cameras = Camera.query.all()
    # # #     for c in cameras:
    # # #         print(c.name)
    # #     alpr.set_cameras(cameras)
    # #     alpr.start()

    startServer()
Ejemplo n.º 5
0
def copy_frame(camera_id, src):
    name = '{}_{}.jpg'.format(camera_id, time.time())
    dst = '{}/{}'.format(get_env('FRAMES_FOLDER'), name)
    shutil.copyfile(src, dst)
    return name
Ejemplo n.º 6
0
        
        # plate.detected_at = result['epoch_time']

        plate.license_number = result['results'][0]['plate']

        
        plate.confidence = result['results'][0]['confidence']
 
        db.session.add(plate)
        db.session.commit()


def dfdf(camera_id, frame_path, result, raw_result):
    print('plate_found_callback', camera_id, frame_path, result, raw_result)

alpr = MASTER_ALPR(get_env('REAL_TIME_FRAMES_FOLDER'), alpr_callback)


def bootstrap():
    server = getServer()
    CORS(server)
    db = connect(server, get_env('DATBASE_URI'))
    load_controllers(server)

    db.create_all(app=server)
    server.debug = True

    # def dfdf():
    #     print('hello')
        
    # # with server.app_context():
def get_frame(frame_name):
    directory = get_env('FRAMES_FOLDER')
    return send_from_directory(directory, frame_name)
def latest_frame(id):
    camera = Camera.query.filter_by(id=id).first_or_404()
    directory = get_env('REAL_TIME_FRAMES_FOLDER')
    frame_name = '{}_0.jpg'.format(camera.id)
    return send_from_directory(directory, frame_name)