From 328ead91682d0f0a9a918032b7de69de801954ec Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Thu, 22 Sep 2022 17:37:10 +0200 Subject: Create servers list if do not exists Otherwise, if the configuration file do not have 'SERVERS' array, ogCP crashes trying to append a new server. --- ogcp/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index cc6c2a3..862cc3e 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1507,7 +1507,11 @@ def save_server(form): with open(filename, 'r+') as file: config = json.load(file) - config['SERVERS'].append(server_dict) + try: + config['SERVERS'].append(server_dict) + except KeyError: + config['SERVERS'] = list() + config['SERVERS'].append(server_dict) file.seek(0) json.dump(config, file, indent='\t') -- cgit v1.2.3-18-g5258