Merge pull request #16 from Konstantine00/config-dir-fix
Fix issue where config dir was not created by defaultkivy_mainline_and_py3.8
commit
ebae64bfdb
|
@ -1,20 +1,19 @@
|
|||
"""
|
||||
Broker configuration mgmt.
|
||||
"""
|
||||
from os import path
|
||||
from os import path, makedirs
|
||||
import configparser
|
||||
import click
|
||||
from ..log import get_logger
|
||||
|
||||
log = get_logger('broker-config')
|
||||
|
||||
_broker_conf_path = path.join(click.get_app_dir('piker'), 'brokers.ini')
|
||||
_config_dir = click.get_app_dir('piker')
|
||||
_broker_conf_path = path.join(_config_dir, 'brokers.ini')
|
||||
|
||||
|
||||
def load() -> (configparser.ConfigParser, str):
|
||||
"""Load broker config.
|
||||
|
||||
Create a ``broker.ini`` file if one dne.
|
||||
"""
|
||||
config = configparser.ConfigParser()
|
||||
read = config.read(_broker_conf_path)
|
||||
|
@ -24,7 +23,13 @@ def load() -> (configparser.ConfigParser, str):
|
|||
|
||||
def write(config: configparser.ConfigParser) -> None:
|
||||
"""Write broker config to disk.
|
||||
|
||||
Create a ``brokers.ini`` file if one does not exist.
|
||||
"""
|
||||
if not path.isdir(_config_dir):
|
||||
log.debug(f"Creating config dir {_config_dir}")
|
||||
makedirs(_config_dir)
|
||||
|
||||
log.debug(f"Writing config file {_broker_conf_path}")
|
||||
with open(_broker_conf_path, 'w') as cf:
|
||||
return config.write(cf)
|
||||
|
|
Loading…
Reference in New Issue