Nicely print the web login URL when authenticating rbt post.

Review Request #14600 — Created Sept. 8, 2025 and submitted

Information

RBTools
release-5.x

Reviewers

In rbt post, a progress bar for commit validation starts up before we
know whether the client is authenticated or not. While the progress bar
is active, we'll prompt for auth credentials. When we prompt for web
login authentication, the "Please log in to the Review Board ..." line
gets printed onto the same line as the progress bar, since the cursor is
set by the bar who is not expected to deal with any external input/output.
When we prompt for username/password authentication, the line
gets printed onto the next line because we write a new line to STDOUT
before prompting for the credentials.

This change makes the web login logs prettier by checking if a progress
bar is active and then logging a new line if so for the web-login flow.
We are using an internal attribute to check if a bar is active, since I
couldn't find any public API for this. This should be fine for our
purposes, if anything changes with that attribute then we'll just get the
ugly printing again.

Made sure things looked nice when using rbt post and other commands
(rbt login, rbt status) when passing --web-login and when using
username and password prompting.

Summary ID
Nicely print the web login URL when authenticating rbt post.
In rbt post, a progress bar for commit validation starts up before we know whether the client is authenticated or not. While the progress bar is active, we'll prompt for auth credentials. When we prompt for web login authentication, for some reason the "Please log in to the Review Board ..." line gets printed onto the same line as the progress bar. However when we prompt for username/password authentication, the line gets printed onto the next line (as it should). I couldn't exactly figure out why these two differed, but this fixes that issue by checking if a progress bar is active and then logging a new line if so for the web-login flow. We are using an internal attribute to check if a bar is active, since I couldn't find any public API for this. This should be fine for our purposes, if anything changes with that attribute then we'll just get the ugly printing again.
bcbdd77bce4fac78a85eac5e32415cff9783b3a6
Description From Last Updated

The reason that's happened is most likely due to the following conditions: The progress bar is keeping the cursor position …

chipx86chipx86

Can we import at the top of the module, or does it need to be here?

chipx86chipx86

Seems like we could just import this as tqdm without the underscore.

daviddavid

I realize I don't even need to do this weird import, I'll just import tqdm like we normally do.

maubinmaubin
chipx86
  1. 
      
  2. Show all issues

    The reason that's happened is most likely due to the following conditions:

    1. The progress bar is keeping the cursor position set within the bar, for the next chunk, expecting to own all input/output.

    2. The "Please log in" is a standard print, so it starts at the cursor position.

    3. The prompt is more special. I believe it takes care to ensure it's on its own line, and uses hints to notify the terminal that input is to be provided for this. It can use readline to handle this, which is likely what's managing that.

    1. Ohh woops I was getting my code paths mixed up and wasn't looking in BaseCommand.credentials_prompt, I was just looking in the standalone credentials_prompt function. BaseCommand.credentials_prompt does do a self.stdout.new_line().

  3. 
      
chipx86
  1. 
      
  2. rbtools/utils/web_login.py (Diff revision 1)
     
     
    Show all issues

    Can we import at the top of the module, or does it need to be here?

    1. It doesn't need to be here, it just seemed more appropriate to have the import contained to this function since its only used here. I can move it though.

  3. 
      
maubin
david
  1. 
      
  2. rbtools/utils/web_login.py (Diff revision 2)
     
     
    Show all issues

    Seems like we could just import this as tqdm without the underscore.

  3. 
      
maubin
maubin
  1. 
      
  2. rbtools/utils/web_login.py (Diff revision 2)
     
     
    Show all issues

    I realize I don't even need to do this weird import, I'll just import tqdm like we normally do.

  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
  1. Ship It!
  2. 
      
maubin
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (79bc7bd)