Bug 1405740 - Add a cancel-all action task r=garndt,jonasfj
MozReview-Commit-ID: 2V8ztB5Pdkc
This commit is contained in:
@@ -10,6 +10,7 @@ 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
|
||||
@@ -17,6 +18,11 @@ from requests.adapters import HTTPAdapter
|
||||
_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
|
||||
|
||||
|
||||
@memoize
|
||||
def get_session():
|
||||
@@ -139,6 +145,15 @@ def get_task_definition(task_id, use_proxy=False):
|
||||
return response.json()
|
||||
|
||||
|
||||
def cancel_task(task_id, use_proxy=False):
|
||||
"""Cancels a task given a task_id. In testing mode, just logs that it would
|
||||
have cancelled."""
|
||||
if testing:
|
||||
logger.info('Would have cancelled {}.'.format(task_id))
|
||||
else:
|
||||
_do_request(get_task_url(task_id, use_proxy) + '/cancel', content={})
|
||||
|
||||
|
||||
def get_taskcluster_artifact_prefix(task_id, postfix='', locale=None):
|
||||
if locale:
|
||||
postfix = '{}/{}'.format(locale, postfix)
|
||||
|
||||
Reference in New Issue
Block a user