-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
38 lines (31 loc) · 1.03 KB
/
config.py
File metadata and controls
38 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# coding: utf-8
from defaults import *
from helpers import *
def validateConfig(cmd):
if(cmd.cloudServerNode < 2):
logError("Cloud server node cannot be less than 2, because 0 is left office router and 1 is right office router")
def setConfig(argv, cmd):
defaults = Defaults()
# For convenience, we add the local variables to the command line argument
# system so that they can be overridden with flags such as
# "--AnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything=42"
for field in dir(defaults):
if field.startswith("__"):
continue
fieldValue = defaults.__getattribute__(field)[0]
fieldDesc = defaults.__getattribute__(field)[1]
cmd.__setattr__(field, fieldValue)
cmd.AddValue(field, fieldDesc)
cmd.Parse(argv)
if(cmd.printConfig):
printConfig(cmd, defaults)
setLogLevel(cmd.logLevel)
validateConfig(cmd)
return cmd
def printConfig(cmd, defaults):
logHeader("Config");
for field in dir(defaults):
if field.startswith("__"):
continue
logData(field, cmd.__getattribute__(field))