Improve 404 error message on download-logs.sh
Includes reasons why a user may get 404 errors from zuul in order to avoid confusions. Change-Id: Iba39e85a9f84ec8f999b0c0ddce76597b4349257
This commit is contained in:
parent
730fca5f1c
commit
09ddbf8807
@ -26,15 +26,27 @@ function get_urls {
|
|||||||
import gzip
|
import gzip
|
||||||
import json
|
import json
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
import sys
|
||||||
|
|
||||||
base_url = urllib.request.urlopen("${ZUUL_API_URL}").read()
|
try:
|
||||||
base_json = json.loads(base_url)
|
base_url = urllib.request.urlopen("${ZUUL_API_URL}").read()
|
||||||
manifest_url = [x['url'] for x in base_json['artifacts'] if x.get('metadata', {}).get('type') == 'zuul_manifest'][0]
|
base_json = json.loads(base_url)
|
||||||
manifest = urllib.request.urlopen(manifest_url)
|
manifest_url = [x['url'] for x in base_json['artifacts'] if x.get('metadata', {}).get('type') == 'zuul_manifest'][0]
|
||||||
if manifest.info().get('Content-Encoding') == 'gzip':
|
manifest = urllib.request.urlopen(manifest_url)
|
||||||
|
if manifest.info().get('Content-Encoding') == 'gzip':
|
||||||
manifest_json = json.loads(gzip.decompress(manifest.read()))
|
manifest_json = json.loads(gzip.decompress(manifest.read()))
|
||||||
else:
|
else:
|
||||||
manifest_json = json.loads(manifest.read())
|
manifest_json = json.loads(manifest.read())
|
||||||
|
except HTTPError as e:
|
||||||
|
if e.code == 404:
|
||||||
|
print(
|
||||||
|
"Could not find build UUID in Zuul API. This can happen with "
|
||||||
|
"buildsets still running, or aborted ones. Try again after the "
|
||||||
|
"buildset is reported back to Zuul.", file=sys.stderr)
|
||||||
|
else:
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
def p(node, parent):
|
def p(node, parent):
|
||||||
if node.get('mimetype') != 'application/directory':
|
if node.get('mimetype') != 'application/directory':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user