diff options
42 files changed, 173 insertions, 133 deletions
diff --git a/src/camera_node.py b/src/camera_node.py index d175e17..3f2c5a4 100755 --- a/src/camera_node.py +++ b/src/camera_node.py @@ -65,7 +65,7 @@ class ESP32CameraNodeServer(MediaNodeServer): if __name__ == '__main__': - config.load('camera_node') + config.load_app('camera_node') recorder_kwargs = {} camera_type = CameraType(config['camera']['type']) diff --git a/src/esp32cam_capture_diff_node.py b/src/esp32cam_capture_diff_node.py index 4363e9e..70ebd47 100755 --- a/src/esp32cam_capture_diff_node.py +++ b/src/esp32cam_capture_diff_node.py @@ -76,7 +76,7 @@ class ESP32CamCaptureDiffNode: if __name__ == '__main__': - config.load('esp32cam_capture_diff_node') + config.load_app('esp32cam_capture_diff_node') loop = asyncio.get_event_loop() ESP32CamCaptureDiffNode() diff --git a/src/gpiorelayd.py b/src/gpiorelayd.py index 85015a7..f1a9e57 100755 --- a/src/gpiorelayd.py +++ b/src/gpiorelayd.py @@ -13,7 +13,7 @@ if __name__ == '__main__': if not os.getegid() == 0: sys.exit('Must be run as root.') - config.load() + config.load_app() try: s = RelayServer(pinname=config.get('relayd.pin'), diff --git a/src/home/config/__init__.py b/src/home/config/__init__.py index cc9c091..10c5bd9 100644 --- a/src/home/config/__init__.py +++ b/src/home/config/__init__.py @@ -1 +1,11 @@ -from .config import ConfigStore, config, is_development_mode, setup_logging +from .config import ( + Config, + config, + is_development_mode, + setup_logging, + app_config +) +from .validators import validate +from ._configs import ( + LinuxBoardsConfig +)
\ No newline at end of file diff --git a/src/home/config/_configs.py b/src/home/config/_configs.py new file mode 100644 index 0000000..2f98d06 --- /dev/null +++ b/src/home/config/_configs.py @@ -0,0 +1,5 @@ +from .config import ConfigUnit + + +class LinuxBoardsConfig(ConfigUnit): + NAME = 'linux_boards' diff --git a/src/home/config/config.py b/src/home/config/config.py index b79fecb..8ed8483 100644 --- a/src/home/config/config.py +++ b/src/home/config/config.py @@ -3,110 +3,74 @@ import yaml import logging import os +from . import validators from os.path import join, isdir, isfile from typing import Optional, Any, MutableMapping from argparse import ArgumentParser from ..util import parse_addr -import _validators as validators -_validators = {} +my_validators = {} def _get_validator(name: str) -> Optional[callable]: if hasattr(validators, f'{name}_validator'): return getattr(validators, f'{name}_validator') - if name in _validators: - return _validators[name] + if name in my_validators: + return my_validators[name] return None def add_validator(name: str, f: callable): - _validators[name] = f + my_validators[name] = f -def _get_config_path(name: str) -> str: - formats = ['toml', 'yaml'] +class ConfigUnit: + NAME = 'dumb' - dirnames = [ - join(os.environ['HOME'], '.config', 'homekit'), - '/etc/homekit' - ] - - for dirname in dirnames: - if isdir(dirname): - for fmt in formats: - filename = join(dirname, f'{name}.{fmt}') - if isfile(filename): - return filename - - raise IOError(f'config \'{name}\' not found') - - -class SingleConfig: data: MutableMapping[str, Any] - def __init__(self): - self.data = {} + @classmethod + def get_config_path(cls, name=None) -> str: + if name is None: + name = cls.NAME + if name is None: + raise ValueError('get_config_path: name is none') - def load(self, - name: Optional[str] = None, - use_cli=True, - parser: ArgumentParser = None): - self.app_name = name + dirnames = ( + join(os.environ['HOME'], '.config', 'homekit'), + '/etc/homekit' + ) - if (name is None) and (not use_cli): - raise RuntimeError('either config name must be none or use_cli must be True') + for dirname in dirnames: + if isdir(dirname): + for fmt in ('toml', 'yaml'): + filename = join(dirname, f'{name}.{fmt}') + if isfile(filename): + return filename - log_default_fmt = False - log_file = None - log_verbose = False - no_config = name is False + raise IOError(f'config \'{name}\' not found') - path = None - if use_cli: - if parser is None: - parser = ArgumentParser() - if not no_config: - parser.add_argument('-c', '--config', type=str, required=name is None, - help='Path to the config in TOML or YAML format') - parser.add_argument('-V', '--verbose', action='store_true') - parser.add_argument('--log-file', type=str) - parser.add_argument('--log-default-fmt', action='store_true') - args = parser.parse_args() + def __init__(self, name=None): + self.data = {} - if not no_config and args.config: - path = args.config + if self.NAME != 'dumb': + self.load_from(self.get_config_path()) + self.validate() - if args.verbose: - log_verbose = True - if args.log_file: - log_file = args.log_file - if args.log_default_fmt: - log_default_fmt = args.log_default_fmt + elif name is not None: + self.NAME = name - if not no_config and path is None: - path = _get_config_path(name) - - if no_config: - self.data = {} - else: - if path.endswith('.toml'): - self.data = toml.load(path) - elif path.endswith('.yaml'): - with open(path, 'r') as fd: - self.data = yaml.safe_load(fd) - - if 'logging' in self: - if not log_file and 'file' in self['logging']: - log_file = self['logging']['file'] - if log_default_fmt and 'default_fmt' in self['logging']: - log_default_fmt = self['logging']['default_fmt'] + def load_from(self, path: str): + if path.endswith('.toml'): + self.data = toml.load(path) + elif path.endswith('.yaml'): + with open(path, 'r') as fd: + self.data = yaml.safe_load(fd) - setup_logging(log_verbose, log_file, log_default_fmt) - - if use_cli: - return args + def validate(self): + v = _get_validator(self.NAME) + v(self.data) def __getitem__(self, key): return self.data[key] @@ -139,22 +103,75 @@ class SingleConfig: class Config: app_name: Optional[str] + app_config: ConfigUnit def __init__(self): - self.app_name = None + self.app_config = ConfigUnit() + def load_app(self, + name: Optional[str] = None, + use_cli=True, + parser: ArgumentParser = None): + self.app_name = name + + if (name is None) and (not use_cli): + raise RuntimeError('either config name must be none or use_cli must be True') + + log_default_fmt = False + log_file = None + log_verbose = False + no_config = name is False + path = None + if use_cli: + if parser is None: + parser = ArgumentParser() + if not no_config: + parser.add_argument('-c', '--config', type=str, required=name is None, + help='Path to the config in TOML or YAML format') + parser.add_argument('-V', '--verbose', action='store_true') + parser.add_argument('--log-file', type=str) + parser.add_argument('--log-default-fmt', action='store_true') + args = parser.parse_args() + + if not no_config and args.config: + path = args.config + + if args.verbose: + log_verbose = True + if args.log_file: + log_file = args.log_file + if args.log_default_fmt: + log_default_fmt = args.log_default_fmt + + if not no_config and path is None: + path = ConfigUnit.get_config_path(name=name) + + if not no_config: + self.app_config.load_from(path) + + if 'logging' in self.app_config: + if not log_file and 'file' in self.app_config['logging']: + log_file = self.app_config['logging']['file'] + if log_default_fmt and 'default_fmt' in self.app_config['logging']: + log_default_fmt = self.app_config['logging']['default_fmt'] + + setup_logging(log_verbose, log_file, log_default_fmt) + + if use_cli: + return args -config = ConfigStore() +config = Config() +app_config = config.app_config def is_development_mode() -> bool: if 'HK_MODE' in os.environ and os.environ['HK_MODE'] == 'dev': return True - return ('logging' in config) and ('verbose' in config['logging']) and (config['logging']['verbose'] is True) + return ('logging' in config.app_config) and ('verbose' in config.app_config['logging']) and (config.app_config['logging']['verbose'] is True) def setup_logging(verbose=False, log_file=None, default_fmt=False): diff --git a/src/home/config/validators/__init__.py b/src/home/config/validators/__init__.py new file mode 100644 index 0000000..0e75132 --- /dev/null +++ b/src/home/config/validators/__init__.py @@ -0,0 +1,2 @@ +from ._validators import * +from ._util import validate diff --git a/src/home/config/validators/_util.py b/src/home/config/validators/_util.py new file mode 100644 index 0000000..5227c40 --- /dev/null +++ b/src/home/config/validators/_util.py @@ -0,0 +1,11 @@ +import inspect + +from cerberus import Validator, DocumentError + + +def validate(schema, data): + v = Validator(schema) + if not v.validate(data): + frame = inspect.currentframe().f_back + caller_name = frame.f_code.co_name + raise DocumentError(f'{caller_name}: failed to validate data: ' + v.errors) diff --git a/src/home/config/_validators.py b/src/home/config/validators/_validators.py index 963a25f..cddc1b0 100644 --- a/src/home/config/_validators.py +++ b/src/home/config/validators/_validators.py @@ -1,23 +1,9 @@ -import logging -import inspect - -from cerberus import Validator, DocumentError - +from ._util import validate __all__ = [ 'linux_boards_validator' ] -_logger = logging.getLogger(__name__) - - -def validate(schema, data): - v = Validator(schema) - if not v.validate(data): - frame = inspect.currentframe().f_back - caller_name = frame.f_code.co_name - raise DocumentError(f'{caller_name}: failed to validate data: ' + v.errors) - def linux_boards_validator(data) -> None: validate({ diff --git a/src/inverter_bot.py b/src/inverter_bot.py index fd5acf3..194263e 100755 --- a/src/inverter_bot.py +++ b/src/inverter_bot.py @@ -44,7 +44,7 @@ flags_map = { } logger = logging.getLogger(__name__) -config.load('inverter_bot') +config.load_app('inverter_bot') bot.initialize() bot.lang.ru( diff --git a/src/inverter_mqtt_util.py b/src/inverter_mqtt_util.py index fa3bdf5..9db25dc 100755 --- a/src/inverter_mqtt_util.py +++ b/src/inverter_mqtt_util.py @@ -8,7 +8,7 @@ if __name__ == '__main__': parser = ArgumentParser() parser.add_argument('mode', type=str, choices=('sender', 'receiver'), nargs=1) - config.load('inverter_mqtt_util', parser=parser) + config.load_app('inverter_mqtt_util', parser=parser) arg = parser.parse_args() mqtt = MqttWrapper(clean_session=arg.mode[0] != 'receiver') diff --git a/src/ipcam_server.py b/src/ipcam_server.py index 2c4915d..a54cd35 100755 --- a/src/ipcam_server.py +++ b/src/ipcam_server.py @@ -556,7 +556,7 @@ logger = logging.getLogger(__name__) # -------------------- if __name__ == '__main__': - config.load('ipcam_server') + config.load_app('ipcam_server') open_database() diff --git a/src/mqtt_node_util.py b/src/mqtt_node_util.py index 70eae95..e5744b0 100755 --- a/src/mqtt_node_util.py +++ b/src/mqtt_node_util.py @@ -23,7 +23,7 @@ if __name__ == '__main__': parser.add_argument('--node-secret', type=str, help='node admin password') - config.load('mqtt_util', parser=parser) + config.load_app('mqtt_util', parser=parser) arg = parser.parse_args() if (arg.switch_relay is not None or arg.node_secret is not None) and 'relay' not in arg.modules: diff --git a/src/openwrt_log_analyzer.py b/src/openwrt_log_analyzer.py index d31c3bf..35b755f 100755 --- a/src/openwrt_log_analyzer.py +++ b/src/openwrt_log_analyzer.py @@ -54,7 +54,7 @@ def main(mac: str, if __name__ == '__main__': - config.load('openwrt_log_analyzer') + config.load_app('openwrt_log_analyzer') for ap in config['openwrt_log_analyzer']['aps']: state_file = config['simple_state']['file'] state_file = state_file.replace('.txt', f'-{ap}.txt') diff --git a/src/openwrt_logger.py b/src/openwrt_logger.py index 3b19de2..97fe7a9 100755 --- a/src/openwrt_logger.py +++ b/src/openwrt_logger.py @@ -46,7 +46,7 @@ if __name__ == '__main__': parser.add_argument('--access-point', type=int, required=True, help='access point number') - arg = config.load('openwrt_logger', parser=parser) + arg = config.load_app('openwrt_logger', parser=parser) state = SimpleState(file=config['simple_state']['file'].replace('{ap}', str(arg.access_point)), default={'seek': 0, 'size': 0}) diff --git a/src/polaris_kettle_bot.py b/src/polaris_kettle_bot.py index 8438ab3..80baef3 100755 --- a/src/polaris_kettle_bot.py +++ b/src/polaris_kettle_bot.py @@ -41,7 +41,7 @@ from telegram.ext import ( ) logger = logging.getLogger(__name__) -config.load('polaris_kettle_bot') +config.load_app('polaris_kettle_bot') primary_choices = (70, 80, 90, 100) all_choices = range( diff --git a/src/polaris_kettle_util.py b/src/polaris_kettle_util.py index 816cff7..12c4388 100755 --- a/src/polaris_kettle_util.py +++ b/src/polaris_kettle_util.py @@ -75,7 +75,7 @@ def main(): parser.add_argument('-t', '--temperature', dest='temp', type=int, default=tempmax, choices=range(tempmin, tempmax+tempstep, tempstep)) - arg = config.load('polaris_kettle_util', use_cli=True, parser=parser) + arg = config.load_app('polaris_kettle_util', use_cli=True, parser=parser) if arg.mode == 'mqtt': server = MqttServer() diff --git a/src/pump_bot.py b/src/pump_bot.py index 1d56044..172108e 100755 --- a/src/pump_bot.py +++ b/src/pump_bot.py @@ -16,7 +16,7 @@ from home.mqtt.module.temphum import MqttTemphumDataPayload from home.mqtt.module.diagnostics import InitialDiagnosticsPayload, DiagnosticsPayload -config.load('pump_bot') +config.load_app('pump_bot') mqtt: Optional[MqttWrapper] = None mqtt_node: Optional[MqttNode] = None diff --git a/src/pump_mqtt_bot.py b/src/pump_mqtt_bot.py index 6a63caf..1c52b03 100755 --- a/src/pump_mqtt_bot.py +++ b/src/pump_mqtt_bot.py @@ -13,7 +13,7 @@ from home.mqtt.module.relay import MqttRelayState from home.mqtt.module.diagnostics import InitialDiagnosticsPayload, DiagnosticsPayload -config.load('pump_mqtt_bot') +config.load_app('pump_mqtt_bot') bot.initialize() bot.lang.ru( diff --git a/src/relay_mqtt_bot.py b/src/relay_mqtt_bot.py index 8fcf423..e7fa613 100755 --- a/src/relay_mqtt_bot.py +++ b/src/relay_mqtt_bot.py @@ -11,7 +11,7 @@ from home.mqtt.module.relay import MqttRelayModule, MqttRelayState from home.mqtt.module.diagnostics import InitialDiagnosticsPayload, DiagnosticsPayload -config.load('relay_mqtt_bot') +config.load_app('relay_mqtt_bot') bot.initialize() bot.lang.ru( diff --git a/src/relay_mqtt_http_proxy.py b/src/relay_mqtt_http_proxy.py index 05cc88d..50a74a1 100755 --- a/src/relay_mqtt_http_proxy.py +++ b/src/relay_mqtt_http_proxy.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 from home import http from home.config import config -from home.mqtt import MqttPayload, MqttWrapper, MqttNode +from home.mqtt import MqttPayload, MqttWrapper, MqttNode, MqttModule from home.mqtt.module.relay import MqttRelayState, MqttRelayModule from home.mqtt.module.diagnostics import InitialDiagnosticsPayload, DiagnosticsPayload -from typing import Optional +from typing import Optional, Union mqtt: Optional[MqttWrapper] = None mqtt_nodes: dict[str, MqttNode] = {} -relay_modules: dict[str, MqttRelayModule] = {} +relay_modules: dict[str, Union[MqttRelayModule, MqttModule]] = {} relay_states: dict[str, MqttRelayState] = {} @@ -60,7 +60,7 @@ class RelayMqttHttpProxy(http.HTTPServer): if __name__ == '__main__': - config.load('relay_mqtt_http_proxy') + config.load_app('relay_mqtt_http_proxy') mqtt = MqttWrapper() for device_id, data in config['relays'].items(): diff --git a/src/sensors_bot.py b/src/sensors_bot.py index dc081b0..152dd24 100755 --- a/src/sensors_bot.py +++ b/src/sensors_bot.py @@ -23,7 +23,7 @@ from home.api.types import ( TemperatureSensorLocation ) -config.load('sensors_bot') +config.load_app('sensors_bot') bot.initialize() bot.lang.ru( diff --git a/src/sound_bot.py b/src/sound_bot.py index 186337a..a2f8342 100755 --- a/src/sound_bot.py +++ b/src/sound_bot.py @@ -23,7 +23,7 @@ from telegram import ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardBu from PIL import Image -config.load('sound_bot') +config.load_app('sound_bot') nodes = {} for nodename, nodecfg in config['nodes'].items(): diff --git a/src/sound_node.py b/src/sound_node.py index 9d53362..b0b4a67 100755 --- a/src/sound_node.py +++ b/src/sound_node.py @@ -77,7 +77,7 @@ if __name__ == '__main__': if not os.getegid() == 0: raise RuntimeError("Must be run as root.") - config.load('sound_node') + config.load_app('sound_node') storage = SoundRecordStorage(config['node']['storage']) diff --git a/src/sound_sensor_node.py b/src/sound_sensor_node.py index d9a8999..e332174 100755 --- a/src/sound_sensor_node.py +++ b/src/sound_sensor_node.py @@ -14,7 +14,7 @@ if __name__ == '__main__': if not os.getegid() == 0: sys.exit('Must be run as root.') - config.load('sound_sensor_node') + config.load_app('sound_sensor_node') kwargs = {} if 'delay' in config['node']: diff --git a/src/sound_sensor_server.py b/src/sound_sensor_server.py index aa62608..3a68a08 100755 --- a/src/sound_sensor_server.py +++ b/src/sound_sensor_server.py @@ -159,7 +159,7 @@ def api_error_handler(exc, name, req: RequestParams): if __name__ == '__main__': - config.load('sound_sensor_server') + config.load_app('sound_sensor_server') hc = HitCounter() api = WebAPIClient(timeout=(10, 60)) diff --git a/src/ssh_tunnels_config_util.py b/src/ssh_tunnels_config_util.py index 3b2ba6e..03a8219 100755 --- a/src/ssh_tunnels_config_util.py +++ b/src/ssh_tunnels_config_util.py @@ -3,7 +3,7 @@ from home.config import config if __name__ == '__main__': - config.load('ssh_tunnels_config_util') + config.load_app('ssh_tunnels_config_util') network_prefix = config['network'] hostnames = [] diff --git a/src/temphum_mqtt_node.py b/src/temphum_mqtt_node.py index bcd72da..c3d1975 100755 --- a/src/temphum_mqtt_node.py +++ b/src/temphum_mqtt_node.py @@ -63,7 +63,7 @@ async def run_server(host, port): if __name__ == '__main__': - config.load() + config.load_app() if 'measure_delay' in config['sensor']: delay = float(config['sensor']['measure_delay']) diff --git a/src/temphum_mqtt_receiver.py b/src/temphum_mqtt_receiver.py index 970d92e..a4b888e 100755 --- a/src/temphum_mqtt_receiver.py +++ b/src/temphum_mqtt_receiver.py @@ -37,7 +37,7 @@ class MqttServer(Mqtt): if __name__ == '__main__': - config.load('temphum_mqtt_receiver') + config.load_app('temphum_mqtt_receiver') mqtt = MqttWrapper(clean_session=False) node = MqttNode(node_id='+') diff --git a/src/temphumd.py b/src/temphumd.py index bcd72da..c3d1975 100755 --- a/src/temphumd.py +++ b/src/temphumd.py @@ -63,7 +63,7 @@ async def run_server(host, port): if __name__ == '__main__': - config.load() + config.load_app() if 'measure_delay' in config['sensor']: delay = float(config['sensor']['measure_delay']) diff --git a/src/test_new_config.py b/src/test_new_config.py new file mode 100644 index 0000000..110e7a1 --- /dev/null +++ b/src/test_new_config.py @@ -0,0 +1,9 @@ +from home.config import config, app_config, LinuxBoardsConfig +from pprint import pprint + + +if __name__ == '__main__': + config.load_app(name=False) + + lbc = LinuxBoardsConfig() + pprint(lbc.data)
\ No newline at end of file diff --git a/src/web_api.py b/src/web_api.py index 0ddc6bd..0aa994a 100755 --- a/src/web_api.py +++ b/src/web_api.py @@ -231,7 +231,7 @@ if __name__ == '__main__': _app_name = 'web_api' if is_development_mode(): _app_name += '_dev' - config.load(_app_name) + config.load_app(_app_name) loop = asyncio.get_event_loop() diff --git a/test/mqtt_relay_server_util.py b/test/mqtt_relay_server_util.py index e6c5255..35bbf02 100755 --- a/test/mqtt_relay_server_util.py +++ b/test/mqtt_relay_server_util.py @@ -12,7 +12,7 @@ from src.home.mqtt.relay import MQTTRelayClient if __name__ == '__main__': - config.load('test_mqtt_relay_server') + config.load_app('test_mqtt_relay_server') relay = MQTTRelayClient('test') relay.configure_tls() relay.connect_and_loop() diff --git a/test/mqtt_relay_util.py b/test/mqtt_relay_util.py index c1096cc..3634bbe 100755 --- a/test/mqtt_relay_util.py +++ b/test/mqtt_relay_util.py @@ -18,7 +18,7 @@ if __name__ == '__main__': parser.add_argument('--off', action='store_true') parser.add_argument('--stat', action='store_true') - config.load('test_mqtt_relay', parser=parser) + config.load_app('test_mqtt_relay', parser=parser) arg = parser.parse_args() relay = MQTTRelayController('test') diff --git a/test/test_amixer.py b/test/test_amixer.py index c8bd546..464941e 100755 --- a/test/test_amixer.py +++ b/test/test_amixer.py @@ -28,7 +28,7 @@ if __name__ == '__main__': parser.add_argument('--decr', type=str) # parser.add_argument('--dump-config', action='store_true') - args = config.load('test_amixer', parser=parser) + args = config.load_app('test_amixer', parser=parser) # if args.dump_config: # print(config.data) diff --git a/test/test_api.py b/test/test_api.py index 1f6361c..e80eb4c 100755 --- a/test/test_api.py +++ b/test/test_api.py @@ -13,7 +13,7 @@ from src.home.config import config if __name__ == '__main__': - config.load('test_api') + config.load_app('test_api') api = WebAPIClient() print(api.log_bot_request(BotType.ADMIN, 1, "test_api.py")) diff --git a/test/test_esp32_cam.py b/test/test_esp32_cam.py index 27ce379..d743f09 100755 --- a/test/test_esp32_cam.py +++ b/test/test_esp32_cam.py @@ -21,7 +21,7 @@ if __name__ == '__main__': parser.add_argument('--status', action='store_true', help='print status and exit') - arg = config.load(False, parser=parser) + arg = config.load_app(False, parser=parser) cam = esp32.WebClient(addr=parse_addr(arg.addr)) if arg.status: diff --git a/test/test_inverter_monitor.py b/test/test_inverter_monitor.py index 3b1c6b0..621c0e9 100755 --- a/test/test_inverter_monitor.py +++ b/test/test_inverter_monitor.py @@ -372,5 +372,5 @@ def main(): if __name__ == '__main__': - config.load('test_inverter_monitor') + config.load_app('test_inverter_monitor') main() diff --git a/test/test_ipcam_server_cleanup.py b/test/test_ipcam_server_cleanup.py index b7eb23a..5f313a4 100644 --- a/test/test_ipcam_server_cleanup.py +++ b/test/test_ipcam_server_cleanup.py @@ -77,5 +77,5 @@ def cleanup_job(): if __name__ == '__main__': - config.load('ipcam_server') + config.load_app('ipcam_server') cleanup_job() diff --git a/test/test_record_upload.py b/test/test_record_upload.py index cbd3ca2..21e3d68 100755 --- a/test/test_record_upload.py +++ b/test/test_record_upload.py @@ -64,7 +64,7 @@ def api_success_handler(response, name, req: RequestParams): if __name__ == '__main__': - config.load('test_record_upload') + config.load_app('test_record_upload') nodes = {} for name, addr in config['nodes'].items(): diff --git a/test/test_sound_server_api.py b/test/test_sound_server_api.py index e68c6f8..5295a5d 100755 --- a/test/test_sound_server_api.py +++ b/test/test_sound_server_api.py @@ -56,7 +56,7 @@ def hits_sender(): if __name__ == '__main__': - config.load('test_api') + config.load_app('test_api') hc = HitCounter() api = WebAPIClient() diff --git a/test/test_telegram_aio_send_photo.py b/test/test_telegram_aio_send_photo.py index 705e534..4d05c03 100644 --- a/test/test_telegram_aio_send_photo.py +++ b/test/test_telegram_aio_send_photo.py @@ -20,7 +20,7 @@ async def main(): if __name__ == '__main__': - config.load('test_telegram_aio_send_photo') + config.load_app('test_telegram_aio_send_photo') loop = asyncio.get_event_loop() asyncio.ensure_future(main()) |