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


Python RBClient.get_root方法代码示例

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


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

示例1: rb_client

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
 def rb_client(self):
     options = {}
     if os.path.exists(".reviewboardrc"):
         with open(".reviewboardrc") as reviewboardrc:
             for line in reviewboardrc:
                 if line.startswith("#"):
                     continue
                 if len(line.strip()) == 0:
                     continue
                 k, v = line.strip().split("=")
                 k = k.strip()
                 v = eval(v.strip())
                 options[k] = v
     rbclient = RBClient(options.get('REVIEWBOARD_URL') or 'https://reviews.apache.org/', RetryingSyncTransport)
     if not rbclient.get_root().get_session()['authenticated']:
         username = self.opt.reviewboard_username[0] if self.opt.reviewboard_username and \
                                                        self.opt.reviewboard_username[0] else raw_input(
             "Enter review board Username: ")
         password = self.opt.reviewboard_password or getpass("Enter password for %s: " % username)
         rbclient.login(username, password)
     root = rbclient.get_root()
     root.repository = options.get('REPOSITORY') or None
     root.branch = options.get('BRANCH') or options.get('TRACKING_BRANCH')
     root.target_groups = None
     if options.has_key('TARGET_GROUPS'):
         root.target_groups = options['TARGET_GROUPS']
     return root
开发者ID:prongs,项目名称:apache-dev-tool,代码行数:29,代码来源:clients.py

示例2: get_rb_client

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
 def get_rb_client(self):
     if not self.rb_client:
         options = {}
         with open(".reviewboardrc") as reviewboardrc:
             for line in reviewboardrc:
                 if line.startswith("#"):
                     continue
                 if len(line.strip()) == 0:
                     continue
                 k, v = line.strip().split("=")
                 k = k.strip()
                 v = eval(v.strip())
                 options[k] = v
         rbclient = RBClient(options['REVIEWBOARD_URL'])
         self.repository = options['REPOSITORY']
         self.branch = options.get('BRANCH') or options.get('TRACKING_BRANCH')
         self.target_groups = None
         if options.has_key('TARGET_GROUPS'):
             self.target_groups = options['TARGET_GROUPS']
         if rbclient.get_root().get_session()['authenticated']:
             return rbclient.get_root()
         username = self.opt.reviewboard_username or raw_input("Enter review board Username: ")
         password = self.opt.reviewboard_password or getpass("Enter password: ")
         rbclient.login(username, password)
         self.rb_client = rbclient.get_root()
     return self.rb_client
开发者ID:rajubairishetti,项目名称:apache-dev-tool,代码行数:28,代码来源:clients.py

示例3: ship_it

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
    def ship_it(self, rrid, username, password):
        """Create and publish a ship-it review"""

        # TODO: this code is lifted from the reviewboard mach commands. If we
        #       need to make more reviewboard api calls in these tests, we
        #       should make a function in the base class to get a RBClient.
        class NoCacheTransport(SyncTransport):
            """API transport with disabled caching."""
            def enable_cache(self):
                pass

        # RBClient is persisting login cookies from call to call
        # in $HOME/.rbtools-cookies. We want to be able to easily switch
        # between users, so we clear that cookie between calls to the
        # server and reauthenticate every time.
        try:
            os.remove(os.path.join(os.environ.get('HOME'), '.rbtools-cookies'))
        except Exception:
            pass

        client = RBClient(self.rburl, username=username,
                          password=password, transport_cls=NoCacheTransport)
        root = client.get_root()

        reviews = root.get_reviews(review_request_id=rrid)
        reviews.create(public=True, ship_it=True)
开发者ID:pombredanne,项目名称:version-control-tools,代码行数:28,代码来源:test-autoland-inbound.py

