How to use the pyzabbix.logger.NullHandler function in pyzabbix

To help you get started, we’ve selected a few pyzabbix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adubkov / py-zabbix / pyzabbix / sender.py View on Github external
import logging
import socket
import struct
import re

# For python 2 and 3 compatibility
try:
    from StringIO import StringIO
    import ConfigParser as configparser
except ImportError:
    from io import StringIO
    import configparser

from .logger import NullHandler

null_handler = NullHandler()
logger = logging.getLogger(__name__)
logger.addHandler(null_handler)


class ZabbixResponse(object):
    """The :class:`ZabbixResponse` contains the parsed response from Zabbix.
    """
    def __init__(self):
        self._processed = 0
        self._failed = 0
        self._total = 0
        self._time = 0
        self._chunk = 0
        pattern = (r'[Pp]rocessed:? (\d*);? [Ff]ailed:? (\d*);? '
                   r'[Tt]otal:? (\d*);? [Ss]econds spent:? (\d*\.\d*)')
        self._regex = re.compile(pattern)
github adubkov / py-zabbix / pyzabbix / api.py View on Github external
import logging
import os
import ssl
import sys

# For Python 2 and 3 compatibility
try:
    import urllib2
except ImportError:
    # Since Python 3, urllib2.Request and urlopen were moved to
    # the urllib.request.
    import urllib.request as urllib2

from .logger import NullHandler

null_handler = NullHandler()
logger = logging.getLogger(__name__)
logger.addHandler(null_handler)


class ZabbixAPIException(Exception):
    """ZabbixAPI exception class.

    :code list:
    :32602: Invalid params (eg already exists)
    :32500: No permissions
    """
    def __init__(self, *args):
        super(Exception, self).__init__(*args)
        if len(args) == 1 and isinstance(args[0], dict):
            self.error = args[0]
            self.message = self.error['message']