From 63d904d977651e359730290057dd0ecda2e33f2f Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 26 Jul 2017 18:29:32 +0200 Subject: [PATCH] TT#19059 python3 related urllib fixes Fixes: | AttributeError: 'module' object has no attribute 'urlopen' See https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen Change-Id: Icd399e7421372c3ada268205ba9003d0935a926e --- repoapi/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/repoapi/utils.py b/repoapi/utils.py index f0d9efc..6487467 100644 --- a/repoapi/utils.py +++ b/repoapi/utils.py @@ -19,7 +19,7 @@ import logging import os import shutil import subprocess -import urllib3 +import urllib from django.conf import settings logger = logging.getLogger(__name__) @@ -43,16 +43,16 @@ def dlfile(url, path): if settings.DEBUG: logger.info("I would call %s", url) else: - remote_file = urllib3.urlopen(url) + remote_file = urllib.request.urlopen(url) logger.debug("url:[%s]", url) with open(path, "wb") as local_file: shutil.copyfileobj(remote_file, local_file) def openurl(url): - req = urllib3.Request(url) + req = urllib.request.Request(url) logger.debug("url:[%s]", url) - response = urllib3.urlopen(req) + response = urllib.request.urlopen(req) if response.code > 199 and response.code < 300: logger.debug("OK[%d] url: %s", url, response.code) return True