Merge ~pitti/autopkgtest-cloud/+git/fixes:master into autopkgtest-cloud:master

Proposed by Martin Pitt
Status: Merged
Merged at revision: 0e11dba8da790617ce033c3131d0972561164f02
Proposed branch: ~pitti/autopkgtest-cloud/+git/fixes:master
Merge into: autopkgtest-cloud:master
Diff against target: 29 lines (+9/-2)
1 file modified
tools/retry-github-test (+9/-2)
Reviewer Review Type Date Requested Status
Iain Lane Approve
Review via email: mp+330743@code.launchpad.net

Description of the change

Fix error messages for retry-github-test. This will turn a relatively useless and verbose

$ retry-gh-systemd-test 6790 fakearch fakerelease
Traceback (most recent call last):
  File "/home/martin/ubuntu/autopkgtest-cloud/tools/retry-github-test", line 32, in <module>
    with urllib.request.urlopen(req) as f:
  File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib64/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: BAD REQUEST

into a more useful

$ retry-gh-systemd-test 6790 fakearch fakerelease
Request failed with code 400: BAD REQUEST
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Autopkgtest Test Request</title>
</head>
<body>
<p>You submitted an invalid request: Unknown release fakerelease</p>
</body>
</html>

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote :

Thanks Martin! I've merged it and deployed - feel free to give it a try.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tools/retry-github-test b/tools/retry-github-test
index 92f043a..e47ecc2 100755
--- a/tools/retry-github-test
+++ b/tools/retry-github-test
@@ -2,9 +2,11 @@
2'''Retry a GitHub PR test request to autopkgtest.ubuntu.com'''2'''Retry a GitHub PR test request to autopkgtest.ubuntu.com'''
33
4import os4import os
5import sys
5import hmac6import hmac
6import json7import json
7import urllib.request8import urllib.request
9import urllib.error
8import argparse10import argparse
911
10p = argparse.ArgumentParser(description='Retry a GitHub PR test request to autopkgtest.ubuntu.com')12p = argparse.ArgumentParser(description='Retry a GitHub PR test request to autopkgtest.ubuntu.com')
@@ -29,5 +31,10 @@ payload_sig = hmac.new(args.secret_file.read().strip(), payload, 'sha1').hexdige
29req = urllib.request.Request(args.test_url, data=payload,31req = urllib.request.Request(args.test_url, data=payload,
30 headers={'X-Hub-Signature': 'sha1=' + payload_sig,32 headers={'X-Hub-Signature': 'sha1=' + payload_sig,
31 'Content-Type': 'application/json'})33 'Content-Type': 'application/json'})
32with urllib.request.urlopen(req) as f:34try:
33 print(f.read().decode())35 with urllib.request.urlopen(req) as f:
36 print(f.read().decode())
37except urllib.error.HTTPError as e:
38 sys.stderr.write('Request failed with code %i: %s' % (e.code, e.msg))
39 sys.stderr.write(e.fp.read().decode('UTF-8', 'replace'))
40 sys.exit(1)

Subscribers

People subscribed via source and target branches