Bug 1381669 - Add backfill as an actions.json task r=dustin

MozReview-Commit-ID: 3Q53x0KGWgG
This commit is contained in:
Brian Stack
2017-07-27 15:27:50 -07:00
parent 70190763e7
commit 4b249f9c1a
2 changed files with 109 additions and 7 deletions

View File

@@ -35,6 +35,16 @@ def _do_request(url):
return response
def _handle_artifact(path, response):
if path.endswith('.json'):
return response.json()
if path.endswith('.yml'):
return yaml.load(response.text)
response.raw.read = functools.partial(response.raw.read,
decode_content=True)
return response.raw
def get_artifact_url(task_id, path, use_proxy=False):
if use_proxy:
ARTIFACT_URL = 'http://taskcluster/queue/v1/task/{}/artifacts/{}'
@@ -53,13 +63,7 @@ def get_artifact(task_id, path, use_proxy=False):
For other types of content, a file-like object is returned.
"""
response = _do_request(get_artifact_url(task_id, path, use_proxy))
if path.endswith('.json'):
return response.json()
if path.endswith('.yml'):
return yaml.load(response.text)
response.raw.read = functools.partial(response.raw.read,
decode_content=True)
return response.raw
return _handle_artifact(path, response)
def list_artifacts(task_id, use_proxy=False):
@@ -80,6 +84,12 @@ def find_task_id(index_path, use_proxy=False):
return response.json()['taskId']
def get_artifact_from_index(index_path, artifact_path, use_proxy=False):
full_path = index_path + '/artifacts/' + artifact_path
response = _do_request(get_index_url(full_path, use_proxy))
return _handle_artifact(full_path, response)
def get_task_url(task_id, use_proxy=False):
if use_proxy:
TASK_URL = 'http://taskcluster/queue/v1/task/{}'