From 868dcc290d1fdedf66860acff8cf3a899d5de096 Mon Sep 17 00:00:00 2001 From: Ross Chadwick Date: Thu, 25 Oct 2018 18:25:06 +0200 Subject: [PATCH] Prompt for new settings if categories are not found/changes --- nordnm/settings.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nordnm/settings.py b/nordnm/settings.py index 71b6174..d4b8384 100644 --- a/nordnm/settings.py +++ b/nordnm/settings.py @@ -5,6 +5,7 @@ import logging import os import ipaddress +import sys class SettingsHandler(object): @@ -103,9 +104,15 @@ def get_categories(self): categories = [] for category in nordapi.VPN_CATEGORIES.keys(): - category_name = category.replace(' ', '-') - if self.settings.getboolean('Categories', category_name): - categories.append(category) + category_name = category.replace(' ', '-').lower() + + try: + if self.settings.getboolean('Categories', category_name): + categories.append(category) + except configparser.NoOptionError: + self.logger.error("VPN category '%s' not found in '%s'. Update settings and try again." % (category_name, self.path)) + self.save_new_settings() + sys.exit(0) return categories