def credentials_prompt(self, realm, uri, username=None, password=None,
                           *args, **kwargs):
        if username is None or password is None:
            if getattr(self.options, 'diff_filename', None) == '-':
                die('HTTP authentication is required, but cannot be '
                    'used with --diff-filename=-')

            # Interactive prompts don't work correctly when input doesn't come
            # from a terminal. This could seem to be a rare case not worth
            # worrying about, but this is what happens when using native
            # Python in Cygwin terminal emulator under Windows and it's very
            # puzzling to the users, especially because stderr is also _not_
            # flushed automatically in this case, so the program just appears
            # to hang.
            if not sys.stdin.isatty():
                logging.error('Authentication is required but input is not a '
                              'tty.')
                if sys.platform == 'win32':
                    logging.info('Check that you are not running this script '
                                 'from a Cygwin terminal emulator (or use '
                                 'Cygwin Python to run it).')

                raise CommandError('Unable to log in to Review Board.')

            print()
            print('Please log in to the Review Board server at %s.' %
                  urlparse(uri)[1])

            # getpass will write its prompt to stderr but input
            # writes to stdout. See bug 2831.
            if username is None:
                sys.stderr.write('Username: ')
                username = input()

            if password is None:
                password = getpass.getpass(b'Password: ')

        return username, password
Prompt the user for credentials using the command line.
dataset/ETHPy150Open reviewboard/rbtools/rbtools/commands/__init__.py/Command.credentials_prompt