def pushes(self, **kwargs): """ Returns a sorted lists of Push objects. The list can not be empty. Basically issue a raw request to the server. """ base_url = "%s/json-pushes?" % self.repo_url url = base_url + "&".join( sorted("%s=%s" % kv for kv in six.iteritems(kwargs))) LOG.debug("Using url: %s" % url) response = retry_get(url) data = response.json() if (response.status_code == 404 and data is not None and "error" in data and "unknown revision" in data["error"]): raise EmptyPushlogError( "The url %r returned a 404 error because the push is not" " in this repo (e.g., not merged yet)." % url) response.raise_for_status() if not data: raise EmptyPushlogError( "The url %r contains no pushlog. Maybe use another range ?" % url) pushlog = [] for key in sorted(data): pushlog.append(Push(key, data[key])) return pushlog
def pushes(self, **kwargs): """ Returns a sorted lists of Push objects. The list can not be empty. Basically issue a raw request to the server. """ base_url = '%s/json-pushes?' % self.repo_url url = base_url + '&'.join("%s=%s" % kv for kv in six.iteritems(kwargs)) LOG.debug("Using url: %s" % url) response = retry_get(url) if response.status_code == 404: raise MozRegressionError( "The url %r returned a 404 error. Please check the" " validity of the url." % url) response.raise_for_status() data = response.json() if not data: raise EmptyPushlogError( "The url %r contains no pushlog. Maybe use another range ?" % url) pushlog = [] for key in sorted(data): pushlog.append(Push(key, data[key])) return pushlog
def _request(self, url): response = retry_get(url) if response.status_code == 404: raise MozRegressionError( "The url %r returned a 404 error. Please check the" " validity of the url." % url) response.raise_for_status() pushlog = response.json() if not pushlog: raise EmptyPushlogError( "The url %r contains no pushlog. Maybe use another range ?" % url) return pushlog
def revision_for_date(self, date): """ Returns the last revision that matches the given date. Raise an explicit EmptyPushlogError if no pushes are available. """ try: return self.pushlog_within_changes( date, date, verbose=False)[-1]['changesets'][-1] except EmptyPushlogError: raise EmptyPushlogError( "No pushes available for the date %s on %s." % (date, self.branch))
def push(self, changeset, **kwargs): """ Returns the Push object that match the given changeset or date. A MozRegressionError is thrown if None is found. """ if is_date_or_datetime(changeset): try: return self.pushes_within_changes(changeset, changeset, verbose=False)[-1] except EmptyPushlogError: raise EmptyPushlogError( "No pushes available for the date %s on %s." % (changeset, self.branch)) return self.pushes(changeset=changeset, **kwargs)[0]