diff --git a/threshold.py b/threshold.py index 4572740..3951b1d 100755 --- a/threshold.py +++ b/threshold.py @@ -64,19 +64,21 @@ class BaseFactory(Factory): else: return -def getConfig(): - with open("config.json", "r") as f: - config = load(f) - if set(["port", "bind", "usessl"]).issubset(set(config.keys())): - if config["usessl"] == True: - if not set(["cert", "key"]).issubset(set(config.keys())): - error("SSL is on but certificate or key is not defined") - return config - else: - error("Mandatory values missing from config") +class Helper(object): + def getConfig(self): + with open("config.json", "r") as f: + config = load(f) + if set(["port", "bind", "usessl"]).issubset(set(config.keys())): + if config["usessl"] == True: + if not set(["cert", "key"]).issubset(set(config.keys())): + error("SSL is on but certificate or key is not defined") + return config + else: + error("Mandatory values missing from config") if __name__ == "__main__": - config = getConfig() + helper = Helper() + config = helper.getConfig() listener = BaseFactory() if config["usessl"] == True: