Python logging.config.Config() Examples

The following are 10 code examples of logging.config.Config(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module logging.config , or try the search function .
Example #1
Source File: __main__.py    From netsuite with MIT License 6 votes vote down vote up
def interact(config, args):
    ns = netsuite.NetSuite(config)

    user_ns = {"ns": ns}

    banner1 = """Welcome to Netsuite WS client interactive mode
Available vars:
    `ns` - NetSuite client

Example usage:
    ws_results = ns.getList('customer', internalIds=[1337])
    restlet_results = ns.restlet.request(987)
    rest_api_results = await ns.rest_api.get("/record/v1/salesOrder")
"""

    IPython.embed(
        user_ns=user_ns,
        banner1=banner1,
        config=traitlets.config.Config(colors="LightBG"),
        # To fix no colored input we pass in `using=False`
        # See: https://github.com/ipython/ipython/issues/11523
        # TODO: Remove once this is fixed upstream
        using=False,
    ) 
Example #2
Source File: __main__.py    From netsuite with MIT License 5 votes vote down vote up
def _load_config_or_error(path: str, section: str) -> config.Config:
    try:
        return config.from_ini(path=path, section=section)
    except FileNotFoundError:
        parser.error(f"Config file {path} not found")
    except KeyError as ex:
        if ex.args == (section,):
            parser.error(f"No config section `{section}` in file {path}")
        else:
            raise ex 
Example #3
Source File: __main__.py    From netsuite with MIT License 5 votes vote down vote up
def _get_rest_api_or_error(config: config.Config):
    ns = netsuite.NetSuite(config)

    try:
        return ns.rest_api  # Cached property that initializes NetSuiteRestApi
    except RuntimeError as ex:
        parser.error(str(ex)) 
Example #4
Source File: app.py    From matrix-registration with MIT License 5 votes vote down vote up
def cli(info, config_path):
    """a token based matrix registration app"""
    config.config = config.Config(config_path)
    logging.config.dictConfig(config.config.logging)
    app = info.load_app()
    with app.app_context():
        app.config.from_mapping(
            SQLALCHEMY_DATABASE_URI=config.config.db.format(cwd=f"{os.getcwd()}/"),
            SQLALCHEMY_TRACK_MODIFICATIONS=False
        )
        db.init_app(app)
        db.create_all()
        tokens.tokens = tokens.Tokens() 
Example #5
Source File: app.py    From sso-dashboard with Mozilla Public License 2.0 5 votes vote down vote up
def dashboard():
    """Primary dashboard the users will interact with."""
    logger.info(
        "User: {} authenticated proceeding to dashboard.".format(
            session.get("id_token")["sub"]
        )
    )

    if "Mozilla-LDAP" in session.get("userinfo")["sub"]:
        logger.info("Mozilla IAM user detected. Attempt enriching with ID-Vault data.")
        try:
            session["idvault_userinfo"] = person_api.get_userinfo(
                session.get("id_token")["sub"]
            )
        except Exception as e:
            logger.error(
                "Could not enrich profile due to: {}.  Perhaps it doesn't exist?".format(
                    e
                )
            )

    # Hotfix to set user id for firefox alert
    # XXXTBD Refactor rules later to support full id_conformant session
    session["userinfo"]["user_id"] = session.get("id_token")["sub"]

    # Transfer any updates in to the app_tiles.
    S3Transfer(config.Config(app).settings).sync_config()

    # Send the user session and browser headers to the alert rules engine.
    Rules(userinfo=session["userinfo"], request=request).run()

    user = User(session, config.Config(app).settings)
    apps = user.apps(Application(app_list.apps_yml).apps)

    return render_template(
        "dashboard.html", config=app.config, user=user, apps=apps, alerts=None
    ) 
Example #6
Source File: app.py    From sso-dashboard with Mozilla Public License 2.0 5 votes vote down vote up
def styleguide_dashboard():
    user = FakeUser(config.Config(app).settings)
    apps = user.apps(Application(app_list.apps_yml).apps)

    return render_template(
        "dashboard.html", config=app.config, user=user, apps=apps, alerts=None
    ) 
Example #7
Source File: app.py    From sso-dashboard with Mozilla Public License 2.0 5 votes vote down vote up
def styleguide_notifications():
    user = FakeUser(config.Config(app).settings)
    return render_template("notifications.html", config=app.config, user=user) 
Example #8
Source File: app.py    From sso-dashboard with Mozilla Public License 2.0 5 votes vote down vote up
def notifications():
    user = User(session, config.Config(app).settings)
    return render_template("notifications.html", config=app.config, user=user) 
Example #9
Source File: app.py    From sso-dashboard with Mozilla Public License 2.0 5 votes vote down vote up
def alert_operation(alert_id):
    if request.method == "POST":
        user = User(session, config.Config(app).settings)
        if request.data is not None:
            data = json.loads(request.data.decode())
            helpfulness = data.get("helpfulness")
            alert_action = data.get("alert_action")

        result = user.take_alert_action(alert_id, alert_action, helpfulness)

        if result["ResponseMetadata"]["HTTPStatusCode"] == 200:
            return "200"
        else:
            return "500" 
Example #10
Source File: hangupsbot.py    From hangoutsbot with GNU Affero General Public License v3.0 4 votes vote down vote up
def __init__(self, cookies_path, config_path, max_retries=5, memory_file=None):
        self.Exceptions = HangupsBotExceptions()

        self.shared = {} # safe place to store references to objects

        self.bridges = {} # WebFramework will register bridges here by uid

        self._client = None
        self._cookies_path = cookies_path
        self._max_retries = max_retries

        # These are populated by on_connect when it's called.
        self._conv_list = None # hangups.ConversationList
        self._user_list = None # hangups.UserList
        self._handlers = None # handlers.py::EventHandler

        self._cache_event_id = {} # workaround for duplicate events

        self._locales = {}

        # Load config file
        try:
            self.config = config.Config(config_path)
        except ValueError:
            logging.exception("failed to load config, malformed json")
            sys.exit()

        # set localisation if anything defined in config.language or ENV[HANGOUTSBOT_LOCALE]
        _language = self.get_config_option('language') or os.environ.get("HANGOUTSBOT_LOCALE")
        if _language:
            self.set_locale(_language)

        # load in previous memory, or create new one
        self.memory = None
        if memory_file:
            _failsafe_backups = int(self.get_config_option('memory-failsafe_backups') or 3)
            _save_delay = int(self.get_config_option('memory-save_delay') or 1)

            logger.info("memory = {}, failsafe = {}, delay = {}".format(
                memory_file, _failsafe_backups, _save_delay))

            self.memory = config.Config(memory_file, failsafe_backups=_failsafe_backups, save_delay=_save_delay)
            if not os.path.isfile(memory_file):
                try:
                    logger.info("creating memory file: {}".format(memory_file))
                    self.memory.force_taint()
                    self.memory.save()

                except (OSError, IOError) as e:
                    logger.exception('FAILED TO CREATE DEFAULT MEMORY FILE')
                    sys.exit()

        # Handle signals on Unix
        # (add_signal_handler is not implemented on Windows)
        try:
            loop = asyncio.get_event_loop()
            for signum in (signal.SIGINT, signal.SIGTERM):
                loop.add_signal_handler(signum, lambda: self.stop())
        except NotImplementedError:
            pass