Ejemplo n.º 1
0
 def _test_using_sys_argv(self, mocked__getLogger):
     with patch('sys.argv',
                new=['/foooo/n6foo/bar/actual_name.py', 'a', 'b']):
         returned = get_logger('__main__')
         self._do_asserts(mocked__getLogger,
                          returned,
                          expected_getLogger_arg='n6foo.bar.actual_name')
Ejemplo n.º 2
0
# Copyright (c) 2013-2021 NASK. All rights reserved.
"""
The Filter component, responsible for assigning events to the right
client organizations -- by adding the `client` item (and also
`urls_matched` if needed) to each processed record dict.
"""

from n6datapipeline.base import LegacyQueuedBase
from n6lib.auth_api import AuthAPI
from n6lib.common_helpers import replace_segment
from n6lib.config import ConfigMixin
from n6lib.log_helpers import get_logger, logging_configured
from n6lib.record_dict import RecordDict

LOGGER = get_logger(__name__)


class Filter(ConfigMixin, LegacyQueuedBase):

    input_queue = {
        'exchange':
        'event',
        'exchange_type':
        'topic',
        'queue_name':
        'filter',
        'accepted_event_types': [
            'event',
            'bl-new',
            'bl-update',
            'bl-change',
Ejemplo n.º 3
0
from n6lib.log_helpers import (
    get_logger,
    logging_configured,
)
from n6lib.record_dict import (
    RecordDict,
    BLRecordDict,
)
from n6lib.common_helpers import (
    ascii_str,
    make_exc_ascii_str,
    replace_segment,
)


LOGGER = get_logger(__name__)

DB_WARN_LOGGER_LEGACY_NAME = 'n6.archiver.mysqldb_patch'  # TODO later: change or make configurable
DB_WARN_LOGGER = get_logger(DB_WARN_LOGGER_LEGACY_NAME)


class N6RecorderCursor(MySQLdb.cursors.Cursor):

    # Note: the places where our `__log_warnings_from_database()` method
    # is invoked are analogous to the places where appropriate warnings-
    # -related stuff was invoked by the default cursor (a client-side one)
    # provided by the version 1.3.14 of the *mysqlclient* library -- see:
    # https://github.com/PyMySQL/mysqlclient/blob/1.3.14/MySQLdb/cursors.py
    # -- which was the last version before removing the warnings-related
    # stuff from that library (now we use a newer version, without that
    # stuff).
Ejemplo n.º 4
0
 def test_main__file__leftmost_toplevel_n6_package__abs_path(
         self, mocked__getLogger):
     returned = get_logger('__main__')
     self._do_asserts(mocked__getLogger,
                      returned,
                      expected_getLogger_arg='n6ham.bar.actual_name')
Ejemplo n.º 5
0
 def test_main__file__with_toplevel_n6_package(self, mocked__getLogger):
     returned = get_logger('__main__')
     self._do_asserts(mocked__getLogger,
                      returned,
                      expected_getLogger_arg='n6foo.bar.actual_name')
Ejemplo n.º 6
0
 def test_some_module_name(self, mocked__getLogger):
     returned = get_logger('my_package.my_module')
     self._do_asserts(mocked__getLogger,
                      returned,
                      expected_getLogger_arg='my_package.my_module')
Ejemplo n.º 7
0
 def test_main__file__without_toplevel_n6_package__single_name__abs_path(
         self, mocked__getLogger):
     returned = get_logger('__main__')
     self._do_asserts(mocked__getLogger,
                      returned,
                      expected_getLogger_arg='actual_name')
Ejemplo n.º 8
0
    LimitedDict,
    ascii_str,
    ipv4_to_str,
    provide_surrogateescape,
)
from n6lib.const import (
    CATEGORY_TO_NORMALIZED_NAME,
    NAME_NORMALIZATION,
)
from n6lib.data_spec import (
    N6DataSpec,
    FieldValueTooLongError,
)
from n6lib.log_helpers import get_logger

LOGGER = get_logger(__name__)
NONSTANDARD_NAMES_LOGGER = get_logger('NONSTANDARD_NAMES')

provide_surrogateescape()

#
# Auxiliary constants

COMMON_URL_SCHEME_DEOBFUSCATIONS = {
    'hxxp': 'http',
    'hxxps': 'https',
    'fxp': 'ftp',
}

#
# Exceptions
Ejemplo n.º 9
0
 def _get_logger_obj(self, logger):
     return (get_logger(self.DEFAULT_LOGGER_NAME) if logger is None else
             (get_logger(logger) if isinstance(logger, str) else logger))