Verified Commit 44ec09c5 authored by Ansgar's avatar Ansgar

use `print` instead of `sys.stderr.write` or `sys.stdout.write`

parent 6c241cb0
......@@ -340,7 +340,7 @@ def check_timestamps():
if os.access(filename, os.R_OK):
f = utils.open_file(filename)
current_file = filename
sys.stderr.write("Processing %s.\n" % (filename))
print("Processing %s." % (filename), file=sys.stderr)
apt_inst.debExtract(f, Ent, "control.tar.gz")
f.seek(0)
apt_inst.debExtract(f, Ent, "data.tar.gz")
......
......@@ -225,9 +225,9 @@ def export_files(session, archive, clpool, progress=False):
stats['unpack'] += 1
if progress:
if stats['unpack'] % 100 == 0:
sys.stderr.write('%d packages unpacked\n' % stats['unpack'])
print('%d packages unpacked' % stats['unpack'], file=sys.stderr)
elif stats['unpack'] % 10 == 0:
sys.stderr.write('.')
print('.', end='', file=sys.stderr)
for file in files:
for f in glob(os.path.join(tempdir, 'debian', '*%s' % file)):
for s in unpack[p][1]:
......
......@@ -170,7 +170,7 @@ SELECT
if Options["Print"]:
for package in sorted(maintainers):
sys.stdout.write(format(package, maintainers[package]))
print(format(package, maintainers[package]), end='')
else:
maintainer_file = open('Maintainers', 'w')
uploader_file = open('Uploaders', 'w')
......
......@@ -123,7 +123,7 @@ def main():
print("Skipping %s as it is marked as untouchable" % suite.suite_name)
continue
sys.stderr.write("Processing %s...\n" % (suite.suite_name))
print("Processing %s..." % (suite.suite_name), file=sys.stderr)
override_suite = suite.overridecodename or suite.codename
for component in session.query(Component).all():
......
......@@ -777,7 +777,7 @@ def end():
sets = "set"
if accept_count > 1:
sets = "sets"
sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, utils.size_type(int(accept_bytes))))
print("Accepted %d package %s, %s." % (accept_count, sets, utils.size_type(int(accept_bytes))), file=sys.stderr)
Logger.log(["total", accept_count, accept_bytes])
if not Options["No-Action"] and not Options["Trainee"]:
......@@ -832,7 +832,7 @@ def main():
readline.parse_and_bind("tab: complete")
if len(uploads) > 1:
sys.stderr.write("Sorting changes...\n")
print("Sorting changes...", file=sys.stderr)
uploads = sort_uploads(new_queue, uploads, session, Options["No-Binaries"])
if Options["Comments"]:
......
......@@ -131,18 +131,14 @@ def open_file(filename, mode='r'):
def our_raw_input(prompt=""):
if prompt:
while 1:
try:
sys.stdout.write(prompt)
break
except IOError:
pass
print(prompt, end='')
# TODO: py3: use `print(..., flush=True)`
sys.stdout.flush()
try:
ret = raw_input()
return ret
except EOFError:
sys.stderr.write("\nUser interrupt (^D).\n")
print("\nUser interrupt (^D).", file=sys.stderr)
raise SystemExit
################################################################################
......@@ -607,12 +603,12 @@ def TemplateSubst(subst_map, filename):
def fubar(msg, exit_code=1):
sys.stderr.write("E: %s\n" % (msg))
print("E:", msg, file=sys.stderr)
sys.exit(exit_code)
def warn(msg):
sys.stderr.write("W: %s\n" % (msg))
print("W:", msg, file=sys.stderr)
################################################################################
......
......@@ -5,6 +5,8 @@
# Author: Filippo Giunchedi <filippo@debian.org>
# Version: 0.5
from __future__ import print_function
import cgi
import os
import os.path
......@@ -110,7 +112,7 @@ def parse_leave_reason(fname):
try:
f = open(fname)
except IOError as e:
sys.stderr.write("Can't open %s: %s\n" % (fname, e))
print("Can't open %s: %s" % (fname, e), file=sys.stderr)
return {}
res = {}
......@@ -195,12 +197,12 @@ if __name__ == "__main__":
(settings, args) = parser.parse_args()
if not os.path.exists(settings.outdir):
sys.stderr.write("Outdir '%s' does not exists\n" % settings.outdir)
print("Outdir '%s' does not exists" % settings.outdir, file=sys.stderr)
parser.print_help()
sys.exit(1)
if not os.path.exists(settings.datadir):
sys.stderr.write("Datadir '%s' does not exists\n" % settings.datadir)
print("Datadir '%s' does not exists" % settings.datadir, file=sys.stderr)
parser.print_help()
sys.exit(1)
......@@ -225,7 +227,7 @@ if __name__ == "__main__":
status.feed_in.write_xml(file(feed_in_file, "w+"), "utf-8")
status.feed_out.write_xml(file(feed_out_file, "w+"), "utf-8")
except IOError as why:
sys.stderr.write("Unable to write feeds: %s\n" % why)
print("Unable to write feeds:", why, file=sys.stderr)
sys.exit(1)
status.queue = current_queue
......@@ -233,7 +235,7 @@ if __name__ == "__main__":
try:
cPickle.dump(status, open(status_db, "w+"))
except IOError as why:
sys.stderr.write("Unable to save status: %s\n" % why)
print("Unable to save status:", why, file=sys.stderr)
sys.exit(1)
# vim:et:ts=4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment