forked from Te-k/analyst-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisplib.py
More file actions
executable file
·26 lines (24 loc) · 738 Bytes
/
misplib.py
File metadata and controls
executable file
·26 lines (24 loc) · 738 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
#!/usr/bin/env python3
try:
import ConfigParser
except ImportError:
# Python 3
import configparser as ConfigParser
import os
def parse_config():
"""Parse configuration file, returns a list of servers"""
config = ConfigParser.ConfigParser()
config.read(os.path.join(os.path.expanduser("~"), ".misp"))
servers = {}
for s in config.sections():
try:
info = {
'url': config.get(s, 'url'),
'key': config.get(s, 'key')
}
servers[s.lower()] = info
if config.get(s, 'default').lower() == 'true':
servers['default'] = info
except ConfigParser.NoOptionError:
pass
return servers