Commit 21d65544 authored by Bastian Blank's avatar Bastian Blank 🙊

Convert to print function

parent 0e3a91c3
......@@ -16,6 +16,7 @@ add his key to the GPGKeyring
# You don't want to read this script if you know python.
# I know what I say. I dont know python and I wrote it. So go and read some other stuff.
from __future__ import print_function
import commands
import sys
......@@ -34,12 +35,12 @@ Logger = None
def usage(exit_code=0):
print """Usage: add-user [OPTION]...
print("""Usage: add-user [OPTION]...
Adds a new user to the dak databases and keyrings
-k, --key keyid of the User
-u, --user userid of the User
-h, --help show this help and exit."""
-h, --help show this help and exit.""")
sys.exit(exit_code)
################################################################################
......@@ -78,7 +79,7 @@ def main():
(result, output) = commands.getstatusoutput(cmd)
m = re_gpg_fingerprint_colon.search(output)
if not m:
print output
print(output)
utils.fubar("0x%s: (1) No fingerprint found in gpg output but it returned 0?\n%s"
% (Cnf["Add-User::Options::Key"], utils.prefix_multi_line_string(output,
" [GPG output:] ")))
......@@ -92,7 +93,7 @@ def main():
else:
u = re_user_address.search(output)
if not u:
print output
print(output)
utils.fubar("0x%s: (2) No userid found in gpg output but it returned 0?\n%s"
% (Cnf["Add-User::Options::Key"], utils.prefix_multi_line_string(output, " [GPG output:] ")))
uid = u.group(1)
......@@ -107,7 +108,7 @@ def main():
continue
emails.append(e.group(2))
print "0x%s -> %s <%s> -> %s -> %s" % (Cnf["Add-User::Options::Key"], name, emails[0], uid, primary_key)
print("0x%s -> %s <%s> -> %s -> %s" % (Cnf["Add-User::Options::Key"], name, emails[0], uid, primary_key))
prompt = "Add user %s with above data (y/N) ? " % (uid)
yn = utils.our_raw_input(prompt).lower()
......@@ -129,8 +130,8 @@ def main():
f.write(mail + '\n')
f.close()
print "Added:\nUid:\t %s (ID: %s)\nMaint:\t %s\nFP:\t %s" % (uid, uid_id,
name, primary_key)
print("Added:\nUid:\t %s (ID: %s)\nMaint:\t %s\nFP:\t %s" % (uid, uid_id,
name, primary_key))
# Should we send mail to the newly added user?
if Cnf.find_b("Add-User::SendEmail"):
......
This diff is collapsed.
......@@ -23,6 +23,8 @@
################################################################################
from __future__ import print_function
import apt_pkg
import errno
import os
......@@ -42,10 +44,10 @@ Logger = None
def usage(exit_code=0):
print """Usage: dak archive-dedup-pool [OPTION]...
print("""Usage: dak archive-dedup-pool [OPTION]...
-h, --help show this help and exit.
-V, --version display the version number and exit
"""
""")
sys.exit(exit_code)
################################################################################
......
......@@ -33,6 +33,8 @@ Check for obsolete binary packages
################################################################################
from __future__ import print_function
import sqlalchemy.sql as sql
import sys
import apt_pkg
......@@ -49,7 +51,7 @@ from daklib.rm import remove, ReverseDependencyChecker
def usage(exit_code=0):
print """Usage: dak auto-decruft
print("""Usage: dak auto-decruft
Automatic removal of common kinds of cruft
-h, --help show this help and exit.
......@@ -62,7 +64,7 @@ Automatic removal of common kinds of cruft
use RMMSG in the removal message (e.g. "NVIU")
--decruft-equal-versions use with --if-newer-version-in to also decruft versions
that are identical in both suites.
"""
""")
sys.exit(exit_code)
################################################################################
......@@ -236,7 +238,7 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
else:
# This case usually happens when versions differ between architectures...
if debug:
print "N: Merging group %s" % (group_name)
print("N: Merging group %s" % (group_name))
groups[group_name] = merge_group(groups[group_name], group)
for group_name in group_order:
......@@ -245,34 +247,34 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
if not groups:
if debug:
print "N: Found no candidates"
print("N: Found no candidates")
return
if debug:
print "N: Considering to remove the following packages:"
print("N: Considering to remove the following packages:")
for group_name in sorted(groups):
group_info = groups[group_name]
pkgs = group_info["packages"]
archs = group_info["architectures"]
print "N: * %s: %s [%s]" % (group_name, ", ".join(pkgs), " ".join(archs))
print("N: * %s: %s [%s]" % (group_name, ", ".join(pkgs), " ".join(archs)))
if debug:
print "N: Compiling ReverseDependencyChecker (RDC) - please hold ..."
print("N: Compiling ReverseDependencyChecker (RDC) - please hold ...")
rdc = ReverseDependencyChecker(session, suite_name)
if debug:
print "N: Computing initial breakage..."
print("N: Computing initial breakage...")
breakage = rdc.check_reverse_depends(full_removal_request)
while breakage:
by_breakers = [(len(breakage[x]), x, breakage[x]) for x in breakage]
by_breakers.sort(reverse=True)
if debug:
print "N: - Removal would break %s (package, architecture)-pairs" % (len(breakage))
print "N: - full breakage:"
print("N: - Removal would break %s (package, architecture)-pairs" % (len(breakage)))
print("N: - full breakage:")
for _, breaker, broken in by_breakers:
bname = "%s/%s" % breaker
broken_str = ", ".join("%s/%s" % b for b in sorted(broken))
print "N: * %s => %s" % (bname, broken_str)
print("N: * %s => %s" % (bname, broken_str))
averted_breakage = set()
......@@ -295,7 +297,7 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
if not already_discard:
avoided = sorted(breakage - averted_breakage)
print "N: - skipping removal of %s (breakage: %s)" % (", ".join(sorted(guilty_groups)), str(avoided))
print("N: - skipping removal of %s (breakage: %s)" % (", ".join(sorted(guilty_groups)), str(avoided)))
averted_breakage |= breakage
for group_name in guilty_groups:
......@@ -304,11 +306,11 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
if not groups:
if debug:
print "N: Nothing left to remove"
print("N: Nothing left to remove")
return
if debug:
print "N: Now considering to remove: %s" % str(", ".join(sorted(groups.iterkeys())))
print("N: Now considering to remove: %s" % str(", ".join(sorted(groups.iterkeys()))))
# Rebuild the removal request with the remaining groups and off
# we go to (not) break the world once more time
......@@ -318,10 +320,10 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
breakage = rdc.check_reverse_depends(full_removal_request)
if debug:
print "N: Removal looks good"
print("N: Removal looks good")
if dryrun:
print "Would remove the equivalent of:"
print("Would remove the equivalent of:")
for group_name in group_order:
if group_name not in groups:
continue
......@@ -331,14 +333,14 @@ def auto_decruft_suite(suite_name, suite_id, session, dryrun, debug):
message = group_info["message"]
# Embed the -R just in case someone wants to run it manually later
print ' dak rm -m "{message}" -s {suite} -a {architectures} -p -R -b {packages}'.format(
print(' dak rm -m "{message}" -s {suite} -a {architectures} -p -R -b {packages}'.format(
message=message, suite=suite_name,
architectures=",".join(archs), packages=" ".join(pkgs),
)
))
print
print "Note: The removals may be interdependent. A non-breaking result may require the execution of all"
print "of the removals"
print()
print("Note: The removals may be interdependent. A non-breaking result may require the execution of all")
print("of the removals")
else:
remove_groups(groups.itervalues(), suite_id, suite_name, session)
......@@ -405,7 +407,7 @@ def decruft_newer_version_in(othersuite, suite_name, suite_id, rm_msg, session,
if nvi_list:
message = "[auto-cruft] %s" % rm_msg
if dryrun:
print " dak rm -m \"%s\" -s %s %s" % (message, suite_name, " ".join(nvi_list))
print(" dak rm -m \"%s\" -s %s %s" % (message, suite_name, " ".join(nvi_list)))
else:
removals = sources2removals(nvi_list, suite_id, session)
remove(session, message, [suite_name], removals, whoami="DAK's auto-decrufter")
......
......@@ -27,6 +27,8 @@ bts -- manage bugs filed against ftp.debian.org
################################################################################
################################################################################
from __future__ import print_function
import sys
import re
import logging
......@@ -38,7 +40,7 @@ import debianbts as bts
def usage():
print """
print("""
SYNOPSIS
dak bts-categorize [options]
......@@ -59,7 +61,7 @@ OPTIONS
-h
--help
Print this documentation.
"""
""")
arguments = [('s', 'simulate', 'BtsCategorize::Options::Simulate'),
('v', 'verbose', 'BtsCategorize::Options::Verbose'),
......@@ -147,7 +149,7 @@ def send_email(commands, simulate=False):
Subst, Cnf["Dir::Templates"] + "/bts-categorize")
if simulate:
print bts_mail_message
print(bts_mail_message)
else:
utils.send_mail(bts_mail_message)
......
This diff is collapsed.
......@@ -54,6 +54,8 @@
################################################################################
from __future__ import print_function
import os
import sys
import apt_pkg
......@@ -75,11 +77,11 @@ blacklist = {}
def usage(exit_code=0):
print """Usage: dak check-overrides
print("""Usage: dak check-overrides
Check for cruft in overrides.
-n, --no-action don't do anything
-h, --help show this help and exit"""
-h, --help show this help and exit""")
sys.exit(exit_code)
......@@ -365,7 +367,7 @@ def main():
originosuite = originosuite.suite_name
originremark = " taking missing from %s" % originosuite
print "Processing %s%s..." % (suite.suite_name, originremark)
print("Processing %s%s..." % (suite.suite_name, originremark))
# Get a list of all suites that use the override file of 'suite.suite_name' as
# well as the suite
......@@ -388,8 +390,8 @@ def main():
otypes.append(ot.overridetype)
for otype in otypes:
print "Processing %s [%s - %s]" \
% (suite.suite_name, component_name, otype)
print("Processing %s [%s - %s]"
% (suite.suite_name, component_name, otype))
sys.stdout.flush()
process(suite.suite_name, suiteids, originosuite, component_name, otype, session)
......
......@@ -33,6 +33,8 @@
################################################################################
from __future__ import print_function
import os
import os.path
import stat
......@@ -55,14 +57,14 @@ delete_date = None
def usage(exit_code=0):
print """Usage: dak clean-queues [OPTIONS]
print("""Usage: dak clean-queues [OPTIONS]
Clean out incoming directories.
-d, --days=DAYS remove anything older than DAYS old
-i, --incoming=INCOMING the incoming directory to clean
-n, --no-action don't do anything
-v, --verbose explain what is being done
-h, --help show this help and exit"""
-h, --help show this help and exit""")
sys.exit(exit_code)
......@@ -115,7 +117,7 @@ def remove(from_dir, f):
if os.access(f, os.R_OK):
Logger.log(["move file to morgue", from_dir, fname, del_dir])
if Options["Verbose"]:
print "Removing '%s' (to '%s')." % (fname, del_dir)
print("Removing '%s' (to '%s')." % (fname, del_dir))
if Options["No-Action"]:
return
......@@ -142,7 +144,7 @@ def flush_old():
remove('Incoming/REJECT', f)
else:
if Options["Verbose"]:
print "Skipping, too new, '%s'." % (os.path.basename(f))
print("Skipping, too new, '%s'." % (os.path.basename(f)))
# Removes any files which are old orphans (not associated with a valid .changes file).
# [Used for Incoming]
......@@ -187,7 +189,7 @@ def flush_orphans():
for key in keys:
if key in all_files:
if Options["Verbose"]:
print "Skipping, has parents, '%s'." % (key)
print("Skipping, has parents, '%s'." % (key))
del all_files[key]
# Anthing left at this stage is not referenced by a .changes (or
......@@ -197,7 +199,7 @@ def flush_orphans():
remove('Incoming', f)
else:
if Options["Verbose"]:
print "Skipping, too new, '%s'." % (os.path.basename(f))
print("Skipping, too new, '%s'." % (os.path.basename(f)))
################################################################################
......@@ -231,13 +233,13 @@ def main():
init(cnf)
if Options["Verbose"]:
print "Processing incoming..."
print("Processing incoming...")
flush_orphans()
reject = cnf["Dir::Reject"]
if os.path.exists(reject) and os.path.isdir(reject):
if Options["Verbose"]:
print "Processing reject directory..."
print("Processing reject directory...")
os.chdir(reject)
flush_old()
......
......@@ -34,6 +34,8 @@
################################################################################
from __future__ import print_function
import errno
import os
import sqlalchemy.sql as sql
......@@ -57,12 +59,12 @@ Logger = None
def usage(exit_code=0):
print """Usage: dak clean-suites [OPTIONS]
print("""Usage: dak clean-suites [OPTIONS]
Clean old packages from suites.
-n, --no-action don't do anything
-h, --help show this help and exit
-m, --maximum maximum number of files to remove"""
-m, --maximum maximum number of files to remove""")
sys.exit(exit_code)
################################################################################
......
......@@ -49,6 +49,8 @@
################################################################################
from __future__ import print_function
import sys
import time
import apt_pkg
......@@ -67,7 +69,7 @@ Logger = None
def usage(exit_code=0):
print """Usage: dak control-overrides [OPTIONS]
print("""Usage: dak control-overrides [OPTIONS]
-h, --help print this help and exit
-c, --component=CMPT list/set overrides by component
......@@ -85,7 +87,7 @@ def usage(exit_code=0):
-q, --quiet be less verbose
-n, --no-action only list the action that would have been done
starred (*) values are default"""
starred (*) values are default""")
sys.exit(exit_code)
################################################################################
......@@ -253,7 +255,7 @@ def process_file(file, suite, component, otype, mode, action, session):
session.commit()
if not cnf["Control-Overrides::Options::Quiet"]:
print "Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time() - start_time), c_updated, c_added, c_removed, c_skipped, c_error)
print("Done in %d seconds. [Updated = %d, Added = %d, Removed = %d, Skipped = %d, Errors = %d]" % (int(time.time() - start_time), c_updated, c_added, c_removed, c_skipped, c_error))
Logger.log(["set complete", c_updated, c_added, c_removed, c_skipped, c_error])
......@@ -286,7 +288,7 @@ def list_overrides(suite, component, otype, session):
AND o.type = :typeid AND o.section = s.id
ORDER BY s.section, o.package""", dat)
for i in q.fetchall():
print utils.result_join(i)
print(utils.result_join(i))
else:
q = session.execute("""SELECT o.package, p.priority, s.section, o.maintainer, p.level
FROM override o, priority p, section s
......@@ -294,7 +296,7 @@ def list_overrides(suite, component, otype, session):
AND o.type = :typeid AND o.priority = p.id AND o.section = s.id
ORDER BY s.section, p.level, o.package""", dat)
for i in q.fetchall():
print utils.result_join(i[:-1])
print(utils.result_join(i[:-1]))
################################################################################
......
......@@ -41,6 +41,8 @@
#######################################################################################
from __future__ import print_function
import sys
import apt_pkg
import os
......@@ -60,7 +62,7 @@ Logger = None
def usage(exit_code=0):
print """Usage: dak control-suite [OPTIONS] [FILE]
print("""Usage: dak control-suite [OPTIONS] [FILE]
Display or alter the contents of a suite using FILE(s), or stdin.
-a, --add=SUITE add to SUITE
......@@ -68,7 +70,7 @@ Display or alter the contents of a suite using FILE(s), or stdin.
-l, --list=SUITE list the contents of SUITE
-r, --remove=SUITE remove from SUITE
-s, --set=SUITE set SUITE
-b, --britney generate changelog entry for britney runs"""
-b, --britney generate changelog entry for britney runs""")
sys.exit(exit_code)
......@@ -381,7 +383,7 @@ def get_list(suite, session):
WHERE ba.suite = :suiteid
AND ba.bin = b.id AND b.architecture = a.id""", {'suiteid': suite_id})
for i in q.fetchall():
print " ".join(i)
print(" ".join(i))
# List source
q = session.execute("""SELECT s.source, s.version
......@@ -389,7 +391,7 @@ def get_list(suite, session):
WHERE sa.suite = :suiteid
AND sa.source = s.id""", {'suiteid': suite_id})
for i in q.fetchall():
print " ".join(i) + " source"
print(" ".join(i) + " source")
#######################################################################################
......@@ -415,7 +417,7 @@ def main():
try:
file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
except SystemError as e:
print "%s\n" % e
print("%s\n" % e)
usage(1)
Options = cnf.subtree("Control-Suite::Options")
......
......@@ -19,6 +19,8 @@
################################################################################
from __future__ import print_function
from daklib.config import Config
import daklib.daksubprocess
......@@ -30,13 +32,13 @@ import sys
def usage(exit_code=0):
print """Usage: dak copy-installer [OPTION]... VERSION
print("""Usage: dak copy-installer [OPTION]... VERSION
-h, --help show this help and exit
-s, --source source suite (defaults to unstable)
-d, --destination destination suite (defaults to testing)
-n, --no-action don't change anything
Exactly 1 version must be specified."""
Exactly 1 version must be specified.""")
sys.exit(exit_code)
......@@ -67,12 +69,12 @@ def main():
initializer["dest"] = Options["Destination"]
copier = InstallerCopier(**initializer)
print copier.get_message()
print(copier.get_message())
if Options["No-Action"]:
print 'Do nothing because --no-action has been set.'
print('Do nothing because --no-action has been set.')
else:
copier.do_copy()
print 'Installer has been copied successfully.'
print('Installer has been copied successfully.')
root_dir = Config()['Dir::Root']
......
This diff is collapsed.
......@@ -33,6 +33,8 @@ G{importgraph}
################################################################################
from __future__ import print_function
import os
import sys
import traceback
......@@ -167,12 +169,12 @@ def init():
def usage(functionality, exit_code=0):
"""Print a usage message and exit with 'exit_code'."""
print """Usage: dak COMMAND [...]
print("""Usage: dak COMMAND [...]
Run DAK commands. (Will also work if invoked as COMMAND.)
Available commands:"""
Available commands:""")
for (command, description) in functionality:
print " %-23s %s" % (command, description)
print(" %-23s %s" % (command, description))
sys.exit(exit_code)
################################################################################
......@@ -227,7 +229,7 @@ def main():
module.main()
except KeyboardInterrupt:
msg = 'KeyboardInterrupt caught; exiting'
print msg
print(msg)
if logger:
logger.log([msg])
sys.exit(1)
......
......@@ -26,6 +26,8 @@ Add a component - suite mapping to only expose certain components in certain sui
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -34,7 +36,7 @@ from daklib.config import Config
def do_update(self):
print __doc__
print(__doc__)
try:
cnf = Config()
......
......@@ -25,6 +25,8 @@ Add column to store compression type of indices
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -36,7 +38,7 @@ def do_update(self):
"""
Add column to store compression type of indices
"""
print __doc__
print(__doc__)
try:
c = self.db.cursor()
......
......@@ -25,6 +25,8 @@ src_associations_full view, now also including sources for all binaries
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -60,7 +62,7 @@ COMMENT ON VIEW src_associations_full IS
def do_update(self):
print __doc__
print(__doc__)
try:
cnf = Config()
......
......@@ -25,6 +25,8 @@ Drop unique .changes name requirement and allow ftpteam to forget seen files
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -39,7 +41,7 @@ statements = [
def do_update(self):
print __doc__
print(__doc__)
try:
cnf = Config()
......
......@@ -25,6 +25,8 @@ Drop created and modified columns from bin_contents and src_contents
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -40,7 +42,7 @@ statements = [
def do_update(self):
print __doc__
print(__doc__)
try:
cnf = Config()
......
......@@ -25,6 +25,8 @@ Add a new release_suite name which we use in generate_releases
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -42,7 +44,7 @@ statements = [
def do_update(self):
print __doc__
print(__doc__)
try:
cnf = Config()
......
......@@ -25,6 +25,8 @@ new views binary_component, source_component and package_list
################################################################################
from __future__ import print_function
import psycopg2
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
......@@ -120,7 +122,7 @@ FROM
def do_update(self):
print __doc__
print(__doc__)