aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-01-22 19:11:23 +0530
committerXavier Claessens <xclaesse@gmail.com>2020-01-22 17:29:38 -0500
commit2661b1bfb5f3084c222dafec39a0e7d0e95eb6c2 (patch)
tree16c15d5abdb895382953c30f4c521d1a4cb94420
parent8c1221b437b2930fa64d78517337293e8a0e079f (diff)
downloadmeson-2661b1bfb5f3084c222dafec39a0e7d0e95eb6c2.zip
meson-2661b1bfb5f3084c222dafec39a0e7d0e95eb6c2.tar.gz
meson-2661b1bfb5f3084c222dafec39a0e7d0e95eb6c2.tar.bz2
wrap: Use uppercase for global constants
This makes things much clearer and follows PEP8.
-rw-r--r--mesonbuild/wrap/wrap.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 0ebc2bc..bd93ac7 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -43,9 +43,9 @@ except ImportError:
has_ssl = False
API_ROOT = 'http://wrapdb.mesonbuild.com/v1/'
-req_timeout = 600.0
-ssl_warning_printed = False
-whitelist_subdomain = 'wrapdb.mesonbuild.com'
+REQ_TIMEOUT = 600.0
+SSL_WARNING_PRINTED = False
+WHITELIST_SUBDOMAIN = 'wrapdb.mesonbuild.com'
def quiet_git(cmd: T.List[str], workingdir: str) -> T.Tuple[bool, str]:
@@ -63,29 +63,29 @@ def whitelist_wrapdb(urlstr: str) -> urllib.parse.ParseResult:
url = urllib.parse.urlparse(urlstr)
if not url.hostname:
raise WrapException('{} is not a valid URL'.format(urlstr))
- if not url.hostname.endswith(whitelist_subdomain):
+ if not url.hostname.endswith(WHITELIST_SUBDOMAIN):
raise WrapException('{} is not a whitelisted WrapDB URL'.format(urlstr))
if has_ssl and not url.scheme == 'https':
raise WrapException('WrapDB did not have expected SSL https url, instead got {}'.format(urlstr))
return url
def open_wrapdburl(urlstring: str) -> 'http.client.HTTPResponse':
- global ssl_warning_printed
+ global SSL_WARNING_PRINTED
url = whitelist_wrapdb(urlstring)
if has_ssl:
try:
- return urllib.request.urlopen(urllib.parse.urlunparse(url), timeout=req_timeout)
+ return urllib.request.urlopen(urllib.parse.urlunparse(url), timeout=REQ_TIMEOUT)
except urllib.error.URLError as excp:
raise WrapException('WrapDB connection failed to {} with error {}'.format(urlstring, excp))
# following code is only for those without Python SSL
nossl_url = url._replace(scheme='http')
- if not ssl_warning_printed:
+ if not SSL_WARNING_PRINTED:
mlog.warning('SSL module not available in {}: WrapDB traffic not authenticated.'.format(sys.executable))
- ssl_warning_printed = True
+ SSL_WARNING_PRINTED = True
try:
- return urllib.request.urlopen(urllib.parse.urlunparse(nossl_url), timeout=req_timeout)
+ return urllib.request.urlopen(urllib.parse.urlunparse(nossl_url), timeout=REQ_TIMEOUT)
except urllib.error.URLError as excp:
raise WrapException('WrapDB connection failed to {} with error {}'.format(urlstring, excp))
@@ -335,13 +335,13 @@ class Resolver:
h = hashlib.sha256()
tmpfile = tempfile.NamedTemporaryFile(mode='wb', dir=self.cachedir, delete=False)
url = urllib.parse.urlparse(urlstring)
- if url.hostname and url.hostname.endswith(whitelist_subdomain):
+ if url.hostname and url.hostname.endswith(WHITELIST_SUBDOMAIN):
resp = open_wrapdburl(urlstring)
- elif whitelist_subdomain in urlstring:
+ elif WHITELIST_SUBDOMAIN in urlstring:
raise WrapException('{} may be a WrapDB-impersonating URL'.format(urlstring))
else:
try:
- resp = urllib.request.urlopen(urlstring, timeout=req_timeout)
+ resp = urllib.request.urlopen(urlstring, timeout=REQ_TIMEOUT)
except urllib.error.URLError:
raise WrapException('could not get {} is the internet available?'.format(urlstring))
with contextlib.closing(resp) as resp: