flake8: apply E501 with max-line-length=99
This commit is contained in:
parent
f1ba6cefd7
commit
c5db34a8e1
28 changed files with 1574 additions and 811 deletions
|
|
@ -47,7 +47,8 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
options.append(o)
|
||||
rel_path = path[len(mount_data['mountpoint']):]
|
||||
rel_path = rel_path[1:] if rel_path.startswith('/') else rel_path
|
||||
res = (os.path.join(mount_data['path'], rel_path), path, mount_data['fstype'], ','.join(options))
|
||||
res = (os.path.join(mount_data['path'], rel_path), path, mount_data['fstype'],
|
||||
','.join(options))
|
||||
return res
|
||||
|
||||
def _read_config(self):
|
||||
|
|
@ -94,11 +95,15 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
except six.moves.configparser.NoOptionError:
|
||||
raise koji.GenericError("bad config: missing options in %s section" % section_name)
|
||||
|
||||
for path in self.config['default_mounts'] + self.config['safe_roots'] + [x[0] for x in self.config['path_subs']]:
|
||||
for path in self.config['default_mounts'] + self.config['safe_roots'] + \
|
||||
[x[0] for x in self.config['path_subs']]:
|
||||
if not path.startswith('/'):
|
||||
raise koji.GenericError("bad config: all paths (default_mounts, safe_roots, path_subs) needs to be absolute: %s" % path)
|
||||
raise koji.GenericError(
|
||||
"bad config: all paths (default_mounts, safe_roots, path_subs) needs to be "
|
||||
"absolute: %s" % path)
|
||||
|
||||
def handler(self, root, arch, command, keep=False, packages=[], mounts=[], repo_id=None, skip_setarch=False, weight=None, upload_logs=None, new_chroot=None):
|
||||
def handler(self, root, arch, command, keep=False, packages=[], mounts=[], repo_id=None,
|
||||
skip_setarch=False, weight=None, upload_logs=None, new_chroot=None):
|
||||
"""Create a buildroot and run a command (as root) inside of it
|
||||
|
||||
Command may be a string or a list.
|
||||
|
|
@ -141,15 +146,19 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
break
|
||||
else:
|
||||
# no overlap
|
||||
raise koji.BuildError("host does not match tag arches: %s (%s)" % (root, tag_arches))
|
||||
raise koji.BuildError(
|
||||
"host does not match tag arches: %s (%s)" % (root, tag_arches))
|
||||
else:
|
||||
br_arch = arch
|
||||
if repo_id:
|
||||
repo_info = self.session.repoInfo(repo_id, strict=True)
|
||||
if repo_info['tag_name'] != root:
|
||||
raise koji.BuildError("build tag (%s) does not match repo tag (%s)" % (root, repo_info['tag_name']))
|
||||
raise koji.BuildError(
|
||||
"build tag (%s) does not match repo tag (%s)" % (root, repo_info['tag_name']))
|
||||
if repo_info['state'] not in (koji.REPO_STATES['READY'], koji.REPO_STATES['EXPIRED']):
|
||||
raise koji.BuildError("repos in the %s state may not be used by runroot" % koji.REPO_STATES[repo_info['state']])
|
||||
raise koji.BuildError(
|
||||
"repos in the %s state may not be used by runroot" %
|
||||
koji.REPO_STATES[repo_info['state']])
|
||||
else:
|
||||
repo_info = self.session.getRepo(root)
|
||||
if not repo_info:
|
||||
|
|
@ -186,12 +195,15 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
cmdstr = ' '.join(["'%s'" % arg.replace("'", r"'\''") for arg in command])
|
||||
# A nasty hack to put command output into its own file until mock can be
|
||||
# patched to do something more reasonable than stuff everything into build.log
|
||||
cmdargs = ['/bin/sh', '-c', "{ %s; } < /dev/null 2>&1 | /usr/bin/tee /builddir/runroot.log; exit ${PIPESTATUS[0]}" % cmdstr]
|
||||
cmdargs = ['/bin/sh', '-c',
|
||||
"{ %s; } < /dev/null 2>&1 | /usr/bin/tee /builddir/runroot.log; exit "
|
||||
"${PIPESTATUS[0]}" % cmdstr]
|
||||
|
||||
# always mount /mnt/redhat (read-only)
|
||||
# always mount /mnt/iso (read-only)
|
||||
# also need /dev bind mount
|
||||
self.do_mounts(rootdir, [self._get_path_params(x) for x in self.config['default_mounts']])
|
||||
self.do_mounts(rootdir,
|
||||
[self._get_path_params(x) for x in self.config['default_mounts']])
|
||||
self.do_extra_mounts(rootdir, mounts)
|
||||
mock_cmd = ['chroot']
|
||||
if new_chroot:
|
||||
|
|
@ -199,7 +211,8 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
elif new_chroot is False: # None -> no option added
|
||||
mock_cmd.append('--old-chroot')
|
||||
if skip_setarch:
|
||||
# we can't really skip it, but we can set it to the current one instead of of the chroot one
|
||||
# we can't really skip it, but we can set it to the current one instead of of the
|
||||
# chroot one
|
||||
myarch = platform.uname()[5]
|
||||
mock_cmd.extend(['--arch', myarch])
|
||||
mock_cmd.append('--')
|
||||
|
|
@ -279,7 +292,8 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
cmd = ['mount', '-t', type, '-o', opts, dev, mpoint]
|
||||
self.logger.info("Mount command: %r" % cmd)
|
||||
koji.ensuredir(mpoint)
|
||||
status = log_output(self.session, cmd[0], cmd, logfile, uploadpath, logerror=True, append=True)
|
||||
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"
|
||||
% (mpoint, parseStatus(status, cmd)))
|
||||
|
|
@ -306,7 +320,8 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
failed = []
|
||||
self.logger.info("Unmounting (runroot): %s" % mounts)
|
||||
for dir in mounts:
|
||||
proc = subprocess.Popen(["umount", "-l", dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
proc = subprocess.Popen(["umount", "-l", dir],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if proc.wait() != 0:
|
||||
output = proc.stdout.read()
|
||||
output += proc.stderr.read()
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ def handle_runroot(options, session, args):
|
|||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.disable_interspersed_args()
|
||||
parser.add_option("-p", "--package", action="append", default=[], help=_("make sure this package is in the chroot"))
|
||||
parser.add_option("-m", "--mount", action="append", default=[], help=_("mount this directory read-write in the chroot"))
|
||||
parser.add_option("-p", "--package", action="append", default=[],
|
||||
help=_("make sure this package is in the chroot"))
|
||||
parser.add_option("-m", "--mount", action="append", default=[],
|
||||
help=_("mount this directory read-write in the chroot"))
|
||||
parser.add_option("--skip-setarch", action="store_true", default=False,
|
||||
help=_("bypass normal setarch in the chroot"))
|
||||
parser.add_option("-w", "--weight", type='int', help=_("set task weight"))
|
||||
|
|
@ -39,7 +41,8 @@ def handle_runroot(options, session, args):
|
|||
parser.add_option("--repo-id", type="int", help=_("ID of the repo to use"))
|
||||
parser.add_option("--nowait", action="store_false", dest="wait",
|
||||
default=True, help=_("Do not wait on task"))
|
||||
parser.add_option("--watch", action="store_true", help=_("Watch task instead of printing runroot.log"))
|
||||
parser.add_option("--watch", action="store_true",
|
||||
help=_("Watch task instead of printing runroot.log"))
|
||||
parser.add_option("--quiet", action="store_true", default=options.quiet,
|
||||
help=_("Do not print the task information"))
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ def handle_save_failed_tree(options, session, args):
|
|||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option("-f", "--full", action="store_true", default=False,
|
||||
help=_("Download whole tree, if not specified, only builddir will be downloaded"))
|
||||
help=_("Download whole tree, if not specified, "
|
||||
"only builddir will be downloaded"))
|
||||
parser.add_option("-t", "--task", action="store_const", dest="mode",
|
||||
const="task", default="task",
|
||||
help=_("Treat ID as a task ID (the default)"))
|
||||
|
|
@ -69,4 +70,5 @@ def handle_save_failed_tree(options, session, args):
|
|||
return
|
||||
else:
|
||||
session.logout()
|
||||
return watch_tasks(session, [task_id], quiet=opts.quiet, poll_interval=options.poll_interval)
|
||||
return watch_tasks(session, [task_id],
|
||||
quiet=opts.quiet, poll_interval=options.poll_interval)
|
||||
|
|
|
|||
|
|
@ -40,10 +40,12 @@ def saveFailedTree(buildrootID, full=False, **opts):
|
|||
taskID = brinfo['task_id']
|
||||
task_info = kojihub.Task(taskID).getInfo()
|
||||
if task_info['state'] != koji.TASK_STATES['FAILED']:
|
||||
raise koji.PreBuildError("Task %s has not failed. Only failed tasks can upload their buildroots." % taskID)
|
||||
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)." %
|
||||
(', '.join(allowed_methods), task_info['id'], task_info['method']))
|
||||
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.")
|
||||
elif not kojihub.get_host(task_info['host_id'])['enabled']:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue