-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
26 lines (22 loc) · 710 Bytes
/
cli.py
File metadata and controls
26 lines (22 loc) · 710 Bytes
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
import ConfigParser
import logging
import sys
def get_logger():
"""Debug mode with param -debug"""
# Using logger instead of print
logger = logging.getLogger()
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.WARNING)
if "-debug" in sys.argv:
logger.setLevel(logging.DEBUG)
return logger
def parse_config():
"""Read config file and loads parameters as variables"""
configParser = ConfigParser.RawConfigParser()
configFilePath = r'./config.cfg'
configParser.read(configFilePath)
cfg = {}
for section in configParser.sections():
for name, value in configParser.items(section):
cfg[name] = value
return cfg