1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/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 sys
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 last:
print("This option is not yet working")
return
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
|