diff options
Diffstat (limited to 'MgaRepo/commands/cancel.py')
-rw-r--r-- | MgaRepo/commands/cancel.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/MgaRepo/commands/cancel.py b/MgaRepo/commands/cancel.py new file mode 100644 index 0000000..899f0d5 --- /dev/null +++ b/MgaRepo/commands/cancel.py @@ -0,0 +1,64 @@ +#!/usr/bin/python +from MgaRepo import Error, config, layout, mirror +from MgaRepo.svn import SVN +from MgaRepo.command import * +from MgaRepo.rpmutil import get_spec, get_submit_info +from MgaRepo.util import get_auth, execcmd, get_helper +import urllib.request, urllib.parse, urllib.error +import getopt +import sys +import re +import subprocess +import uuid + +import xmlrpc.client + +HELP = """\ +Usage: mgarepo cancel [OPTIONS] [PACKAGE_SUBMISSION] + +Options: + -l cancel the last submission + +Examples: + mgarepo cancel -l + mgarepo cancel cauldron/core/release/20231231235959.pterjan.duvel.424242 +""" + +DEFAULT_TARGET = "cauldron" + + +def parse_options(): + parser = OptionParser(help=HELP) + parser.add_option("-l", dest="last", default=None) + opts, args = parser.parse_args() + opts.url = args[0] + return opts + +def cancel(url, last = False, submithost=None): + if submithost is None: + submithost = config.get("submit", "host") + if submithost is None: + # extract the submit host from the svn host + type, rest = urllib.parse.splittype(pkgdirurl) + host, path = urllib.parse.splithost(rest) + user, host = urllib.parse.splituser(host) + submithost, port = urllib.parse.splitport(host) + del type, user, port, path, rest + print(f"Trying to cancel {url}") + # runs a cancel_build in the server through ssh + cancel_build = get_helper("cancel_build") + command = ["ssh", submithost, cancel_build, url] + print(command) + status, output = execcmd(*command) + if status == 0: + print("Package canceled!") + else: + sys.stderr.write(output) + sys.exit(status) + + +def main(): + do_command(parse_options, cancel) + + +# vim:et:ts=4:sw=4 |