示例4: get_api

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def get_api(server_url, **kwargs):
    """Returns an RBClient instance and the associated root resource.

    Hooks should use this method to gain access to the API, instead of
    instantiating their own client.

    Args:
        server_url (unicode):
            The server URL to retrieve.

        **kwargs (dict):
            Additional keyword arguments to pass to the
            :py:class:`~rbtools.api.client.RBClient` constructor. See
            :py:meth:`SyncTransport.__init__()
            <rbtools.api.transport.sync.SyncTransport.__init__>` for arguments
            that are accepted.

    Returns:
        tuple:
        This returns a 2-tuple of the :py:class:`~rbtools.api.client.RBClient`
        and :py:class:`<root resource> rbtools.api.resource.Resource`.
    """
    api_client = RBClient(server_url, **kwargs)

    try:
        api_root = api_client.get_root()
    except ServerInterfaceError as e:
        raise HookError('Could not reach the Review Board server at %s: %s'
                        % (server_url, e))
    except APIError as e:
        raise HookError('Unexpected API Error: %s' % e)

    return api_client, api_root
开发者ID:clach04,项目名称:rbtools,代码行数:35,代码来源:common.py

示例5: main

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def main(url, group_names, days_old=7, dry_run=False):
    """ do something """
    try:
        user = os.environ['RBUSER']
    except KeyError:
        raise SystemExit("please set RBUSER environment variable for reviewboard user")
    try:
        passwd = os.environ['RBPASS']
    except KeyError:
        raise SystemExit("please set RBPASS environment variable for reviewboard password")
    #client = RBClient(url, user, passwd)
    client = RBClient(url)
    root = client.get_root()
    if not root:
        raise SystemExit("Error - could not get RBClient root.")

    for g_name in group_names:
        o = get_group_id_by_name(root, g_name, dry_run=dry_run)
        if not o:
            raise SystemExit("ERROR: no group '%s' found." % g_name)
        logger.debug("Found group '%s' id=%d" % (g_name, o))

    reviews = get_reviews_for_groups(root, group_names, dry_run=dry_run)

    old_reviews = filter_reviews_older_than(root, reviews, days_old, dry_run=dry_run)
    logger.info("found %d reviews for target groups and last updated %d or more days ago" % (len(old_reviews), days_old))

    if len(old_reviews) < 1:
        logger.info("Found no reviews matching criteria, exiting")
        return False

    users = get_submitters_for_reviews(old_reviews)
    logger.debug("got user information for %d users" % len(users))
    recipients = []
    for u in users:
        recipients.append("{u.fullname} <{u.email}>".format(u=users[u]))

    table = generate_report_html_table(old_reviews, url)

    body = "<h1>ReviewBoard reminder</h1>\n"
    body += """<p>You're receiving this message because you have one or more pending code reviews on <a href="{url}">{url}</a>
targeted at the '{group_names}' group(s) that have not been updated in over {days_old} days and have not been submitted.
At your convenience, please evaluate these reviews and close/submit any that have been merged or discarded.
Thank You.</p>\n""".format(url=url, days_old=days_old, group_names=", ".join(group_names))
    body += table
    body += "\n<br />\n"
    host = node()
    user = getuser()
    body += """
<p><em>generated by <a href=\"https://github.com/jantman/misc-scripts/blob/master/reviewboard_reminder_mail.py">reviewboard_reminder_mail.py</a>
running on {host} as {user} at {ds}</em></p>
""".format(host=host, user=user, ds=datetime.datetime.now().isoformat())

    if dry_run:
        print("Message to send:\n##############################\n{msg}\n#################################\n".format(msg=body))
        print("Would send to:\n {to}".format(to=", ".join(recipients)))
    else:
        raise SystemExit("Oops - never actually implemented the mail sending...")

    return True
开发者ID:jantman,项目名称:misc-scripts,代码行数:62,代码来源:reviewboard_reminder_mail.py

