5001: Please add detailed information about reviewboard URL to rbt login

shubhar

What version are you running?

4.0.10

Describe the enhancement and the motivation for it.

We have an issue where from one P4 workspace we can have multiple ReviewBoard site invocations depending on how environment variables are setup. So rbt login doesn't give enough information about which ReviewBoard instance was logged into.

Please provide any additional information below. Example below.

It would be nice if we had an actual ReviewBoard URL in the message.

Please log in to the Review Board server at www.blahblah.com
Username: mickeymouse
Password:
You are already logged in to Review Board at www.blahblah.com

*Should add the actual ReviewBoard instance to the verbiage
For instance which ReviewBoard server ?

chipx86
#1 chipx86

Good suggestion, and I agree, we should do that.

  • -New
    +Confirmed
  • +Release-5.x
#2 shubhar

Has anything been done on this ? If not, I am willing to work on it and try to deliver a patch.

david
#3 david

To my knowledge, there has been no work on this. We'd love a contribution!

Thanks

#4 shubhar

I'm not going to submit a patch for this. But here is the fix. It's super easy. I hope you roll it into 4.1 too.
change rbtools_install/rbtools/commands/login.py as follows (use self.server_url instead of self.api_client.domain)

 """Run the command."""
    session = self.api_root.get_session(expand='user')
    was_authenticated = session.authenticated

    if not was_authenticated:
        try:
            session = get_authenticated_session(api_client=self.api_client,
                                                api_root=self.api_root,
                                                auth_required=True,
                                                session=session)
        except AuthorizationError:
            raise CommandError('Unable to log in to Review Board.')

    if session.authenticated:
        if not was_authenticated or (self.options.username and
                                     self.options.password):
            logging.info('Successfully logged in to Review Board at %s', self.server_url)
        else:
            logging.info('You are already logged in to Review Board at %s',
                         self.server_url)
#5 shubhar

an alternative method:
root = self.api_client.get_root()
#pdb.set_trace()
rb_url = root.transport.url
if not was_authenticated:
try:
session = get_authenticated_session(api_client=self.api_client,
api_root=self.api_root,
auth_required=True,
session=session)
except AuthorizationError:
raise CommandError('Unable to log in to Review Board at %s', rb

    if session.authenticated:
        if not was_authenticated or (self.options.username and
                                     self.options.password):
            logging.info('Successfully logged in to Review Board at %s', rb_
        else:
            logging.info('You are already logged in to Review Board at %s',
                         rb_url
            )
#6 shubhar

Sorry looks like part of the previous post got truncated. Here's the full login.py
from future import unicode_literals

import logging

from rbtools.api.errors import AuthorizationError
from rbtools.commands import Command, CommandError
from rbtools.utils.users import get_authenticated_session

import pdb

class Login(Command):
"""Logs into a Review Board server.

The user will be prompted for a username and password, unless otherwise
passed on the command line, allowing the user to log in and save a
session cookie without needing to be in a repository or posting to
the server.

If the user is already logged in, this won't do anything.
"""

name = 'login'
author = 'The Review Board Project'

needs_api = True

option_list = [
    Command.server_options,
]

def main(self):
    """Run the command."""
    session = self.api_root.get_session(expand='user')
    was_authenticated = session.authenticated
    root = self.api_client.get_root()
    #pdb.set_trace()
    rb_url = root._transport.url
    if not was_authenticated:
        try:
            session = get_authenticated_session(api_client=self.api_client,
                                                api_root=self.api_root,
                                                auth_required=True,
                                                session=session)
        except AuthorizationError:
            raise CommandError('Unable to log in to Review Board at %s', rb_url)

    if session.authenticated:
        if not was_authenticated or (self.options.username and
                                     self.options.password):
            logging.info('Successfully logged in to Review Board at %s', rb_url)
        else:
            logging.info('You are already logged in to Review Board at %s',
                         rb_url
            )