bug 1442793 - get_artifact_prefix and get_artifact_path. r=bhearsum
authorAki Sasaki <asasaki@mozilla.com>
Wed, 07 Mar 2018 10:37:33 -0800
changeset 467485 0ffeb06f9541f6ac7d78c165fd8badc32e699d5a
parent 467484 9f8c088dce9f9ec8a0ca3c708e14ac298e207414
child 467486 d8d0e4665d0bd561b11e195476fc802638aa9e02
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhearsum
bugs1442793
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1442793 - get_artifact_prefix and get_artifact_path. r=bhearsum MozReview-Commit-ID: E1VBN88h03M
taskcluster/taskgraph/util/taskcluster.py
--- a/taskcluster/taskgraph/util/taskcluster.py
+++ b/taskcluster/taskgraph/util/taskcluster.py
@@ -9,16 +9,17 @@ from __future__ import absolute_import, 
 import datetime
 import functools
 import yaml
 import requests
 import logging
 from mozbuild.util import memoize
 from requests.packages.urllib3.util.retry import Retry
 from requests.adapters import HTTPAdapter
+from taskgraph.task import Task
 
 _TC_ARTIFACT_LOCATION = \
         'https://queue.taskcluster.net/v1/task/{task_id}/artifacts/public/build/{postfix}'
 
 logger = logging.getLogger(__name__)
 
 # this is set to true for `mach taskgraph action-callback --test`
 testing = False
@@ -85,16 +86,29 @@ def get_artifact(task_id, path, use_prox
     return _handle_artifact(path, response)
 
 
 def list_artifacts(task_id, use_proxy=False):
     response = _do_request(get_artifact_url(task_id, '', use_proxy).rstrip('/'))
     return response.json()['artifacts']
 
 
+def get_artifact_prefix(task):
+    prefix = None
+    if isinstance(task, dict):
+        prefix = task.get('attributes', {}).get("artifact_prefix")
+    elif isinstance(task, Task):
+        prefix = task.attributes.get("artifact_prefix")
+    return prefix or "public/build"
+
+
+def get_artifact_path(task, path):
+    return "{}/{}".format(get_artifact_prefix(task), path)
+
+
 def get_index_url(index_path, use_proxy=False, multiple=False):
     if use_proxy:
         INDEX_URL = 'http://taskcluster/index/v1/task{}/{}'
     else:
         INDEX_URL = 'https://index.taskcluster.net/v1/task{}/{}'
     return INDEX_URL.format('s' if multiple else '', index_path)