Skip to content

Commit 3bf3d81

Browse files
committed
Merge branch 'develop'
2 parents 76d7b07 + 75c8033 commit 3bf3d81

File tree

8 files changed

+31
-16
lines changed

8 files changed

+31
-16
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.3
2+
current_version = 0.3.4
33
commit = False
44
tag = False
55
files = setup.py netuitive/__init__.py

.python-version

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2.6.9
2-
2.7.11
3-
3.2.6
4-
3.3.6
5-
3.4.3
6-
3.5.1
1+
2.7.15
2+
3.4.9
3+
3.5.6
4+
3.6.7
5+
3.7.1

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ sudo: false
33

44
language: python
55
python:
6-
- "2.6"
76
- "2.7"
8-
- "3.3"
97
- "3.4"
108
- "3.5"
11-
9+
- "3.6"
10+
matrix:
11+
include:
12+
- python: 3.7
13+
dist: xenial
14+
sudo: true
1215

1316
cache:
1417
directories:

netuitive/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
__author__ = 'Netuitive, Inc'
4-
__version__ = '0.3.3'
4+
__version__ = '0.3.4'
55

66
from .client import Client # nopep8 # flake8: noqa
77
from .element import Element # nopep8 # flake8: noqa

netuitive/client.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self, url='https://api.app.netuitive.com/ingest',
5151
self.post_error_count = 0
5252
self.max_post_errors = 10
5353
self.connection_timeout = connection_timeout
54+
self.max_check_retry_count = 3
5455

5556
def post(self, element):
5657
"""
@@ -170,11 +171,11 @@ def post_check(self, check):
170171
+ check.name + '/' \
171172
+ check.elementId + '/' \
172173
+ str(check.ttl)
174+
headers = {'User-Agent': self.agent}
173175
try:
174-
headers = {'User-Agent': self.agent}
175176
request = urllib2.Request(
176177
url, data='', headers=headers)
177-
resp = urllib2.urlopen(request, timeout=self.connection_timeout)
178+
resp = self._repeat_request(request, self.connection_timeout)
178179
logging.debug("Response code: %d", resp.getcode())
179180
resp.close()
180181

@@ -219,3 +220,15 @@ def time_insync(self):
219220

220221
else:
221222
return(False)
223+
224+
def _repeat_request(self, request, timeout):
225+
for i in range(self.max_check_retry_count + 1):
226+
try:
227+
return urllib2.urlopen(request, timeout=timeout)
228+
except urllib2.HTTPError as e:
229+
if 500 <= e.code < 600 and i < self.max_check_retry_count:
230+
logging.debug("Response code: %d, retry count: %d from %d",
231+
e.code, i + 1, self.max_check_retry_count)
232+
time.sleep(0.25 * (i + 1))
233+
else:
234+
raise

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
setup(
2626
name='netuitive',
27-
version='0.3.3',
27+
version='0.3.4',
2828
description="Python Client for Netuitive Cloud",
2929
long_description=readme + '\n\n' + history,
3030
author="Netuitive",

tests/test_netuitive_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def test_failure_general_http(self, mock_logging, mock_post):
441441
resp = a.post_check(e)
442442

443443
self.assertNotEqual(resp, True)
444-
444+
self.assertEquals(mock_post.call_count, a.max_check_retry_count + 1)
445445
self.assertEqual(mock_logging.exception.call_args_list[0][0][0], 'HTTPError posting payload to api ingest endpoint (%s): %s')
446446

447447
@mock.patch('netuitive.client.urllib2.urlopen')

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py26, py27, py33, py34, py35
2+
envlist = py27, py34, py35, py36, py37
33
tox_pyenv_fallback = False
44

55
[testenv]

0 commit comments

Comments
 (0)