-
Notifications
You must be signed in to change notification settings - Fork 4
/
pyldnconfig.py
39 lines (30 loc) · 1.16 KB
/
pyldnconfig.py
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
39
#!/usr/bin/env python
# config.py: An object to manage pyldn's config
from configparser import SafeConfigParser
import logging
clog = logging.getLogger(__name__)
class Pyldnconfig(object):
def __init__(self):
'''
Class constructor
'''
CONFIG_INI = 'config.ini'
config = SafeConfigParser()
config.read(CONFIG_INI)
self._base_path = config.get('ldn', 'basePath')
self._inbox_path = config.get('ldn', 'inboxPath')
# self._port = int(config.get('ldn', 'port'))
if not self._base_path:
self._base_path = 'http://localhost'
if not self._inbox_path:
self._inbox_path = '/inbox/'
# if not self._port:
# self._port = 80
# port_str = ":" + str(self._port) if self._port != 80 else ""
# self._inbox_url = self._base_path + port_str + self._inbox_path
self._inbox_url = self._base_path + self._inbox_path
self._ldn_counter = 1
def log_config(self):
clog.info('Current pyldn configuration')
clog.info('Base path: {}'.format(self._base_path))
clog.info('Inbox path: {}'.format(self._inbox_path))