From 6dd77e0fa4eb0586ff850d1ea0affd3b5c33af69 Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Mar 03 2020 13:38:22 +0000 Subject: flake8: apply E502 rule --- diff --git a/.flake8 b/.flake8 index 4a0e68a..99e9967 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -select = I,C,F,E1,E2,E3,E4 +select = I,C,F,E1,E2,E3,E4,E502 ignore = E266 exclude = .git, diff --git a/builder/kojid b/builder/kojid index ca7459b..fb42a7a 100755 --- a/builder/kojid +++ b/builder/kojid @@ -233,7 +233,7 @@ class BuildRoot(object): self.tag_id = self.config['id'] self.tag_name = self.config['name'] if self.config['id'] != repo_info['tag_id']: - raise koji.BuildrootError("tag/repo mismatch: %s vs %s" \ + raise koji.BuildrootError("tag/repo mismatch: %s vs %s" % (self.config['name'], repo_info['tag_name'])) repo_state = koji.REPO_STATES[repo_info['state']] if repo_state == 'EXPIRED': @@ -699,7 +699,7 @@ class BuildRoot(object): if maven_files: path_comps = relpath.split('/') if len(path_comps) < 3: - raise koji.BuildrootError('files found in unexpected path in local Maven repo, directory: %s, files: %s' % \ + raise koji.BuildrootError('files found in unexpected path in local Maven repo, directory: %s, files: %s' % (relpath, ', '.join([f['filename'] for f in maven_files]))) # extract the Maven info from the path within the local repo maven_info = {'version': path_comps[-1], @@ -967,7 +967,7 @@ class BuildTask(BaseTaskHandler): if repo_info is not None: # make sure specified repo matches target if repo_info['tag_id'] != target_info['build_tag']: - raise koji.BuildError('Repo/Target mismatch: %s/%s' \ + raise koji.BuildError('Repo/Target mismatch: %s/%s' % (repo_info['tag_name'], target_info['build_tag_name'])) else: # if repo_id is specified, we can allow the 'target' arg to simply specify @@ -1023,10 +1023,10 @@ class BuildTask(BaseTaskHandler): if not self.opts.get('skip_tag') and not self.opts.get('scratch'): # Make sure package is on the list for this tag if pkg_cfg is None: - raise koji.BuildError("package %s not in list for tag %s" \ + raise koji.BuildError("package %s not in list for tag %s" % (data['name'], target_info['dest_tag_name'])) elif pkg_cfg['blocked']: - raise koji.BuildError("package %s is blocked for tag %s" \ + raise koji.BuildError("package %s is blocked for tag %s" % (data['name'], target_info['dest_tag_name'])) # TODO - more pre tests archlist = self.getArchList(build_tag, h, extra=extra_arches) @@ -1278,8 +1278,8 @@ class BaseBuildTask(BaseTaskHandler): tag_arches = [koji.canonArch(a) for a in tag['arches'].split()] host_arches = hostdata['arches'].split() if not set(tag_arches).intersection(host_arches): - self.logger.info('Task %s (%s): tag arches (%s) and ' \ - 'host arches (%s) are disjoint' % \ + self.logger.info('Task %s (%s): tag arches (%s) and ' + 'host arches (%s) are disjoint' % (self.id, self.method, ', '.join(tag_arches), ', '.join(host_arches))) return False @@ -1506,10 +1506,10 @@ class MavenTask(MultiPlatformTask): dest_cfg = self.session.getPackageConfig(dest_tag['id'], build_info['name']) # Make sure package is on the list for this tag if dest_cfg is None: - raise koji.BuildError("package %s not in list for tag %s" \ + raise koji.BuildError("package %s not in list for tag %s" % (build_info['name'], dest_tag['name'])) elif dest_cfg['blocked']: - raise koji.BuildError("package %s is blocked for tag %s" \ + raise koji.BuildError("package %s is blocked for tag %s" % (build_info['name'], dest_tag['name'])) build_info = self.session.host.initMavenBuild(self.id, build_info, maven_info) @@ -1666,8 +1666,8 @@ class BuildMavenTask(BaseBuildTask): # Apply patches, if present if self.opts.get('patches'): # filter out directories and files beginning with . (probably scm metadata) - patches = [patch for patch in os.listdir(patchcheckoutdir) if \ - os.path.isfile(os.path.join(patchcheckoutdir, patch)) and \ + patches = [patch for patch in os.listdir(patchcheckoutdir) if + os.path.isfile(os.path.join(patchcheckoutdir, patch)) and patch.endswith('.patch')] if not patches: raise koji.BuildError('no patches found at %s' % self.opts.get('patches')) @@ -2019,10 +2019,10 @@ class WrapperRPMTask(BaseBuildTask): if not opts.get('skip_tag'): # Make sure package is on the list for this tag if pkg_cfg is None: - raise koji.BuildError("package %s not in list for tag %s" \ + raise koji.BuildError("package %s not in list for tag %s" % (data['name'], build_target['dest_tag_name'])) elif pkg_cfg['blocked']: - raise koji.BuildError("package %s is blocked for tag %s" \ + raise koji.BuildError("package %s is blocked for tag %s" % (data['name'], build_target['dest_tag_name'])) self.new_build_id = self.session.host.initBuild(data) @@ -2047,7 +2047,7 @@ class WrapperRPMTask(BaseBuildTask): else: if self.new_build_id: self.session.host.failBuild(self.id, self.new_build_id) - raise koji.BuildError('multiple srpms found in %s: %s, %s' % \ + raise koji.BuildError('multiple srpms found in %s: %s, %s' % (resultdir, srpm, filename)) elif filename.endswith('.rpm'): rpms.append(filename) @@ -2056,7 +2056,7 @@ class WrapperRPMTask(BaseBuildTask): else: if self.new_build_id: self.session.host.failBuild(self.id, self.new_build_id) - raise koji.BuildError('unexpected file found in %s: %s' % \ + raise koji.BuildError('unexpected file found in %s: %s' % (resultdir, filename)) if not srpm: @@ -2141,10 +2141,10 @@ class ChainMavenTask(MultiPlatformTask): dest_cfg = self.session.getPackageConfig(dest_tag['id'], package) # Make sure package is on the list for this tag if dest_cfg is None: - raise koji.BuildError("package %s not in list for tag %s" \ + raise koji.BuildError("package %s not in list for tag %s" % (package, dest_tag['name'])) elif dest_cfg['blocked']: - raise koji.BuildError("package %s is blocked for tag %s" \ + raise koji.BuildError("package %s is blocked for tag %s" % (package, dest_tag['name'])) self.depmap = {} @@ -2236,7 +2236,7 @@ class ChainMavenTask(MultiPlatformTask): break else: raise koji.BuildError('could not find buildMaven subtask of %s' % task_id) - self.results.append('%s built from %s by task %s' % \ + self.results.append('%s built from %s by task %s' % (package, task_url, task_id)) else: task_builds = self.session.listBuilds(taskID=task_id) @@ -2987,7 +2987,7 @@ class ImageTask(BaseTaskHandler): """ found = False hdrlist = [] - fields = ['name', 'version', 'release', 'epoch', 'arch', \ + fields = ['name', 'version', 'release', 'epoch', 'arch', 'buildtime', 'sigmd5'] for root, dirs, files in os.walk(cachepath): for f in files: @@ -5322,7 +5322,7 @@ class CreaterepoTask(BaseTaskHandler): logfile = '%s/createrepo.log' % self.workdir status = log_output(self.session, cmd[0], cmd, logfile, self.getUploadDir(), logerror=True) if not isSuccess(status): - raise koji.GenericError('failed to create repo: %s' \ + raise koji.GenericError('failed to create repo: %s' % parseStatus(status, ' '.join(cmd))) def merge_repos(self, external_repos, arch, groupdata): @@ -5381,7 +5381,7 @@ class CreaterepoTask(BaseTaskHandler): logfile = '%s/mergerepos.log' % self.workdir status = log_output(self.session, cmd[0], cmd, logfile, self.getUploadDir(), logerror=True) if not isSuccess(status): - raise koji.GenericError('failed to merge repos: %s' \ + raise koji.GenericError('failed to merge repos: %s' % parseStatus(status, ' '.join(cmd))) @@ -5632,7 +5632,7 @@ class createDistRepoTask(BaseTaskHandler): logfile = '%s/%s.log' % (self.workdir, logname) status = log_output(self.session, cmd[0], cmd, logfile, self.getUploadDir(), logerror=True) if not isSuccess(status): - raise koji.GenericError('failed to create repo: %s' \ + raise koji.GenericError('failed to create repo: %s' % parseStatus(status, ' '.join(cmd))) def do_multilib_dnf(self, arch, ml_arch, conf): @@ -6096,12 +6096,12 @@ class WaitrepoTask(BaseTaskHandler): if repo and repo != last_repo: if builds: if koji.util.checkForBuilds(self.session, taginfo['id'], builds, repo['create_event']): - self.logger.debug("Successfully waited %s for %s to appear in the %s repo" % \ + self.logger.debug("Successfully waited %s for %s to appear in the %s repo" % (koji.util.duration(start), koji.util.printList(nvrs), taginfo['name'])) return repo elif newer_than: if repo['create_ts'] > newer_than: - self.logger.debug("Successfully waited %s for a new %s repo" % \ + self.logger.debug("Successfully waited %s for a new %s repo" % (koji.util.duration(start), taginfo['name'])) return repo else: @@ -6110,10 +6110,10 @@ class WaitrepoTask(BaseTaskHandler): if (time.time() - start) > (self.TIMEOUT * 60.0): if builds: - raise koji.GenericError("Unsuccessfully waited %s for %s to appear in the %s repo" % \ + raise koji.GenericError("Unsuccessfully waited %s for %s to appear in the %s repo" % (koji.util.duration(start), koji.util.printList(nvrs), taginfo['name'])) else: - raise koji.GenericError("Unsuccessfully waited %s for a new %s repo" % \ + raise koji.GenericError("Unsuccessfully waited %s for a new %s repo" % (koji.util.duration(start), taginfo['name'])) time.sleep(self.PAUSE) diff --git a/builder/mergerepos b/builder/mergerepos index 3b806d5..1dbe893 100755 --- a/builder/mergerepos +++ b/builder/mergerepos @@ -242,7 +242,7 @@ class RepoMerge(object): '%s < %s\n' % (pkg.sourcerpm, other_srpm)) # otherwise same, so we already have it elif srpm_name in self.blocked: - sys.stderr.write('Ignoring blocked package: %s\n\n' % \ + sys.stderr.write('Ignoring blocked package: %s\n\n' % pkg.sourcerpm) continue else: diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 6277567..8687659 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -1703,7 +1703,7 @@ def handle_prune_signed_copies(options, session, args): elif our_entry['revoke_ts'] > cutoff_ts: # we were still tagged here sometime before the cutoff if options.debug: - print("Build %s had protected tag %s until %s" \ + print("Build %s had protected tag %s until %s" % (nvr, tag_name, time.asctime(time.localtime(our_entry['revoke_ts'])))) is_protected = True break @@ -1721,7 +1721,7 @@ def handle_prune_signed_copies(options, session, args): if entry['build_id'] == binfo['id']: if is_create: # shouldn't happen - raise koji.GenericError("Duplicate creation event found for %s in %s" \ + raise koji.GenericError("Duplicate creation event found for %s in %s" % (nvr, tag_name)) else: # we've been revoked @@ -1762,19 +1762,19 @@ def handle_prune_signed_copies(options, session, args): # replaced (but not revoked) timestamps.append(replaced_ts) if options.debug: - print("tag %s: %s not latest (replaced %s)" \ + print("tag %s: %s not latest (replaced %s)" % (tag_name, nvr, time.asctime(time.localtime(replaced_ts)))) elif replaced_ts is None: # revoked but not replaced timestamps.append(revoke_ts) if options.debug: - print("tag %s: %s not latest (revoked %s)" \ + print("tag %s: %s not latest (revoked %s)" % (tag_name, nvr, time.asctime(time.localtime(revoke_ts)))) else: # revoked AND replaced timestamps.append(min(revoke_ts, replaced_ts)) if options.debug: - print("tag %s: %s not latest (revoked %s, replaced %s)" \ + print("tag %s: %s not latest (revoked %s, replaced %s)" % (tag_name, nvr, time.asctime(time.localtime(revoke_ts)), time.asctime(time.localtime(replaced_ts)))) last_latest = max(timestamps) @@ -1866,7 +1866,7 @@ def handle_prune_signed_copies(options, session, args): total_files += build_files total_space += build_space if options.verbose: - print("Build: %s, Removed %i signed copies (%i bytes). Total: %i/%i" \ + print("Build: %s, Removed %i signed copies (%i bytes). Total: %i/%i" % (nvr, build_files, build_space, total_files, total_space)) elif options.debug and by_sig: print("(build has no signed copies)") @@ -5373,7 +5373,7 @@ def handle_add_external_repo(goptions, session, args): if options.mode: callopts['merge_mode'] = options.mode session.addExternalRepoToTag(tag, rinfo['name'], priority, **callopts) - print("Added external repo %s to tag %s (priority %i)" \ + print("Added external repo %s to tag %s (priority %i)" % (rinfo['name'], tag, priority)) @@ -6004,17 +6004,17 @@ def handle_win_build(options, session, args): usage = _("usage: %prog win-build [options] ") parser = OptionParser(usage=get_usage_str(usage)) parser.add_option("--winspec", metavar="URL", - help=_("SCM URL to retrieve the build descriptor from. " + \ - "If not specified, the winspec must be in the root directory " + \ + help=_("SCM URL to retrieve the build descriptor from. " + + "If not specified, the winspec must be in the root directory " + "of the source repository.")) parser.add_option("--patches", metavar="URL", - help=_("SCM URL of a directory containing patches to apply " + \ + help=_("SCM URL of a directory containing patches to apply " + "to the sources before building")) parser.add_option("--cpus", type="int", - help=_("Number of cpus to allocate to the build VM " + \ + help=_("Number of cpus to allocate to the build VM " + "(requires admin access)")) parser.add_option("--mem", type="int", - help=_("Amount of memory (in megabytes) to allocate to the build VM " + \ + help=_("Amount of memory (in megabytes) to allocate to the build VM " + "(requires admin access)")) parser.add_option("--static-mac", action="store_true", help=_("Retain the original MAC address when cloning the VM")) @@ -6261,15 +6261,15 @@ def handle_set_pkg_owner_global(goptions, session, args): for entry in to_change: if user['id'] == entry['owner_id']: if options.verbose: - print("Preserving owner=%s for package %s in tag %s" \ + print("Preserving owner=%s for package %s in tag %s" % (user['name'], package, entry['tag_name'])) else: if options.test: - print("Would have changed owner for %s in tag %s: %s -> %s" \ + print("Would have changed owner for %s in tag %s: %s -> %s" % (entry['package_name'], entry['tag_name'], entry['owner_name'], user['name'])) continue if options.verbose: - print("Changing owner for %s in tag %s: %s -> %s" \ + print("Changing owner for %s in tag %s: %s -> %s" % (entry['package_name'], entry['tag_name'], entry['owner_name'], user['name'])) session.packageListSetOwner(entry['tag_id'], entry['package_name'], user['id']) diff --git a/hub/kojihub.py b/hub/kojihub.py index c1ac40b..6992a69 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -262,7 +262,7 @@ class Task(object): raise koji.GenericError("No such task: %i" % self.id) oldstate = row[0] if koji.TASK_STATES[oldstate] in ['CLOSED', 'CANCELED', 'FAILED']: - raise koji.GenericError("Cannot free task %i, state is %s" % \ + raise koji.GenericError("Cannot free task %i, state is %s" % (self.id, koji.TASK_STATES[oldstate])) newstate = koji.TASK_STATES['FREE'] newhost = None @@ -1003,7 +1003,7 @@ def _direct_pkglist_add(taginfo, pkginfo, owner, block, extra_arches, force, block = bool(block) if update and not force: # if update flag is true, require that there be a previous entry - raise koji.GenericError("cannot update: tag %s has no data for package %s" \ + raise koji.GenericError("cannot update: tag %s has no data for package %s" % (tag['name'], pkg['name'])) else: # already there (possibly via inheritance) @@ -1075,7 +1075,7 @@ def pkglist_block(taginfo, pkginfo, force=False): tag = get_tag(taginfo, strict=True) pkg = lookup_package(pkginfo, strict=True) if not readPackageList(tag['id'], pkgID=pkg['id'], inherit=True): - raise koji.GenericError("Package %s is not in tag listing for %s" % \ + raise koji.GenericError("Package %s is not in tag listing for %s" % (pkg['name'], tag['name'])) pkglist_add(taginfo, pkginfo, block=True, force=force) @@ -1100,7 +1100,7 @@ def pkglist_unblock(taginfo, pkginfo, force=False): pkglist = readPackageList(tag_id, pkgID=pkg_id, inherit=True) previous = pkglist.get(pkg_id, None) if previous is None: - raise koji.GenericError("no data (blocked or otherwise) for package %s in tag %s" \ + raise koji.GenericError("no data (blocked or otherwise) for package %s in tag %s" % (pkg['name'], tag['name'])) if not previous['blocked']: raise koji.GenericError("package %s NOT blocked in tag %s" % (pkg['name'], tag['name'])) @@ -1884,7 +1884,7 @@ def _grp_pkg_add(taginfo, grpinfo, pkg_name, block, force, **opts): if previous is not None: # already there (possibly via inheritance) if previous['blocked'] and not force: - raise koji.GenericError("package %s blocked in group %s, tag %s" \ + raise koji.GenericError("package %s blocked in group %s, tag %s" % (pkg_name, group['name'], tag['name'])) # check for duplication and grab old data for defaults changed = False @@ -1966,7 +1966,7 @@ def _grp_pkg_unblock(taginfo, grpinfo, pkg_name): values=locals(), opts={'rowlock': True}) blocked = query.singleValue(strict=False) if not blocked: - raise koji.GenericError("package %s is NOT blocked in group %s, tag %s" \ + raise koji.GenericError("package %s is NOT blocked in group %s, tag %s" % (pkg_name, grp_id, tag_id)) update = UpdateProcessor('group_package_listing', values=locals(), clauses=clauses) update.make_revoke() @@ -2008,7 +2008,7 @@ def _grp_req_add(taginfo, grpinfo, reqinfo, block, force, **opts): if previous is not None: # already there (possibly via inheritance) if previous['blocked'] and not force: - raise koji.GenericError("requirement on group %s blocked in group %s, tag %s" \ + raise koji.GenericError("requirement on group %s blocked in group %s, tag %s" % (req['name'], group['name'], tag['name'])) # check for duplication and grab old data for defaults changed = False @@ -2093,7 +2093,7 @@ def _grp_req_unblock(taginfo, grpinfo, reqinfo): values=locals(), opts={'rowlock': True}) blocked = query.singleValue(strict=False) if not blocked: - raise koji.GenericError("group req %s is NOT blocked in group %s, tag %s" \ + raise koji.GenericError("group req %s is NOT blocked in group %s, tag %s" % (req_id, grp_id, tag_id)) update = UpdateProcessor('group_req_listing', values=locals(), clauses=clauses) update.make_revoke() @@ -2531,7 +2531,7 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None, with_separa # see https://pagure.io/koji/issue/588 for background rpms, builds = readTaggedRPMS(tag_id, event=event_id, inherit=True, latest=latest) groups = readTagGroups(tag_id, event=event_id, inherit=True) - blocks = [pkg for pkg in readPackageList(tag_id, event=event_id, inherit=True).values() \ + blocks = [pkg for pkg in readPackageList(tag_id, event=event_id, inherit=True).values() if pkg['blocked']] repodir = koji.pathinfo.repo(repo_id, tinfo['name']) os.makedirs(repodir) # should not already exist @@ -2740,7 +2740,7 @@ def repo_set_state(repo_id, state, check=True): q = """SELECT state FROM repo WHERE id = %(repo_id)s FOR UPDATE""" oldstate = _singleValue(q, locals()) if oldstate > state: - raise koji.GenericError("Invalid repo state transition %s->%s" \ + raise koji.GenericError("Invalid repo state transition %s->%s" % (oldstate, state)) q = """UPDATE repo SET state=%(state)s WHERE id = %(repo_id)s""" _dml(q, locals()) @@ -3631,10 +3631,10 @@ def add_external_repo_to_tag(tag_info, repo_info, priority, merge_mode='koji'): tag_repos = get_tag_external_repos(tag_info=tag_id) if [tr for tr in tag_repos if tr['external_repo_id'] == repo_id]: - raise koji.GenericError('tag %s already associated with external repo %s' % \ + raise koji.GenericError('tag %s already associated with external repo %s' % (tag['name'], repo['name'])) if [tr for tr in tag_repos if tr['priority'] == priority]: - raise koji.GenericError('tag %s already associated with an external repo at priority %i' % \ + raise koji.GenericError('tag %s already associated with an external repo at priority %i' % (tag['name'], priority)) insert = InsertProcessor('tag_external_repos') @@ -3655,7 +3655,7 @@ def remove_external_repo_from_tag(tag_info, repo_info): repo_id = repo['id'] if not get_tag_external_repos(tag_info=tag_id, repo_info=repo_id): - raise koji.GenericError('external repo %s not associated with tag %s' % \ + raise koji.GenericError('external repo %s not associated with tag %s' % (repo['name'], tag['name'])) update = UpdateProcessor('tag_external_repos', values=locals(), @@ -3677,7 +3677,7 @@ def edit_tag_external_repo(tag_info, repo_info, priority): tag_repos = get_tag_external_repos(tag_info=tag_id, repo_info=repo_id) if not tag_repos: - raise koji.GenericError('external repo %s not associated with tag %s' % \ + raise koji.GenericError('external repo %s not associated with tag %s' % (repo['name'], tag['name'])) tag_repo = tag_repos[0] @@ -5764,7 +5764,7 @@ def import_build(srpm, rpms, brmap=None, task_id=None, build_id=None, logs=None) if build[key] != binfo[key]: raise koji.GenericError("Unable to complete build: %s mismatch (build: %s, rpm: %s)" % (key, binfo[key], build[key])) if binfo['state'] != koji.BUILD_STATES['BUILDING']: - raise koji.GenericError("Unable to complete build: state is %s" \ + raise koji.GenericError("Unable to complete build: state is %s" % koji.BUILD_STATES[binfo['state']]) # update build state update = UpdateProcessor('build', clauses=['id=%(id)s'], values=binfo) @@ -5844,10 +5844,10 @@ def import_rpm(fn, buildinfo=None, brootid=None, wrapper=False, fileinfo=None): # itself (for the srpm) if rpminfo['sourcepackage'] != 1: if rpminfo['sourcerpm'] != srpmname: - raise koji.GenericError("srpm mismatch for %s: %s (expected %s)" \ + raise koji.GenericError("srpm mismatch for %s: %s (expected %s)" % (fn, rpminfo['sourcerpm'], srpmname)) elif basename != srpmname: - raise koji.GenericError("srpm mismatch for %s: %s (expected %s)" \ + raise koji.GenericError("srpm mismatch for %s: %s (expected %s)" % (fn, basename, srpmname)) # if we're adding an rpm to it, then this build is of rpm type @@ -6620,7 +6620,7 @@ def add_external_rpm(rpminfo, external_repo, strict=True): if strict: raise koji.GenericError("external rpm already exists: %s" % disp) elif data['payloadhash'] != previous['payloadhash']: - raise koji.GenericError("hash changed for external rpm: %s (%s -> %s)" \ + raise koji.GenericError("hash changed for external rpm: %s (%s -> %s)" % (disp, previous['payloadhash'], data['payloadhash'])) else: return previous @@ -6721,7 +6721,7 @@ def merge_scratch(task_id): srpm = srpm_name else: if srpm != srpm_name: - raise koji.ImportError('task srpm names do not match: %s, %s' % \ + raise koji.ImportError('task srpm names do not match: %s, %s' % (srpm, srpm_name)) elif output.endswith('.noarch.rpm'): continue @@ -6730,7 +6730,7 @@ def merge_scratch(task_id): if 'arch' not in info: info['arch'] = rpminfo['arch'] elif info['arch'] != rpminfo['arch']: - raise koji.ImportError('multiple arches generated by task %s: %s, %s' % \ + raise koji.ImportError('multiple arches generated by task %s: %s, %s' % (child['id'], info['arch'], rpminfo['arch'])) info['rpms'].append(output) elif output.endswith('.log'): @@ -6752,7 +6752,7 @@ def merge_scratch(task_id): build_nvr = koji.parse_NVRA(srpm) build = get_build(build_nvr) if not build: - raise koji.ImportError('no such build: %(name)s-%(version)s-%(release)s' % \ + raise koji.ImportError('no such build: %(name)s-%(version)s-%(release)s' % build_nvr) if build['state'] != koji.BUILD_STATES['COMPLETE']: raise koji.ImportError('%s did not complete successfully' % build['nvr']) @@ -6765,14 +6765,14 @@ def merge_scratch(task_id): # compare the task and build and make sure they are compatible with importing if task_info['request'][0] != build_task_info['request'][0]: - raise koji.ImportError('SCM URLs for the task and build do not match: %s, %s' % \ + raise koji.ImportError('SCM URLs for the task and build do not match: %s, %s' % (task_info['request'][0], build_task_info['request'][0])) build_arches = set() for rpminfo in list_rpms(buildID=build['id']): if rpminfo['arch'] == 'src': build_srpm = '%s.src.rpm' % rpminfo['nvr'] if srpm != build_srpm: - raise koji.ImportError('task and build srpm names do not match: %s, %s' % \ + raise koji.ImportError('task and build srpm names do not match: %s, %s' % (srpm, build_srpm)) elif rpminfo['arch'] == 'noarch': continue @@ -6783,7 +6783,7 @@ def merge_scratch(task_id): task_arches = set([t['arch'] for t in tasks.values()]) overlapping_arches = task_arches.intersection(build_arches) if overlapping_arches: - raise koji.ImportError('task %s and %s produce rpms with the same arches: %s' % \ + raise koji.ImportError('task %s and %s produce rpms with the same arches: %s' % (task_info['id'], build['nvr'], ', '.join(overlapping_arches))) # everything looks good, do the import @@ -6905,7 +6905,7 @@ def new_maven_build(build, maven_info): # already exists, verify that it matches for field in ('group_id', 'artifact_id', 'version'): if current_maven_info[field] != maven_info[field]: - raise koji.BuildError('%s mismatch (current: %s, new: %s)' % \ + raise koji.BuildError('%s mismatch (current: %s, new: %s)' % (field, current_maven_info[field], maven_info[field])) else: maven_info['build_id'] = build['id'] @@ -7081,11 +7081,11 @@ def import_archive_internal(filepath, buildinfo, type, typeInfo, buildroot_id=No pom_maveninfo = koji.pom_to_maven_info(pom_info) # sanity check: Maven info from pom must match the user-supplied typeInfo if koji.mavenLabel(pom_maveninfo) != koji.mavenLabel(typeInfo): - raise koji.BuildError('Maven info from .pom file (%s) does not match user-supplied typeInfo (%s)' % \ + raise koji.BuildError('Maven info from .pom file (%s) does not match user-supplied typeInfo (%s)' % (koji.mavenLabel(pom_maveninfo), koji.mavenLabel(typeInfo))) # sanity check: the filename of the pom file must match -.pom if filename != '%(artifact_id)s-%(version)s.pom' % typeInfo: - raise koji.BuildError('Maven info (%s) is not consistent with pom filename (%s)' % \ + raise koji.BuildError('Maven info (%s) is not consistent with pom filename (%s)' % (koji.mavenLabel(typeInfo), filename)) insert = InsertProcessor('maven_archives', data=dslice(typeInfo, ('group_id', 'artifact_id', 'version'))) @@ -7185,7 +7185,7 @@ def add_rpm_sig(an_rpm, sighdr): # calling function should perform permission checks, if applicable rinfo = get_rpm(an_rpm, strict=True) if rinfo['external_repo_id']: - raise koji.GenericError("Not an internal rpm: %s (from %s)" \ + raise koji.GenericError("Not an internal rpm: %s (from %s)" % (an_rpm, rinfo['external_repo_name'])) binfo = get_build(rinfo['build_id']) builddir = koji.pathinfo.build(binfo) @@ -7302,7 +7302,7 @@ def check_rpm_sig(an_rpm, sigkey, sighdr): else: found_key = koji.get_sigpacket_key_id(raw_key) if sigkey != found_key: - raise koji.GenericError("Signature key mismatch: got %s, expected %s" \ + raise koji.GenericError("Signature key mismatch: got %s, expected %s" % (found_key, sigkey)) os.unlink(temp) @@ -7323,7 +7323,7 @@ def write_signed_rpm(an_rpm, sigkey, force=False): """Write a signed copy of the rpm""" rinfo = get_rpm(an_rpm, strict=True) if rinfo['external_repo_id']: - raise koji.GenericError("Not an internal rpm: %s (from %s)" \ + raise koji.GenericError("Not an internal rpm: %s (from %s)" % (an_rpm, rinfo['external_repo_name'])) binfo = get_build(rinfo['build_id']) nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % rinfo @@ -12333,7 +12333,7 @@ class RootExports(object): orig_notif = self.getBuildNotification(id, strict=True) if not (orig_notif['user_id'] == currentUser['id'] or self.hasPerm('admin')): - raise koji.GenericError('user %i cannot update notifications for user %i' % \ + raise koji.GenericError('user %i cannot update notifications for user %i' % (currentUser['id'], orig_notif['user_id'])) # sanitize input @@ -12367,7 +12367,7 @@ class RootExports(object): raise koji.GenericError('invalid user ID: %s' % user_id) if not (notificationUser['id'] == currentUser['id'] or self.hasPerm('admin')): - raise koji.GenericError('user %s cannot create notifications for user %s' % \ + raise koji.GenericError('user %s cannot create notifications for user %s' % (currentUser['name'], notificationUser['name'])) # sanitize input @@ -12402,7 +12402,7 @@ class RootExports(object): if not (notification['user_id'] == currentUser['id'] or self.hasPerm('admin')): - raise koji.GenericError('user %i cannot delete notifications for user %i' % \ + raise koji.GenericError('user %i cannot delete notifications for user %i' % (currentUser['id'], notification['user_id'])) delete = """DELETE FROM build_notifications WHERE id = %(id)i""" _dml(delete, locals()) @@ -12420,7 +12420,7 @@ class RootExports(object): raise koji.GenericError('invalid user ID: %s' % user_id) if not (notificationUser['id'] == currentUser['id'] or self.hasPerm('admin')): - raise koji.GenericError('user %s cannot create notification blocks for user %s' % \ + raise koji.GenericError('user %s cannot create notification blocks for user %s' % (currentUser['name'], notificationUser['name'])) # sanitize input @@ -12449,7 +12449,7 @@ class RootExports(object): if not (block['user_id'] == currentUser['id'] or self.hasPerm('admin')): - raise koji.GenericError('user %i cannot delete notification blocks for user %i' % \ + raise koji.GenericError('user %i cannot delete notification blocks for user %i' % (currentUser['id'], block['user_id'])) delete = """DELETE FROM build_notifications_block WHERE id = %(id)i""" _dml(delete, locals()) @@ -12662,7 +12662,7 @@ class BuildRoot(object): def assertTask(self, task_id): self.assertStandard() if not self.verifyTask(task_id): - raise koji.ActionNotAllowed('Task %s does not have lock on buildroot %s' \ + raise koji.ActionNotAllowed('Task %s does not have lock on buildroot %s' % (task_id, self.id)) def verifyHost(self, host_id): @@ -12672,7 +12672,7 @@ class BuildRoot(object): def assertHost(self, host_id): self.assertStandard() if not self.verifyHost(host_id): - raise koji.ActionNotAllowed("Host %s not owner of buildroot %s" \ + raise koji.ActionNotAllowed("Host %s not owner of buildroot %s" % (host_id, self.id)) def setState(self, state): @@ -13529,7 +13529,7 @@ class HostExports(object): build_info = get_build(build_id, strict=True) if build_info['state'] != koji.BUILD_STATES['COMPLETE']: - raise koji.GenericError('cannot import wrapper rpms for %s: build state is %s, not complete' % \ + raise koji.GenericError('cannot import wrapper rpms for %s: build state is %s, not complete' % (koji.buildLabel(build_info), koji.BUILD_STATES[build_info['state']].lower())) if list_rpms(buildID=build_info['id']): @@ -13665,10 +13665,10 @@ class HostExports(object): result = _singleRow(query, locals(), ('state', 'completion_time')) if result['state'] != koji.BUILD_STATES['BUILDING']: - raise koji.GenericError('cannot update build %i, state: %s' % \ + raise koji.GenericError('cannot update build %i, state: %s' % (build_id, koji.BUILD_STATES[result['state']])) elif result['completion_time'] is not None: - raise koji.GenericError('cannot update build %i, completed at %s' % \ + raise koji.GenericError('cannot update build %i, completed at %s' % (build_id, result['completion_time'])) update = """UPDATE build @@ -13943,7 +13943,7 @@ class HostExports(object): logger.error("Build supplies %i archives: %r", len(build_archives), to_list(build_archives.keys())) if tag_archive: logger.error("Size mismatch, br: %i, db: %i", fileinfo['size'], tag_archive['size']) - raise koji.BuildrootError('Unknown file in build environment: %s, size: %s' % \ + raise koji.BuildrootError('Unknown file in build environment: %s, size: %s' % ('%s/%s' % (fileinfo['path'], fileinfo['filename']), fileinfo['size'])) return br.updateArchiveList(archives, project) diff --git a/koji/__init__.py b/koji/__init__.py index 20cb3be..1f26689 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -716,7 +716,7 @@ class RawHeader(object): print("Data: %r" % self.header[next:pos]) elif pos < next: print("** OVERLAPPING entries") - print("Tag: %d [%s], Type: %d, Offset: %x, Count: %d" \ + print("Tag: %d [%s], Type: %d, Offset: %x, Count: %d" % (tag, tags.get(tag, '?'), dtype, offset, count)) if dtype == 0: # null @@ -1777,12 +1777,12 @@ def _check_rpm_file(fo): try: hdr = ts.hdrFromFdno(fo.fileno()) except rpm.error as ex: - raise GenericError("rpm's header can't be extracted: %s (rpm error: %s)" % \ + raise GenericError("rpm's header can't be extracted: %s (rpm error: %s)" % (fo.name, ', '.join(ex.args))) try: rpm.TransactionSet().hdrCheck(hdr.unload()) except rpm.error as ex: - raise GenericError("rpm's header can't be checked: %s (rpm error: %s)" % \ + raise GenericError("rpm's header can't be checked: %s (rpm error: %s)" % (fo.name, ', '.join(ex.args))) fo.seek(0) @@ -2932,7 +2932,7 @@ class ClientSession(object): if result['size'] != len(chunk): raise GenericError("server returned wrong chunk size: %s != %s" % (result['size'], len(chunk))) if result['hexdigest'] != hexdigest: - raise GenericError('upload checksum failed: %s != %s' \ + raise GenericError('upload checksum failed: %s != %s' % (result['hexdigest'], hexdigest)) ofs += len(chunk) now = time.time() @@ -2952,10 +2952,10 @@ class ClientSession(object): if result is None: raise GenericError("File upload failed: %s/%s" % (path, name)) if int(result['size']) != ofs: - raise GenericError("Uploaded file is wrong length: %s/%s, %s != %s" \ + raise GenericError("Uploaded file is wrong length: %s/%s, %s != %s" % (path, name, result['size'], ofs)) if problems and result['hexdigest'] != full_chksum.hexdigest(): - raise GenericError("Uploaded file has wrong checksum: %s/%s, %s != %s" \ + raise GenericError("Uploaded file has wrong checksum: %s/%s, %s != %s" % (path, name, result['hexdigest'], full_chksum.hexdigest())) self.logger.debug("Fast upload: %s complete. %i bytes in %.1f seconds", localfile, size, t2) diff --git a/koji/auth.py b/koji/auth.py index 124c1b3..420c6f5 100644 --- a/koji/auth.py +++ b/koji/auth.py @@ -137,7 +137,7 @@ class Session(object): lastcall = session_data['callnum'] if lastcall is not None: if lastcall > callnum: - raise koji.SequenceError("%d > %d (session %d)" \ + raise koji.SequenceError("%d > %d (session %d)" % (lastcall, callnum, id)) elif lastcall == callnum: # Some explanation: @@ -151,7 +151,7 @@ class Session(object): method = getattr(context, 'method', 'UNKNOWN') if method not in RetryWhitelist: raise koji.RetryError( - "unable to retry call %d (method %s) for session %d" \ + "unable to retry call %d (method %s) for session %d" % (callnum, method, id)) # read user data diff --git a/koji/daemon.py b/koji/daemon.py index 892182b..2e4c574 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -412,7 +412,7 @@ class SCM(object): _count[0] += 1 if log_output(session, cmd[0], cmd, logfile, uploadpath, cwd=chdir, logerror=1, append=append, env=env): - raise koji.BuildError('Error running %s command "%s", see %s for details' % \ + raise koji.BuildError('Error running %s command "%s", see %s for details' % (self.scmtype, ' '.join(cmd), os.path.basename(logfile))) if self.scmtype == 'CVS': diff --git a/plugins/builder/runroot.py b/plugins/builder/runroot.py index ff4d6bc..31552c0 100644 --- a/plugins/builder/runroot.py +++ b/plugins/builder/runroot.py @@ -281,7 +281,7 @@ class RunRootTask(koji.tasks.BaseTaskHandler): koji.ensuredir(mpoint) status = log_output(self.session, cmd[0], cmd, logfile, uploadpath, logerror=True, append=True) if not isSuccess(status): - error = koji.GenericError("Unable to mount %s: %s" \ + error = koji.GenericError("Unable to mount %s: %s" % (mpoint, parseStatus(status, cmd))) break fslog.write("%s\n" % mpoint) diff --git a/plugins/hub/rpm2maven.py b/plugins/hub/rpm2maven.py index b677740..a03a5de 100644 --- a/plugins/hub/rpm2maven.py +++ b/plugins/hub/rpm2maven.py @@ -65,8 +65,8 @@ def expand_rpm(filepath, tmpdir): stdout=devnull, stderr=devnull, close_fds=True) if rpm2cpio.wait() != 0 or cpio.wait() != 0: - raise koji.CallbackError('error extracting files from %s, ' \ - 'rpm2cpio returned %s, cpio returned %s' % \ + raise koji.CallbackError('error extracting files from %s, ' + 'rpm2cpio returned %s, cpio returned %s' % (filepath, rpm2cpio.wait(), cpio.wait())) devnull.close() diff --git a/plugins/hub/runroot_hub.py b/plugins/hub/runroot_hub.py index 21e9584..0a3e28a 100644 --- a/plugins/hub/runroot_hub.py +++ b/plugins/hub/runroot_hub.py @@ -56,7 +56,7 @@ def runroot(tagInfo, arch, command, channel=None, **opts): chanarches = get_channel_arches(taskopts['channel']) choices = [x for x in tagarches if x in chanarches] if not choices: - raise koji.GenericError('no common arches for tag/channel: %s/%s' \ + raise koji.GenericError('no common arches for tag/channel: %s/%s' % (tagInfo, taskopts['channel'])) taskopts['arch'] = koji.canonArch(random.choice(choices)) diff --git a/plugins/hub/save_failed_tree.py b/plugins/hub/save_failed_tree.py index 59881a3..beb18e6 100644 --- a/plugins/hub/save_failed_tree.py +++ b/plugins/hub/save_failed_tree.py @@ -42,7 +42,7 @@ def saveFailedTree(buildrootID, full=False, **opts): if task_info['state'] != koji.TASK_STATES['FAILED']: raise koji.PreBuildError("Task %s has not failed. Only failed tasks can upload their buildroots." % taskID) elif allowed_methods != '*' and task_info['method'] not in allowed_methods: - raise koji.PreBuildError("Only %s tasks can upload their buildroots (Task %s is %s)." % \ + raise koji.PreBuildError("Only %s tasks can upload their buildroots (Task %s is %s)." % (', '.join(allowed_methods), task_info['id'], task_info['method'])) elif task_info["owner"] != context.session.user_id and not context.session.hasPerm('admin'): raise koji.ActionNotAllowed("Only owner of failed task or 'admin' can run this task.") diff --git a/util/koji-shadow b/util/koji-shadow index 3377b4d..69262e0 100755 --- a/util/koji-shadow +++ b/util/koji-shadow @@ -1175,7 +1175,7 @@ class BuildTracker(object): build.updateState() ret = True if build.state != 'common': - log("Task %i finished, but %s still missing" \ + log("Task %i finished, but %s still missing" % (build.task_id, build.nvr)) return ret diff --git a/vm/kojikamid.py b/vm/kojikamid.py index 8f231a0..1b12120 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -200,8 +200,8 @@ class WindowsBuild(object): def applyPatches(self, sourcedir, patchdir): """Apply patches in patchdir to files in sourcedir)""" - patches = [patch for patch in os.listdir(patchdir) if \ - os.path.isfile(os.path.join(patchdir, patch)) and \ + patches = [patch for patch in os.listdir(patchdir) if + os.path.isfile(os.path.join(patchdir, patch)) and patch.endswith('.patch')] if not patches: raise BuildError('no patches found at %s' % patchdir) # noqa: F821 diff --git a/vm/kojivmd b/vm/kojivmd index 82dacf6..fc5dfdc 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -383,10 +383,10 @@ class WinBuildTask(MultiPlatformTask): if not opts.get('skip_tag'): # Make sure package is on the list for this tag if pkg_cfg is None: - raise koji.BuildError("package %s not in list for tag %s" \ + raise koji.BuildError("package %s not in list for tag %s" % (build_info['name'], dest_tag['name'])) elif pkg_cfg['blocked']: - raise koji.BuildError("package %s is blocked for tag %s" \ + raise koji.BuildError("package %s is blocked for tag %s" % (build_info['name'], dest_tag['name'])) build_info = self.session.host.initWinBuild(self.id, build_info, @@ -456,7 +456,7 @@ class VMExecTask(BaseTaskHandler): output, dummy = proc.communicate() ret = proc.wait() if ret: - raise koji.BuildError('unable to create qcow2 image, "%s" returned %s; output was: %s' % \ + raise koji.BuildError('unable to create qcow2 image, "%s" returned %s; output was: %s' % (' '.join(cmd), ret, output)) vm_user = pwd.getpwnam(self.options.vmuser) os.chown(new_path, vm_user.pw_uid, vm_user.pw_gid) @@ -712,7 +712,7 @@ class VMExecTask(BaseTaskHandler): os.path.basename(fileinfo['localpath']), fileinfo['payloadhash'], payloadhash)) if not koji.util.check_sigmd5(localpath): - raise koji.BuildError("Downloaded rpm %s doesn't match sigmd5" % \ + raise koji.BuildError("Downloaded rpm %s doesn't match sigmd5" % os.path.basename(fileinfo['localpath'])) else: self.verifyChecksum(localpath, fileinfo['checksum'], koji.CHECKSUM_TYPES[fileinfo['checksum_type']]) @@ -752,7 +752,7 @@ class VMExecTask(BaseTaskHandler): raise koji.BuildError('% does not exist' % local_path) size = os.path.getsize(local_path) if offset != size: - raise koji.BuildError('cannot write to %s at offset %s, size is %s' % \ + raise koji.BuildError('cannot write to %s at offset %s, size is %s' % (local_path, offset, size)) fobj = open(local_path, 'r+') fobj.seek(offset) @@ -796,7 +796,7 @@ class VMExecTask(BaseTaskHandler): if sum.hexdigest() == checksum: return True else: - raise koji.BuildError('%s checksum validation failed for %s, %s (computed) != %s (provided)' % \ + raise koji.BuildError('%s checksum validation failed for %s, %s (computed) != %s (provided)' % (algo, local_path, sum.hexdigest(), checksum)) def closeTask(self, output): @@ -861,7 +861,7 @@ class VMExecTask(BaseTaskHandler): self.logger.info('Started VM %s', clone_name) except libvirt.libvirtError as e: self.logger.error('error starting VM %s', clone_name, exc_info=True) - raise koji.PreBuildError('error starting VM %s, error was: %s' % \ + raise koji.PreBuildError('error starting VM %s, error was: %s' % (clone_name, e)) start = time.time() @@ -879,7 +879,7 @@ class VMExecTask(BaseTaskHandler): if mins > timeout: vm.destroy() self.server.server_close() - raise koji.BuildError('Task did not complete after %.2f minutes, VM %s has been destroyed' % \ + raise koji.BuildError('Task did not complete after %.2f minutes, VM %s has been destroyed' % (mins, clone_name)) else: vm.destroy() diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index dd128a3..24e712d 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -1105,7 +1105,7 @@ def tagparent(environ, tagID, parentID, action): if datum['priority'] > maxPriority: maxPriority = datum['priority'] values['maxPriority'] = maxPriority - inheritanceData = [datum for datum in inheritanceData \ + inheritanceData = [datum for datum in inheritanceData if datum['parent_id'] == parent['id']] if len(inheritanceData) == 0: values['inheritanceData'] = None @@ -1775,7 +1775,7 @@ def rpmlist(environ, type, buildrootID=None, imageID=None, start=None, order='nv # If/When future image types are supported, add elifs here if needed. if type == 'image': kojiweb.util.paginateMethod(server, values, 'listRPMs', - kw={'imageID': imageID}, \ + kw={'imageID': imageID}, start=start, dataName='rpms', prefix='rpm', order=order) else: