def fetch_layout_test_results(self, results_url): # FIXME: This should cache that the result was a 404 and stop hitting the network. results_file = NetworkTransaction(convert_404_to_None=True).run( lambda: self._fetch_file_from_results(results_url, "full_results.json")) return LayoutTestResults.results_from_string(results_file)
def update_svn_revision(self, svn_revision_number, broken_bot): _log.info("SVN revision: %s broke %s" % (svn_revision_number, broken_bot)) return NetworkTransaction().run(lambda: self._post_svn_revision_to_server(svn_revision_number, broken_bot))
def _retrieve_zip_file(self, zip_url): temp_file = NetworkTransaction().run( lambda: urllib.urlretrieve(zip_url)[0]) return (temp_file, zipfile.ZipFile(temp_file))
def update_work_items(self, queue_name, work_items): _log.debug("Recording work items: %s for %s" % (work_items, queue_name)) return NetworkTransaction().run(lambda: self._post_work_items_to_server(queue_name, work_items))
def update_status(self, queue_name, status, patch=None, results_file=None): _log.info(status) return NetworkTransaction().run(lambda: self._post_status_to_server(queue_name, status, patch, results_file))
def update_work_items(self, queue_name, high_priority_work_items, work_items): _log.info("Recording work items: %s for %s" % (high_priority_work_items + work_items, queue_name)) return NetworkTransaction().run(lambda: self._post_work_items_to_server(queue_name, high_priority_work_items, work_items))
def release_work_item(self, queue_name, patch): _log.info("Releasing work item %s from %s" % (patch.id(), queue_name)) return NetworkTransaction(convert_404_to_None=True).run(lambda: self._post_release_work_item(queue_name, patch))
def test_success(self): transaction = NetworkTransaction() self.assertEqual(transaction.run(lambda: 42), 42)
def test_convert_404_to_None(self): transaction = NetworkTransaction(convert_404_to_None=True) self.assertEqual(transaction.run(lambda: self._raise_404_error()), None)
def submit_to_ews(self, attachment_id): _log.info( 'Submitting attachment {} to EWS queues'.format(attachment_id)) return NetworkTransaction().run( lambda: self._post_patch_to_ews(attachment_id))
def get_binary(self, url, convert_404_to_None=False): return NetworkTransaction(convert_404_to_None=convert_404_to_None).run( lambda: urllib2.urlopen(url).read())
def bug_id_for_attachment_id(self, attachment_id, throw_on_access_error=False): return NetworkTransaction().run( lambda: self.get_bug_id_for_attachment_id(attachment_id, throw_on_access_error))
def _get_json(self): return NetworkTransaction().run( lambda: urllib2.urlopen(self._json_url()).read())
def test_convert_404_to_None(self): transaction = NetworkTransaction(convert_404_to_None=True) self.assertIsNone(transaction.run(self._raise_404_error))
def bug_id_for_attachment_id(self, attachment_id): return NetworkTransaction().run(lambda: self.get_bug_id_for_attachment_id(attachment_id))
def submit_to_ews(self, attachment_id): _log.info("Submitting attachment %s to EWS queues" % attachment_id) return NetworkTransaction().run(lambda: self._post_work_item_to_ews(attachment_id))
def open_url(self, url): return NetworkTransaction().run(lambda: self.browser.open(url), url)
def upload_attachment(self, attachment): _log.info('Uploading attachment {} to status server'.format(attachment.id())) # FIXME: Remove argument convert_404_to_None once we update AppEngine to support uploading attachments. return NetworkTransaction(convert_404_to_None=True).run(lambda: self._upload_attachment_to_server(attachment.id(), attachment.to_json(), attachment.contents()))