summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-11-12 07:59:27 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-11-12 08:14:43 (GMT)
commit9c961f948f31336e1b877591038c58ddf2944127 (patch)
treedbe5ef551fc77823ac58e52c89bd9c0219166e21
parent3347e77a8dd852a4eb61c93b373b8045b70012b9 (diff)
downloadwcs-9c961f948f31336e1b877591038c58ddf2944127.zip
wcs-9c961f948f31336e1b877591038c58ddf2944127.tar.gz
wcs-9c961f948f31336e1b877591038c58ddf2944127.tar.bz2
misc: use print as function (#37580)
-rw-r--r--tests/test_sql.py8
-rw-r--r--wcs/ctl/check_hobos.py18
-rw-r--r--wcs/ctl/management/commands/trigger_jumps.py4
-rw-r--r--wcs/qommon/ctl.py14
4 files changed, 26 insertions, 18 deletions
diff --git a/tests/test_sql.py b/tests/test_sql.py
index 6914835..d6e504d 100644
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+from __future__ import print_function
+
import datetime
import os
import random
@@ -1760,7 +1762,7 @@ def test_view_performances():
formdef.store()
formdefs.append(formdef)
- print 'create formdatas'
+ print('create formdatas')
# create formdatas
for i in range(nb_formdatas):
data_class = random.choice(formdefs).data_class()
@@ -1775,7 +1777,7 @@ def test_view_performances():
formdata.jump_status('st%s' % (j+2))
if random.random() < 0.5:
break
- print 'done'
+ print('done')
t0 = time.time()
user_roles = [random.choice(roles).id, random.choice(roles).id]
@@ -1784,7 +1786,7 @@ def test_view_performances():
criterias.append(st.Equal('is_at_endpoint', False))
criterias.append(st.Intersects('actions_roles_array', user_roles))
formdatas = sql.AnyFormData.select(criterias, order_by='receipt_time', limit=20, offset=0)
- print time.time() - t0
+ print(time.time() - t0)
assert (time.time() - t0) < 0.5
diff --git a/wcs/ctl/check_hobos.py b/wcs/ctl/check_hobos.py
index 9bedd31..0662780 100644
--- a/wcs/ctl/check_hobos.py
+++ b/wcs/ctl/check_hobos.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
import ConfigParser
import json
import os
@@ -118,7 +120,7 @@ class CmdCheckHobos(Command):
pub.app_dir = os.path.join(global_app_dir,
self.get_instance_path(service))
if not os.path.exists(pub.app_dir):
- print 'initializing instance in', pub.app_dir
+ print('initializing instance in', pub.app_dir)
os.mkdir(pub.app_dir)
pub.initialize_app_dir()
@@ -129,14 +131,14 @@ class CmdCheckHobos(Command):
pub.import_zip(file(skeleton_filepath))
new_site = True
else:
- print 'updating instance in', pub.app_dir
+ print('updating instance in', pub.app_dir)
new_site = False
try:
self.configure_site_options(service, pub,
ignore_timestamp=sub_options.ignore_timestamp)
except NoChange:
- print ' skipping'
+ print(' skipping')
return
pub.set_config(skip_sql=True)
@@ -324,7 +326,7 @@ class CmdCheckHobos(Command):
try:
rfd = misc.urlopen(metadata_url)
except misc.ConnectionError as e:
- print >> sys.stderr, 'failed to get metadata URL', metadata_url, e
+ print('failed to get metadata URL', metadata_url, e, file=sys.stderr)
continue
s = rfd.read()
@@ -507,8 +509,8 @@ class CmdCheckHobos(Command):
try:
pgconn = psycopg2.connect(**createdb_cfg)
except psycopg2.Error as e:
- print >> sys.stderr, 'failed to connect to postgresql (%s)' % \
- psycopg2.errorcodes.lookup(e.pgcode)
+ print('failed to connect to postgresql (%s)' % \
+ psycopg2.errorcodes.lookup(e.pgcode), file=sys.stderr)
return
pgconn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
@@ -527,8 +529,8 @@ class CmdCheckHobos(Command):
if cur.fetchall():
new_database = False
else:
- print >> sys.stderr, 'failed to create database (%s)' % \
- psycopg2.errorcodes.lookup(e.pgcode)
+ print('failed to create database (%s)' % \
+ psycopg2.errorcodes.lookup(e.pgcode), file=sys.stderr)
return
else:
cur.close()
diff --git a/wcs/ctl/management/commands/trigger_jumps.py b/wcs/ctl/management/commands/trigger_jumps.py
index 6ffe8b7..027d657 100644
--- a/wcs/ctl/management/commands/trigger_jumps.py
+++ b/wcs/ctl/management/commands/trigger_jumps.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
import json
import os
@@ -116,7 +118,7 @@ def jump_and_perform(formdata, action, workflow_data=None):
get_publisher().substitutions.feed(get_publisher())
get_publisher().substitutions.feed(formdata.formdef)
get_publisher().substitutions.feed(formdata)
- print 'formdata %s jumps to status %s' % (formdata, action.status)
+ print('formdata %s jumps to status %s' % (formdata, action.status))
wcs_jump_and_perform(formdata, action, workflow_data=workflow_data)
def select_and_jump_formdata(formdef, trigger, rows, status_ids=None):
diff --git a/wcs/qommon/ctl.py b/wcs/qommon/ctl.py
index 9c3513d..221c873 100644
--- a/wcs/qommon/ctl.py
+++ b/wcs/qommon/ctl.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
+from __future__ import print_function
+
import ConfigParser
import optparse
from optparse import make_option
@@ -47,13 +49,13 @@ class Command(object):
def run(self, args, base_options):
if base_options.configfile:
if not os.path.exists(base_options.configfile):
- print >> sys.stderr, 'Missing configuration file %s' % base_options.configfile
+ print('Missing configuration file %s' % base_options.configfile, file=sys.stderr)
sys.exit(1)
try:
self.config.read(base_options.configfile)
except ConfigParser.ParsingError as e:
- print >> sys.stderr, 'Invalid configuration file %s' % base_options.configfile
- print >> sys.stderr, e
+ print('Invalid configuration file %s' % base_options.configfile, file=sys.stderr)
+ print(e, file=sys.stderr)
sys.exit(1)
if not self.config.has_section('main'):
self.config.add_section('main')
@@ -127,13 +129,13 @@ class Ctl(object):
def print_help(self, *args):
self.parser.print_help()
self.load_all_commands()
- print
+ print()
commands = [(x.name, x.doc) for x in self.get_commands().values()]
commands.sort()
- print 'Available commands:'
+ print('Available commands:')
for name, description in commands:
- print ' %-15s %s' % (name, description)
+ print(' %-15s %s' % (name, description))
sys.exit(0)
def run(self, args):