Skip to content
Snippets Groups Projects

Added mpcdf_build_status

Merged Tobias Melson requested to merge mpcdf_build_status into master
+ 69
0
#!/usr/bin/python3
import os
import osc
import osc.conf
import osc.core
from xml.etree import ElementTree
def do_mpcdf_build_status(self, subcmd, opts, *args):
"""${cmd_name}: List build statuses of a package for all software projects
For a given package or the one from the current directory, iterate over all
projects in "software" and the user's "home" project and display the build
statuses of that package. Lines will be skipped if the status is "succeeded",
"excluded", or "disabled".
Usage:
osc ${cmd_name} [PACKAGE]
${cmd_option_list}
"""
api_url = self.get_api_url()
if len(args) == 0:
if osc.core.is_package_dir(os.curdir):
project = osc.core.store_read_project(os.curdir)
package = osc.core.store_read_package(os.curdir)
else:
raise osc.oscerr.WrongArgs("Specify PACKAGE or run command in an osc package checkout directory")
elif len(args) == 1:
project = osc.core.store_read_project(os.curdir)
package, = args
else:
raise osc.oscerr.WrongArgs("Too many arguments")
url = osc.core.makeurl(api_url, ["source"])
entries = ElementTree.fromstringlist(osc.core.streamfile(url, osc.core.http_GET))
user = osc.conf.get_apiurl_usr(api_url)
for entry in entries.findall("./entry"):
project = entry.get("name")
if project.startswith("software:") or project == "home:{0}".format(user):
print(project)
project_url = osc.core.makeurl(api_url, ["build", project, "_result?view=status&multibuild=1&package={0}".format(package)])
resultlist = ElementTree.fromstringlist(osc.core.streamfile(project_url, osc.core.http_GET))
actualPackages = set()
for result in resultlist.findall("./result"):
for status in result.findall("./status"):
actualPackages.add(status.get("package"))
for pack in actualPackages:
print(" {0} (https://obs-api.mpcdf.mpg.de/package/show/{1}/{2}):".format(pack, project, pack))
cnt = 0
for result in resultlist.findall("./result"):
for status in result.findall("./status"):
if status.get("package") == pack:
if status.get("code") not in ["disabled", "excluded", "succeeded"]:
print(" {0}: {1}".format(result.get("repository"), status.get("code")))
cnt = cnt + 1
if cnt == 0:
print(" all succeeded")
print()
Loading