def check_config_updates(*args): logger.info( "Checking for config updates: %s" % args ) try: server_configs = server.get_config() if server_configs is None or server_configs[constants.CONFIG_VERSION] < config.get(constants.CONFIG_VERSION): logger.info("Server config out of date, sending updated cam config") server.send_config() elif server_configs[constants.CONFIG_VERSION] > config.get(constants.CONFIG_VERSION): logger.info("Cam config updating from server") config.update(server_configs) config.set_status(constants.CONFIG_STATUS_UPDATED) server.send_config_status(config.get_status()) #restart capture to load the most recent configs capture.restart() socket.config_updated(config.get_status()) except ValueError: logger.exception("Could not parse response from server") except Exception as ex: logger.exception("Could not update configs from the server")
def patch(self): try: if not request.json["status"]: abort(400) result = config.set_status(request.json["status"]) if result: return {'error': result}, 409 else: return {'status':config.get_status()}, 204 except exceptions.HTTPException: raise except ValueError as ex: logger.exception("Invalid configuration object") abort(400) except Exception as ex: logger.exception("An error occurred while attempting to update config") abort(500)