Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Prompt for new settings if categories are not found/changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed Oct 25, 2018
1 parent 6026383 commit 868dcc2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nordnm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import os
import ipaddress
import sys


class SettingsHandler(object):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 868dcc2

Please sign in to comment.