mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
use print() instead of sys.stdout.write()
We're relying on sys.stdout.write() to flush its buffer which isn't guaranteed, and is not the case in Python 3. Change to use print() everywhere to be standard, and utilize the end= keyword to get the EOL semantics we need. We can't use print's flush= keyword as that's only in Python 3. Leave behind a TODO to clean it up when we can drop Python 2. Bug: https://crbug.com/gerrit/10418 Change-Id: I562128c7f1e6d154f4a6ecdf33a70fa2811dc2af Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/230392 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
parent
4f42a97067
commit
ab85fe7c53
@ -294,7 +294,9 @@ to update the working directory files.
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def _Prompt(self, prompt, value):
|
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()
|
a = sys.stdin.readline().strip()
|
||||||
if a == '':
|
if a == '':
|
||||||
return value
|
return value
|
||||||
@ -328,7 +330,9 @@ to update the working directory files.
|
|||||||
|
|
||||||
print()
|
print()
|
||||||
print('Your identity is: %s <%s>' % (name, email))
|
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()
|
a = sys.stdin.readline().strip().lower()
|
||||||
if a in ('yes', 'y', 't', 'true'):
|
if a in ('yes', 'y', 't', 'true'):
|
||||||
break
|
break
|
||||||
@ -370,7 +374,9 @@ to update the working directory files.
|
|||||||
out.printer(fg='black', attr=c)(' %-6s ', c)
|
out.printer(fg='black', attr=c)(' %-6s ', c)
|
||||||
out.nl()
|
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()
|
a = sys.stdin.readline().strip().lower()
|
||||||
if a in ('y', 'yes', 't', 'true', 'on'):
|
if a in ('y', 'yes', 't', 'true', 'on'):
|
||||||
gc.SetString('color.ui', 'auto')
|
gc.SetString('color.ui', 'auto')
|
||||||
|
@ -221,7 +221,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
for commit in commit_list:
|
for commit in commit_list:
|
||||||
print(' %s' % commit)
|
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 = sys.stdin.readline().strip().lower()
|
||||||
answer = answer in ('y', 'yes', '1', 'true', 't')
|
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 they want to auto upload, let's not ask because it could be automated
|
||||||
if answer is None:
|
if answer is None:
|
||||||
sys.stdout.write('Uncommitted changes in ' + branch.project.name)
|
print()
|
||||||
sys.stdout.write(' (did you forget to amend?):\n')
|
print('Uncommitted changes in %s (did you forget to amend?):'
|
||||||
sys.stdout.write('\n'.join(changes) + '\n')
|
% branch.project.name)
|
||||||
sys.stdout.write('Continue uploading? (y/N) ')
|
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()
|
a = sys.stdin.readline().strip().lower()
|
||||||
if a not in ('y', 'yes', 't', 'true', 'on'):
|
if a not in ('y', 'yes', 't', 'true', 'on'):
|
||||||
print("skipping upload", file=sys.stderr)
|
print("skipping upload", file=sys.stderr)
|
||||||
|
Loading…
Reference in New Issue
Block a user