Use TreeherderClient's add_revision() instead of add_revision_hash()

Since the latter has been deprecated for some time and now removed
in the latest treeherder-client release. It is no longer necessary
to perform the separate lookup to map a revision to the revision
hash.
This commit is contained in:
Ed Morley 2017-08-31 01:04:52 +01:00 коммит произвёл Benjamin Bouvier
Родитель 131295adec
Коммит 6dc210f7c2
1 изменённых файлов: 1 добавлений и 32 удалений

Просмотреть файл

@ -5,7 +5,6 @@
import json
import logging
import os
import requests
import socket
import time
from urlparse import urljoin
@ -17,11 +16,6 @@ except:
print "run 'sudo pip install treeherder-client' to install the needed libraries"
exit()
DEFAULT_REQUEST_HEADERS = {
'Accept': 'application/json',
'User-Agent': 'arewefastyet',
}
RESULTSET_FRAGMENT = 'api/project/{repository}/resultset/?revision={revision}'
JOB_FRAGMENT = '/#/jobs?repo={repository}&revision={revision}'
BUILD_STATES = ['running', 'completed']
@ -77,7 +71,7 @@ class Submission(object):
job.add_product_name('firefox')
job.add_project(self.repository)
job.add_revision_hash(self.retrieve_revision_hash())
job.add_revision(self.revision)
# Add platform and build information
job.add_machine(socket.getfqdn())
@ -103,31 +97,6 @@ class Submission(object):
return job
def retrieve_revision_hash(self):
"""Retrieves the unique hash for the current revision."""
if not self.url:
raise ValueError('URL for Treeherder is missing.')
lookup_url = urljoin(self.url,
RESULTSET_FRAGMENT.format(repository=self.repository,
revision=self.revision))
if self.url == "mock":
logger.info('Pretend to get revision hash from: {}'.format(lookup_url))
return None
logger.info('Getting revision hash from: {}'.format(lookup_url))
response = requests.get(lookup_url, headers=DEFAULT_REQUEST_HEADERS)
response.raise_for_status()
if not response.json():
raise ValueError('Unable to determine revision hash for {}. '
'Perhaps it has not been ingested by '
'Treeherder?'.format(self.revision))
return response.json()['results'][0]['revision_hash']
def submit(self, job):
"""Submit the job to treeherder.