From d6a5cdf987a13df200f0c76838152b1e507444a3 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Oct 31 2017 15:05:16 +0000 Subject: [PATCH 1/4] python-modernize -f lib2to3.fixes.fix_except . -w --- diff --git a/hub/kojihub.py b/hub/kojihub.py index cbad388..42c1176 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -419,7 +419,7 @@ class Task(object): # If the result is a Fault, then loads will raise it # This is normally what we want to happen result, method = xmlrpclib.loads(xml_result) - except xmlrpclib.Fault, fault: + except xmlrpclib.Fault as fault: if raise_fault: raise # Note that you can't really return a fault over xmlrpc, except by @@ -8902,7 +8902,7 @@ class RootExports(object): fn = get_upload_path(path, name, create=True, volume=volume) try: st = os.lstat(fn) - except OSError, e: + except OSError as e: if e.errno == errno.ENOENT: pass else: @@ -8971,7 +8971,7 @@ class RootExports(object): data = {} try: fd = os.open(fn, os.O_RDONLY) - except OSError, e: + except OSError as e: if e.errno == errno.ENOENT: return None else: @@ -8979,7 +8979,7 @@ class RootExports(object): try: try: fcntl.lockf(fd, fcntl.LOCK_SH|fcntl.LOCK_NB) - except IOError, e: + except IOError as e: raise koji.LockError(e) st = os.fstat(fd) if not stat.S_ISREG(st.st_mode): @@ -10491,7 +10491,7 @@ class RootExports(object): #handle older base64 encoded data val = base64.decodestring(val) data, method = xmlrpclib.loads(val) - except xmlrpclib.Fault, fault: + except xmlrpclib.Fault as fault: data = fault task[f] = data yield task @@ -12593,7 +12593,7 @@ class HostExports(object): logger.debug("os.link(%r, %r)", rpmpath, l_dst) try: os.link(rpmpath, l_dst) - except OSError, ose: + except OSError as ose: if ose.errno == 18: shutil.copy2( rpmpath, os.path.join(archdir, bnplet, bnp)) @@ -12690,7 +12690,7 @@ def handle_upload(environ): try: try: fcntl.lockf(fd, fcntl.LOCK_EX|fcntl.LOCK_NB) - except IOError, e: + except IOError as e: raise koji.LockError(e) if offset == -1: offset = os.lseek(fd, 0, 2) diff --git a/hub/kojixmlrpc.py b/hub/kojixmlrpc.py index 7809c4c..2307d59 100644 --- a/hub/kojixmlrpc.py +++ b/hub/kojixmlrpc.py @@ -229,7 +229,7 @@ class ModXMLRPCRequestHandler(object): # wrap response in a singleton tuple response = (response,) response = dumps(response, methodresponse=1, marshaller=Marshaller) - except Fault, fault: + except Fault as fault: self.traceback = True response = dumps(fault, marshaller=Marshaller) except: @@ -323,7 +323,7 @@ class ModXMLRPCRequestHandler(object): for call in calls: try: result = self._dispatch(call['methodName'], call['params']) - except Fault, fault: + except Fault as fault: results.append({'faultCode': fault.faultCode, 'faultString': fault.faultString}) except: # transform unknown exceptions into XML-RPC Faults diff --git a/koji/daemon.py b/koji/daemon.py index 7f0eeff..c4f9e17 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -637,7 +637,7 @@ class TaskManager(object): rootdir = "%s/root" % topdir try: st = os.lstat(rootdir) - except OSError, e: + except OSError as e: if e.errno == errno.ENOENT: rootdir = None else: @@ -658,13 +658,13 @@ class TaskManager(object): #also remove the config try: os.unlink(data['cfg']) - except OSError, e: + except OSError as e: self.logger.warn("%s: can't remove config: %s" % (desc, e)) elif age > 120: if rootdir: try: flist = os.listdir(rootdir) - except OSError, e: + except OSError as e: self.logger.warn("%s: can't list rootdir: %s" % (desc, e)) continue if flist: @@ -892,7 +892,7 @@ class TaskManager(object): prefix = "Task %i (pid %i)" % (task_id, pid) try: (childpid, status) = os.waitpid(pid, os.WNOHANG) - except OSError, e: + except OSError as e: #check errno if e.errno != errno.ECHILD: #should not happen @@ -933,7 +933,7 @@ class TaskManager(object): try: os.kill(pid, sig) - except OSError, e: + except OSError as e: # process probably went away, we'll find out on the next iteration self.logger.info('Error sending signal %i to %s (pid %i, taskID %i): %s' % (sig, execname, pid, task_id, e)) @@ -1222,7 +1222,7 @@ class TaskManager(object): self.logger.info("RESPONSE: %r" % response) self.session.host.closeTask(handler.id, response) return - except koji.xmlrpcplus.Fault, fault: + except koji.xmlrpcplus.Fault as fault: response = koji.xmlrpcplus.dumps(fault) tb = ''.join(traceback.format_exception(*sys.exc_info())).replace(r"\n", "\n") self.logger.warn("FAULT:\n%s" % tb) diff --git a/koji/ssl/SSLConnection.py b/koji/ssl/SSLConnection.py index d854770..2e53db7 100644 --- a/koji/ssl/SSLConnection.py +++ b/koji/ssl/SSLConnection.py @@ -106,7 +106,7 @@ class SSLConnection: try: sent = con.send(data, flags) - except SSL.SysCallError, e: + except SSL.SysCallError as e: if e[0] == 32: # Broken Pipe self.close() sent = 0 @@ -142,7 +142,7 @@ class SSLConnection: return None except SSL.WantReadError: time.sleep(0.2) - except SSL.SysCallError, e: + except SSL.SysCallError as e: if e.args == (-1, 'Unexpected EOF'): break raise diff --git a/koji/tasks.py b/koji/tasks.py index b8ad060..a776680 100644 --- a/koji/tasks.py +++ b/koji/tasks.py @@ -233,7 +233,7 @@ class BaseTaskHandler(object): continue try: self.session.getTaskResult(task) - except (koji.GenericError, xmlrpclib.Fault), task_error: + except (koji.GenericError, xmlrpclib.Fault) as task_error: self.logger.info("task %s failed or was canceled" % task) failed = True break From 379ec8ae63d455fb29ea0f89867e1e053b9b095a Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Oct 31 2017 15:05:16 +0000 Subject: [PATCH 2/4] python-modernize -f lib2to3.fixes.file . -w --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 42c1176..d588d5d 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -2331,7 +2331,7 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None): groupsdir = "%s/groups" % (repodir) koji.ensuredir(groupsdir) comps = koji.generate_comps(groups, expand_groups=True) - fo = file("%s/comps.xml" % groupsdir, 'w') + fo = open("%s/comps.xml" % groupsdir, 'w') fo.write(comps) fo.close() @@ -2350,7 +2350,7 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None): top_relpath = koji.util.relpath(koji.pathinfo.topdir, archdir) top_link = os.path.join(archdir, 'toplink') os.symlink(top_relpath, top_link) - pkglist[repoarch] = file(os.path.join(archdir, 'pkglist'), 'w') + pkglist[repoarch] = open(os.path.join(archdir, 'pkglist'), 'w') #NOTE - rpms is now an iterator for rpminfo in rpms: if not with_debuginfo and koji.is_debuginfo(rpminfo['name']): @@ -2375,7 +2375,7 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None): #write blocked package lists for repoarch in repo_arches: - blocklist = file(os.path.join(repodir, repoarch, 'blocklist'), 'w') + blocklist = open(os.path.join(repodir, repoarch, 'blocklist'), 'w') for pkg in blocks: blocklist.write(pkg['package_name']) blocklist.write('\n') @@ -2442,7 +2442,7 @@ def _write_maven_repo_metadata(destdir, artifacts): """ % datetime.datetime.now().strftime('%Y%m%d%H%M%S') - mdfile = file(os.path.join(destdir, 'maven-metadata.xml'), 'w') + mdfile = open(os.path.join(destdir, 'maven-metadata.xml'), 'w') mdfile.write(contents) mdfile.close() _generate_maven_metadata(destdir) @@ -6080,7 +6080,7 @@ def check_old_image_files(old): (img_path, img_size, old['filesize'])) # old images always used sha256 hashes sha256sum = hashlib.sha256() - image_fo = file(img_path, 'r') + image_fo = open(img_path, 'r') while True: data = image_fo.read(1048576) sha256sum.update(data) @@ -6232,7 +6232,7 @@ def import_archive_internal(filepath, buildinfo, type, typeInfo, buildroot_id=No filename = koji.fixEncoding(os.path.basename(filepath)) archiveinfo['filename'] = filename archiveinfo['size'] = os.path.getsize(filepath) - archivefp = file(filepath) + archivefp = open(filepath) m = md5_constructor() while True: contents = archivefp.read(8192) @@ -6372,14 +6372,14 @@ def _generate_maven_metadata(mavendir): sumfile = mavenfile + ext if sumfile not in mavenfiles: sum = sum_constr() - fobj = file('%s/%s' % (mavendir, mavenfile)) + fobj = open('%s/%s' % (mavendir, mavenfile)) while True: content = fobj.read(8192) if not content: break sum.update(content) fobj.close() - sumobj = file('%s/%s' % (mavendir, sumfile), 'w') + sumobj = open('%s/%s' % (mavendir, sumfile), 'w') sumobj.write(sum.hexdigest()) sumobj.close() @@ -6435,7 +6435,7 @@ def add_rpm_sig(an_rpm, sighdr): # - write to fs sigpath = "%s/%s" % (builddir, koji.pathinfo.sighdr(rinfo, sigkey)) koji.ensuredir(os.path.dirname(sigpath)) - fo = file(sigpath, 'wb') + fo = open(sigpath, 'wb') fo.write(sighdr) fo.close() koji.plugin.run_callbacks('postRPMSign', sigkey=sigkey, sighash=sighash, build=binfo, rpm=rinfo) @@ -6451,7 +6451,7 @@ def _scan_sighdr(sighdr, fn): sig_start, sigsize = koji.find_rpm_sighdr(fn) hdr_start = sig_start + sigsize hdrsize = koji.rpm_hdr_size(fn, hdr_start) - inp = file(fn, 'rb') + inp = open(fn, 'rb') outp = tempfile.TemporaryFile(mode='w+b') #before signature outp.write(inp.read(sig_start)) @@ -6488,7 +6488,7 @@ def check_rpm_sig(an_rpm, sigkey, sighdr): koji.splice_rpm_sighdr(sighdr, rpm_path, temp) ts = rpm.TransactionSet() ts.setVSFlags(0) #full verify - fo = file(temp, 'rb') + fo = open(temp, 'rb') hdr = ts.hdrFromFdno(fo.fileno()) fo.close() except: @@ -6551,7 +6551,7 @@ def write_signed_rpm(an_rpm, sigkey, force=False): else: os.unlink(signedpath) sigpath = "%s/%s" % (builddir, koji.pathinfo.sighdr(rinfo, sigkey)) - fo = file(sigpath, 'rb') + fo = open(sigpath, 'rb') sighdr = fo.read() fo.close() koji.ensuredir(os.path.dirname(signedpath)) @@ -9018,7 +9018,7 @@ class RootExports(object): if not os.path.isfile(filePath): raise koji.GenericError('no file "%s" output by task %i' % (fileName, taskID)) # Let the caller handler any IO or permission errors - f = file(filePath, 'r') + f = open(filePath, 'r') if isinstance(offset, str): offset = int(offset) if offset != None and offset > 0: @@ -12641,11 +12641,11 @@ def get_upload_path(reldir, name, create=False, volume=None): # assuming login was asserted earlier u_fn = os.path.join(udir, '.user') if os.path.exists(u_fn): - user_id = int(file(u_fn, 'r').read()) + user_id = int(open(u_fn, 'r').read()) if context.session.user_id != user_id: raise koji.GenericError("Invalid upload directory, not owner: %s" % orig_reldir) else: - fo = file(u_fn, 'w') + fo = open(u_fn, 'w') fo.write(str(context.session.user_id)) fo.close() return os.path.join(udir, name) diff --git a/koji/daemon.py b/koji/daemon.py index c4f9e17..193b28c 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -142,7 +142,7 @@ def log_output(session, path, args, outfile, uploadpath, cwd=None, logerror=0, a if not outfd: try: - outfd = file(outfile, 'r') + outfd = open(outfile, 'r') except IOError: # will happen if the forked process has not created the logfile yet continue @@ -691,7 +691,7 @@ class TaskManager(object): fn = "%s/%s" % (configdir, f) if not os.path.isfile(fn): continue - fo = file(fn, 'r') + fo = open(fn, 'r') id = None name = None for n in xrange(10): @@ -957,14 +957,14 @@ class TaskManager(object): proc_path = '/proc/%i/stat' % pid if not os.path.isfile(proc_path): return None - proc_file = file(proc_path) + proc_file = open(proc_path) procstats = [not field.isdigit() and field or int(field) for field in proc_file.read().split()] proc_file.close() cmd_path = '/proc/%i/cmdline' % pid if not os.path.isfile(cmd_path): return None - cmd_file = file(cmd_path) + cmd_file = open(cmd_path) procstats[1] = cmd_file.read().replace('\0', ' ').strip() cmd_file.close() if not procstats[1]: diff --git a/koji/tasks.py b/koji/tasks.py index a776680..d6521b7 100644 --- a/koji/tasks.py +++ b/koji/tasks.py @@ -322,7 +322,7 @@ class BaseTaskHandler(object): fsrc = six.moves.urllib.request.urlopen(url) if not os.path.exists(os.path.dirname(fn)): os.makedirs(os.path.dirname(fn)) - fdst = file(fn, 'w') + fdst = open(fn, 'w') shutil.copyfileobj(fsrc, fdst) fsrc.close() fdst.close() diff --git a/plugins/hub/rpm2maven.py b/plugins/hub/rpm2maven.py index c216fdc..ad78b8f 100644 --- a/plugins/hub/rpm2maven.py +++ b/plugins/hub/rpm2maven.py @@ -52,7 +52,7 @@ def maven_import(cbtype, *args, **kws): rmtree(tmpdir) def expand_rpm(filepath, tmpdir): - devnull = file('/dev/null', 'r+') + devnull = open('/dev/null', 'r+') rpm2cpio = subprocess.Popen(['/usr/bin/rpm2cpio', filepath], stdout=subprocess.PIPE, stdin=devnull, stderr=devnull, diff --git a/tests/test_builder/test_build_notification.py b/tests/test_builder/test_build_notification.py index 6ba4d95..c6a30ea 100644 --- a/tests/test_builder/test_build_notification.py +++ b/tests/test_builder/test_build_notification.py @@ -71,7 +71,7 @@ class TestBuildNotification(unittest.TestCase): # task_info['id'], method, params, self.session, self.options task_id = 999 fn = os.path.join(os.path.dirname(__file__), 'data/calls', 'build_notif_1', 'params.json') - with file(fn) as fp: + with open(fn) as fp: kwargs = json.load(fp) self.session = MyClientSession('https://koji.example.com/kojihub') self.session.load_calls('build_notif_1') @@ -95,6 +95,6 @@ class TestBuildNotification(unittest.TestCase): self.assertEqual(from_addr, "koji@example.com") self.assertEqual(recipients, ["user@example.com"]) fn = os.path.join(os.path.dirname(__file__), 'data/calls', 'build_notif_1', 'message.txt') - with file(fn) as fp: + with open(fn) as fp: msg_expect = fp.read() self.assertEqual(message, msg_expect) diff --git a/tests/test_hub/test_complete_image_build.py b/tests/test_hub/test_complete_image_build.py index 1835b4d..0f67b15 100644 --- a/tests/test_hub/test_complete_image_build.py +++ b/tests/test_hub/test_complete_image_build.py @@ -83,15 +83,15 @@ class TestCompleteImageBuild(unittest.TestCase): def set_up_files(self, name): datadir = os.path.join(os.path.dirname(__file__), 'data/image', name) # load image result data for our test build - data = json.load(file(datadir + '/data.json')) - self.db_expect = json.load(file(datadir + '/db.json')) + data = json.load(open(datadir + '/data.json')) + self.db_expect = json.load(open(datadir + '/db.json')) for arch in data: taskdir = koji.pathinfo.task(data[arch]['task_id']) os.makedirs(taskdir) filenames = data[arch]['files'] + data[arch]['logs'] for filename in filenames: path = os.path.join(taskdir, filename) - with file(path, 'w') as fp: + with open(path, 'w') as fp: fp.write('Test file for %s\n%s\n' % (arch, filename)) self.image_data = data diff --git a/tests/test_hub/test_complete_maven_build.py b/tests/test_hub/test_complete_maven_build.py index b7280f3..45ec01c 100644 --- a/tests/test_hub/test_complete_maven_build.py +++ b/tests/test_hub/test_complete_maven_build.py @@ -49,7 +49,7 @@ class TestCompleteMavenBuild(unittest.TestCase): def set_up_files(self, name): datadir = os.path.join(os.path.dirname(__file__), 'data/maven', name) # load maven result data for our test build - data = json.load(file(datadir + '/data.json')) + data = json.load(open(datadir + '/data.json')) data['task_id'] = 9999 taskdir = koji.pathinfo.task(data['task_id']) for subdir in data['files']: @@ -64,7 +64,7 @@ class TestCompleteMavenBuild(unittest.TestCase): dst = os.path.join(taskdir, fn) shutil.copy(src, dst) self.maven_data = data - files = file(datadir + '/files').readlines() + files = open(datadir + '/files').readlines() files = [l.strip() for l in files] self.expected_files = files diff --git a/tests/test_hub/test_get_build_logs.py b/tests/test_hub/test_get_build_logs.py index 7ebfa51..88157aa 100644 --- a/tests/test_hub/test_get_build_logs.py +++ b/tests/test_hub/test_get_build_logs.py @@ -31,7 +31,7 @@ class TestGetBuildLogs(unittest.TestCase): dirpath = os.path.dirname(path) koji.ensuredir(dirpath) if path: - with file(path, 'w') as fo: + with open(path, 'w') as fo: fo.write('TEST LOG FILE CONTENTS\n') def test_get_build_logs_basic(self): diff --git a/tests/test_hub/test_get_upload_path.py b/tests/test_hub/test_get_upload_path.py index f789192..a1191ce 100644 --- a/tests/test_hub/test_get_upload_path.py +++ b/tests/test_hub/test_get_upload_path.py @@ -36,7 +36,7 @@ class TestGetUploadPath(unittest.TestCase): fullpath = '{0}/{1}'.format(work.return_value, reldir) os.makedirs(fullpath) - with file('{0}/.user'.format(fullpath), 'wb') as f: + with open('{0}/.user'.format(fullpath), 'wb') as f: f.write('1') with self.assertRaises(GenericError): diff --git a/vm/kojikamid.py b/vm/kojikamid.py index 0499c74..1d40e68 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -301,7 +301,7 @@ class WindowsBuild(object): """Download the file from buildreq, at filepath, into the basedir""" destpath = os.path.join(basedir, fileinfo['localpath']) ensuredir(os.path.dirname(destpath)) - destfile = file(destpath, 'w') + destfile = open(destpath, 'w') offset = 0 checksum = hashlib.md5() while True: @@ -560,7 +560,7 @@ def upload_file(server, prefix, path): """upload a single file to the vmd""" logger = logging.getLogger('koji.vm') destpath = os.path.join(prefix, path) - fobj = file(destpath, 'r') + fobj = open(destpath, 'r') offset = 0 sum = hashlib.md5() while True: @@ -614,7 +614,7 @@ def setup_logging(opts): if opts.debug: level = logging.DEBUG logger.setLevel(level) - logfd = file(logfile, 'w') + logfd = open(logfile, 'w') handler = logging.StreamHandler(logfd) handler.setLevel(level) handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(name)s: %(message)s')) @@ -643,7 +643,7 @@ def stream_logs(server, handler, builds): if not fd: if os.path.isfile(log): try: - fd = file(log, 'r') + fd = open(log, 'r') logs[log] = (relpath, fd) except: log_local('Error opening %s' % log) From 1f6ca9ae72ae742dd3400abf3e491e767a03b61d Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Oct 31 2017 15:07:34 +0000 Subject: [PATCH 3/4] python-modernize -f lib2to3.fixes.fix_numliterals . -w --- diff --git a/hub/kojihub.py b/hub/kojihub.py index d588d5d..dedcbc6 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -8916,7 +8916,7 @@ class RootExports(object): # but we allow .log files to be uploaded multiple times to support # realtime log-file viewing raise koji.GenericError("file already exists: %s" % fn) - fd = os.open(fn, os.O_RDWR | os.O_CREAT, 0666) + fd = os.open(fn, os.O_RDWR | os.O_CREAT, 0o666) # log_error("fd=%r" %fd) try: if offset == 0 or (offset == -1 and size == len(contents)): @@ -12686,7 +12686,7 @@ def handle_upload(environ): size = 0 chksum = sum_cls() inf = environ['wsgi.input'] - fd = os.open(fn, os.O_RDWR | os.O_CREAT, 0666) + fd = os.open(fn, os.O_RDWR | os.O_CREAT, 0o666) try: try: fcntl.lockf(fd, fcntl.LOCK_EX|fcntl.LOCK_NB) diff --git a/koji/daemon.py b/koji/daemon.py index 193b28c..f279a67 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -111,7 +111,7 @@ def log_output(session, path, args, outfile, uploadpath, cwd=None, logerror=0, a flags = os.O_CREAT | os.O_WRONLY if append: flags |= os.O_APPEND - fd = os.open(outfile, flags, 0666) + fd = os.open(outfile, flags, 0o666) os.dup2(fd, 1) if logerror: os.dup2(fd, 2) From 09651a9a8fb32fbb9d903158442dd73b17b11518 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Oct 31 2017 15:18:04 +0000 Subject: [PATCH 4/4] Explicit tuple in list constructor --- diff --git a/builder/kojid b/builder/kojid index 98e1fb5..be7116a 100755 --- a/builder/kojid +++ b/builder/kojid @@ -661,7 +661,7 @@ class BuildRoot(object): repodir = pathinfo.repo(self.repo_info['id'], self.repo_info['tag_name']) repomdpath = os.path.join(repodir, self.br_arch, 'repodata', 'repomd.xml') - opts = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir']) + opts = dict([(k, getattr(self.options, k)) for k in ('topurl','topdir')]) opts['tempdir'] = self.options.workdir fo = koji.openRemoteFile(repomdpath, **opts) try: @@ -940,7 +940,7 @@ class BuildTask(BaseTaskHandler): #srpm arg should be a path relative to /work self.logger.debug("Reading SRPM") relpath = "work/%s" % srpm - opts = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir']) + opts = dict([(k, getattr(self.options, k)) for k in ('topurl','topdir')]) opts['tempdir'] = self.workdir fo = koji.openRemoteFile(relpath, **opts) h = koji.get_rpm_header(fo) @@ -3347,7 +3347,7 @@ class OzImageTask(BaseTaskHandler): srcdir=scmsrcdir) kspath = os.path.join(scmsrcdir, os.path.basename(ksfile)) else: - tops = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir']) + tops = dict([(k, getattr(self.options, k)) for k in ('topurl','topdir')]) tops['tempdir'] = self.workdir ks_src = koji.openRemoteFile(ksfile, **tops) kspath = os.path.join(self.workdir, os.path.basename(ksfile)) @@ -4160,7 +4160,7 @@ class BuildIndirectionImageTask(OzImageTask): srcdir=scmsrcdir) final_path = os.path.join(scmsrcdir, os.path.basename(filepath)) else: - tops = dict([(k, getattr(self.options, k)) for k in 'topurl','topdir']) + tops = dict([(k, getattr(self.options, k)) for k in ('topurl','topdir')]) tops['tempdir'] = self.workdir remote_fileobj = koji.openRemoteFile(filepath, **tops) final_path = os.path.join(self.workdir, os.path.basename(filepath))