diff --git a/.travis.yml b/.travis.yml index 4b29093..bfa12ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,15 +22,17 @@ before_install: - popd install: - - pip install coveralls + - pip install coveralls pep8 script: - while ! nc -z 127.0.0.1 10051; do sleep 1; done + - pep8 pyzabbix/ + - pep8 tests/*.py - coverage run setup.py test after_success: coveralls notifications: - - email: - - maksim77ster@gmail.com + email: + - maksim77ster@gmail.com \ No newline at end of file diff --git a/pyzabbix/api.py b/pyzabbix/api.py index 2272f35..c3be322 100644 --- a/pyzabbix/api.py +++ b/pyzabbix/api.py @@ -84,6 +84,7 @@ def fn(*args, **kwargs): return fn + def ssl_context_compat(func): def inner(req): # We shoul explicitly disable cert verification to support @@ -111,10 +112,12 @@ def inner(req): return inner + @ssl_context_compat def urlopen(*args, **kwargs): return urllib2.urlopen(*args, **kwargs) + class ZabbixAPI(object): """ZabbixAPI class, implement interface to zabbix api. @@ -213,8 +216,7 @@ def do_request(self, method, params=None): } # apiinfo.version and user.login doesn't require auth token - if (self.auth - and (method not in ('apiinfo.version', 'user.login'))): + if self.auth and (method not in ('apiinfo.version', 'user.login')): request_json['auth'] = self.auth logger.debug( @@ -336,8 +338,8 @@ def get_id(self, item_type, item=None, with_id=False, hostid=None, **args): for obj in response: # Check if object not belong current template if args.get('templateids'): - if (not obj.get('templateid') in ("0", None) - or not len(obj.get('templateids', [])) == 0): + if (not obj.get('templateid') in ("0", None) or + not len(obj.get('templateids', [])) == 0): continue if name: diff --git a/pyzabbix/logger.py b/pyzabbix/logger.py index c954989..11e3a01 100644 --- a/pyzabbix/logger.py +++ b/pyzabbix/logger.py @@ -19,6 +19,7 @@ import logging + class NullHandler(logging.Handler): """Null logger handler. diff --git a/pyzabbix/sender.py b/pyzabbix/sender.py index 28d6aed..cac6d1e 100644 --- a/pyzabbix/sender.py +++ b/pyzabbix/sender.py @@ -48,8 +48,9 @@ def __init__(self): self._total = 0 self._time = 0 self._chunk = 0 - - self._regex = re.compile(r'processed: (\d*); failed: (\d*); total: (\d*); seconds spent: (\d*\.\d*)') + pattern = (r'processed: (\d*); failed: (\d*); total: (\d*); ' + 'seconds spent: (\d*\.\d*)') + self._regex = re.compile(pattern) def __repr__(self): """Represent detailed ZabbixResponse view.""" @@ -286,7 +287,12 @@ def _create_packet(self, request): data_len = struct.pack('