launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24924
[Merge] ~cjwatson/launchpad:py3-database-print-function into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-database-print-function into launchpad:master.
Commit message:
Port database scripts to print_function
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/386525
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-database-print-function into launchpad:master.
diff --git a/database/replication/helpers.py b/database/replication/helpers.py
index b83ae28..8f8adf6 100644
--- a/database/replication/helpers.py
+++ b/database/replication/helpers.py
@@ -3,6 +3,8 @@
"""Common helpers for replication scripts."""
+from __future__ import absolute_import, print_function
+
__metaclass__ = type
__all__ = []
@@ -216,7 +218,7 @@ def execute_slonik(script, sync=None, exit_on_fail=True, auto_preamble=True):
# to slonik via stdin. This way it can be examined if slonik appears
# to hang.
script_on_disk = NamedTemporaryFile(prefix="slonik", suffix=".sk")
- print >> script_on_disk, script
+ print(script, file=script_on_disk)
script_on_disk.flush()
# Run slonik
diff --git a/database/replication/preamble.py b/database/replication/preamble.py
index f5e5605..8f2b38d 100755
--- a/database/replication/preamble.py
+++ b/database/replication/preamble.py
@@ -6,6 +6,8 @@
"""Generate a preamble for slonik(1) scripts based on the current LPCONFIG.
"""
+from __future__ import absolute_import, print_function
+
__metaclass__ = type
__all__ = []
@@ -29,7 +31,7 @@ if __name__ == '__main__':
scripts.execute_zcml_for_scripts(use_web_security=False)
con = connect()
- print '# slonik(1) preamble generated %s' % time.ctime()
- print '# LPCONFIG=%s' % config.instance_name
- print
- print replication.helpers.preamble(con)
+ print('# slonik(1) preamble generated %s' % time.ctime())
+ print('# LPCONFIG=%s' % config.instance_name)
+ print()
+ print(replication.helpers.preamble(con))
diff --git a/database/replication/walblock.py b/database/replication/walblock.py
index af793ef..46a36ec 100755
--- a/database/replication/walblock.py
+++ b/database/replication/walblock.py
@@ -3,7 +3,9 @@
# Copyright 2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-"""Feed stdin to stout, blocking if there are too many unshipped WAL files"""
+"""Feed stdin to stdout, blocking if there are too many unshipped WAL files."""
+
+from __future__ import absolute_import, print_function
__metaclass__ = type
__all__ = []
@@ -39,11 +41,13 @@ def main():
while len(glob(ready_wal_glob)) > options.num_ready:
if options.verbose and not notified:
notified = True
- print >> sys.stderr, 'Blocking on {0} unshipped WAL'.format(
- len(glob(ready_wal_glob))),
+ print(
+ 'Blocking on {0} unshipped WAL'.format(
+ len(glob(ready_wal_glob))),
+ end='', file=sys.stderr)
time.sleep(5)
if options.verbose and notified:
- print >> sys.stderr, '... Done'
+ print(' ... Done', file=sys.stderr)
chunk = sys.stdin.read(chunk_size)
if chunk == '':
diff --git a/database/schema/emptytables.py b/database/schema/emptytables.py
index 471be46..e8ef47d 100755
--- a/database/schema/emptytables.py
+++ b/database/schema/emptytables.py
@@ -5,6 +5,8 @@
"""List empty database tables."""
+from __future__ import absolute_import, print_function
+
__metaclass__ = type
import _pythonpath
@@ -31,7 +33,7 @@ def main(options):
"SELECT TRUE FROM public.%s LIMIT 1" % quote_identifier(table)
)
if cur.fetchone() is None:
- print table
+ print(table)
if __name__ == '__main__':
diff --git a/database/schema/fti.py b/database/schema/fti.py
index b4257d1..e18d634 100755
--- a/database/schema/fti.py
+++ b/database/schema/fti.py
@@ -7,6 +7,9 @@
"""
Add full text indexes to the launchpad database
"""
+
+from __future__ import absolute_import, print_function
+
__metaclass__ = type
import _pythonpath
@@ -157,7 +160,7 @@ def sexecute(con, sql):
SQL script. Otherwise execute on the DB.
"""
if slonik_sql is not None:
- print >> slonik_sql, dedent(sql + ';')
+ print(dedent(sql + ';'), file=slonik_sql)
else:
execute(con, sql)
diff --git a/database/schema/online_fti_updater.py b/database/schema/online_fti_updater.py
index c3f061a..1bc6335 100755
--- a/database/schema/online_fti_updater.py
+++ b/database/schema/online_fti_updater.py
@@ -7,6 +7,9 @@
Rebuild the full text indexes in a more friendly fashion, enabling this to
be done without downtime.
"""
+
+from __future__ import absolute_import, print_function
+
__metaclass__ = type
import _pythonpath
@@ -22,7 +25,7 @@ def main():
cur = con.cursor()
for table, ignored in ALL_FTI:
- print 'Doing %(table)s' % vars(),
+ print('Doing %(table)s' % vars(), end='')
cur.execute("SELECT id FROM %(table)s" % vars())
ids = [row[0] for row in cur.fetchall()]
for id in ids:
@@ -30,8 +33,8 @@ def main():
"UPDATE %(table)s SET fti=NULL WHERE id=%(id)s" % vars()
)
if id % 100 == 0:
- print '.',
- print
+ print('.', end='')
+ print()
if __name__ == '__main__':
main()