• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python client.TreeherderClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中treeherder.client.TreeherderClient的典型用法代码示例。如果您正苦于以下问题:Python TreeherderClient类的具体用法?Python TreeherderClient怎么用?Python TreeherderClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TreeherderClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: post_collection

def post_collection(
        project, th_collection, status=None, expect_errors=False,
        consumer_key=None, consumer_secret=None):

    # Set the credentials
    OAuthCredentials.set_credentials(SampleData.get_credentials())

    credentials = OAuthCredentials.get_credentials(project)

    # The only time the credentials should be overridden are when
    # a client needs to test authentication failure confirmation
    consumer_key = consumer_key or credentials['consumer_key']
    consumer_secret = consumer_secret or credentials['consumer_secret']

    auth = TreeherderAuth(consumer_key, consumer_secret, project)
    client = TreeherderClient(protocol='http', host='localhost', auth=auth)
    uri = client._get_project_uri(project, th_collection.endpoint_base)

    req = Request('POST', uri,
                  json=th_collection.get_collection_data(),
                  auth=auth)
    prepped_request = req.prepare()

    response = TestApp(application).post_json(
        prepped_request.url,
        params=th_collection.get_collection_data(),
        status=status
    )

    return response
开发者ID:kingaki007,项目名称:treeherder,代码行数:30,代码来源:test_utils.py


示例2: test_send_with_oauth

    def test_send_with_oauth(self, mock_post, mock_time,
                             mock_generate_nonce):

        """Tests that oauth data is sent to server"""
        mock_time.return_value = 1342229050
        mock_generate_nonce.return_value = "46810593"
        mock_post.return_value = self._expected_response_return_object()

        client = TreeherderClient(
            protocol='http',
            host='host',
            )

        tjc = TreeherderJobCollection()

        for job in self.job_data:

            tjc.add(tjc.get_job(job))
            break

        client.post_collection('project', 'key', 'secret', tjc)

        self.assertEqual(mock_post.call_count, 1)

        path, resp = mock_post.call_args
        self.assertEqual(path[0], "http://host/api/project/project/objectstore/?oauth_body_hash=IKbDoi5GvTRaqjRTCDyKIN5wWiY%3D&oauth_nonce=46810593&oauth_timestamp=1342229050&oauth_consumer_key=key&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=&user=project&oauth_signature=uq%2BrkJCRPyPUdXExSasm25ab8m4%3D")
开发者ID:serious6,项目名称:treeherder,代码行数:26,代码来源:test_treeherder_client.py


示例3: post_treeherder_collections

def post_treeherder_collections(th_collections, chunk_size=1):

    errors = []
    cli = TreeherderClient(
        protocol=settings.TREEHERDER_REQUEST_PROTOCOL,
        host=settings.TREEHERDER_REQUEST_HOST,
    )

    for project in th_collections:

        credentials = OAuthCredentials.get_credentials(project)

        auth = TreeherderAuth(credentials.get('consumer_key'),
                              credentials.get('consumer_secret'),
                              project)

        logger.info(
            "collection loading request for project {0}: {1}".format(
                project,
                th_collections[project].endpoint_base))

        collection_chunks = th_collections[project].get_chunks(chunk_size)

        for collection in collection_chunks:
            try:
                cli.post_collection(project, collection, auth=auth)
            except Exception:
                errors.append({
                    "project": project,
                    "url": th_collections[project].endpoint_base,
                    "message": traceback.format_exc()
                })

    if errors:
        raise CollectionNotLoadedException(errors)
开发者ID:EdgarChen,项目名称:treeherder,代码行数:35,代码来源:th_publisher.py


示例4: test_send_result_collection

    def test_send_result_collection(self, mock_post):
        """Can add a treeherder collections to a TreeherderRequest."""
        mock_post.return_value = self._expected_response_return_object()

        trc = TreeherderResultSetCollection()

        for resultset in self.resultset_data:

            trc.add(trc.get_resultset(resultset))

        client = TreeherderClient(
            protocol='http',
            host='host',
            )

        auth = TreeherderAuth('key', 'secret', 'project')
        client.post_collection('project', trc, auth=auth)

        path, resp = mock_post.call_args

        self.assertEqual(mock_post.call_count, 1)
        self.assertEqual(
            trc.get_collection_data(),
            resp['json']
            )
