diff --git a/subcmds/init.py b/subcmds/init.py index 6c8b1ddc..1c809ab4 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -294,7 +294,9 @@ to update the working directory files. sys.exit(1) def _Prompt(self, prompt, value): - sys.stdout.write('%-10s [%s]: ' % (prompt, value)) + print('%-10s [%s]: ' % (prompt, value), end='') + # TODO: When we require Python 3, use flush=True w/print above. + sys.stdout.flush() a = sys.stdin.readline().strip() if a == '': return value @@ -328,7 +330,9 @@ to update the working directory files. print() print('Your identity is: %s <%s>' % (name, email)) - sys.stdout.write('is this correct [y/N]? ') + print('is this correct [y/N]? ', end='') + # TODO: When we require Python 3, use flush=True w/print above. + sys.stdout.flush() a = sys.stdin.readline().strip().lower() if a in ('yes', 'y', 't', 'true'): break @@ -370,7 +374,9 @@ to update the working directory files. out.printer(fg='black', attr=c)(' %-6s ', c) out.nl() - sys.stdout.write('Enable color display in this user account (y/N)? ') + print('Enable color display in this user account (y/N)? ', end='') + # TODO: When we require Python 3, use flush=True w/print above. + sys.stdout.flush() a = sys.stdin.readline().strip().lower() if a in ('y', 'yes', 't', 'true', 'on'): gc.SetString('color.ui', 'auto') diff --git a/subcmds/upload.py b/subcmds/upload.py index e7e5b1bf..d0dd3837 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py @@ -221,7 +221,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/ for commit in commit_list: print(' %s' % commit) - sys.stdout.write('to %s (y/N)? ' % remote.review) + print('to %s (y/N)? ' % remote.review, end='') + # TODO: When we require Python 3, use flush=True w/print above. + sys.stdout.flush() answer = sys.stdin.readline().strip().lower() answer = answer in ('y', 'yes', '1', 'true', 't') @@ -360,10 +362,13 @@ Gerrit Code Review: https://www.gerritcodereview.com/ # if they want to auto upload, let's not ask because it could be automated if answer is None: - sys.stdout.write('Uncommitted changes in ' + branch.project.name) - sys.stdout.write(' (did you forget to amend?):\n') - sys.stdout.write('\n'.join(changes) + '\n') - sys.stdout.write('Continue uploading? (y/N) ') + print() + print('Uncommitted changes in %s (did you forget to amend?):' + % branch.project.name) + print('\n'.join(changes)) + print('Continue uploading? (y/N) ', end='') + # TODO: When we require Python 3, use flush=True w/print above. + sys.stdout.flush() a = sys.stdin.readline().strip().lower() if a not in ('y', 'yes', 't', 'true', 'on'): print("skipping upload", file=sys.stderr)