Move getConfig to a helper class
This commit is contained in:
parent
1fbcec3931
commit
92b9692304
24
threshold.py
24
threshold.py
|
@ -64,19 +64,21 @@ class BaseFactory(Factory):
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
def getConfig():
|
class Helper(object):
|
||||||
with open("config.json", "r") as f:
|
def getConfig(self):
|
||||||
config = load(f)
|
with open("config.json", "r") as f:
|
||||||
if set(["port", "bind", "usessl"]).issubset(set(config.keys())):
|
config = load(f)
|
||||||
if config["usessl"] == True:
|
if set(["port", "bind", "usessl"]).issubset(set(config.keys())):
|
||||||
if not set(["cert", "key"]).issubset(set(config.keys())):
|
if config["usessl"] == True:
|
||||||
error("SSL is on but certificate or key is not defined")
|
if not set(["cert", "key"]).issubset(set(config.keys())):
|
||||||
return config
|
error("SSL is on but certificate or key is not defined")
|
||||||
else:
|
return config
|
||||||
error("Mandatory values missing from config")
|
else:
|
||||||
|
error("Mandatory values missing from config")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
config = getConfig()
|
helper = Helper()
|
||||||
|
config = helper.getConfig()
|
||||||
|
|
||||||
listener = BaseFactory()
|
listener = BaseFactory()
|
||||||
if config["usessl"] == True:
|
if config["usessl"] == True:
|
||||||
|
|
Loading…
Reference in New Issue