Conditions | 2 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | 1 | import os |
|
10 | 1 | def __init__(self, config_file: str, listener: str): |
|
11 | """Init the Queue from config parameters""" |
||
12 | |||
13 | 1 | base_path = os.path.abspath(os.path.dirname(__file__)) |
|
14 | 1 | config_specs = base_path + '/static/specs.yml' |
|
15 | 1 | config_default = base_path + '/static/default.yml' |
|
16 | |||
17 | 1 | config = ConfigReader().parse(config_file, config_specs, config_default) |
|
18 | 1 | config_listener = config.get('distributer') |
|
19 | |||
20 | 1 | redis = Redis(config_listener['host'], config_listener['port']) |
|
21 | |||
22 | 1 | if listener not in config: |
|
23 | 1 | raise KeyError('You must have a key {} in your config with a sub-key queue'.format(listener)) |
|
24 | |||
25 | 1 | self._logger = Logger('distributer', config_file) |
|
26 | 1 | self._logger.log.debug('Distributer QueueManager called') |
|
27 | 1 | self._logger.log.debug('Connect to queue {}'.format(config[listener]['queue'])) |
|
28 | 1 | self._queue = RedisQueue(config[listener]['queue'], connection=redis) |
|
29 | |||
35 |