示例6: process_review_requests

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def process_review_requests(client, channel, nick, review_ids):
    """
    Processes a list of review request ids using a shared client
    """
    logger.info("Starting codereview of: {0}".format(review_ids))
    api = RBClient(settings.CODEREVIEW_REVIEWBOARD_API_URL,
                   username=settings.CODEREVIEW_REVIEWBOARD_API_USERNAME,
                   password=settings.CODEREVIEW_REVIEWBOARD_API_PASSWORD)

    try:
        api_root = api.get_root()
    except:
        logger.exception("Cannot access reviewboard")
        client.msg(
            channel,
            "I can't complete your review {0} because I can't access reviewboard".format(nick)
        )
        return

    errors = []

    for review_id in review_ids:
        try:
            do_review(client, channel, nick, api_root, review_id)
        except:
            logger.exception("Cannot codereview cr{0}".format(review_id))
            errors.append(review_id)

    if errors:
        cr_list = ', '.join(map(lambda id: 'cr{0}'.format(id), errors))
        client.msg(channel, 'Codereview complete {0}, but I was unable to review: {1}'.format(nick, cr_list))
    else:
        client.msg(channel, 'Codereview complete {0}'.format(nick))
开发者ID:michaelorr,项目名称:helga-codereview,代码行数:35,代码来源:helga_codereview.py

示例7: get_api

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def get_api(server_url, username, password):
    """Returns an RBClient instance and the associated root resource.

    Hooks should use this method to gain access to the API, instead of
    instantianting their own client.
    """
    api_client = RBClient(server_url, username=username, password=password)

    try:
        api_root = api_client.get_root()
    except ServerInterfaceError, e:
        raise HookError('Could not reach the Review Board server at %s: %s'
                        % (server_url, e))
开发者ID:MistShi,项目名称:rbtools,代码行数:15,代码来源:common.py

示例8: get_open_reviews

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def get_open_reviews(args):
    # get open reviews to a specified user, group, etc.
    args['status'] = 'pending'
    args['max_results'] = MAX_RESULTS

    client = RBClient(RB_URL)
    root = client.get_root()
    if not root:
        print "Error - could not get RBClient root."
        return False

    req = root.get_review_requests(**args)
    print "\n\nGot %d pending/unsubmitted reviews" % req.total_results
    for review in req:
        print "%d - %s - %s" % (review.id, review.get_submitter().username, review.summary)
开发者ID:jantman,项目名称:reviewboard-scripts,代码行数:17,代码来源:list_mine.py

示例9: shipit

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def shipit(use_merge):
  subprocess.check_call(["git", "fetch"])

  if use_merge:
    subprocess.check_call(["git", "merge", "origin/master"])
  else:
    subprocess.check_call(["git", "rebase", "origin/master"])

  # run spec
  try:
    if os.path.exists("scripts/test.sh"):
      subprocess.check_call(["scripts/test.sh"])
  except subprocess.CalledProcessError:
    exit(1)

  branch = current_branch()
  rid = get_branch_info("rid")

  if not rid:
    print "You don't have a review branch."
    exit(1)
  else:
    rid = int(rid)

  # git checkout master
  subprocess.check_call(["git", "checkout", "master"])

  # git pull origin master
  subprocess.check_call(["git", "pull", "origin", "master"])

  # git merge current_branch
  subprocess.check_call(["git", "merge", branch])

  # git push origin master
  subprocess.check_call(["git", "push", "origin", "master"])

  # git push origin :current_branch
  subprocess.check_call(["git", "push", "origin", ":" + branch])

  # git branch -D current_branch
  subprocess.check_call(["git", "branch", "-D", branch])

  # close reviewboard request
  from rbtools.api.client import RBClient
  client = RBClient('http://reviewboard.nodeswork.com')
  root = client.get_root()
  request = root.get_review_request(review_request_id=rid)
  request.update(status="submitted")
开发者ID:nodeswork,项目名称:reviewboard-tool,代码行数:50,代码来源:reviewboard_tool.py

