コード例 #1
0
def setup_logging(config_uri):
    """Include-aware Python logging setup from INI config file.
    """
    path, _ = _getpathsec(config_uri, None)
    parser = IncludeAwareConfigParser()
    parser.read([path])

    if parser.has_section('loggers'):
        config_file = os.path.abspath(path)
        defaults = dict(parser, here=os.path.dirname(config_file))
        return fileConfig(parser, defaults)
コード例 #2
0
ファイル: cmdline.py プロジェクト: LukeSwart/websauna
def setup_logging(config_uri):
    """Include-aware Python logging setup from INI config file.
    """
    path, _ = _getpathsec(config_uri, None)
    parser = IncludeAwareConfigParser()
    parser.read([path])

    if parser.has_section('loggers'):
        config_file = os.path.abspath(path)
        defaults = dict(parser, here=os.path.dirname(config_file))
        return fileConfig(parser, defaults)
コード例 #3
0
ファイル: celeryloader.py プロジェクト: arianmaykon/websauna
    def read_configuration(self) -> dict:
        """Load Celery config from Pyramid INI file.

        We need to be able to do this without ramping up full Websauna, because that's the order of the evens Celery worker wants. This way we avoid circular dependencies during Celery worker start up.
        """
        config = IncludeAwareConfigParser()
        config.read(ini_file)

        # TODO: We have ugly app:main hardcode hack here
        value = config.get("app:main", "websauna.celery_config")
        if not value:
            raise RuntimeError("Could not find websauna.celery_config in {}".format(ini_file))

        config = parse_celery_config(value)
        return config
コード例 #4
0
ファイル: celeryloader.py プロジェクト: lelit/websauna
    def read_configuration(self) -> dict:
        """Load Celery config from Pyramid INI file.

        We need to be able to do this without ramping up full Websauna, because that's the order of the evens Celery worker wants. This way we avoid circular dependencies during Celery worker start up.
        """
        config = IncludeAwareConfigParser()
        config.read(ini_file)

        # TODO: We have ugly app:main hardcode hack here
        value = config.get("app:main", "websauna.celery_config")
        if not value:
            raise RuntimeError("Could not find websauna.celery_config in {}".format(ini_file))

        config = parse_celery_config(value)
        return config
コード例 #5
0
ファイル: conftest.py プロジェクト: gitter-badger/websauna
def browser(request, browser_instance_getter, ini_settings) -> Browser:
    """Websauna specic browser fixtures.

    This is a py.test fixture to create a :term:`pytest-splinter` based browser instance. It is configured with splinter settings from an INI ``[splinter]`` section.

    .. note ::

        These will override any command line options given.

    .. note ::

        This is a temporary mechanism and will be phased out with INI based configuration.

    Example in ``test.ini``::

        [splinter]
        make_screenshot_on_failure = false

    For list of possible settings see this function source code.

    More information

    * https://github.com/pytest-dev/pytest-splinter/blob/master/pytest_splinter/plugin.py
    """

    splinter_command_line_args = [
        "splinter_session_scoped_browser",
        "splinter_browser_load_condition",
        "splinter_browser_load_timeout",
        "splinter_download_file_types",
        "splinter_driver_kwargs",
        "splinter_file_download_dir",
        "splinter_firefox_profile_preferences",
        "splinter_firefox_profile_directory",
        "splinter_make_screenshot_on_failure",
        "splinter_remote_url",
        "splinter_screenshot_dir",
        "splinter_selenium_implicit_wait",
        "splinter_wait_time",
        "splinter_selenium_socket_timeout",
        "splinter_selenium_speed",
        "splinter_webdriver_executable",
        "splinter_window_size",
        "splinter_browser_class",
        "splinter_clean_cookies_urls",
    ]

    # Cache read settings on a function attribute
    full_config = getattr(browser, "full_config", None)
    if not full_config:
        parser = IncludeAwareConfigParser()
        parser.read(ini_settings["_ini_file"])
        full_config = browser.full_config = parser

    # If INI provides any settings override splinter defaults
    for arg in splinter_command_line_args:
        ini_setting_name = arg.replace("splinter_", "")
        # Read setting from splinter section
        arg_value = full_config.get("splinter",
                                    ini_setting_name,
                                    fallback=None)
        if arg_value:
            setattr(request.config.option, arg, arg_value)

    return browser_instance_getter(request, browser)
コード例 #6
0
ファイル: conftest.py プロジェクト: gitter-badger/websauna
def browser(request, browser_instance_getter, ini_settings) -> Browser:
    """Websauna specic browser fixtures.

    This is a py.test fixture to create a :term:`pytest-splinter` based browser instance. It is configured with splinter settings from an INI ``[splinter]`` section.

    .. note ::

        These will override any command line options given.

    .. note ::

        This is a temporary mechanism and will be phased out with INI based configuration.

    Example in ``test.ini``::

        [splinter]
        make_screenshot_on_failure = false

    For list of possible settings see this function source code.

    More information

    * https://github.com/pytest-dev/pytest-splinter/blob/master/pytest_splinter/plugin.py
    """

    splinter_command_line_args = [
        "splinter_session_scoped_browser",
        "splinter_browser_load_condition",
        "splinter_browser_load_timeout",
        "splinter_download_file_types",
        "splinter_driver_kwargs",
        "splinter_file_download_dir",
        "splinter_firefox_profile_preferences",
        "splinter_firefox_profile_directory",
        "splinter_make_screenshot_on_failure",
        "splinter_remote_url",
        "splinter_screenshot_dir",
        "splinter_selenium_implicit_wait",
        "splinter_wait_time",
        "splinter_selenium_socket_timeout",
        "splinter_selenium_speed",
        "splinter_webdriver_executable",
        "splinter_window_size",
        "splinter_browser_class",
        "splinter_clean_cookies_urls",
    ]

    # Cache read settings on a function attribute
    full_config = getattr(browser, "full_config", None)
    if not full_config:
        parser = IncludeAwareConfigParser()
        parser.read(ini_settings["_ini_file"])
        full_config = browser.full_config = parser

    # If INI provides any settings override splinter defaults
    for arg in splinter_command_line_args:
        ini_setting_name = arg.replace("splinter_", "")
        # Read setting from splinter section
        arg_value = full_config.get("splinter", ini_setting_name, fallback=None)
        if arg_value:
            setattr(request.config.option, arg, arg_value)

    return browser_instance_getter(request, browser)