From 62355023fa995f58ec6f1f10ef2e074e0e7579f1 Mon Sep 17 00:00:00 2001 From: Benjamin Dweck Date: Fri, 16 Oct 2020 11:48:12 +0200 Subject: [PATCH] Variable rename --- test/test_integration.py | 10 +++++----- torch_sub/torch_sub.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test_integration.py b/test/test_integration.py index aaf9bb1..955dd41 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -55,13 +55,13 @@ def publish(client_id, onion_hostname, use_tls=True): class GivenBroker(TestCase): def setUp(self) -> None: - if os.path.exists(torch_sub.database_file): - os.remove(torch_sub.database_file) + if os.path.exists(torch_sub.database_filename): + os.remove(torch_sub.database_filename) def tearDown(self) -> None: os.system("docker container stop mosquitto") - if os.path.exists(torch_sub.database_file): - os.remove(torch_sub.database_file) + if os.path.exists(torch_sub.database_filename): + os.remove(torch_sub.database_filename) @staticmethod def run_broker(tls): @@ -95,7 +95,7 @@ class GivenBroker(TestCase): @staticmethod def loadDatabase(): - with open(torch_sub.database_file, "r") as database_file: + with open(torch_sub.database_filename, "r") as database_file: return json.load(database_file) diff --git a/torch_sub/torch_sub.py b/torch_sub/torch_sub.py index b318d5f..8805061 100644 --- a/torch_sub/torch_sub.py +++ b/torch_sub/torch_sub.py @@ -4,7 +4,7 @@ import threading import paho.mqtt.subscribe as mqtt -database_file = "clients.json" +database_filename = "clients.json" database_lock = threading.Lock() # noinspection PyUnusedLocal @@ -12,11 +12,11 @@ def update_client_record(client, userdata, message): database_lock.acquire() - if not os.path.exists(database_file): - with open(database_file, 'w') as database_blank: + if not os.path.exists(database_filename): + with open(database_filename, 'w') as database_blank: json.dump({}, database_blank) - with open(database_file, 'r') as infile: + with open(database_filename, 'r') as infile: database = json.load(infile) payload = message.payload.decode('utf-8') @@ -24,7 +24,7 @@ def update_client_record(client, userdata, message): database[response['clientId']] = response - with open(database_file, 'w') as outfile: + with open(database_filename, 'w') as outfile: json.dump(database, outfile) database_lock.release()