Esempio n. 1
0
    def __init__(self, name="", markers=None):
        if sys.version_info > (2, 7):
            super(MarkerFilter, self).__init__(name)
        else:
            Filter.__init__(self, name)

        self.markerToMatch = markers
Esempio n. 2
0
    def __init__(self, name):
        """Initialize the ExcludeFilter

        :param name: Name to match for within a:class:`logging.LogRecord`'s
            ``name`` field for filtering.
        :type name: str
        """
        if not name:
            raise ValueError('ExcludeFilter requires a non-empty name')
        Filter.__init__(self, name)
Esempio n. 3
0
    def __init__(self, name):
        """Initialize the ExcludeFilter

        :param name: Name to match for within a :class:`logging.LogRecord`'s
            ``name`` field for filtering.
        :type name: str
        """
        if not name:
            raise ValueError("ExcludeFilter requires a non-empty name")
        Filter.__init__(self, name)
Esempio n. 4
0
    def __init__(self, include_raw=True):
        """RawFilter constructor.

        :param include_raw: if True then keep only RAW level records. If False
            discard RAW level record
        :type include_raw: bool
        """
        Filter.__init__(self)
        if include_raw:
            self.include_raw = 1
        else:
            self.include_raw = 0
Esempio n. 5
0
    def filter(self, record):
        record.sampled = ServiceContext.sampled
        record.trace_id = ServiceContext.trace_id
        record.span_id = ServiceContext.span_id
        record.request_id = ServiceContext.request_id
        record.component = ServiceContext.component_name

        return Filter.filter(self, record)
Esempio n. 6
0
    def filter(self, record):
        if Filter.filter(self, record) == 0:
            return 0

        if self.pattern:
            match = self.pattern.match(record.getMessage()) is not None
            match = not match if self.exclude else match
            return 1 if match else 0

        return 1
Esempio n. 7
0
def fileLogging(fname):
    """
    Remove all StreamHandlers;
    Add a single FileHandler (filename given as arg);
    Add a filter to omit dots.

    """
    def dotfilter(record):
        if record.msg.strip() != '.':
            return True
    logfilter = Filter()
    logfilter.filter = dotfilter

    fhandler = FileHandler(fname, 'w')
    for logger in list(_loggers.values()):
        for handler in logger.handlers:
            logger.removeHandler(handler)
        logger.addHandler(fhandler)
        logger.addFilter(logfilter)
Esempio n. 8
0
def fileLogging(fname):
    """
    Remove all StreamHandlers;
    Add a single FileHandler (filename given as arg);
    Add a filter to omit dots.

    """
    def dotfilter(record):
        if record.msg.strip() != '.':
            return True
    logfilter = Filter()
    logfilter.filter = dotfilter

    fhandler = FileHandler(fname, 'w')
    for logger in _loggers.values():
        for handler in logger.handlers:
            logger.removeHandler(handler)
        logger.addHandler(fhandler)
        logger.addFilter(logfilter)
Esempio n. 9
0
def _config(name: str) -> None:
    global OUTDIR
    OUTDIR = _get_outdir(name)
    os.makedirs(OUTDIR, exist_ok=True)
    getLogger().setLevel(logging.INFO)
    formatter = Formatter('[%(asctime)s] %(levelname)s:%(name)s:%(message)s')
    stderr_handler = getStderrHandler()
    stderr_handler.addFilter(lambda record: record.levelno >= logging.WARNING)
    stdout_handler = getStdoutHandler()
    stdout_handler.addFilter(
        lambda record: (record.levelno < logging.WARNING and not Filter(
            pylabzmqinterface.__name__).filter(record) and not Filter(
                pylabzmqmockclient.__name__).filter(record)))
    file_handler = FileHandler(os.path.join(OUTDIR, 'debug.log'))
    for handler in [stderr_handler, stdout_handler, file_handler]:
        handler.setFormatter(formatter)
        handler.setLevel(logging.INFO)
        getLogger().addHandler(handler)
    captureStderr()
    captureStdout()
Esempio n. 10
0
def main(args):
    logger = getLogger(__name__)
    sh = StreamHandler()
    sh.addFilter(Filter('HealthPlanetDataTool'))
    basicConfig(handlers=[sh])
    if args.verbose:
        getLogger('HealthPlanetDataTool').setLevel(DEBUG)
    else:
        getLogger('HealthPlanetDataTool').setLevel(INFO)

    passwd_client = Password(prompt='Please enter your password: ')
    passwd = passwd_client.launch()

    client = HealthPlanetExport(client_id=args.client_id,
                                client_secret=args.client_secret,
                                login_id=args.login_id,
                                login_pass=passwd)
    client.get_auth()
    client.get_token()
    client.get_data(args.from_date, args.to_date)
    client.save(args.out_file)
