Skip to content

Commit 5b5eb2c

Browse files
committed
fix flake8
1 parent 9f745b4 commit 5b5eb2c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

msc-wis2node-management/msc_wis2node/env.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###############################################################################
22
#
3-
# Copyright (C) 2024 Tom Kralidis
3+
# Copyright (C) 2025 Tom Kralidis
44
#
55
# This program is free software: you can redistribute it and/or modify
66
# it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
3232
TOPIC_PREFIX = os.environ.get('MSC_WIS2NODE_TOPIC_PREFIX', 'origin/a/wis2')
3333
DISCOVERY_METADATA_ZIP_URL = os.environ.get('MSC_WIS2NODE_DISCOVERY_METADATA_ZIP_URL') # noqa
3434
CACHE = os.environ.get('MSC_WIS2NODE_CACHE')
35+
CACHE_EXPIRY_SECONDS = int(os.environ.get('MSC_WIS2NODE_CACHE_EXPIRY_SECONDS', 86400)) # noqa
3536
CENTRE_ID = os.environ.get('MSC_WIS2NODE_CENTRE_ID')
3637
WIS2_GDC = os.environ.get('MSC_WIS2NODE_WIS2_GDC')
3738

msc-wis2node-management/msc_wis2node/publisher.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import json
2424
import logging
2525
import re
26-
import sqlite
2726
from typing import Union
2827
import uuid
2928

@@ -34,8 +33,8 @@
3433
import yaml
3534

3635
from msc_wis2node.env import (BROKER_HOSTNAME, BROKER_PORT, BROKER_USERNAME,
37-
BROKER_PASSWORD, CACHE, CENTRE_ID, DATASET_CONFIG,
38-
TOPIC_PREFIX)
36+
BROKER_PASSWORD, CACHE, CACHE_EXPIRY_SECONDS,
37+
CENTRE_ID, DATASET_CONFIG, TOPIC_PREFIX)
3938
from msc_wis2node.util import get_mqtt_client_id, get_mqtt_tls_settings
4039

4140
LOGGER = logging.getLogger(__name__)
@@ -77,7 +76,7 @@ class WIS2Publisher:
7776
def __init__(self):
7877
"""initialize"""
7978

80-
self.cache = memcache_base.Client(CACHE]
79+
self.cache = memcache_base.Client(CACHE)
8180
self.datasets = []
8281
self.tls = None
8382

@@ -183,12 +182,13 @@ def publish_to_wis2(self, dataset: dict, url: str) -> None:
183182
)
184183

185184
LOGGER.debug('Checking for data update')
186-
if message['properties']['data_id'] in self.cache:
185+
if self.cache.get(message['properties']['data_id']) is not None:
187186
update_link = deepcopy(message['links'][0])
188187
update_link['rel'] = 'update'
189188
message['links'].append(update_link)
190189
else:
191-
self.cache.append(messages['properties']['data_id']
190+
self.cache.set(message['properties']['data_id'],
191+
CACHE_EXPIRY_SECONDS)
192192

193193
cache = dataset.get('cache', True)
194194
if not cache:

0 commit comments

Comments
 (0)