From fbdaa34c84321b000ec4884064a6ee84f6371831 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 12 Jul 2016 21:54:43 +0100 Subject: [PATCH] Switch to using TreeherderClient's new server_url argument (#493) treeherder-client 3.0.0 has switched from using separate `host` and `protocol` arguments to a single `server_url` one. As before, this argument can be omitted to default to production Treeherder. Whilst treeherder-client 3.0.0 supports the old style arguments, they're deprecated. In `TreeherderApi` I've stuck with the same argument name as used in `TreeherderClient` for greater consistency. In addition, calling `TreeherderApi(treeherder_server_url='foo')` feels a little redundant, since the class is only for Treeherder, so it's already clear about what `server_url` is referring. --- mozci/query_jobs.py | 9 +++++++-- mozci/repositories.py | 3 +-- setup.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mozci/query_jobs.py b/mozci/query_jobs.py index ec057bb..51b8395 100644 --- a/mozci/query_jobs.py +++ b/mozci/query_jobs.py @@ -222,8 +222,13 @@ def find_all_jobs_by_status(self, repo_name, revision, status): class TreeherderApi(QueryApi): - def __init__(self, treeherder_host='treeherder.mozilla.org'): - self.treeherder_client = TreeherderClient(host=treeherder_host) + def __init__(self, server_url='https://treeherder.mozilla.org', treeherder_host=None): + if treeherder_host: + LOG.warning("The `TreeherderApi()` parameter `treeherder_host` is deprecated. " + "Use `server_url` instead, or omit entirely to use the default of " + "production Treeherder.") + server_url = 'https://%s' % treeherder_host + self.treeherder_client = TreeherderClient(server_url=server_url) def get_all_jobs(self, repo_name, revision, **params): """ diff --git a/mozci/repositories.py b/mozci/repositories.py index c3784f3..76afbed 100644 --- a/mozci/repositories.py +++ b/mozci/repositories.py @@ -11,7 +11,6 @@ LOG = logging.getLogger('mozci') REPOSITORIES = {} -TREEHERDER_URL = 'treeherder.mozilla.org' # @@ -61,7 +60,7 @@ def query_repositories(clear_cache=False): if REPOSITORIES: return REPOSITORIES - th_client = TreeherderClient(protocol='https', host=TREEHERDER_URL) + th_client = TreeherderClient() treeherderRepos = th_client.get_repositories() REPOSITORIES = {} for th_repo in treeherderRepos: diff --git a/setup.py b/setup.py index 52225f3..0399967 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ "pushlog_client", "requests", "taskcluster", - "treeherder-client", + "treeherder-client>=3.0.0", "jsonschema", "pyyaml" ]