#!/usr/bin/python3
# autopkgtest rerun link generator considering extra dependencies
# usage:
# wget http://people.canonical.com/~ubuntu-archive/proposed-migration/zesty/update_excuses.yaml
# autopkgtest-triggers.py < update_excuses.yaml
import urllib.parse
import yaml
import sys
def url_quote(string):
"""URL-encode package/version string"""
return urllib.parse.quote_plus(string).replace("/","%2F")
def rerun_link(package, arch, triggers):
"""Create linkk for restarting autopkgtest for a given package, architecture with the list of trigger packages"""
link = "https://autopkgtest.ubuntu.com/request.cgi?release=zesty&arch=" + arch + "&package=" + url_quote(package)
for trigger in triggers:
link += "&trigger=" + url_quote(trigger)
return link
def main():
# extra dependencies to add for re-runs
extra_deps = {'r-bioc-annotationhub/2.6.4-1' : ['r-bioc-genomeinfodb/1.10.3-1']}
data_loaded = yaml.load(sys.stdin)
for pkg in data_loaded['sources']:
if not pkg['is-candidate'] and 'autopkgtest' in pkg['reason']:
for rdep, results in pkg['policy_info']['autopkgtest'].items():
regressions = [ arch for arch, arch_res in results.items() if arch_res[0] == 'REGRESSION']
if len(regressions) > 0 and rdep in extra_deps.keys():
for arch in regressions:
print(rerun_link(rdep, arch, [pkg['source'] + "/" + pkg['new-version']] + extra_deps[rdep]))
if __name__ == "__main__":
main()