开发者ID:mjzffr,项目名称:treeherder,代码行数:25,代码来源:test_treeherder_client.py


示例5: test_post_job_collection

    def test_post_job_collection(self, mock_post):
        """Can add a treeherder collections to a TreeherderRequest."""
        mock_post.return_value = self._expected_response_return_object()

        tjc = TreeherderJobCollection()

        for job in self.job_data:
            tjc.add(tjc.get_job(job))

        client = TreeherderClient(
            protocol='http',
            host='host',
            client_id='client-abc',
            secret='secret123',
            )

        client.post_collection('project', tjc)

        path, resp = mock_post.call_args

        self.assertEqual(mock_post.call_count, 1)
        self.assertEqual(
            tjc.get_collection_data(),
            resp['json']
            )
开发者ID:EricRahm,项目名称:treeherder,代码行数:25,代码来源:test_treeherder_client.py


示例6: test_send_artifact_collection

    def test_send_artifact_collection(self, mock_post):
        """Can add a artifact collections to a TreeherderRequest."""
        mock_post.return_value = self._expected_response_return_object()

        tac = TreeherderArtifactCollection()

        for artifact in self.artifact_data:
            tac.add(tac.get_artifact(artifact))

        client = TreeherderClient(
            protocol='http',
            host='host',
            client_id='client-abc',
            secret='secret123',
            )

        client.post_collection('project', tac)

        path, resp = mock_post.call_args

        self.assertEqual(mock_post.call_count, 1)
        self.assertEqual(
            tac.get_collection_data(),
            resp['json']
            )
开发者ID:EricRahm,项目名称:treeherder,代码行数:25,代码来源:test_treeherder_client.py


示例7: post_treeherder_collections

def post_treeherder_collections(th_collections, chunk_size=1):

    errors = []
    credentials = Credentials.objects.get(client_id=settings.ETL_CLIENT_ID)

    cli = TreeherderClient(
        protocol=settings.TREEHERDER_REQUEST_PROTOCOL,
        host=settings.TREEHERDER_REQUEST_HOST,
        client_id=credentials.client_id,
        secret=str(credentials.secret),
    )

    for project in th_collections:
        logger.info(
            "collection loading request for project {0}: {1}".format(
                project,
                th_collections[project].endpoint_base))

        collection_chunks = th_collections[project].get_chunks(chunk_size)

        for collection in collection_chunks:
            try:
                cli.post_collection(project, collection)
            except Exception:
                errors.append({
                    "project": project,
                    "url": th_collections[project].endpoint_base,
                    "message": traceback.format_exc()
                })

    if errors:
        raise CollectionNotLoadedException(errors)
开发者ID:KWierso,项目名称:treeherder,代码行数:32,代码来源:th_publisher.py


示例8: post_collection

def post_collection(
        project, th_collection, status=None, expect_errors=False,
        consumer_key=None, consumer_secret=None):

    # Set the credentials
    OAuthCredentials.set_credentials(SampleData.get_credentials())

    credentials = OAuthCredentials.get_credentials(project)

    # The only time the credentials should be overridden are when
    # a client needs to test authentication failure confirmation
    if consumer_key:
        credentials['consumer_key'] = consumer_key

    if consumer_secret:
        credentials['consumer_secret'] = consumer_secret

    cli = TreeherderClient(
        protocol='http',
        host='localhost',
    )

    jsondata = th_collection.to_json()
    signed_uri = cli._get_uri(project, th_collection.endpoint_base,
                              data=jsondata,
                              oauth_key=credentials['consumer_key'],
                              oauth_secret=credentials['consumer_secret'],
                              method='POST')

    response = TestApp(application).post_json(
        str(signed_uri), params=th_collection.get_collection_data(),
        status=status
    )

    return response
开发者ID:ccooper,项目名称:treeherder,代码行数:35,代码来源:test_utils.py


示例9: post_log_artifacts

def post_log_artifacts(project, job_guid, job_log_url, retry_task, extract_artifacts_cb):
    """Post a list of artifacts to a job."""

    def _retry(e):
        # Initially retry after 1 minute, then for each subsequent retry
        # lengthen the retry time by another minute.
        retry_task.retry(exc=e, countdown=(1 + retry_task.request.retries) * 60)
        # .retry() raises a RetryTaskError exception,
        # so nothing after this function will be executed

    log_description = "%s %s (%s)" % (project, job_guid, job_log_url)
    logger.debug("Downloading/parsing log for %s", log_description)

    job_log = JobLog.objects.get(job__guid=job_guid, url=job_log_url)

    credentials = Credentials.objects.get(client_id=settings.ETL_CLIENT_ID)
    client = TreeherderClient(
        protocol=settings.TREEHERDER_REQUEST_PROTOCOL,
        host=settings.TREEHERDER_REQUEST_HOST,
        client_id=credentials.client_id,
        secret=str(credentials.secret),
    )

    try:
        artifact_list = extract_artifacts_cb(project, job_log_url, job_guid)
    except Exception as e:
        job_log.update_status(JobLog.FAILED)

        # unrecoverable http error (doesn't exist or permission denied)
        # (apparently this can happen somewhat often with taskcluster if
        # the job fails, so just warn about it -- see
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1154248)
        if isinstance(e, urllib2.HTTPError) and e.code in (403, 404):
            logger.warning("Unable to retrieve log for %s: %s", log_description, e)
            return
        # possibly recoverable http error (e.g. problems on our end)
        elif isinstance(e, urllib2.URLError):
            logger.error("Failed to download log for %s: %s", log_description, e)
            _retry(e)
        # parse error or other unrecoverable error
        else:
            logger.error("Failed to download/parse log for %s: %s", log_description, e)
        # re-raise exception if we're not retrying, so new relic sees the
        # error
        raise

    # store the artifacts generated
    tac = TreeherderArtifactCollection()
    for artifact in artifact_list:
        ta = tac.get_artifact(artifact)
        tac.add(ta)

    try:
        client.post_collection(project, tac)
        job_log.update_status(JobLog.PARSED)
        logger.debug("Finished posting artifact for %s %s", project, job_guid)
    except Exception as e:
        logger.error("Failed to upload parsed artifact for %s: %s", log_description, e)
        _retry(e)
开发者ID:samh12,项目名称:treeherder,代码行数:59,代码来源:utils.py


示例10: test_update_parse_status_nonexistent_id

def test_update_parse_status_nonexistent_id(test_project, mock_post_json):
    """
    Attempting to update the parse status for a non-existent log should return a 404.
    """
    client = TreeherderClient(protocol='http', host='localhost')
    non_existent_id = 9999999
    with pytest.raises(AppError) as e:
        client.update_parse_status(test_project, non_existent_id, 'parsed')
    assert "404 NOT FOUND" in str(e.value)
开发者ID:PratikDhanave,项目名称:treeherder,代码行数:9,代码来源:test_job_log_url.py


示例11: test_get_results

    def test_get_results(self):
        tdc = TreeherderClient()
        url = tdc._get_project_uri("mozilla-inbound", tdc.RESULTSET_ENDPOINT)
        content = {"meta": {"count": 3, "repository": "mozilla-inbound", "offset": 0}, "results": self.RESULTSETS}
        responses.add(responses.GET, url, json=content, match_querystring=True, status=200)

        resultsets = tdc.get_resultsets("mozilla-inbound")
        self.assertEqual(len(resultsets), 3)
        self.assertEqual(resultsets, self.RESULTSETS)
开发者ID:samh12,项目名称:treeherder,代码行数:9,代码来源:test_treeherder_client.py


示例12: test_get_results

    def test_get_results(self, mock_get):

        mock_get.return_value = self._get_mock_response({
            "meta": {"count": 3, "repository": "mozilla-inbound",
                     "offset": 0},
            "results": self.RESULTSETS})

        tdc = TreeherderClient()
        resultsets = tdc.get_resultsets("mozilla-inbound")
        self.assertEqual(len(resultsets), 3)
        self.assertEqual(resultsets, self.RESULTSETS)
开发者ID:EricRahm,项目名称:treeherder,代码行数:11,代码来源:test_treeherder_client.py


示例13: test_get_job

    def test_get_job(self):
        tdc = TreeherderClient()
        url = tdc._get_endpoint_url(tdc.JOBS_ENDPOINT, project='mozilla-inbound')
        content = {
            "meta": {"count": 3,
                     "repository": "mozilla-inbound",
                     "offset": 0},
            "results": self.JOB_RESULTS
        }
        responses.add(responses.GET, url, json=content, match_querystring=True, status=200)

        jobs = tdc.get_jobs("mozilla-inbound")
        self.assertEqual(len(jobs), 3)
        self.assertEqual(jobs, self.JOB_RESULTS)
开发者ID:SebastinSanty,项目名称:treeherder,代码行数:14,代码来源:test_treeherder_client.py


示例14: test_send_artifact_collection

    def test_send_artifact_collection(self, mock_post):
        """Can add a artifact collections to a TreeherderRequest."""
        mock_post.return_value = self._expected_response_return_object()

        tac = TreeherderArtifactCollection()

        for artifact in self.artifact_data:

            tac.add(tac.get_artifact(artifact))

        client = TreeherderClient(protocol="http", host="host")

        auth = TreeherderAuth("key", "secret", "project")
        client.post_collection("project", tac, auth=auth)

        path, resp = mock_post.call_args

        self.assertEqual(mock_post.call_count, 1)
        self.assertEqual(tac.get_collection_data(), resp["json"])
开发者ID:EdgarChen,项目名称:treeherder,代码行数:19,代码来源:test_treeherder_client.py


示例15: test_post_job_collection

    def test_post_job_collection(self, mock_post):
        """Can add a treeherder collections to a TreeherderRequest."""
        mock_post.return_value = self._expected_response_return_object()

        tjc = TreeherderJobCollection()

        for job in self.job_data:

            tjc.add(tjc.get_job(job))

        client = TreeherderClient(protocol="http", host="host")

        auth = TreeherderAuth("key", "secret", "project")
        client.post_collection("project", tjc, auth=auth)

        path, resp = mock_post.call_args

        self.assertEqual(mock_post.call_count, 1)
        self.assertEqual(tjc.get_collection_data(), resp["json"])
开发者ID:EdgarChen,项目名称:treeherder,代码行数:19,代码来源:test_treeherder_client.py


示例16: test_post_job_collection

    def test_post_job_collection(self):
        """Can add a treeherder collections to a TreeherderRequest."""
        tjc = TreeherderJobCollection()

        for job in self.job_data:
            tjc.add(tjc.get_job(job))

        client = TreeherderClient(protocol="http", host="host", client_id="client-abc", secret="secret123")

        def request_callback(request):
            # Check that the expected content was POSTed.
            posted_json = json.loads(request.body)
            self.assertEqual(posted_json, tjc.get_collection_data())
            return (200, {}, '{"message": "Job successfully updated"}')

        url = client._get_project_uri("project", tjc.endpoint_base)
        responses.add_callback(
            responses.POST, url, match_querystring=True, callback=request_callback, content_type="application/json"
        )

        client.post_collection("project", tjc)
开发者ID:samh12,项目名称:treeherder,代码行数:21,代码来源:test_treeherder_client.py


示例17: test_send_result_collection

    def test_send_result_collection(self):
        """Can add a treeherder collections to a TreeherderRequest."""
        trc = TreeherderResultSetCollection()

        for resultset in self.resultset_data:
            trc.add(trc.get_resultset(resultset))

        client = TreeherderClient(protocol="http", host="host", client_id="client-abc", secret="secret123")

        def request_callback(request):
            # Check that the expected content was POSTed.
            posted_json = json.loads(request.body)
            self.assertEqual(posted_json, trc.get_collection_data())
            return (200, {}, '{"message": "well-formed JSON stored", "resultsets": [123, 456]}')

        url = client._get_project_uri("project", trc.endpoint_base)
        responses.add_callback(
            responses.POST, url, match_querystring=True, callback=request_callback, content_type="application/json"
        )

        client.post_collection("project", trc)
开发者ID:samh12,项目名称:treeherder,代码行数:21,代码来源:test_treeherder_client.py


示例18: test_send_artifact_collection

    def test_send_artifact_collection(self):
        """Can add a artifact collections to a TreeherderRequest."""
        tac = TreeherderArtifactCollection()

        for artifact in self.artifact_data:
            tac.add(tac.get_artifact(artifact))

        client = TreeherderClient(protocol="http", host="host", client_id="client-abc", secret="secret123")

        def request_callback(request):
            # Check that the expected content was POSTed.
            posted_json = json.loads(request.body)
            self.assertEqual(posted_json, tac.get_collection_data())
            return (200, {}, '{"message": "Artifacts stored successfully"}')

        url = client._get_project_uri("project", tac.endpoint_base)
        responses.add_callback(
            responses.POST, url, match_querystring=True, callback=request_callback, content_type="application/json"
        )

        client.post_collection("project", tac)
开发者ID:samh12,项目名称:treeherder,代码行数:21,代码来源:test_treeherder_client.py


示例19: handle

    def handle(self, *args, **options):
        server_params = urlparse(options['server'])
        c = TreeherderClient(protocol=server_params.scheme,
                             host=server_params.netloc)

        # options / option collection hashes
        for (uuid, props) in c.get_option_collection_hash().iteritems():
            for prop in props:
                option, _ = Option.objects.get_or_create(name=prop['name'])
                OptionCollection.objects.get_or_create(
                    option_collection_hash=uuid,
                    option=option)

        # machine platforms
        for machine_platform in c.get_machine_platforms():
            MachinePlatform.objects.get_or_create(
                    os_name=machine_platform['os_name'],
                    platform=machine_platform['platform'],
                    architecture=machine_platform['architecture'],
                    defaults={
                        'active_status': machine_platform['active_status']
                    })
开发者ID:vaishalitekale,项目名称:treeherder,代码行数:22,代码来源:import_reference_data.py


示例20: post_log_artifacts

def post_log_artifacts(project,
                       job_guid,
                       job_log_url,
                       retry_task,
                       extract_artifacts_cb,
                       check_errors=False):
    """Post a list of artifacts to a job."""
    def _retry(e):
        # Initially retry after 1 minute, then for each subsequent retry
        # lengthen the retry time by another minute.
        retry_task.retry(exc=e, countdown=(1 + retry_task.request.retries) * 60)
        # .retry() raises a RetryTaskError exception,
        # so nothing after this function will be executed

    log_description = "%s %s (%s)" % (project, job_guid, job_log_url['url'])
    logger.debug("Downloading/parsing log for %s", log_description)

    credentials = OAuthCredentials.get_credentials(project)
    client = TreeherderClient(
        protocol=settings.TREEHERDER_REQUEST_PROTOCOL,
        host=settings.TREEHERDER_REQUEST_HOST
    )

    try:
        artifact_list = extract_artifacts_cb(job_log_url['url'],
                                             job_guid, check_errors)
    except Exception as e:
        client.update_parse_status(project, credentials.get('consumer_key'),
                                   credentials.get('consumer_secret'),
                                   job_log_url['id'], 'failed')
        if isinstance(e, urllib2.HTTPError) and e.code in (403, 404):
            logger.debug("Unable to retrieve log for %s: %s", log_description, e)
            return
        logger.error("Failed to download/parse log for %s: %s", log_description, e)
        _retry(e)

    # store the artifacts generated
    tac = TreeherderArtifactCollection()
    for artifact in artifact_list:
        ta = tac.get_artifact(artifact)
        tac.add(ta)

    try:
        client.post_collection(project, credentials.get('consumer_key'),
                               credentials.get('consumer_secret'),
                               tac)
        client.update_parse_status(project, credentials.get('consumer_key'),
                                   credentials.get('consumer_secret'),
                                   job_log_url['id'], 'parsed')
        logger.debug("Finished posting artifact for %s %s", project, job_guid)
    except Exception as e:
        logger.error("Failed to upload parsed artifact for %s: %s", log_description, e)
        _retry(e)
开发者ID:TheTeraByte,项目名称:treeherder,代码行数:53,代码来源:utils.py



注:本文中的treeherder.client.TreeherderClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python client.TreeherderJob类代码示例发布时间:2022-05-27
下一篇:
Python client.TreeherderArtifactCollection类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap