diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2019-06-13 10:32:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-13 10:32:40 +0300 |
commit | c4e259985acae52278c1a54fcd07354421a7ca8b (patch) | |
tree | f3c0582b4201a83f4b4629bfe179d78dd7e7e02c /collectors/python.d.plugin/python_modules | |
parent | 08b0212bf975b2602506eab41d5d28d48a8268cf (diff) |
UrlService: add min required version check (#6263)
* check urllib3 version on init
Diffstat (limited to 'collectors/python.d.plugin/python_modules')
-rw-r--r-- | collectors/python.d.plugin/python_modules/bases/FrameworkServices/UrlService.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/UrlService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/UrlService.py index 4394566551..b6f75bd5c7 100644 --- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/UrlService.py +++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/UrlService.py @@ -6,6 +6,8 @@ import urllib3 +from distutils.version import StrictVersion as version + from bases.FrameworkServices.SimpleService import SimpleService try: @@ -14,9 +16,30 @@ except AttributeError: pass +# https://github.com/urllib3/urllib3/blob/master/CHANGES.rst#19-2014-07-04 +# New retry logic and urllib3.util.retry.Retry configuration object. (Issue https://github.com/urllib3/urllib3/pull/326) +URLLIB3_MIN_REQUIRED_VERSION = '1.9' +URLLIB3_VERSION = urllib3.__version__ +URLLIB3 = 'urllib3' + + +def version_check(): + if version(URLLIB3_VERSION) >= version(URLLIB3_MIN_REQUIRED_VERSION): + return + + err = '{0} version: {1}, minimum required version: {2}, please upgrade'.format( + URLLIB3, + URLLIB3_VERSION, + URLLIB3_MIN_REQUIRED_VERSION, + ) + raise Exception(err) + + class UrlService(SimpleService): def __init__(self, configuration=None, name=None): + version_check() SimpleService.__init__(self, configuration=configuration, name=name) + self.debug("{0} version: {1}".format(URLLIB3, URLLIB3_VERSION)) self.url = self.configuration.get('url') self.user = self.configuration.get('user') self.password = self.configuration.get('pass') |