diff options
author | Ondrej Novy <ondrej.novy@firma.seznam.cz> | 2015-08-08 16:09:22 +0200 |
---|---|---|
committer | Ondřej Nový <ondrej.novy@firma.seznam.cz> | 2015-10-05 21:57:06 +0200 |
commit | c0f473d9757afa680e6b6883cbd16d45ec3551fa (patch) | |
tree | 5181c7c090c3a61ec3f7492ddc76d705c8ef50ef /swiftbench/utils.py | |
parent | d64b007deb99e3ac65034623993961f23351b78d (diff) | |
download | swift-bench-c0f473d9757afa680e6b6883cbd16d45ec3551fa.tar.gz |
Try to detect HTTP proxy and warn about it.
swift-bench test results could be altered when using HTTP proxy server.
This patch add warning when HTTP proxy has been detected.
Change-Id: Id818203345914efee37852e96541c259de6ae555
Diffstat (limited to 'swiftbench/utils.py')
-rw-r--r-- | swiftbench/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/swiftbench/utils.py b/swiftbench/utils.py index 14611d9..1916ac9 100644 --- a/swiftbench/utils.py +++ b/swiftbench/utils.py @@ -15,6 +15,11 @@ import sys from ConfigParser import ConfigParser, RawConfigParser +try: + from urllib import getproxies, proxy_bypass +except ImportError: + from urllib.request import getproxies, proxy_bypass +from urlparse import urlparse # Used when reading config values TRUE_VALUES = set(('true', '1', 'yes', 'on', 't', 'y')) @@ -77,3 +82,12 @@ def config_true_value(value): """ return value is True or \ (isinstance(value, basestring) and value.lower() in TRUE_VALUES) + + +def using_http_proxy(url): + """ + Return True if the url will use HTTP proxy. + Returns False otherwise. + """ + up = urlparse(url) + return up.scheme.lower() in getproxies() and not proxy_bypass(up.netloc) |