Esempio n. 11
0
    handler.setLevel(STREAM_LEVEL)
    logger.addHandler(handler)
# file
if FILE_LEVEL != 'NONE':
    if not os.path.exists(LOG_PATH):
        os.makedirs(LOG_PATH)
    # all
    handler = logging.handlers.TimedRotatingFileHandler(os.path.join(LOG_PATH, 'all.log'), when='MIDNIGHT', backupCount=config.getint('LogFileRotateCount'))
    handler.setFormatter(logging.Formatter(fmt=FORMAT, datefmt=DATE_FORMAT))
    handler.setLevel(FILE_LEVEL)
    logger.addHandler(handler)
    # only app module
    handler = logging.handlers.TimedRotatingFileHandler(os.path.join(LOG_PATH, 'cogs.log'), when='MIDNIGHT', backupCount=config.getint('LogFileRotateCount'))
    handler.setFormatter(logging.Formatter(fmt=FORMAT, datefmt=DATE_FORMAT))
    handler.setLevel(FILE_LEVEL)
    handler.addFilter(Filter('Cogs'))
    logger.addHandler(handler)
logger.setLevel(ROOT_LEVEL)

class DCbot(commands.Bot):
    def __init__(self, command_prefix):
        super().__init__(command_prefix)
        self.load_extension('ConfigCog')
        self.get_cog('Config').config = config_parser
        self.load_extension('Cogs.Kujira')
        self.load_extension('Cogs.VCinout')
        self.load_extension('Cogs.Note')
        self.load_extension('Cogs.Prenotice')

    async def on_ready(self):
        # print('Logged on as {{0}} (ID: {{0.id}})'.format(self.user))
Esempio n. 12
0
 def __init__(self):
     Filter.__init__(self)
     self.thread_names = []
Esempio n. 13
0
	def __init__(self, thread = None, name = ''):
		Filter.__init__(self, name = name)
		self.thread = thread or current_thread()
Esempio n. 14
0
 def __init__(self, level):
     Filter.__init__(self)
     self.level = level
 def __init__(self, thread=None, name=''):
     Filter.__init__(self, name=name)
     self.thread = thread or current_thread()
Esempio n. 16
0
 def __init__(self, low, high=None):
     Filter.__init__(self)
     self._low = low
     self._high = high if high else 100
Esempio n. 17
0
 def __init__(self, level):
     Filter.__init__(self)
     self.level = level
Esempio n. 18
0
 def __init__(self, name=''):
     Filter.__init__(self, name=name)
Esempio n. 19
0
 def __init__(self, name='', pattern=None, exclude=False):
     Filter.__init__(self, name=name)
     self.pattern = re.compile(pattern) if pattern else None
     self.exclude = exclude
Esempio n. 20
0
class Filter:

    def __init__(self):
        self.blocked = []

    def filter(self, sequence):
        return [x for x in sequence if x not in self.blocked]


class SPAM_Filter(Filter):
    def __init__(self):
        self.blocked = ['SPAM']


f = Filter()
print f.filter([1, 2, 3])

s = SPAM_Filter()
s_list = ['SPAM', 'SPAM', 'ONE', 'spam']
print 'Origin list:', s_list
print 'List after filtering with SPAM:', s.filter(s_list)


# issubclass()
if issubclass(SPAM_Filter, Filter):
    print 'SPAM_Filter is a subclass of Filter.'
else:
    print 'SPAM_Filter is NOT a subclass of Filter.'

# __bases__
Esempio n. 21
0
 def __init__(self, name=''):
     Filter.__init__(self, name=name)
Esempio n. 22
0
 def __init__(self, *whitelist):
     super(Filter, self).__init__()
     self.whitelist = [Filter(name) for name in whitelist]
Esempio n. 23
0
 def __init__(self,name,cfg):
     Filter.__init__(self)
     self.name = name
     self.cfg = cfg
    def __init__(self, name=""):

        Filter.__init__(self, name)
Esempio n. 25
0
 def __init__(self, *patterns):
     Filter.__init__(self, patterns)
     self.patterns = patterns
Esempio n. 26
0
 def __init__(self, *patterns):
   Filter.__init__(self, patterns)
   self.patterns = patterns