示例10: run

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def run(old_value, new_value, ref):
    diff = call_cmd("git diff %s..%s"%(old_value, new_value))
    info(diff)

    ci_range = "%s..%s"%(old_value, new_value)
    # get author name
    cmd = "git log --format=%cn -1 " + new_value
    author = call_cmd(cmd).strip()
    if author in AUTHOR_MAP:
        author = AUTHOR_MAP[author]
    reviewer = REVIEWER_MAP[author]

    # get summary desc
    cmd = "git log --format=%s " + ci_range
    logs = call_cmd(cmd)
    summary = logs.split(os.linesep)[0]
    cmd = "git log --pretty=fuller " + ci_range
    desc = call_cmd(cmd)
    summary = summary.replace("\"", "@")
    desc = desc.replace("\"", "@")

    repo_branch = ref.split("/")[-1]

    # 创建review_request
    client = RBClient(rbcfg["rbserver"], username=rbcfg["rbadmin"], password=rbcfg["rbadminpw"])
    root = client.get_root()
    request_data = {
            "repository" : rbcfg["rbrepo"],
            "submit_as" : author,
            }
    r = root.get_review_requests().create(**request_data)
    vl = root.get_diff_validation()
    basedir = "/"
    #info("------------------"+diff)
    vl.validate_diff(rbcfg["rbrepo"], diff, base_dir=basedir)
    r.get_diffs().upload_diff(diff, base_dir=basedir)
    draft = r.get_draft()
    update_data = {
            "branch" : repo_branch,
            "summary" : summary,
            "description" : desc,
            "target_people" : reviewer,
            "public" : True,
            }
            
    ret = draft.update(**update_data)
    info("repo:<%s> rev:<%s> rid:<%s>"%(rbcfg["rbserver"], ci_range, r.id))
开发者ID:bttscut,项目名称:hooks-for-reviewboard,代码行数:49,代码来源:cron_post.py

示例11: ProcessReviewRequest

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def ProcessReviewRequest(payload, tool_settings):
    """Execute an automated review on a review request."""
    routing_key = ProcessReviewRequest.request.delivery_info['routing_key']
    route_parts = routing_key.partition('.')
    tool_ep = route_parts[0]
    logger.info(
        "Request to execute review tool '%s' for %s" % (
            tool_ep, payload['url']))

    try:
        logger.info("Initializing RB API")
        api_client = RBClient(
            payload['url'],
            cookie_file=COOKIE_FILE,
            agent=AGENT,
            session=payload['session'])
        api_root = api_client.get_root()
    except:
        logger.error("Could not contact RB server at '%s'" % payload['url'])
        return False

    logger.info("Loading requested tool '%s'" % tool_ep)
    tools = []
    for ep in pkg_resources.iter_entry_points(group='reviewbot.tools',
                                              name=tool_ep):
        tools.append(ep.load())

    if len(tools) > 1:
        _update_tool_execution(api_root, payload['request'], status=FAILED,
                               msg="Tool '%s' is ambiguous" % tool_ep)
        return False
    elif len(tools) == 0:
        _update_tool_execution(api_root, payload['request'], status=FAILED,
                               msg="Tool '%s' not found" % tool_ep)
        return False

    tool = tools[0]
    try:
        logger.info("Initializing review")
        review = Review(api_root, payload['request'],
                        payload['review_settings'])
    except Exception, e:
        _update_tool_execution(api_root, payload['request'], status=FAILED,
                               msg="Error initializing review: %s" % str(e))
        return False
开发者ID:djl197,项目名称:ReviewBot,代码行数:47,代码来源:tasks.py

示例12: get_open_reviews

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def get_open_reviews(args):
    """
    get open reviews to a specified user, group, etc.
    """
    args['status'] = 'pending'
    if 'max_results' not in args:
        args['max_results'] = 100

    client = RBClient(RB_URL)
    root = client.get_root()
    if not root:
        print "Error - could not get RBClient root."
        return False

    req = root.get_review_requests(**args)
    ret = {'total': req.total_results, 'reviews': []}
    for review in req:
        ret['reviews'].append("(%s) %s <%s/r/%d/>" % (review.get_submitter().username, review.summary, RB_URL, review.id))
    return ret
