From b42eabf7703ddae37ecc47db89e73ef9a0df0b76 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 20 2019 21:08:44 +0000 Subject: PR#1432: py2.6 compatibility fix Merges #1432 https://pagure.io/koji/pull-request/1432 Fixes: #1431 https://pagure.io/koji/issue/1431 koji-builder-1.17.0 not compatible with python 2.6 --- diff --git a/builder/kojid b/builder/kojid index 3eb95b8..fc23e8a 100755 --- a/builder/kojid +++ b/builder/kojid @@ -765,16 +765,18 @@ class BuildRoot(object): #at this point we know there were external repos at the create event, #so there should be an origins file. origin_idx = {} - with GzipFile(fileobj=fo, mode='r') as fo2: - if six.PY3: - fo2 = io.TextIOWrapper(fo2, encoding='utf-8') - for line in fo2: - parts=line.split(None, 2) - if len(parts) < 2: - continue - #first field is formated by yum as [e:]n-v-r.a - nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % koji.parse_NVRA(parts[0]) - origin_idx[nvra] = parts[1] + # don't use 'with GzipFile' as it is not supported on py2.6 + fo2 = GzipFile(fileobj=fo, mode='r') + if six.PY3: + fo2 = io.TextIOWrapper(fo2, encoding='utf-8') + for line in fo2: + parts=line.split(None, 2) + if len(parts) < 2: + continue + #first field is formated by yum as [e:]n-v-r.a + nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % koji.parse_NVRA(parts[0]) + origin_idx[nvra] = parts[1] + fo2.close() # mergerepo starts from a local repo in the task workdir, so internal # rpms have an odd-looking origin that we need to look for localtail = '/repo_%s_premerge/' % self.repo_info['id']