Exemplo n.º 1
0
def _new_tko_connection():
    global_config = autotest.load('client.common_lib.global_config')
    config = global_config.global_config
    try:
        host = config.get_config_value('AUTOTEST_WEB', 'global_db_host')
        user = config.get_config_value('AUTOTEST_WEB', 'global_db_user')
        password = config.get_config_value('AUTOTEST_WEB', 'global_db_password')
        database = config.get_config_value('AUTOTEST_WEB', 'database')
    except global_config.ConfigError:
        logging.exception('Could not load TKO connection configuration')
        return None
    try:
        if host.startswith('/'):
            return mysql.connector.connect(unix_socket=host, user=user,
                                           password=password, database=database)
        else:
            return mysql.connector.connect(host=host, user=user,
                                           password=password, database=database)
    except mysql.connector.Error:
        logging.exception('Failed to connect to TKO database')
        return None
Exemplo n.º 2
0
 def _get_config(self):
     config = Config()
     self.token = config.get_config_value(ConfigKeys.slack_bot_token)
     self.command_trigger = config.get_prefix() + self._get_command_symbol() + " "
 def _get_config(self):
     config = Config()
     self.token = config.get_config_value(ConfigKeys.slack_bot_token)
Exemplo n.º 4
0
import datetime
import logging
import logging.config

from slack_sdk import WebClient
from slack_sdk.rtm import RTMClient
from slack_sdk.errors import SlackApiError

from config import Config, ConfigKeys
from model.member import Member
from slack_channel import *

live_mode = "live"

config = Config()
token = config.get_config_value(ConfigKeys.slack_bot_token)
debug = Config().get_config_value(ConfigKeys.env_key) != live_mode

logging.config.fileConfig('logging.conf')
logger = logging.getLogger('bottomly')
for handler in logger.handlers:
    if debug:
        handler.setLevel(logging.INFO)
    else:
        handler.setLevel(logging.WARN)

_command_handlers = list([
    GoogleEventHandler(debug),
    UrbanEventHandler(debug),
    WikipediaEventHandler(debug),
    IncrementKarmaEventHandler(debug),
import logging.config
from pathlib import Path

from datagateway_api.common.config import APIConfigOptions, config

LOG_FILE_NAME = Path(config.get_config_value(APIConfigOptions.LOG_LOCATION))
logger_config = {
    "version": 1,
    "formatters": {
        "default": {
            "format":
            "[%(asctime)s] {%(module)s:%(filename)s:%(funcName)s:%(lineno)d}"
            " %(levelname)s - %(message)s",
        },
    },
    "handlers": {
        "default": {
            "level": config.get_config_value(APIConfigOptions.LOG_LEVEL),
            "formatter": "default",
            "class": "logging.handlers.RotatingFileHandler",
            "filename": LOG_FILE_NAME,
            "maxBytes": 5000000,
            "backupCount": 10,
        },
    },
    "root": {
        "level": config.get_config_value(APIConfigOptions.LOG_LEVEL),
        "handlers": ["default"],
    },
}