From 84140d2dab8203c01373f228f6e03fff76110f68 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 12 Oct 2013 19:11:45 +0300 Subject: [PATCH] config cache fixes --- src/config.py | 16 ++++++++++------ src/handlers.py | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/config.py b/src/config.py index 3c408d6..8805164 100644 --- a/src/config.py +++ b/src/config.py @@ -282,9 +282,8 @@ def set_camera(camera_id, data): def add_camera(device_details): - global _camera_ids - - _camera_ids = None + global _camera_ids_cache + global _camera_config_cache # determine the last camera id camera_ids = get_camera_ids() @@ -320,13 +319,15 @@ def add_camera(device_details): # write the configuration to file set_camera(camera_id, data) + _camera_ids_cache = None + _camera_config_cache = None + return camera_id, data def rem_camera(camera_id): - global _camera_ids - - _camera_ids = None + global _camera_ids_cache + global _camera_config_cache camera_config_name = _CAMERA_CONFIG_FILE_NAME % {'id': camera_id} camera_config_path = _CAMERA_CONFIG_FILE_PATH % {'id': camera_id} @@ -342,6 +343,9 @@ def rem_camera(camera_id): logging.info('removing camera config file %(path)s...' % {'path': camera_config_path}) + _camera_ids_cache = None + _camera_config_cache = None + try: os.remove(camera_config_path) diff --git a/src/handlers.py b/src/handlers.py index 574125f..9c757f2 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -333,7 +333,6 @@ class ConfigHandler(BaseHandler): def on_response_builder(camera_id, camera_config): def on_response(remote_ui_config): if remote_ui_config is None: - #length[0] -= 1 cameras.append({ 'id': camera_id, 'name': '<error>', -- 2.39.5