Skip to content

Commit

Permalink
Small stability changes and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zpriddy committed Apr 17, 2020
1 parent ba3ba97 commit bd08144
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/glados/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import logging as RootLogging
from logging import Logger
from pkg_resources import get_distribution

__version__ = get_distribution("glados").version

LOGGING_FORMAT = "%(levelname)-8s :: [ %(module)s.%(funcName)s:%(lineno)s ] %(message)s"
LOGGING_LEVEL = "WARNING"
Expand Down
3 changes: 3 additions & 0 deletions src/glados/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict, List, NoReturn, Optional
from pkg_resources import get_distribution

from glados import (
BotImporter,
Expand All @@ -17,6 +18,8 @@


class Glados:
__version__ = get_distribution("glados").version

def __init__(
self,
config_file: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion src/glados/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def interaction(self) -> Optional[DataStoreInteraction]:
"""Returns the interaction for the request"""
if not self.has_interaction():
return None
return self.interaction
return self._interaction

@property
def data(self) -> PyJSON:
Expand Down
8 changes: 6 additions & 2 deletions src/glados/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ def check_for_env_vars(value: Union[str, dict]):
-------
Any:
Returns the value of the var from either the passed in value, or the env var value.
Raises
------
KeyError if the env var is not set for what youre tying to get.
"""
if type(value) is dict and "env_var" in value:
var_name = value["env_var"]
try:
return get_var(var_name)
except KeyError:
logging.critical(f"missing env var: {value['env_var']}")
raise KeyError(f"missing env var: {value['env_var']}")
if type(value) is dict and "enc_env_var" in value:
var_name = value["enc_env_var"]
try:
return get_enc_var(var_name)
except KeyError:
logging.critical(f"missing enc env var: {value['enc_env_var']}")
raise KeyError(f"missing enc env var: {value['enc_env_var']}")
return value


Expand Down
5 changes: 3 additions & 2 deletions tests/test_glados_configs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from tests import GLADOS_CONFIG_FILE, GLADOS_CONFIG_SECTIONS, POSTGRES_HOST
from glados import GladosConfig, check_for_env_vars
from glados import GladosConfig

from os import environ

environ["POSTGRES_HOST"] = POSTGRES_HOST

def test_bad_config_file_path():
gc = GladosConfig("blah.yaml")
Expand All @@ -21,7 +22,7 @@ def test_reading_glados_config():


def test_reading_glados_config_datastore():
environ["POSTGRES_HOST"] = POSTGRES_HOST

gc = GladosConfig(GLADOS_CONFIG_FILE)
gc.read_config()

Expand Down

0 comments on commit bd08144

Please sign in to comment.