From ce1f9928afdab5f0124ad93cbfb98f0e63efdeaa Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Wed, 26 Feb 2020 02:08:41 +0800 Subject: [PATCH] flake8: apply E1 rules --- .flake8 | 2 +- builder/kojid | 454 +++++++++++----------- builder/mergerepos | 18 +- cli/koji | 4 +- cli/koji_cli/commands.py | 422 ++++++++++----------- cli/koji_cli/lib.py | 30 +- hub/kojihub.py | 652 ++++++++++++++++---------------- hub/kojixmlrpc.py | 16 +- koji/__init__.py | 66 ++-- koji/arch.py | 4 +- koji/auth.py | 10 +- koji/daemon.py | 6 +- koji/plugin.py | 2 +- koji/policy.py | 2 +- koji/tasks.py | 8 +- koji/util.py | 10 +- koji/xmlrpcplus.py | 4 +- plugins/builder/runroot.py | 20 +- plugins/cli/runroot.py | 12 +- plugins/cli/save_failed_tree.py | 12 +- plugins/hub/rpm2maven.py | 4 +- plugins/hub/runroot_hub.py | 2 +- plugins/hub/save_failed_tree.py | 2 +- util/koji-gc | 14 +- util/koji-shadow | 12 +- util/kojira | 50 +-- vm/kojikamid.py | 2 +- vm/kojivmd | 34 +- www/kojiweb/index.py | 16 +- www/lib/kojiweb/util.py | 26 +- 30 files changed, 958 insertions(+), 958 deletions(-) diff --git a/.flake8 b/.flake8 index 27b4d7f7..b20a51cc 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -select = I,C,F,E265 +select = I,C,F,E1,E265 exclude = .git, __pycache__, diff --git a/builder/kojid b/builder/kojid index a775b5d9..fd607a75 100755 --- a/builder/kojid +++ b/builder/kojid @@ -231,7 +231,7 @@ class BuildRoot(object): self.tag_name = self.config['name'] if self.config['id'] != repo_info['tag_id']: raise koji.BuildrootError("tag/repo mismatch: %s vs %s" \ - % (self.config['name'], repo_info['tag_name'])) + % (self.config['name'], repo_info['tag_name'])) repo_state = koji.REPO_STATES[repo_info['state']] if repo_state == 'EXPIRED': # This should be ok. Expired repos are still intact, just not @@ -698,7 +698,7 @@ class BuildRoot(object): 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' % \ - (relpath, ', '.join([f['filename'] for f in maven_files]))) + (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], 'artifact_id': path_comps[-2], @@ -966,7 +966,7 @@ class BuildTask(BaseTaskHandler): # make sure specified repo matches target if repo_info['tag_id'] != target_info['build_tag']: raise koji.BuildError('Repo/Target mismatch: %s/%s' \ - % (repo_info['tag_name'], target_info['build_tag_name'])) + % (repo_info['tag_name'], target_info['build_tag_name'])) else: # if repo_id is specified, we can allow the 'target' arg to simply specify # the destination tag (since the repo specifies the build tag). @@ -1022,10 +1022,10 @@ class BuildTask(BaseTaskHandler): # 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" \ - % (data['name'], target_info['dest_tag_name'])) + % (data['name'], target_info['dest_tag_name'])) elif pkg_cfg['blocked']: raise koji.BuildError("package %s is blocked for tag %s" \ - % (data['name'], target_info['dest_tag_name'])) + % (data['name'], target_info['dest_tag_name'])) # TODO - more pre tests archlist = self.getArchList(build_tag, h, extra=extra_arches) # let the system know about the build we're attempting @@ -1034,11 +1034,11 @@ class BuildTask(BaseTaskHandler): build_id = self.session.host.initBuild(data) # (initBuild raises an exception if there is a conflict) failany = (self.opts.get('fail_fast', False) - or not getattr(self.options, 'build_arch_can_fail', False)) + or not getattr(self.options, 'build_arch_can_fail', False)) try: self.extra_information = { "src": src, "data": data, "target": target } srpm,rpms,brmap,logs = self.runBuilds(srpm, build_tag, archlist, - repo_info['id'], failany=failany) + repo_info['id'], failany=failany) if opts.get('scratch'): # scratch builds do not get imported @@ -1192,8 +1192,8 @@ class BuildTask(BaseTaskHandler): archlist = [ a for a in archlist if a not in excludearch ] if not archlist: raise koji.BuildError("No valid arches were found. tag %r, " - "exclusive %r, exclude %r" % (tag_arches, - exclusivearch, excludearch)) + "exclusive %r, exclude %r" % (tag_arches, + exclusivearch, excludearch)) if set(archlist) != set(tag_arches): return random.choice(archlist) else: @@ -1256,10 +1256,10 @@ class BuildTask(BaseTaskHandler): # create the tagBuild subtask # this will handle the "post tests" task_id = self.session.host.subtask(method='tagBuild', - arglist=[dest_tag,build_id,False,None,True], - label='tag', - parent=self.id, - arch='noarch') + arglist=[dest_tag,build_id,False,None,True], + label='tag', + parent=self.id, + arch='noarch') self.wait(task_id) @@ -1506,10 +1506,10 @@ class MavenTask(MultiPlatformTask): # 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" \ - % (build_info['name'], dest_tag['name'])) + % (build_info['name'], dest_tag['name'])) elif dest_cfg['blocked']: raise koji.BuildError("package %s is blocked for tag %s" \ - % (build_info['name'], dest_tag['name'])) + % (build_info['name'], dest_tag['name'])) build_info = self.session.host.initMavenBuild(self.id, build_info, maven_info) self.build_id = build_info['id'] @@ -1666,8 +1666,8 @@ class BuildMavenTask(BaseBuildTask): 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 \ - patch.endswith('.patch')] + 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')) patches.sort() @@ -2018,10 +2018,10 @@ class WrapperRPMTask(BaseBuildTask): # 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" \ - % (data['name'], build_target['dest_tag_name'])) + % (data['name'], build_target['dest_tag_name'])) elif pkg_cfg['blocked']: raise koji.BuildError("package %s is blocked for tag %s" \ - % (data['name'], build_target['dest_tag_name'])) + % (data['name'], build_target['dest_tag_name'])) self.new_build_id = self.session.host.initBuild(data) try: @@ -2046,7 +2046,7 @@ class WrapperRPMTask(BaseBuildTask): 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' % \ - (resultdir, srpm, filename)) + (resultdir, srpm, filename)) elif filename.endswith('.rpm'): rpms.append(filename) elif filename.endswith('.log'): @@ -2055,7 +2055,7 @@ class WrapperRPMTask(BaseBuildTask): if self.new_build_id: self.session.host.failBuild(self.id, self.new_build_id) raise koji.BuildError('unexpected file found in %s: %s' % \ - (resultdir, filename)) + (resultdir, filename)) if not srpm: if self.new_build_id: @@ -2139,10 +2139,10 @@ class ChainMavenTask(MultiPlatformTask): # 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" \ - % (package, dest_tag['name'])) + % (package, dest_tag['name'])) elif dest_cfg['blocked']: raise koji.BuildError("package %s is blocked for tag %s" \ - % (package, dest_tag['name'])) + % (package, dest_tag['name'])) self.depmap = {} for package, params in builds.items(): @@ -2357,7 +2357,7 @@ class BuildImageTask(MultiPlatformTask): def initImageBuild(self, name, version, release, target_info, opts): """create a build object for this image build""" pkg_cfg = self.session.getPackageConfig(target_info['dest_tag_name'], - name) + name) self.logger.debug("%r" % pkg_cfg) if not opts.get('skip_tag') and not opts.get('scratch'): # Make sure package is on the list for this tag @@ -2366,7 +2366,7 @@ class BuildImageTask(MultiPlatformTask): elif pkg_cfg['blocked']: raise koji.BuildError("package (image) %s is blocked for tag %s" % (name, target_info['dest_tag_name'])) return self.session.host.initImageBuild(self.id, - dict(name=name, version=version, release=release, epoch=0)) + dict(name=name, version=version, release=release, epoch=0)) def getRelease(self, name, ver): """return the next available release number for an N-V""" @@ -2408,7 +2408,7 @@ class BuildBaseImageTask(BuildImageTask): raise koji.ApplianceError('The Release may not have a hyphen') if not opts.get('scratch'): bld_info = self.initImageBuild(name, version, release, - target_info, opts) + target_info, opts) subtasks = {} self.logger.debug("Spawning jobs for image arches: %r" % (arches)) @@ -2418,7 +2418,7 @@ class BuildBaseImageTask(BuildImageTask): subtasks[arch] = self.session.host.subtask( method='createImage', arglist=[name, version, release, arch, target_info, - build_tag, repo_info, inst_url, opts], + build_tag, repo_info, inst_url, opts], label=arch, parent=self.id, arch=arch) if arch in opts.get('optional_arches', []): canfail.append(subtasks[arch]) @@ -2476,7 +2476,7 @@ class BuildBaseImageTask(BuildImageTask): self.session.host.moveImageBuildToScratch(self.id, results) else: self.session.host.completeImageBuild(self.id, bld_info['id'], - results) + results) except (SystemExit,ServerExit,KeyboardInterrupt): # we do not trap these @@ -2492,8 +2492,8 @@ class BuildBaseImageTask(BuildImageTask): # tag it if not opts.get('scratch') and not opts.get('skip_tag'): tag_task_id = self.session.host.subtask(method='tagBuild', - arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], - label='tag', parent=self.id, arch='noarch') + arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], + label='tag', parent=self.id, arch='noarch') self.wait(tag_task_id) # report results @@ -2540,11 +2540,11 @@ class BuildApplianceTask(BuildImageTask): release = self.getRelease(name, version) if not opts.get('scratch'): bld_info = self.initImageBuild(name, version, release, - target_info, opts) + target_info, opts) create_task_id = self.session.host.subtask(method='createAppliance', - arglist=[name, version, release, arch, target_info, build_tag, - repo_info, ksfile, opts], - label='appliance', parent=self.id, arch=arch) + arglist=[name, version, release, arch, target_info, build_tag, + repo_info, ksfile, opts], + label='appliance', parent=self.id, arch=arch) results = self.wait(create_task_id) self.logger.info('image build task (%s) completed' % create_task_id) self.logger.info('results: %s' % results) @@ -2578,14 +2578,14 @@ class BuildApplianceTask(BuildImageTask): # tag it if not opts.get('scratch') and not opts.get('skip_tag'): tag_task_id = self.session.host.subtask(method='tagBuild', - arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], - label='tag', parent=self.id, arch='noarch') + arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], + label='tag', parent=self.id, arch='noarch') self.wait(tag_task_id) # report results if opts.get('scratch'): respath = os.path.join(koji.pathinfo.work(), - koji.pathinfo.taskrelpath(create_task_id)) + koji.pathinfo.taskrelpath(create_task_id)) report = 'Scratch ' else: respath = koji.pathinfo.imagebuild(bld_info) @@ -2613,7 +2613,7 @@ class BuildLiveCDTask(BuildImageTask): opts = {} if not image_enabled: self.logger.error("LiveCD features require the following dependencies: " - "pykickstart, pycdio, and possibly python-hashlib") + "pykickstart, pycdio, and possibly python-hashlib") raise koji.LiveCDError('LiveCD functions not available') # build the image @@ -2624,11 +2624,11 @@ class BuildLiveCDTask(BuildImageTask): release = self.getRelease(name, version) if not opts.get('scratch'): bld_info = self.initImageBuild(name, version, release, - target_info, opts) + target_info, opts) create_task_id = self.session.host.subtask(method='createLiveCD', - arglist=[name, version, release, arch, target_info, build_tag, - repo_info, ksfile, opts], - label='livecd', parent=self.id, arch=arch) + arglist=[name, version, release, arch, target_info, build_tag, + repo_info, ksfile, opts], + label='livecd', parent=self.id, arch=arch) results = self.wait(create_task_id) self.logger.info('image build task (%s) completed' % create_task_id) self.logger.info('results: %s' % results) @@ -2662,14 +2662,14 @@ class BuildLiveCDTask(BuildImageTask): # tag it if necessary if not opts.get('scratch') and not opts.get('skip_tag'): tag_task_id = self.session.host.subtask(method='tagBuild', - arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], - label='tag', parent=self.id, arch='noarch') + arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], + label='tag', parent=self.id, arch='noarch') self.wait(tag_task_id) # report the results if opts.get('scratch'): respath = os.path.join(koji.pathinfo.work(), - koji.pathinfo.taskrelpath(create_task_id)) + koji.pathinfo.taskrelpath(create_task_id)) report = 'Scratch ' else: respath = koji.pathinfo.imagebuild(bld_info) @@ -2704,7 +2704,7 @@ class BuildLiveMediaTask(BuildImageTask): if not image_enabled: # XXX - are these still required here? self.logger.error("Missing the following dependencies: " - "pykickstart, pycdio, and possibly python-hashlib") + "pykickstart, pycdio, and possibly python-hashlib") raise koji.PreBuildError('Live Media functions not available') # build the image @@ -2715,14 +2715,14 @@ class BuildLiveMediaTask(BuildImageTask): release = self.getRelease(name, version) if not opts.get('scratch'): bld_info = self.initImageBuild(name, version, release, - target_info, opts) + target_info, opts) subtasks = {} canfail = [] for arch in arches: subtasks[arch] = self.subtask('createLiveMedia', - [name, version, release, arch, target_info, build_tag, - repo_info, ksfile, opts], - label='livemedia %s' % arch, arch=arch) + [name, version, release, arch, target_info, build_tag, + repo_info, ksfile, opts], + label='livemedia %s' % arch, arch=arch) if arch in opts.get('optional_arches', []): canfail.append(subtasks[arch]) self.logger.debug("Tasks that can fail: %r", canfail) @@ -2762,9 +2762,9 @@ class BuildLiveMediaTask(BuildImageTask): if arch in ignored_arches: continue arglist = [spec_url, target_info, bld_info, tinfo, - {'repo_id': repo_info['id']}] + {'repo_id': repo_info['id']}] wrapper_tasks[arch] = self.subtask('wrapperRPM', arglist, - label='wrapper %s' % arch, arch='noarch') + label='wrapper %s' % arch, arch='noarch') results2 = self.wait(to_list(wrapper_tasks.values()), all=True, failany=True) self.logger.debug('wrapper results: %r', results2) @@ -2800,8 +2800,8 @@ class BuildLiveMediaTask(BuildImageTask): # tag it if necessary if not opts.get('scratch') and not opts.get('skip_tag'): tag_task_id = self.session.host.subtask(method='tagBuild', - arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], - label='tag', parent=self.id, arch='noarch') + arglist=[target_info['dest_tag'], bld_info['id'], False, None, True], + label='tag', parent=self.id, arch='noarch') self.wait(tag_task_id) # report the results @@ -2919,7 +2919,7 @@ class ImageTask(BaseTaskHandler): "'%s' : %s" % (kspath, e)) except kserrors.KickstartError as e: raise koji.LiveCDError("Failed to parse kickstart file " - "'%s' : %s" % (kspath, e)) + "'%s' : %s" % (kspath, e)) def prepareKickstart(self, repo_info, target_info, arch, broot, opts): """ @@ -3002,27 +3002,27 @@ class ImageTask(BaseTaskHandler): # Duplicated with pungi-fedora fedora.conf # see https://pagure.io/koji/pull-request/817 substitutions = { - 'Beta': 'B', - 'Rawhide': 'rawh', - 'Astronomy_KDE': 'AstK', - 'Atomic': 'AH', - 'Cinnamon': 'Cinn', - 'Cloud': 'C', - 'Design_suite': 'Dsgn', - 'Electronic_Lab': 'Elec', - 'Everything': 'E', + 'Beta': 'B', + 'Rawhide': 'rawh', + 'Astronomy_KDE': 'AstK', + 'Atomic': 'AH', + 'Cinnamon': 'Cinn', + 'Cloud': 'C', + 'Design_suite': 'Dsgn', + 'Electronic_Lab': 'Elec', + 'Everything': 'E', 'Games': 'Game', 'Images': 'img', 'Jam_KDE': 'Jam', - 'MATE_Compiz': 'MATE', - # Note https://pagure.io/pungi-fedora/issue/533 - 'Python-Classroom': 'Clss', - 'Python_Classroom': 'Clss', + 'MATE_Compiz': 'MATE', + # Note https://pagure.io/pungi-fedora/issue/533 + 'Python-Classroom': 'Clss', + 'Python_Classroom': 'Clss', 'Robotics': 'Robo', - 'Scientific_KDE': 'SciK', + 'Scientific_KDE': 'SciK', 'Security': 'Sec', 'Server': 'S', - 'Workstation': 'WS', + 'Workstation': 'WS', 'WorkstationOstree': 'WS', } @@ -3125,7 +3125,7 @@ class ApplianceTask(ImageTask): if not opts.get('scratch'): hdrlist = self.getImagePackages(os.path.join(broot.rootdir(), - cachedir[1:])) + cachedir[1:])) broot.markExternalRPMs(hdrlist) imgdata['rpmlist'] = hdrlist @@ -3216,7 +3216,7 @@ class LiveCDTask(ImageTask): self.opts = opts broot = self.makeImgBuildRoot(build_tag, repo_info, arch, - 'livecd-build') + 'livecd-build') kspath = self.fetchKickstart(broot, ksfile, target_info['build_tag_name']) self.readKickstart(kspath, opts) kskoji = self.prepareKickstart(repo_info, target_info, arch, broot, opts) @@ -3268,19 +3268,19 @@ class LiveCDTask(ImageTask): self.uploadFile(isosrc, remoteName=isoname) imgdata = {'arch': arch, - 'files': [isoname], - 'rootdev': None, - 'task_id': self.id, - 'logs': ['build.log', 'mock_output.log', 'root.log', 'state.log', - 'livecd.log', os.path.basename(ksfile), - os.path.basename(kskoji)], - 'name': name, - 'version': version, - 'release': release - } + 'files': [isoname], + 'rootdev': None, + 'task_id': self.id, + 'logs': ['build.log', 'mock_output.log', 'root.log', 'state.log', + 'livecd.log', os.path.basename(ksfile), + os.path.basename(kskoji)], + 'name': name, + 'version': version, + 'release': release + } if not opts.get('scratch'): hdrlist = self.getImagePackages(os.path.join(broot.rootdir(), - cachedir[1:])) + cachedir[1:])) imgdata ['rpmlist'] = hdrlist broot.markExternalRPMs(hdrlist) @@ -3397,7 +3397,7 @@ class LiveMediaTask(ImageTask): self.opts = opts broot = self.makeImgBuildRoot(build_tag, repo_info, arch, - 'livemedia-build') + 'livemedia-build') kspath = self.fetchKickstart(broot, ksfile, target_info['build_tag_name']) self.readKickstart(kspath, opts) kskoji = self.prepareKickstart(repo_info, target_info, arch, broot, opts) @@ -3415,7 +3415,7 @@ class LiveMediaTask(ImageTask): '--resultdir', resultdir, '--project', name, # '--tmp', '/tmp' - ] + ] volid = opts.get('volid') @@ -3430,12 +3430,12 @@ class LiveMediaTask(ImageTask): cmd.extend(['--make-iso', '--volid', volid, '--iso-only', - ]) + ]) isoname='%s-%s-%s-%s.iso' % (name, arch, version, release) cmd.extend(['--iso-name', isoname, '--releasever', version, - ]) + ]) if arch == 'x86_64': @@ -3453,7 +3453,7 @@ class LiveMediaTask(ImageTask): logdirs = [ os.path.join(broot.tmpdir(), 'lmc-logs'), os.path.join(broot.tmpdir(), 'lmc-logs/anaconda'), - ] + ] for logdir in logdirs: if not os.path.isdir(logdir): continue @@ -3499,16 +3499,16 @@ class LiveMediaTask(ImageTask): self.uploadFile(isosrc, remoteName=isoname) imgdata = {'arch': arch, - 'files': [isoname], - 'rootdev': None, - 'task_id': self.id, - 'logs': ['build.log', 'mock_output.log', 'root.log', 'state.log', - 'livemedia-out.log', os.path.basename(ksfile), - os.path.basename(kskoji)], - 'name': name, - 'version': version, - 'release': release - } + 'files': [isoname], + 'rootdev': None, + 'task_id': self.id, + 'logs': ['build.log', 'mock_output.log', 'root.log', 'state.log', + 'livemedia-out.log', os.path.basename(ksfile), + os.path.basename(kskoji)], + 'name': name, + 'version': version, + 'release': release + } if not opts.get('scratch'): # TODO - generate list of rpms in image # (getImagePackages doesn't work here) @@ -3549,7 +3549,7 @@ class OzImageTask(BaseTaskHandler): logfile = os.path.join(self.workdir, 'checkout-%s.log' % self.arch) self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag, scratch=self.opts.get('scratch')) scmsrcdir = scm.checkout(self.workdir, self.session, - self.getUploadDir(), logfile) + self.getUploadDir(), logfile) self.run_callbacks("postSCMCheckout", scminfo=scm.get_info(), build_tag=build_tag, @@ -3589,10 +3589,10 @@ class OzImageTask(BaseTaskHandler): ks.readKickstart(kspath) except IOError as e: raise koji.BuildError("Failed to read kickstart file " - "'%s' : %s" % (kspath, e)) + "'%s' : %s" % (kspath, e)) except kserrors.KickstartError as e: raise koji.BuildError("Failed to parse kickstart file " - "'%s' : %s" % (kspath, e)) + "'%s' : %s" % (kspath, e)) return ks def prepareKickstart(self, kspath, install_tree): @@ -3627,7 +3627,7 @@ class OzImageTask(BaseTaskHandler): # --repo was not given, so we use the target's build repo path_info = koji.PathInfo(topdir=self.options.topurl) repopath = path_info.repo(self.repo_info['id'], - self.target_info['build_tag_name']) + self.target_info['build_tag_name']) baseurl = '%s/%s' % (repopath, self.arch) self.logger.debug('BASEURL: %s' % baseurl) ks.handler.repo.repoList.append(repo_class( @@ -3686,7 +3686,7 @@ class OzImageTask(BaseTaskHandler): 'rhevm_image_format': 'qcow2', 'tdl_require_root_pw': False, 'image_manager_args': { - 'storage_path': os.path.join(self.workdir, 'output_image')}, + 'storage_path': os.path.join(self.workdir, 'output_image')}, } def makeTemplate(self, name, inst_tree): @@ -3705,9 +3705,9 @@ class OzImageTask(BaseTaskHandler): # TODO: intelligently guess the distro based on the install tree URL distname, distver = self.parseDistro(self.opts.get('distro')) if self.arch in ['armhfp','armv7hnl','armv7hl']: - arch = 'armv7l' + arch = 'armv7l' else: - arch = self.arch + arch = self.arch template = """