当前位置: 首页>>代码示例>>Python>>正文


Python RBClient.get_path方法代码示例

本文整理汇总了Python中rbtools.api.client.RBClient.get_path方法的典型用法代码示例。如果您正苦于以下问题:Python RBClient.get_path方法的具体用法?Python RBClient.get_path怎么用?Python RBClient.get_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rbtools.api.client.RBClient的用法示例。


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

示例1: ReviewBoardClient

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_path [as 别名]
def ReviewBoardClient(url, username=None, password=None, apikey=None):
    """Obtain a RBClient instance via a context manager.

    This exists as a context manager because of gross hacks necessary for
    dealing with cookies. ``RBClient`` is coded such that it assumes it is
    being used under a user account and storing cookies is always acceptable.
    There is no way to disable cookie file writing or to tell it to use a file
    object (such as BytesIO) as the cookies database.

    We work around this deficiency by creating a temporary file and using it as
    the cookies database for the lifetime of the context manager. When the
    context manager exits, the temporary cookies file is deleted.
    """
    fd, path = tempfile.mkstemp()
    os.close(fd)
    try:
        if username and apikey:
            rbc = RBClient(url, cookie_file=path,
                           transport_cls=NoCacheTransport)
            login_resource = rbc.get_path(
                'extensions/mozreview.extension.MozReviewExtension/'
                'bugzilla-api-key-logins/')
            login_resource.create(username=username, api_key=apikey)
        else:
            rbc = RBClient(url, username=username, password=password,
                           cookie_file=path, transport_cls=NoCacheTransport)

        yield rbc
    finally:
        try:
            os.unlink(path)
        except Exception:
            pass
开发者ID:Nephyrin,项目名称:bzexport,代码行数:35,代码来源:pushhooks.py

示例2: ReviewBoardClient

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_path [as 别名]
def ReviewBoardClient(url, username=None, password=None, apikey=None):
    """Obtain a RBClient instance."""
    if username and apikey:
        rbc = RBClient(url, save_cookies=False, allow_caching=False)
        login_resource = rbc.get_path("extensions/mozreview.extension.MozReviewExtension/" "bugzilla-api-key-logins/")
        login_resource.create(username=username, api_key=apikey)
    else:
        rbc = RBClient(url, username=username, password=password, save_cookies=False, allow_caching=False)

    return rbc
开发者ID:pkdevboxy,项目名称:version-control-tools,代码行数:12,代码来源:pushhooks.py

示例3: post_reviews

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_path [as 别名]

#.........这里部分代码省略.........
    or discarding.

    When publishing the squashed review request:

    * A: close "discarded" because it was never used
    * B: publish draft
    * C: publish draft
    * D: close "discarded" because it is obsolete
    * set unpublished_rids to empty '[]'
    * set discard_on_publish_rids to empty '[]'

    When discarding the draft of a published squashed review request:

    * A: close "discarded" because it was never used (so it does not appear in
      the owners dashboard)
    * B: close "discarded" because it was never used (so it does not appear in
      the owners dashboard)
    * C: DELETE the review request draft
    * D: do nothing
    * set unpublished_rids to empty '[]'
    * set discard_on_publish_rids to empty '[]'

    When discarding an unpublished squashed review request (always a close "discarded"):

    * TODO Bug 1047465
    """
    rbc = None

    if userid and cookie:
        # TODO: This is bugzilla specific code that really shouldn't be inside
        # of this file. The whole bugzilla cookie resource is a hack anyways
        # though so we'll deal with this for now.
        rbc = RBClient(url)
        login_resource = rbc.get_path(
            'extensions/rbbz.extension.BugzillaExtension/'
            'bugzilla-cookie-logins/')
        login_resource.create(login_id=userid, login_cookie=cookie)
    else:
        rbc = RBClient(url, username=username, password=password)

    api_root = rbc.get_root()

    # This assumes that we pushed to the repository/URL that Review Board is
    # configured to use. This assumption may not always hold.
    repo = api_root.get_repository(repository_id=repoid)
    repo_url = repo.path

    # Retrieve the squashed review request or create it.
    previous_commits = []
    squashed_rr = None
    rrs = api_root.get_review_requests(commit_id=identifier,
                                       repository=repoid)

    if rrs.total_results > 0:
        squashed_rr = rrs[0]
    else:
        # A review request for that identifier doesn't exist - this
        # is the first push to this identifier and we'll need to create
        # it from scratch.
        squashed_rr = rrs.create(**{
            "extra_data.p2rb": "True",
            "extra_data.p2rb.is_squashed": "True",
            "extra_data.p2rb.identifier": identifier,
            "extra_data.p2rb.discard_on_publish_rids": '[]',
            "extra_data.p2rb.unpublished_rids": '[]',
            "commit_id": identifier,
开发者ID:simar7,项目名称:git-version-control-tools-clone,代码行数:70,代码来源:pushhooks.py


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