开发者ID:jantman,项目名称:reviewboard-scripts,代码行数:21,代码来源:willie_reviews.py

示例13: update_tools_list

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def update_tools_list(panel, payload):
    """Update the RB server with installed tools.

    This will detect the installed analysis tool plugins
    and inform Review Board of them.
    """
    logging.info("Request to refresh installed tools from '%s'" %
                 payload['url'])

    logging.info("Iterating Tools")
    tools = []

    for ep in pkg_resources.iter_entry_points(group='reviewbot.tools'):
        entry_point = ep.name
        tool_class = ep.load()
        tool = tool_class()
        logging.info("Tool: %s" % entry_point)

        if tool.check_dependencies():
            tools.append({
                'name': tool_class.name,
                'entry_point': entry_point,
                'version': tool_class.version,
                'description': tool_class.description,
                'tool_options': json.dumps(tool_class.options),
            })
        else:
            logging.warning("%s dependency check failed." % ep.name)

    logging.info("Done iterating Tools")
    tools = json.dumps(tools)
    hostname = panel.hostname

    try:
        api_client = RBClient(
            payload['url'],
            cookie_file=COOKIE_FILE,
            agent=AGENT,
            session=payload['session'])
        api_root = api_client.get_root()
    except Exception, e:
        logging.error("Could not reach RB server: %s" % str(e))
        return {'error': 'Could not reach RB server.'}
开发者ID:djl197,项目名称:ReviewBot,代码行数:45,代码来源:tasks.py

示例14: get_rb_client

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
 def get_rb_client(self):
     options = {}
     with open(".reviewboardrc") as reviewboardrc:
         for line in reviewboardrc:
             k, v = line.split("=")
             k = k.strip()
             v = eval(v.strip())
             options[k] = v
     rbclient = RBClient(options['REVIEWBOARD_URL'])
     self.repository = options['REPOSITORY']
     self.branch = options['BRANCH']
     self.target_groups = None
     if options.has_key('TARGET_GROUPS'):
         self.target_groups = options['TARGET_GROUPS']
     if rbclient.get_root().get_session()['authenticated']:
         return rbclient
     username = raw_input("Enter review board Username: ")
     password = getpass("Enter password: ")
     rbclient.login(username, password)
     return rbclient
开发者ID:yssharma,项目名称:rbt-jira,代码行数:22,代码来源:clients.py

示例15: get_open_reviews

# 需要导入模块: from rbtools.api.client import RBClient [as 别名]
# 或者: from rbtools.api.client.RBClient import get_root [as 别名]
def get_open_reviews(args):
    """
    get open reviews to a specified user, group, etc.
    """
    args['status'] = 'pending'
    if 'max_results' not in args:
        args['max_results'] = 100

    client = RBClient(REVIEWBOARD_URL)

    # If we have a username and password, login
    if REVIEWBOARD_USERNAME and REVIEWBOARD_PASSWORD:
        client.login(REVIEWBOARD_USERNAME, REVIEWBOARD_PASSWORD)

    root = client.get_root()

    if not root:
        logger.error(u'Could not get RBClient root')
        return None

    try:
        req = root.get_review_requests(**args)
    except APIError:
        logger.exception(u'Error querying API')
        return None

    ret = {'total': req.total_results, 'reviews': []}
    review_fmt = u"[{user}] {summary} ({url}/r/{id})"

    for review in req:
        ret['reviews'].append(review_fmt.format(user=review.get_submitter().username,
                                                summary=review.summary,
                                                url=REVIEWBOARD_URL,
                                                id=review.id))

    return ret
开发者ID:shaunduncan,项目名称:helga-reviews,代码行数:38,代码来源:helga_reviews.py


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