From 43b128bde85c1c55ec7ce7eef0d656cf785bd89e Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 12 2020 11:15:04 +0000 Subject: fix potentially undeclared variable error Fixes: https://pagure.io/koji/issue/1957 --- diff --git a/koji/__init__.py b/koji/__init__.py index 94f14c2..f7cf234 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -1676,8 +1676,8 @@ def openRemoteFile(relpath, topurl=None, topdir=None, tempdir=None): if topurl: url = "%s/%s" % (topurl, relpath) fo = tempfile.TemporaryFile(dir=tempdir) + resp = requests.get(url, stream=True) try: - resp = requests.get(url, stream=True) for chunk in resp.iter_content(chunk_size=8192): fo.write(chunk) finally: diff --git a/koji/tasks.py b/koji/tasks.py index c4e10c4..af603a0 100644 --- a/koji/tasks.py +++ b/koji/tasks.py @@ -478,8 +478,8 @@ class BaseTaskHandler(object): return fn self.logger.debug("Downloading %s", relpath) url = "%s/%s" % (self.options.topurl, relpath) + resp = requests.get(url, stream=True) try: - resp = requests.get(url, stream=True) if not os.path.exists(os.path.dirname(fn)): os.makedirs(os.path.dirname(fn)) with open(fn, 'wb') as fdst: