Commit b7f35cdf authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: use print() in product.

parent c6d77a49
...@@ -22,7 +22,7 @@ result = connection.getresponse() ...@@ -22,7 +22,7 @@ result = connection.getresponse()
path = result.getheader("X-Document-Location") path = result.getheader("X-Document-Location")
result.close() result.close()
path = '/%s' % '/'.join(path.split('/')[3:]) path = '/%s' % '/'.join(path.split('/')[3:])
print path print(path)
###################################### ######################################
# Upload chunks # Upload chunks
......
...@@ -53,7 +53,7 @@ def main(): ...@@ -53,7 +53,7 @@ def main():
threads[len(threads)-1].start() threads[len(threads)-1].start()
request_number += 1 request_number += 1
i+=1 i+=1
print "thread: %i request: %i url: %s" % (i,request_number,url) print("thread: %i request: %i url: %s" % (i,request_number,url))
else: else:
for t in range(0,max_thread): for t in range(0,max_thread):
if threads[t].isAlive() == 0: if threads[t].isAlive() == 0:
...@@ -63,7 +63,7 @@ def main(): ...@@ -63,7 +63,7 @@ def main():
threads[t].start() threads[t].start()
i+=1 i+=1
request_number += 1 request_number += 1
print "thread: %i request: %i url: %s" % (i,request_number,url) print("thread: %i request: %i url: %s" % (i,request_number,url))
break break
...@@ -146,17 +146,17 @@ class Checker(URLOpener): ...@@ -146,17 +146,17 @@ class Checker(URLOpener):
thread.start() thread.start()
while thread.isAlive(): while thread.isAlive():
sleep(0.5) sleep(0.5)
print "Connection to %s went fine" % url print("Connection to %s went fine" % url)
except IOError as err: except IOError as err:
(errno, strerror) = err.args (errno, strerror) = err.args
print "Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror) print("Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror))
def SearchUrl(self, url=None): def SearchUrl(self, url=None):
try: try:
conn = self.open_http(url) conn = self.open_http(url)
except IOError as err: except IOError as err:
(errno, strerror) = err.args (errno, strerror) = err.args
print "Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror) print("Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror))
def raise_error(self, error_key, field): def raise_error(self, error_key, field):
......
...@@ -188,8 +188,8 @@ class TestInvalidationBug(ERP5TypeTestCase): ...@@ -188,8 +188,8 @@ class TestInvalidationBug(ERP5TypeTestCase):
module.setIdGenerator('_generatePerDayId') module.setIdGenerator('_generatePerDayId')
#module.migrateToHBTree() #module.migrateToHBTree()
self.tic() self.tic()
print 'OID(%s) = %r' % (module.getRelativeUrl(), module._p_oid) print('OID(%s) = %r' % (module.getRelativeUrl(), module._p_oid))
print ' OID(_tree) = %r' % module._tree._p_oid print(' OID(_tree) = %r' % module._tree._p_oid)
previous = DateTime() previous = DateTime()
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
if 'create_script' in skin_folder.objectIds(): if 'create_script' in skin_folder.objectIds():
......
...@@ -748,7 +748,7 @@ if validator_to_use == 'tidy': ...@@ -748,7 +748,7 @@ if validator_to_use == 'tidy':
warning = False warning = False
validator_path = '/usr/bin/tidy' validator_path = '/usr/bin/tidy'
if not os.path.exists(validator_path): if not os.path.exists(validator_path):
print 'tidy is not installed at %s' % validator_path print('tidy is not installed at %s' % validator_path)
else: else:
validator = TidyValidator(validator_path, show_warnings) validator = TidyValidator(validator_path, show_warnings)
......
...@@ -27,5 +27,5 @@ ...@@ -27,5 +27,5 @@
############################################################################## ##############################################################################
def say_hello(): def say_hello():
print 'hello' print('hello')
...@@ -438,10 +438,10 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase): ...@@ -438,10 +438,10 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
def _verboseErrorLog(self, size=10): def _verboseErrorLog(self, size=10):
for entry in self.portal.error_log.getLogEntries()[:size]: for entry in self.portal.error_log.getLogEntries()[:size]:
print "="*20 print(("="*20))
print "ERROR ID : %s" % entry["id"] print(("ERROR ID : %s" % entry["id"]))
print "TRACEBACK :" print("TRACEBACK :")
print entry["tb_text"] print((entry["tb_text"]))
def testFunctionalTestRunner(self): def testFunctionalTestRunner(self):
# Check the zuite page templates can be rendered, because selenium test # Check the zuite page templates can be rendered, because selenium test
......
...@@ -33,4 +33,4 @@ class TestPystone(unittest.TestCase): ...@@ -33,4 +33,4 @@ class TestPystone(unittest.TestCase):
"""Tests to get pystone value """Tests to get pystone value
""" """
def test_pystone(self): def test_pystone(self):
print "PYSTONE RESULT (time,score) : %r" % (pystone.pystones(),) print(("PYSTONE RESULT (time,score) : %r" % (pystone.pystones(),)))
...@@ -55,11 +55,11 @@ class TestSQLBench(unittest.TestCase): ...@@ -55,11 +55,11 @@ class TestSQLBench(unittest.TestCase):
sqlbench_path + '/test-alter-table', sqlbench_path + '/test-alter-table',
'--database', database, '--database', database,
'--host', host, '--user', user, '--password', password] '--host', host, '--user', user, '--password', password]
print command_list print(command_list)
process = subprocess.Popen(command_list, process = subprocess.Popen(command_list,
cwd = sqlbench_path, cwd = sqlbench_path,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate() output, error = process.communicate()
self.assertEqual(0, len(error), error) self.assertEqual(0, len(error), error)
print output print(output)
self.assertTrue(output.find("Total time: ")>=0) self.assertTrue(output.find("Total time: ")>=0)
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function # six.PY2
import argparse, sys, os, textwrap import argparse, sys, os, textwrap
from erp5.util import taskdistribution from erp5.util import taskdistribution
...@@ -8,7 +9,7 @@ from erp5.util import taskdistribution ...@@ -8,7 +9,7 @@ from erp5.util import taskdistribution
from . import ERP5TypeTestSuite from . import ERP5TypeTestSuite
def _parsingErrorHandler(data, _): def _parsingErrorHandler(data, _):
print >> sys.stderr, 'Error parsing data:', repr(data) print('Error parsing data:', repr(data), file=sys.stderr)
taskdistribution.patchRPCParser(_parsingErrorHandler) taskdistribution.patchRPCParser(_parsingErrorHandler)
def makeSuite( def makeSuite(
...@@ -119,8 +120,8 @@ def main(): ...@@ -119,8 +120,8 @@ def main():
args.zserver_frontend_url_list.split(',') if args.zserver_frontend_url_list else ()) args.zserver_frontend_url_list.split(',') if args.zserver_frontend_url_list else ())
if args.zserver_address_list and len(args.zserver_address_list) < args.node_quantity: if args.zserver_address_list and len(args.zserver_address_list) < args.node_quantity:
print >> sys.stderr, 'Not enough zserver address/frontends for node quantity %s (%r)' % ( print('Not enough zserver address/frontends for node quantity %s (%r)' % (
args.node_quantity, args.zserver_address_list) args.node_quantity, args.zserver_address_list), file=sys.stderr)
sys.exit(1) sys.exit(1)
# sanity check # sanity check
......
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
from __future__ import print_function # six.PY2
import os import os
import sys import sys
import pdb import pdb
...@@ -691,7 +692,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -691,7 +692,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
transaction.commit() transaction.commit()
except: except:
import traceback import traceback
print "runUnitTestList Exception : %r" % (traceback.print_exc(),) print("runUnitTestList Exception : %r" % (traceback.print_exc(),))
# finally does not expect opened transaction, even in the # finally does not expect opened transaction, even in the
# case of a Ctrl-C. # case of a Ctrl-C.
transaction.abort() transaction.abort()
...@@ -725,10 +726,10 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -725,10 +726,10 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
def usage(stream, msg=None): def usage(stream, msg=None):
if msg: if msg:
print >>stream, msg print(msg, file=stream)
print >>stream print(file=stream)
program = os.path.basename(sys.argv[0]) program = os.path.basename(sys.argv[0])
print >>stream, __doc__ % {"program": program} print(__doc__ % {"program": program}, file=stream)
log_directory = None log_directory = None
def main(argument_list=None): def main(argument_list=None):
......
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function # six.PY2
import os import os
import logging import logging
from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase
...@@ -44,8 +45,8 @@ class TransformTest(ATSiteTestCase): ...@@ -44,8 +45,8 @@ class TransformTest(ATSiteTestCase):
output = open(output) output = open(output)
except IOError: except IOError:
import sys import sys
print >>sys.stderr, 'No output file found.' print('No output file found.', file=sys.stderr)
print >>sys.stderr, 'File %s created, check it !' % self.output print('File %s created, check it !' % self.output, file=sys.stderr)
output = open(output, 'w') output = open(output, 'w')
output.write(got) output.write(got)
output.close() output.close()
...@@ -238,7 +239,7 @@ def make_tests(test_descr=TRANSFORMS_TESTINFO): ...@@ -238,7 +239,7 @@ def make_tests(test_descr=TRANSFORMS_TESTINFO):
continue continue
if TR_NAMES is not None and not _transform.name() in TR_NAMES: if TR_NAMES is not None and not _transform.name() in TR_NAMES:
print 'skip test for', _transform.name() print('skip test for', _transform.name())
continue continue
class TransformTestSubclass(TransformTest): class TransformTestSubclass(TransformTest):
......
...@@ -2,7 +2,7 @@ import sys ...@@ -2,7 +2,7 @@ import sys
import httplib import httplib
if ( len(sys.argv) != 5 ): if ( len(sys.argv) != 5 ):
print "usage tinyWebClient.py host port method path" print("usage tinyWebClient.py host port method path")
else: else:
host = sys.argv[1] host = sys.argv[1]
port = sys.argv[2] port = sys.argv[2]
...@@ -10,7 +10,7 @@ else: ...@@ -10,7 +10,7 @@ else:
path = sys.argv[4] path = sys.argv[4]
info = (host, port) info = (host, port)
print "%s:%s" % info print("%s:%s" % info)
conn = httplib.HTTPConnection("%s:%s" % info) conn = httplib.HTTPConnection("%s:%s" % info)
conn.request(method, path) conn.request(method, path)
print conn.getresponse().msg print(conn.getresponse().msg)
...@@ -62,12 +62,12 @@ if __name__ == '__main__': ...@@ -62,12 +62,12 @@ if __name__ == '__main__':
server_address = ('', port) server_address = ('', port)
httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler) httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler)
print "serving at port", port print("serving at port", port)
print "To run the entire JsUnit test suite, open" print("To run the entire JsUnit test suite, open")
print (" http://localhost:8000/jsunit/testRunner.html?testPage=" print (" http://localhost:8000/jsunit/testRunner.html?testPage="
"http://localhost:8000/tests/JsUnitSuite.html&autoRun=true") "http://localhost:8000/tests/JsUnitSuite.html&autoRun=true")
print "To run the acceptance test suite, open" print("To run the acceptance test suite, open")
print " http://localhost:8000/TestRunner.html" print(" http://localhost:8000/TestRunner.html")
while not HTTPHandler.quitRequestReceived : while not HTTPHandler.quitRequestReceived :
httpd.handle_request() httpd.handle_request()
......
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