Mercurial > public > mercurial-scm > hg-stable
diff mercurial/keepalive.py @ 30482:39d13b8c101d
py3: bulk replace sys.stdin/out/err by util's
Almost all sys.stdin/out/err in hgext/ and mercurial/ are replaced by util's.
There are a few exceptions:
- lsprof.py and statprof.py are untouched since they are a kind of vendor
code and they never import mercurial modules right now.
- ui._readline() needs to replace sys.stdin and stdout to pass them to
raw_input(). We'll need another workaround here.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 20 Oct 2016 23:53:36 +0900 |
parents | bc0def54c17d |
children | 88a448a12ae8 |
line wrap: on
line diff
--- a/mercurial/keepalive.py Thu Oct 20 23:40:24 2016 +0900 +++ b/mercurial/keepalive.py Thu Oct 20 23:53:36 2016 +0900 @@ -660,14 +660,14 @@ def comp(N, url): print(' making %i connections to:\n %s' % (N, url)) - sys.stdout.write(' first using the normal urllib handlers') + util.stdout.write(' first using the normal urllib handlers') # first use normal opener opener = urlreq.buildopener() urlreq.installopener(opener) t1 = fetch(N, url) print(' TIME: %.3f s' % t1) - sys.stdout.write(' now using the keepalive handler ') + util.stdout.write(' now using the keepalive handler ') # now install the keepalive handler and try again opener = urlreq.buildopener(HTTPHandler()) urlreq.installopener(opener) @@ -712,11 +712,11 @@ i = 20 print(" waiting %i seconds for the server to close the connection" % i) while i > 0: - sys.stdout.write('\r %2i' % i) - sys.stdout.flush() + util.stdout.write('\r %2i' % i) + util.stdout.flush() time.sleep(1) i -= 1 - sys.stderr.write('\r') + util.stderr.write('\r') print(" fetching the file a second time") fo = urlreq.urlopen(url)