3114: `rbt post' prompts for username even if --username if provided; `post-review --username` doesn't

yane****@gmai***** (Google Code) (Is this you? Claim this profile.)
Oct. 24, 2013
What version are you running?

$ post-review --version
RBTools 0.5.2
$ git ls-remote origin HEAD
834103615b50ab63f0fcd56dab8eba2fccde5659        HEAD

What's the URL of the page containing the problem?

n/a

What steps will reproduce the problem?

1. rbt post --username foo

What is the expected output? What do you see instead?

I should not be prompted for a password (post-review doesn't prompt me for
one).

What operating system are you using? What browser?

$ uname -a
CYGWIN_NT-6.1 ZL00757 1.7.25(0.270/5/3) 2013-08-31 20:37 x86_64 Cygwin

Please provide any additional information below.

garrett.cooper@ZL00757 ~/git/rbtools~
$ post-review --username yaneurabeya --diff-filename 0002-Don-t-bomb-out-if-a-password-wasn-t-provided.patch
==> HTTP Authentication Required
Enter authorization information for "Web API" at reviews.reviewboard.org
Password: Traceback (most recent call last):
  File "/usr/bin/post-review", line 8, in <module>
    load_entry_point('RBTools==0.5.2.dev', 'console_scripts', 'post-review')()
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/postreview.py", line 1314, in main
    server.load_capabilities()
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/postreview.py", line 274, in load_capabilities
    info = self.api_get('api/info/')
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/postreview.py", line 705, in api_get
    return self.process_json(self.http_get(path))
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/postreview.py", line 675, in http_get
    rsp = urllib2.urlopen(url).read()
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 402, in open
    req = meth(req)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/postreview.py", line 80, in http_request
    self.password_mgr.find_user_password('Web API', self.url)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/postreview.py", line 180, in find_user_password
    self.rb_pass = getpass.getpass('Password: ')
  File "/usr/lib/python2.7/getpass.py", line 71, in unix_getpass
    passwd = _raw_input(prompt, stream, input=input)
  File "/usr/lib/python2.7/getpass.py", line 133, in _raw_input
    line = input.readline()
KeyboardInterrupt

garrett.cooper@ZL00757 ~/git/rbtools~
$ rbt post --username yaneurabeya --diff-filename 0002-Don-t-bomb-out-if-a-password-wasn-t-provided.patch
==> HTTP Authentication Required
Enter authorization information for "Web API" at reviews.reviewboard.org
Username: Traceback (most recent call last):
  File "/usr/bin/rbt", line 8, in <module>
    load_entry_point('RBTools==0.5.2.dev', 'console_scripts', 'rbt')()
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/commands/main.py", line 106, in main
    command.run_from_argv([RB_MAIN] + args)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/commands/__init__.py", line 157, in run_from_argv
    exit_code = self.main(*args) or 0
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/commands/post.py", line 464, in main
    api_client, api_root = self.get_api(server_url)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/commands/__init__.py", line 255, in get_api
    api_root = api_client.get_root()
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/api/client.py", line 16, in get_root
    return self._transport.get_root(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/api/transport/sync.py", line 35, in get_root
    return self._execute_request(HttpRequest(self.server.url))
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/api/transport/sync.py", line 69, in _execute_request
    rsp = self.server.make_request(request)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/api/request.py", line 413, in make_request
    rsp = urllib2.urlopen(r)
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 402, in open
    req = meth(req)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/api/request.py", line 151, in http_request
    self.password_mgr.find_user_password('Web API', self.url)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/api/request.py", line 235, in find_user_password
    username, password = self.auth_callback(realm, uri)
  File "/usr/lib/python2.7/site-packages/RBTools-0.5.2.dev-py2.7.egg/rbtools/commands/__init__.py", line 230, in credentials_prompt
    username = raw_input()
KeyboardInterrupt
#1 yane****@gmai***** (Google Code) (Is this you? Claim this profile.)
Found the problem and it's easy to fix (will submit a review for this soon):

213     def credentials_prompt(self, realm, uri, *args, **kwargs):
214         """Prompt the user for credentials using the command line.
215
216         This will prompt the user, and then return the provided
217         username and password. This is used as a callback in the
218         API when the user requires authorization.
219         """
220         if getattr(self.options, 'diff_filename', None) == '-':
221             die('HTTP authentication is required, but cannot be '
222                 'used with --diff-filename=-')
223
224         print "==> HTTP Authentication Required"
225         print 'Enter authorization information for "%s" at %s' % \
226             (realm, urlparse(uri)[1])
227         # getpass will write its prompt to stderr but raw_input
228         # writes to stdout. See bug 2831.
229         sys.stderr.write('Username: ')
230         username = raw_input()
231         password = getpass.getpass('Password: ')
david
#2 david
Fixed in rbtools release-0.5.x (9ab0cac). Thanks!
  • +Fixed