Skip to content

Commit

Permalink
Added more logging and bumped version number
Browse files Browse the repository at this point in the history
  • Loading branch information
zpriddy committed Apr 16, 2020
1 parent 6850dae commit bd5c5d1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = glados
version = 0.0.1-dev17
version = 0.0.1-dev18
description = A library to help with slackbot development
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
16 changes: 16 additions & 0 deletions src/glados/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def read_config(self, bot_name: Optional[str] = None) -> NoReturn:

# Config datastore
if "datastore" in self.global_config.sections:
logging.info("setting up glados datastore")
ds_config = self.global_config.config.datastore
ds_enabled = ds_config.get("enabled", False)
ds_host = ds_config.get("host")
Expand Down Expand Up @@ -136,6 +137,21 @@ def read_config(self, bot_name: Optional[str] = None) -> NoReturn:
database=ds_database,
)
self.datastore.create_table(force=ds_recreate)
logging.info("testing datastore connection...")
session = self.datastore.create_session()
if not session.is_active:
logging.warning(
f"datastore session is not active. {session.info}"
)
else:
logging.info(
f"datastore connection is successful. {session.info}"
)
session.close()
else:
logging.info(
"datastore is not enabled. continuing without the datastore."
)
else:
logging.warning("datastore section not found in config file")
self.enable_datastore = False
Expand Down
4 changes: 4 additions & 0 deletions src/glados/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ def create_table(
drop existing tables and rebuild. (default: False)
"""
logging.info("creating datastore table")
if force:
logging.warning(
"DROPPING CURRENT TABLES! the 'force' flag was passed when calling create table."
)
if tables:
for table in tables:
self.drop_table(table)
Expand Down
22 changes: 19 additions & 3 deletions src/glados/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(
bot=None,
**kwargs,
):
"""
"""Plugin Config Object.
Parameters
----------
Expand Down Expand Up @@ -94,7 +94,15 @@ def update(self, config: "PluginConfig", use_base_module: bool = True) -> NoRetu
config.update(self_config)
self.__dict__ = config

def to_dict(self, user_config_only=True):
def to_dict(self, user_config_only=True) -> dict:
"""Return config as dict
Parameters
----------
user_config_only
if True only get get waht is in the config file and not the running config.
"""
config = dict(enabled=self.enabled, bot=self.bot.to_dict())
if not user_config_only:
config["module"] = self.module
Expand All @@ -106,7 +114,15 @@ def to_yaml(self, user_config_only=True):

class PluginImporter:
def __init__(self, plugins_folder: str, plugins_config_folder: str):
"""Create the PluginImporter object."""
"""Create the PluginImporter object.
Parameters
----------
plugins_folder
plugin folder
plugins_config_folder
plugin config folder
"""
self.plugins = dict()
self.plugins_folder = plugins_folder
self.plugins_config_folder = plugins_config_folder
Expand Down

0 comments on commit bd5c5d1

Please sign in to comment.