From 07a19bf49a4aff1b4a5d8b530fef8e1ea8f84bf7 Mon Sep 17 00:00:00 2001 From: remittor Date: Fri, 19 Nov 2021 07:41:03 +0300 Subject: [PATCH] Delete initial file config.txt --- config.txt | 3 --- gateway.py | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 config.txt diff --git a/config.txt b/config.txt deleted file mode 100644 index 2ec2995..0000000 --- a/config.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "device_ip_addr": "192.168.1.1" -} \ No newline at end of file diff --git a/gateway.py b/gateway.py index 3e98c0c..b5344c8 100644 --- a/gateway.py +++ b/gateway.py @@ -206,8 +206,11 @@ class Gateway(): def load_config(self): self.config = {} - with open('config.txt', 'r') as file: - self.config = json.load(file) + if os.path.exists('config.txt'): + with open('config.txt', 'r') as file: + self.config = json.load(file) + if not "device_ip_addr" in self.config: + self.config['device_ip_addr'] = "192.168.1.1" self.config['device_ip_addr'] = (self.config['device_ip_addr']).strip() def save_config(self):