diff --git a/applications/admin/private/hosts.deny b/applications/admin/private/hosts.deny
index e69de29b..3e4e651c 100644
--- a/applications/admin/private/hosts.deny
+++ b/applications/admin/private/hosts.deny
@@ -0,0 +1 @@
+127.0.0.1 2 1464635785
diff --git a/gluon/admin.py b/gluon/admin.py
index 87b76924..61aa56e8 100644
--- a/gluon/admin.py
+++ b/gluon/admin.py
@@ -9,6 +9,7 @@
Utility functions for the Admin application
-------------------------------------------
"""
+from __future__ import print_function
import os
import sys
import traceback
@@ -60,7 +61,7 @@ def app_pack(app, request, raise_ex=False, filenames=None):
return filename
except Exception as e:
import traceback
- print traceback.format_exc()
+ print(traceback.format_exc())
if raise_ex:
raise
return False
@@ -343,7 +344,7 @@ def check_new_version(myversion, version_url):
pmyversion = parse_version(myversion)
except IOError:
import traceback
- print traceback.format_exc()
+ print(traceback.format_exc())
return -1, myversion
if pversion[:3]+pversion[-6:] > pmyversion[:3]+pmyversion[-6:]:
diff --git a/gluon/contrib/AuthorizeNet.py b/gluon/contrib/AuthorizeNet.py
index 13888be5..02f7a697 100755
--- a/gluon/contrib/AuthorizeNet.py
+++ b/gluon/contrib/AuthorizeNet.py
@@ -13,6 +13,7 @@ Modifed by Massimo Di Pierro
- namedtuple from http://code.activestate.com/recipes/500261/
"""
+from __future__ import print_function
__all__ = ['AIM']
@@ -248,23 +249,23 @@ def test():
payment.setParameter('x_email_customer', False)
payment.process()
if payment.isApproved():
- print 'Response Code: ', payment.response.ResponseCode
- print 'Response Text: ', payment.response.ResponseText
- print 'Response: ', payment.getResultResponseFull()
- print 'Transaction ID: ', payment.response.TransactionID
- print 'CVV Result: ', payment.response.CVVResponse
- print 'Approval Code: ', payment.response.AuthCode
- print 'AVS Result: ', payment.response.AVSResponse
+ print('Response Code: ', payment.response.ResponseCode)
+ print('Response Text: ', payment.response.ResponseText)
+ print('Response: ', payment.getResultResponseFull())
+ print('Transaction ID: ', payment.response.TransactionID)
+ print('CVV Result: ', payment.response.CVVResponse)
+ print('Approval Code: ', payment.response.AuthCode)
+ print('AVS Result: ', payment.response.AVSResponse)
elif payment.isDeclined():
- print 'Your credit card was declined by your bank'
+ print('Your credit card was declined by your bank')
elif payment.isError():
raise AIM.AIMError('An uncaught error occurred')
except AIM.AIMError as e:
- print "Exception thrown:", e
- print 'An error occured'
- print 'approved', payment.isApproved()
- print 'declined', payment.isDeclined()
- print 'error', payment.isError()
+ print("Exception thrown:", e)
+ print('An error occured')
+ print('approved', payment.isApproved())
+ print('declined', payment.isDeclined())
+ print('error', payment.isError())
if __name__ == '__main__':
test()
diff --git a/gluon/contrib/DowCommerce.py b/gluon/contrib/DowCommerce.py
index 00487046..31fd7927 100644
--- a/gluon/contrib/DowCommerce.py
+++ b/gluon/contrib/DowCommerce.py
@@ -9,6 +9,7 @@ Modifed by Dave Stoll dave.stoll@gmail.com
- modifed to support Dow Commerce API
"""
+from __future__ import print_function
__all__ = ['DowCommerce']
@@ -227,18 +228,18 @@ def test():
payment.process()
if payment.isApproved():
- print 'Payment approved!'
- print payment.getFullResponse()
+ print('Payment approved!')
+ print(payment.getFullResponse())
elif payment.isDeclined():
- print 'Your credit card was declined by your bank'
+ print('Your credit card was declined by your bank')
elif payment.isError():
raise DowCommerce.DowCommerceError('An uncaught error occurred')
except DowCommerce.DowCommerceError as e:
- print "Exception thrown:", e
- print 'An error occured'
- print 'approved', payment.isApproved()
- print 'declined', payment.isDeclined()
- print 'error', payment.isError()
+ print("Exception thrown:", e)
+ print('An error occured')
+ print('approved', payment.isApproved())
+ print('declined', payment.isDeclined())
+ print('error', payment.isError())
if __name__ == '__main__':
test()
diff --git a/gluon/contrib/autolinks.py b/gluon/contrib/autolinks.py
index c673ac66..1bd2bc8e 100644
--- a/gluon/contrib/autolinks.py
+++ b/gluon/contrib/autolinks.py
@@ -41,6 +41,7 @@ wordpress.com
revision3.com
viddler.com
"""
+from __future__ import print_function
import re
import cgi
@@ -215,6 +216,6 @@ laoreet tortor.
if __name__ == "__main__":
if len(sys.argv) > 1:
- print expand_html(open(sys.argv[1]).read())
+ print(expand_html(open(sys.argv[1]).read()))
else:
- print test()
+ print(test())
diff --git a/gluon/contrib/markdown/markdown2.py b/gluon/contrib/markdown/markdown2.py
index 50af2a5f..6eda8502 100644
--- a/gluon/contrib/markdown/markdown2.py
+++ b/gluon/contrib/markdown/markdown2.py
@@ -35,6 +35,7 @@ This implementation of Markdown implements the full "core" syntax plus a
number of extras (e.g., code syntax coloring, footnotes) as described on
.
"""
+from __future__ import print_function
cmdln_desc = """A fast and complete Python implementation of Markdown, a
text-to-HTML conversion tool for web writers.
diff --git a/gluon/contrib/markmin/markmin2html.py b/gluon/contrib/markmin/markmin2html.py
index 3e03010a..c053a6b0 100755
--- a/gluon/contrib/markmin/markmin2html.py
+++ b/gluon/contrib/markmin/markmin2html.py
@@ -3,6 +3,7 @@
# created by Massimo Di Pierro
# recreated by Vladyslav Kozlovskyy
# license MIT/BSD/GPL
+from __future__ import print_function
import re
import urllib
from cgi import escape
@@ -45,11 +46,11 @@ Example of usage:
``
m = "Hello **world** [[link http://web2py.com]]"
from markmin2html import markmin2html
-print markmin2html(m)
+print(markmin2html(m))
from markmin2latex import markmin2latex
-print markmin2latex(m)
+print(markmin2latex(m))
from markmin2pdf import markmin2pdf # requires pdflatex
-print markmin2pdf(m)
+print(markmin2pdf(m))
``
====================
# This is a test block
@@ -803,7 +804,7 @@ def render(text,
>>> render("``aaa``:custom", extra=dict(custom=lambda text: 'x'+text+'x'))
'xaaax'
- >>> print render(r"$$\int_a^b sin(x)dx$$")
+ >>> print(render(r"$$\int_a^b sin(x)dx$$"))
>>> markmin2html(r"use backslash: \[\[[[mess\[[ag\]]e link]]\]]")
@@ -1494,17 +1495,17 @@ if __name__ == '__main__':
pre { background-color: #E0E0E0; padding: 5px; }
""")[1:]
- print html % dict(title="Markmin markup language",
+ print(html % dict(title="Markmin markup language",
style=style,
- body=markmin2html(__doc__, pretty_print=True))
+ body=markmin2html(__doc__, pretty_print=True)))
elif sys.argv[1:2] == ['-t']:
from timeit import Timer
loops = 1000
ts = Timer("markmin2html(__doc__)", "from markmin2html import markmin2html")
- print 'timeit "markmin2html(__doc__)":'
+ print('timeit "markmin2html(__doc__)":')
t = min([ts.timeit(loops) for i in range(3)])
- print "%s loops, best of 3: %.3f ms per loop" % (loops, t / 1000 * loops)
+ print("%s loops, best of 3: %.3f ms per loop" % (loops, t / 1000 * loops))
elif len(sys.argv) > 1:
fargv = open(sys.argv[1], 'r')
try:
@@ -1523,15 +1524,15 @@ if __name__ == '__main__':
else:
markmin_style = ""
- print html % dict(title=sys.argv[1], style=markmin_style,
- body=markmin2html(markmin_text, pretty_print=True))
+ print(html % dict(title=sys.argv[1], style=markmin_style,
+ body=markmin2html(markmin_text, pretty_print=True)))
finally:
fargv.close()
else:
- print "Usage: " + sys.argv[0] + " -h | -t | file.markmin [file.css|@path_to/css]"
- print "where: -h - print __doc__"
- print " -t - timeit __doc__ (for testing purpuse only)"
- print " file.markmin [file.css] - process file.markmin + built in file.css (optional)"
- print " file.markmin [@path_to/css] - process file.markmin + link path_to/css (optional)"
+ print("Usage: " + sys.argv[0] + " -h | -t | file.markmin [file.css|@path_to/css]")
+ print("where: -h - print __doc__")
+ print(" -t - timeit __doc__ (for testing purpuse only)")
+ print(" file.markmin [file.css] - process file.markmin + built in file.css (optional)")
+ print(" file.markmin [@path_to/css] - process file.markmin + link path_to/css (optional)")
run_doctests()
diff --git a/gluon/contrib/markmin/markmin2latex.py b/gluon/contrib/markmin/markmin2latex.py
index 65bfbab2..ce1fe1d1 100755
--- a/gluon/contrib/markmin/markmin2latex.py
+++ b/gluon/contrib/markmin/markmin2latex.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# created my Massimo Di Pierro
# license MIT/BSD/GPL
+from __future__ import print_function
import re
import cgi
import sys
@@ -309,4 +310,4 @@ if __name__ == '__main__':
output = markmin2latex(content,
wrapper=wrapper,
chapters=options.chapters)
- print output
+ print(output)
diff --git a/gluon/contrib/markmin/markmin2pdf.py b/gluon/contrib/markmin/markmin2pdf.py
index 95739651..89728a9f 100644
--- a/gluon/contrib/markmin/markmin2pdf.py
+++ b/gluon/contrib/markmin/markmin2pdf.py
@@ -2,6 +2,7 @@
Created by Massimo Di Pierro
License BSD
"""
+from __future__ import print_function
import subprocess
import os
@@ -22,7 +23,7 @@ def removeall(path):
__func__(path)
except OSError as xxx_todo_changeme:
(errno, strerror) = xxx_todo_changeme.args
- print ERROR_STR % {'path': path, 'error': strerror}
+ print(ERROR_STR % {'path': path, 'error': strerror})
files = [path]
@@ -113,10 +114,10 @@ if __name__ == '__main__':
if sys.argv[1:2] == ['-h']:
data, warnings, errors = markmin2pdf(markmin2html.__doc__)
if errors:
- print 'ERRORS:' + '\n'.join(errors)
- print 'WARNGINS:' + '\n'.join(warnings)
+ print('ERRORS:' + '\n'.join(errors))
+ print('WARNGINS:' + '\n'.join(warnings))
else:
- print data
+ print(data)
elif len(sys.argv) > 1:
fargv = open(sys.argv[1], 'rb')
try:
@@ -124,9 +125,9 @@ if __name__ == '__main__':
finally:
fargv.close()
if errors:
- print 'ERRORS:' + '\n'.join(errors)
- print 'WARNGINS:' + '\n'.join(warnings)
+ print('ERRORS:' + '\n'.join(errors))
+ print('WARNGINS:' + '\n'.join(warnings))
else:
- print data
+ print(data)
else:
doctest.testmod()
diff --git a/gluon/contrib/pam.py b/gluon/contrib/pam.py
index 5b200376..d63c281a 100644
--- a/gluon/contrib/pam.py
+++ b/gluon/contrib/pam.py
@@ -9,6 +9,7 @@ a user against the Pluggable Authentication Modules (PAM) on the system.
Implemented using ctypes, so no compilation is necessary.
"""
+from __future__ import print_function
__all__ = ['authenticate']
from ctypes import CDLL, POINTER, Structure, CFUNCTYPE, cast, pointer, sizeof
@@ -125,4 +126,4 @@ def authenticate(username, password, service='login'):
if __name__ == "__main__":
import getpass
- print authenticate(getpass.getuser(), getpass.getpass())
+ print(authenticate(getpass.getuser(), getpass.getpass()))
diff --git a/gluon/contrib/pbkdf2.py b/gluon/contrib/pbkdf2.py
index b311c53f..66b8b287 100644
--- a/gluon/contrib/pbkdf2.py
+++ b/gluon/contrib/pbkdf2.py
@@ -40,6 +40,7 @@
:copyright: (c) Copyright 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
+from __future__ import print_function
import hmac
try:
from hashlib import sha1
@@ -92,14 +93,14 @@ def test():
def check(data, salt, iterations, keylen, expected):
rv = pbkdf2_hex(data, salt, iterations, keylen)
if rv != expected:
- print 'Test failed:'
- print ' Expected: %s' % expected
- print ' Got: %s' % rv
- print ' Parameters:'
- print ' data=%s' % data
- print ' salt=%s' % salt
- print ' iterations=%d' % iterations
- print
+ print('Test failed:')
+ print(' Expected: %s' % expected)
+ print(' Got: %s' % rv)
+ print(' Parameters:')
+ print(' data=%s' % data)
+ print(' salt=%s' % salt)
+ print(' iterations=%d' % iterations)
+ print()
failed.append(1)
# From RFC 6070
diff --git a/gluon/contrib/pbkdf2_ctypes.py b/gluon/contrib/pbkdf2_ctypes.py
index 6aa62343..4d64a12f 100644
--- a/gluon/contrib/pbkdf2_ctypes.py
+++ b/gluon/contrib/pbkdf2_ctypes.py
@@ -18,6 +18,7 @@
:license: LGPLv3
"""
+from __future__ import print_function
import ctypes
import ctypes.util
diff --git a/gluon/contrib/pdfinvoice.py b/gluon/contrib/pdfinvoice.py
index 4c04fc0f..483e78d8 100644
--- a/gluon/contrib/pdfinvoice.py
+++ b/gluon/contrib/pdfinvoice.py
@@ -1,6 +1,7 @@
"""
BSD license - created by Massimo Di Pierro
"""
+from __future__ import print_function
from reportlab.pdfgen.canvas import Canvas
from reportlab.platypus import Table
from reportlab.lib.pagesizes import A4
@@ -158,4 +159,4 @@ if __name__=='__main__':
['000001','Chairs',600.0],
['','Tax',50.0]],
}
- print PDF().draw(invoice,items_page=20)
+ print(PDF().draw(invoice,items_page=20))
diff --git a/gluon/contrib/populate.py b/gluon/contrib/populate.py
index cc7dd216..92c1fec6 100644
--- a/gluon/contrib/populate.py
+++ b/gluon/contrib/populate.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import re
import cPickle
import random
@@ -267,4 +268,4 @@ def populate_generator(table, default=True, compute=False, contents={}):
if __name__ == '__main__':
ell = Learner()
ell.loadd(IUP)
- print ell.generate(1000, prefix=None)
+ print(ell.generate(1000, prefix=None))
diff --git a/gluon/contrib/pyrtf/Elements.py b/gluon/contrib/pyrtf/Elements.py
index 40732cb1..afdff5f8 100644
--- a/gluon/contrib/pyrtf/Elements.py
+++ b/gluon/contrib/pyrtf/Elements.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
from types import IntType, FloatType, LongType, StringTypes
from copy import deepcopy
from binascii import hexlify
@@ -386,7 +387,7 @@ def _get_emf_dimensions( fin ):
if 0:
klist = sorted(header.__dict__.keys())
for k in klist:
- print "%20s:%s" % (k,header.__dict__[k])
+ print("%20s:%s" % (k,header.__dict__[k]))
dw = header.FrameRight-header.FrameLeft
dh = header.FrameBottom-header.FrameTop
diff --git a/gluon/contrib/qdb.py b/gluon/contrib/qdb.py
index feaaaabd..6e32e6f7 100644
--- a/gluon/contrib/qdb.py
+++ b/gluon/contrib/qdb.py
@@ -2,6 +2,7 @@
# coding:utf-8
"Queues(Pipe)-based independent remote client-server Python Debugger"
+from __future__ import print_function
__author__ = "Mariano Reingart (reingart@gmail.com)"
__copyright__ = "Copyright (C) 2011 Mariano Reingart"
@@ -260,7 +261,7 @@ class Qdb(bdb.Bdb):
self.frame.f_lineno = arg
return arg
except ValueError as e:
- print '*** Jump failed:', e
+ print('*** Jump failed:', e)
return False
def do_list(self, arg):
@@ -317,7 +318,7 @@ class Qdb(bdb.Bdb):
# required by BDB to remove temp breakpoints!
err = self.clear_bpbynumber(arg)
if err:
- print '*** DO_CLEAR failed', err
+ print('*** DO_CLEAR failed', err)
def do_eval(self, arg, safe=True):
ret = eval(arg, self.frame.f_globals,
@@ -612,8 +613,8 @@ class Frontend(object):
# nested request received (i.e. readline)! process it!
self.process_message(res)
elif long(req['id']) != long(res['id']):
- print "DEBUGGER wrong packet received: expecting id", req[
- 'id'], res['id']
+ print("DEBUGGER wrong packet received: expecting id", req[
+ 'id'], res['id'])
# protocol state is unknown
elif 'error' in res and res['error']:
raise RPCError(res['error']['message'])
@@ -639,7 +640,7 @@ class Frontend(object):
def do_jump(self, arg):
"Set the next line that will be executed."
res = self.call('do_jump', arg)
- print res
+ print(res)
def do_where(self, arg=None):
"Print a stack trace, with the most recent frame at the bottom."
@@ -719,22 +720,22 @@ class Cli(Frontend, cmd.Cmd):
try:
Frontend.run(self)
except KeyboardInterrupt:
- print "Interupting..."
+ print("Interupting...")
self.interrupt()
def interaction(self, filename, lineno, line):
- print "> %s(%d)\n-> %s" % (filename, lineno, line),
+ print("> %s(%d)\n-> %s" % (filename, lineno, line), end=' ')
self.filename = filename
self.cmdloop()
def exception(self, title, extype, exvalue, trace, request):
- print "=" * 80
- print "Exception", title
- print request
- print "-" * 80
+ print("=" * 80)
+ print("Exception", title)
+ print(request)
+ print("-" * 80)
def write(self, text):
- print text,
+ print(text, end=' ')
def readline(self):
return raw_input()
@@ -753,7 +754,7 @@ class Cli(Frontend, cmd.Cmd):
def do_eval(self, args):
"Inspect the value of the expression"
- print Frontend.do_eval(self, args)
+ print(Frontend.do_eval(self, args))
def do_list(self, args):
"List source code for the current file"
@@ -768,19 +769,19 @@ class Cli(Frontend, cmd.Cmd):
def do_environment(self, args=None):
env = Frontend.do_environment(self)
for key in env:
- print "=" * 78
- print key.capitalize()
- print "-" * 78
+ print("=" * 78)
+ print(key.capitalize())
+ print("-" * 78)
for name, value in env[key].items():
- print "%-12s = %s" % (name, value)
+ print("%-12s = %s" % (name, value))
def do_list_breakpoint(self, arg=None):
"List all breakpoints"
breaks = Frontend.do_list_breakpoint(self)
- print "Num File Line Temp Enab Hits Cond"
+ print("Num File Line Temp Enab Hits Cond")
for bp in breaks:
- print '%-4d%-30s%4d %4s %4s %4d %s' % bp
- print
+ print('%-4d%-30s%4d %4s %4s %4d %s' % bp)
+ print()
def do_set_breakpoint(self, arg):
"Set a breakpoint at filename:breakpoint"
@@ -802,26 +803,26 @@ class Cli(Frontend, cmd.Cmd):
def default(self, line):
"Default command"
if line[:1] == '!':
- print self.do_exec(line[1:])
+ print(self.do_exec(line[1:]))
else:
- print "*** Unknown command: ", line
+ print("*** Unknown command: ", line)
def print_lines(self, lines):
for filename, lineno, bp, current, source in lines:
- print "%s:%4d%s%s\t%s" % (filename, lineno, bp, current, source),
- print
+ print("%s:%4d%s%s\t%s" % (filename, lineno, bp, current, source), end=' ')
+ print()
def test():
def f(pipe):
- print "creating debugger"
+ print("creating debugger")
qdb = Qdb(pipe=pipe, redirect_stdio=False)
- print "set trace"
+ print("set trace")
my_var = "Mariano!"
qdb.set_trace()
- print "hello world!"
- print "good by!"
+ print("hello world!")
+ print("good by!")
saraza
if '--process' in sys.argv:
@@ -841,20 +842,20 @@ def test():
class Test(Frontend):
def interaction(self, *args):
- print "interaction!", args
+ print("interaction!", args)
def exception(self, *args):
- print "exception", args
+ print("exception", args)
#raise RuntimeError("exception %s" % repr(args))
qdb = Test(front_conn)
time.sleep(5)
while True:
- print "running..."
+ print("running...")
Frontend.run(qdb)
time.sleep(1)
- print "do_next"
+ print("do_next")
qdb.do_next()
p.join()
@@ -865,7 +866,7 @@ def connect(host="localhost", port=6000, authkey='secret password'):
address = (host, port)
from multiprocessing.connection import Client
- print "qdb debugger fronted: waiting for connection to", address
+ print("qdb debugger fronted: waiting for connection to", address)
conn = Client(address, authkey=authkey)
try:
Cli(conn).run()
@@ -879,12 +880,12 @@ def main(host='localhost', port=6000, authkey='secret password'):
"Debug a script and accept a remote frontend"
if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
- print "usage: pdb.py scriptfile [arg] ..."
+ print("usage: pdb.py scriptfile [arg] ...")
sys.exit(2)
mainpyfile = sys.argv[1] # Get script filename
if not os.path.exists(mainpyfile):
- print 'Error:', mainpyfile, 'does not exist'
+ print('Error:', mainpyfile, 'does not exist')
sys.exit(1)
del sys.argv[0] # Hide "pdb.py" from argument list
@@ -895,20 +896,20 @@ def main(host='localhost', port=6000, authkey='secret password'):
from multiprocessing.connection import Listener
address = (host, port) # family is deduced to be 'AF_INET'
listener = Listener(address, authkey=authkey)
- print "qdb debugger backend: waiting for connection at", address
+ print("qdb debugger backend: waiting for connection at", address)
conn = listener.accept()
- print 'qdb debugger backend: connected to', listener.last_accepted
+ print('qdb debugger backend: connected to', listener.last_accepted)
# create the backend
qdb = Qdb(conn, redirect_stdio=True, allow_interruptions=True)
try:
- print "running", mainpyfile
+ print("running", mainpyfile)
qdb._runscript(mainpyfile)
- print "The program finished"
+ print("The program finished")
except SystemExit:
# In most cases SystemExit does not warrant a post-mortem session.
- print "The program exited via sys.exit(). Exit status: ",
- print sys.exc_info()[1]
+ print("The program exited via sys.exit(). Exit status: ", end=' ')
+ print(sys.exc_info()[1])
raise
except:
raise
diff --git a/gluon/contrib/shell.py b/gluon/contrib/shell.py
index 18d1b44e..c843c0a5 100755
--- a/gluon/contrib/shell.py
+++ b/gluon/contrib/shell.py
@@ -28,6 +28,7 @@
"""
An interactive, stateful AJAX shell that runs Python code on the server.
"""
+from __future__ import print_function
import logging
import new
@@ -270,4 +271,4 @@ def run(history, statement, env={}):
if __name__ == '__main__':
history = History()
while True:
- print run(history, raw_input('>>> ')).rstrip()
+ print(run(history, raw_input('>>> ')).rstrip())
diff --git a/gluon/contrib/simplejsonrpc.py b/gluon/contrib/simplejsonrpc.py
index d4bea7fd..2a4547f7 100644
--- a/gluon/contrib/simplejsonrpc.py
+++ b/gluon/contrib/simplejsonrpc.py
@@ -10,6 +10,7 @@
# for more details.
"Pythonic simple JSON RPC Client implementation"
+from __future__ import print_function
__author__ = "Mariano Reingart (reingart@gmail.com)"
__copyright__ = "Copyright (C) 2011 Mariano Reingart"
@@ -145,4 +146,4 @@ if __name__ == "__main__":
# basic tests:
location = "http://www.web2py.com.ar/webservices/sample/call/jsonrpc"
client = ServerProxy(location, verbose='--verbose' in sys.argv,)
- print client.add(1, 2)
+ print(client.add(1, 2))
diff --git a/gluon/contrib/spreadsheet.py b/gluon/contrib/spreadsheet.py
index 5317ef34..e9c4c76f 100644
--- a/gluon/contrib/spreadsheet.py
+++ b/gluon/contrib/spreadsheet.py
@@ -3,6 +3,7 @@
"""
Developed by Massimo Di Pierro, optional component of web2py, BSDv3 license.
"""
+from __future__ import print_function
import re
import pickle
@@ -900,4 +901,4 @@ if __name__ == '__main__':
s.cell('a', value="2")
s.cell('b', value="=sin(a)")
s.cell('c', value="=cos(a)**2+b*b")
- print s['c'].computed_value
+ print(s['c'].computed_value)
diff --git a/gluon/contrib/stripe.py b/gluon/contrib/stripe.py
index c3575174..9c779cdd 100644
--- a/gluon/contrib/stripe.py
+++ b/gluon/contrib/stripe.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import urllib
import json
from hashlib import sha1
@@ -244,8 +245,8 @@ jQuery(function(){
if __name__ == '__main__':
key = raw_input('user>')
d = Stripe(key).charge(100)
- print 'charged', d['paid']
+ print('charged', d['paid'])
s = Stripe(key).check(d[u'id'])
- print 'paid', s['paid'], s['amount'], s['currency']
+ print('paid', s['paid'], s['amount'], s['currency'])
s = Stripe(key).refund(d[u'id'])
- print 'refunded', s['refunded']
+ print('refunded', s['refunded'])
diff --git a/gluon/contrib/taskbar_widget.py b/gluon/contrib/taskbar_widget.py
index 1d0ec7d8..785c3ce2 100644
--- a/gluon/contrib/taskbar_widget.py
+++ b/gluon/contrib/taskbar_widget.py
@@ -6,6 +6,7 @@
# # 11/7/08
# dual licensed under the web2py license (LGPL) and the Python license.
+from __future__ import print_function
import os
import sys
import base64
@@ -78,7 +79,7 @@ class TaskBarIcon:
hicon = self.__loadFromFile(fp)
os.unlink(fp)
except:
- print "Can't load web2py icons - using default"
+ print("Can't load web2py icons - using default")
hicon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
flags = win32gui.NIF_ICON | win32gui.NIF_MESSAGE\
@@ -101,7 +102,7 @@ class TaskBarIcon:
# This is common when windows is starting, and this code is hit
# before the taskbar has been created.
- print 'Failed to add the taskbar icon - is explorer running?'
+ print('Failed to add the taskbar icon - is explorer running?')
# but keep running anyway - when explorer starts, we get the
@@ -197,7 +198,7 @@ class TaskBarIcon:
self.status.append(self.EnumStatus.QUIT)
self.Destroy()
else:
- print 'Unknown command -', id
+ print('Unknown command -', id)
def Destroy(self):
win32gui.DestroyWindow(self.hwnd)
diff --git a/gluon/contrib/timecollect.py b/gluon/contrib/timecollect.py
index fc497c44..22384c22 100644
--- a/gluon/contrib/timecollect.py
+++ b/gluon/contrib/timecollect.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
# Only Python 2.6 and up, because of NamedTuple.
import time
from collections import namedtuple
diff --git a/gluon/contrib/webclient.py b/gluon/contrib/webclient.py
index 69cb8337..3beca75c 100644
--- a/gluon/contrib/webclient.py
+++ b/gluon/contrib/webclient.py
@@ -15,6 +15,7 @@ mostly for testing purposes
Some examples at the bottom.
"""
+from __future__ import print_function
import re
import time
import urllib
@@ -160,7 +161,7 @@ class WebClient(object):
if match:
name = match.group('name')
if name in self.sessions and self.sessions[name] != value:
- print RuntimeError('Changed session ID %s' % name)
+ print(RuntimeError('Changed session ID %s' % name))
self.sessions[name] = value
# find all forms and formkeys in page
@@ -202,13 +203,13 @@ def test_web2py_registration_and_login():
assert 'Welcome Homer' in client.text
# print some variables
- print '\nsessions:\n', client.sessions
- print '\nheaders:\n', client.headers
- print '\ncookies:\n', client.cookies
- print '\nforms:\n', client.forms
- print
+ print('\nsessions:\n', client.sessions)
+ print('\nheaders:\n', client.headers)
+ print('\ncookies:\n', client.cookies)
+ print('\nforms:\n', client.forms)
+ print()
for method, url, status, t in client.history:
- print method, url, status, t
+ print(method, url, status, t)
if __name__ == '__main__':
test_web2py_registration_and_login()
diff --git a/gluon/contrib/websocket_messaging.py b/gluon/contrib/websocket_messaging.py
index d732e07e..5531629a 100644
--- a/gluon/contrib/websocket_messaging.py
+++ b/gluon/contrib/websocket_messaging.py
@@ -83,6 +83,7 @@ Acknowledgements:
Tornado code inspired by http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
"""
+from __future__ import print_function
import tornado.httpserver
import tornado.websocket
@@ -117,7 +118,7 @@ class PostHandler(tornado.web.RequestHandler):
if 'message' in self.request.arguments:
message = self.request.arguments['message'][0]
group = self.request.arguments.get('group', ['default'])[0]
- print '%s:MESSAGE to %s:%s' % (time.time(), group, message)
+ print('%s:MESSAGE to %s:%s' % (time.time(), group, message))
if hmac_key:
signature = self.request.arguments['signature'][0]
if not hmac.new(hmac_key, message).hexdigest() == signature:
@@ -167,7 +168,7 @@ class DistributeHandler(tornado.websocket.WebSocketHandler):
client.write_message('+' + self.name)
listeners[self.group].append(self)
names[self] = self.name
- print '%s:CONNECT to %s' % (time.time(), self.group)
+ print('%s:CONNECT to %s' % (time.time(), self.group))
def on_message(self, message):
pass
@@ -179,7 +180,7 @@ class DistributeHandler(tornado.websocket.WebSocketHandler):
# notify clients that a member has left the groups
for client in listeners.get(self.group, []):
client.write_message('-' + self.name)
- print '%s:DISCONNECT from %s' % (time.time(), self.group)
+ print('%s:DISCONNECT from %s' % (time.time(), self.group))
# if your webserver is different from tornado server uncomment this
# or override using something more restrictive:
diff --git a/gluon/highlight.py b/gluon/highlight.py
index cdafbd1d..13d164f2 100644
--- a/gluon/highlight.py
+++ b/gluon/highlight.py
@@ -6,6 +6,7 @@
| Copyrighted by Massimo Di Pierro
| License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
"""
+from __future__ import print_function
import re
import cgi
@@ -341,5 +342,5 @@ if __name__ == '__main__':
argfp = open(sys.argv[1])
data = argfp.read()
argfp.close()
- print '' + highlight(data, sys.argv[2])\
- + ''
+ print('' + highlight(data, sys.argv[2])\
+ + '')
diff --git a/gluon/html.py b/gluon/html.py
index 00082c17..6a3608bd 100644
--- a/gluon/html.py
+++ b/gluon/html.py
@@ -9,6 +9,7 @@
Template helpers
--------------------------------------------
"""
+from __future__ import print_function
import cgi
import os
@@ -743,7 +744,7 @@ class DIV(XmlComponent):
>>> a=DIV()
>>> a.append(SPAN('x'))
- >>> print a
+ >>> print(a)
x
"""
self._setnode(value)
@@ -759,7 +760,7 @@ class DIV(XmlComponent):
>>> a=DIV()
>>> a.insert(0, SPAN('x'))
- >>> print a
+ >>> print(a)
x
"""
self._setnode(value)
@@ -1025,10 +1026,10 @@ class DIV(XmlComponent):
>>> a = DIV(DIV(SPAN('x'),3,DIV(SPAN('y'))))
>>> for c in a.elements('span', first_only=True): c[0]='z'
- >>> print a
+ >>> print(a)
>>> for c in a.elements('span'): c[0]='z'
- >>> print a
+ >>> print(a)
It also supports a syntax compatible with jQuery
@@ -1036,10 +1037,10 @@ class DIV(XmlComponent):
Examples:
>>> a=TAG('')
- >>> for e in a.elements('div a#1-1, p.is'): print e.flatten()
+ >>> for e in a.elements('div a#1-1, p.is'): print(e.flatten())
hello
world
- >>> for e in a.elements('#1-1'): print e.flatten()
+ >>> for e in a.elements('#1-1'): print(e.flatten())
hello
>>> a.elements('a[u:v=$]')[0].xml()
'hello'
@@ -1056,7 +1057,7 @@ class DIV(XmlComponent):
>>> a = DIV(DIV(SPAN('x', _class='abc'), DIV(SPAN('y', _class='abc'), SPAN('z', _class='abc'))))
>>> b = a.elements('span.abc', replace=P('x', _class='xyz'))
- >>> print a # We should .xml() here instead of print
+ >>> print(a) # We should .xml() here instead of print
"replace" can be a callable, which will be passed the original element and
@@ -1066,7 +1067,7 @@ class DIV(XmlComponent):
>>> a = DIV(DIV(SPAN('x', _class='abc'), DIV(SPAN('y', _class='abc'), SPAN('z', _class='abc'))))
>>> b = a.elements('span.abc', replace=lambda el: P(el[0], _class='xyz'))
- >>> print a
+ >>> print(a)
If replace=None, matching elements will be removed completely.
@@ -1075,7 +1076,7 @@ class DIV(XmlComponent):
>>> a = DIV(DIV(SPAN('x', _class='abc'), DIV(SPAN('y', _class='abc'), SPAN('z', _class='abc'))))
>>> b = a.elements('span', find='y', replace=None)
- >>> print a
+ >>> print(a)
If a "find_text" argument is specified, elements will be searched for text
@@ -1087,7 +1088,7 @@ class DIV(XmlComponent):
>>> a = DIV(DIV(SPAN('x', _class='abc'), DIV(SPAN('y', _class='abc'), SPAN('z', _class='abc'))))
>>> b = a.elements(find_text=re.compile('x|y|z'), replace='hello')
- >>> print a
+ >>> print(a)
If other attributes are specified along with find_text, then only components
@@ -1097,7 +1098,7 @@ class DIV(XmlComponent):
>>> a = DIV(DIV(SPAN('x', _class='abc'), DIV(SPAN('y', _class='efg'), SPAN('z', _class='abc'))))
>>> b = a.elements('span.efg', find_text=re.compile('x|y|z'), replace='hello')
- >>> print a
+ >>> print(a)
"""
if len(args) == 1:
@@ -1273,7 +1274,7 @@ class __TAG__(XmlComponent):
Examples:
- >>> print TAG.first(TAG.second('test'), _key = 3)
+ >>> print(TAG.first(TAG.second('test'), _key = 3))
test
"""
@@ -1633,7 +1634,7 @@ class CODE(DIV):
Examples:
- {{=CODE(\"print 'hello world'\", language='python', link=None,
+ {{=CODE(\"print('hello world')\", language='python', link=None,
counter=1, styles={}, highlight_line=None)}}
@@ -1862,7 +1863,7 @@ class INPUT(DIV):
(value, errors) = validator(value)
except:
import traceback
- print traceback.format_exc()
+ print(traceback.format_exc())
msg = "Validation error, field:%s %s" % (name,validator)
raise Exception(msg)
if errors is not None:
@@ -2608,34 +2609,34 @@ def test():
Example:
>>> from validators import *
- >>> print DIV(A('click me', _href=URL(a='a', c='b', f='c')), BR(), HR(), DIV(SPAN("World"), _class='unknown')).xml()
+ >>> print(DIV(A('click me', _href=URL(a='a', c='b', f='c')), BR(), HR(), DIV(SPAN("World"), _class='unknown')).xml())
- >>> print DIV(UL("doc","cat","mouse")).xml()
+ >>> print(DIV(UL("doc","cat","mouse")).xml())
- >>> print DIV(UL("doc", LI("cat", _class='feline'), 18)).xml()
+ >>> print(DIV(UL("doc", LI("cat", _class='feline'), 18)).xml())
- >>> print TABLE(['a', 'b', 'c'], TR('d', 'e', 'f'), TR(TD(1), TD(2), TD(3))).xml()
+ >>> print(TABLE(['a', 'b', 'c'], TR('d', 'e', 'f'), TR(TD(1), TD(2), TD(3))).xml())
>>> form=FORM(INPUT(_type='text', _name='myvar', requires=IS_EXPR('int(value)<10')))
- >>> print form.xml()
+ >>> print(form.xml())
- >>> print form.accepts({'myvar':'34'}, formname=None)
+ >>> print(form.accepts({'myvar':'34'}, formname=None))
False
- >>> print form.xml()
+ >>> print(form.xml())
- >>> print form.accepts({'myvar':'4'}, formname=None, keepvalues=True)
+ >>> print(form.accepts({'myvar':'4'}, formname=None, keepvalues=True))
True
- >>> print form.xml()
+ >>> print(form.xml())
>>> form=FORM(SELECT('cat', 'dog', _name='myvar'))
- >>> print form.accepts({'myvar':'dog'}, formname=None, keepvalues=True)
+ >>> print(form.accepts({'myvar':'dog'}, formname=None, keepvalues=True))
True
- >>> print form.xml()
+ >>> print(form.xml())
>>> form=FORM(INPUT(_type='text', _name='myvar', requires=IS_MATCH('^\w+$', 'only alphanumeric!')))
- >>> print form.accepts({'myvar':'as df'}, formname=None)
+ >>> print(form.accepts({'myvar':'as df'}, formname=None))
False
- >>> print form.xml()
+ >>> print(form.xml())
>>> session={}
>>> form=FORM(INPUT(value="Hello World", _name="var", requires=IS_MATCH('^\w+$')))
@@ -2645,8 +2646,8 @@ def test():
True
>>> isinstance(form.as_json(), basestring) and len(form.as_json(sanitize=False)) > 0
True
- >>> if form.accepts({}, session,formname=None): print 'passed'
- >>> if form.accepts({'var':'test ', '_formkey': session['_formkey[None]']}, session, formname=None): print 'passed'
+ >>> if form.accepts({}, session,formname=None): print('passed')
+ >>> if form.accepts({'var':'test ', '_formkey': session['_formkey[None]']}, session, formname=None): print('passed')
"""
pass
diff --git a/gluon/main.py b/gluon/main.py
index 8243cb6b..0bf22a3d 100644
--- a/gluon/main.py
+++ b/gluon/main.py
@@ -9,6 +9,7 @@
The gluon wsgi application
---------------------------
"""
+from __future__ import print_function
if False: import import_all # DO NOT REMOVE PART OF FREEZE PROCESS
import gc
@@ -570,9 +571,9 @@ def save_password(password, port):
chars = string.letters + string.digits
password = ''.join([random.choice(chars) for _ in range(8)])
cpassword = CRYPT()(password)[0]
- print '******************* IMPORTANT!!! ************************'
- print 'your admin password is "%s"' % password
- print '*********************************************************'
+ print('******************* IMPORTANT!!! ************************')
+ print('your admin password is "%s"' % password)
+ print('*********************************************************')
elif password == '':
# reuse the current password if any
if exists(password_file):
diff --git a/gluon/rewrite.py b/gluon/rewrite.py
index 69f30d64..3ada7b7c 100644
--- a/gluon/rewrite.py
+++ b/gluon/rewrite.py
@@ -15,6 +15,7 @@ routes.py supports two styles of URL rewriting, depending on whether 'routers' i
Refer to router.example.py and routes.example.py for additional documentation.
"""
+from __future__ import print_function
import os
import re
@@ -117,7 +118,7 @@ def log_rewrite(string):
elif params.logging == 'off' or not params.logging:
pass
elif params.logging == 'print':
- print string
+ print(string)
elif params.logging == 'info':
logger.info(string)
elif params.logging == 'warning':
diff --git a/gluon/rocket.py b/gluon/rocket.py
index 6122e35c..74d1ab64 100644
--- a/gluon/rocket.py
+++ b/gluon/rocket.py
@@ -5,6 +5,7 @@
# Modified by Massimo Di Pierro
# Import System Modules
+from __future__ import print_function
import sys
import errno
import socket
@@ -1681,7 +1682,7 @@ class WSGIWorker(Worker):
environ['SSL_CLIENT_RAW_CERT'] = \
peercert and ssl.DER_cert_to_PEM_cert(peercert)
except Exception:
- print sys.exc_info()[1]
+ print(sys.exc_info()[1])
else:
environ['wsgi.url_scheme'] = 'http'
@@ -1907,7 +1908,7 @@ def demo():
(options, args) = parser.parse_args()
global static_folder
static_folder = options.static
- print 'Rocket running on %s:%s' % (options.ip, options.port)
+ print('Rocket running on %s:%s' % (options.ip, options.port))
r=Rocket((options.ip,int(options.port)),'wsgi', {'wsgi_app':demo_app})
r.start()
diff --git a/gluon/rocket.py.footer b/gluon/rocket.py.footer
index d6be8ef3..7d76ea4b 100644
--- a/gluon/rocket.py.footer
+++ b/gluon/rocket.py.footer
@@ -1,3 +1,4 @@
+from __future__ import print_function
# The following code is not part of Rocket but was added to
# web2py for testing purposes.
@@ -42,7 +43,7 @@ def demo():
(options, args) = parser.parse_args()
global static_folder
static_folder = options.static
- print 'Rocket running on %s:%s' % (options.ip, options.port)
+ print('Rocket running on %s:%s' % (options.ip, options.port))
r = Rocket((options.ip, int(options.port)), 'wsgi', {'wsgi_app': demo_app})
r.start()
diff --git a/gluon/scheduler.py b/gluon/scheduler.py
index 1e588ed1..27721c99 100644
--- a/gluon/scheduler.py
+++ b/gluon/scheduler.py
@@ -8,6 +8,7 @@
Background processes made simple
---------------------------------
"""
+from __future__ import print_function
import os
@@ -1458,26 +1459,26 @@ def main():
)
(options, args) = parser.parse_args()
if not options.tasks or not options.db_uri:
- print USAGE
+ print(USAGE)
if options.tasks:
path, filename = os.path.split(options.tasks)
if filename.endswith('.py'):
filename = filename[:-3]
sys.path.append(path)
- print 'importing tasks...'
+ print('importing tasks...')
tasks = __import__(filename, globals(), locals(), [], -1).tasks
- print 'tasks found: ' + ', '.join(tasks.keys())
+ print('tasks found: ' + ', '.join(tasks.keys()))
else:
tasks = {}
group_names = [x.strip() for x in options.group_names.split(',')]
logging.getLogger().setLevel(options.logger_level)
- print 'groups for this worker: ' + ', '.join(group_names)
- print 'connecting to database in folder: ' + options.db_folder or './'
- print 'using URI: ' + options.db_uri
+ print('groups for this worker: ' + ', '.join(group_names))
+ print('connecting to database in folder: ' + options.db_folder or './')
+ print('using URI: ' + options.db_uri)
db = DAL(options.db_uri, folder=options.db_folder)
- print 'instantiating scheduler...'
+ print('instantiating scheduler...')
scheduler = Scheduler(db=db,
worker_name=options.worker_name,
tasks=tasks,
@@ -1487,7 +1488,7 @@ def main():
max_empty_runs=options.max_empty_runs,
utc_time=options.utc_time)
signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1))
- print 'starting main worker loop...'
+ print('starting main worker loop...')
scheduler.loop()
if __name__ == '__main__':
diff --git a/gluon/shell.py b/gluon/shell.py
index 1e1cbebd..ae30a4f1 100644
--- a/gluon/shell.py
+++ b/gluon/shell.py
@@ -10,6 +10,7 @@
Web2py environment in the shell
--------------------------------
"""
+from __future__ import print_function
import os
import sys
@@ -265,7 +266,7 @@ def run(
if import_models:
BaseAdapter.close_all_instances('commit')
except Exception as e:
- print traceback.format_exc()
+ print(traceback.format_exc())
if import_models:
BaseAdapter.close_all_instances('rollback')
elif python_code:
@@ -274,7 +275,7 @@ def run(
if import_models:
BaseAdapter.close_all_instances('commit')
except Exception as e:
- print traceback.format_exc()
+ print(traceback.format_exc())
if import_models:
BaseAdapter.close_all_instances('rollback')
else:
@@ -347,7 +348,7 @@ def parse_path_info(path_info, av=False):
def die(msg):
- print >> sys.stderr, msg
+ print(msg, file=sys.stderr)
sys.exit(1)
diff --git a/gluon/tests/test_appadmin.py b/gluon/tests/test_appadmin.py
index 674399fd..f8a62ee6 100644
--- a/gluon/tests/test_appadmin.py
+++ b/gluon/tests/test_appadmin.py
@@ -4,6 +4,7 @@
"""
Unit tests for gluon.sqlhtml
"""
+from __future__ import print_function
import os
import sys
import unittest
@@ -87,7 +88,7 @@ class TestAppAdmin(unittest.TestCase):
try:
self.run_view()
except Exception as e:
- print e.message
+ print(e.message)
self.fail('Could not make the view')
def test_select(self):
@@ -102,7 +103,7 @@ class TestAppAdmin(unittest.TestCase):
try:
self.run_view()
except Exception as e:
- print e.message
+ print(e.message)
self.fail('Could not make the view')
def test_insert(self):
@@ -116,7 +117,7 @@ class TestAppAdmin(unittest.TestCase):
try:
self.run_view()
except Exception as e:
- print e.message
+ print(e.message)
self.fail('Could not make the view')
def test_insert_submit(self):
@@ -138,7 +139,7 @@ class TestAppAdmin(unittest.TestCase):
try:
self.run_view()
except Exception as e:
- print e.message
+ print(e.message)
self.fail('Could not make the view')
db = self.env['db']
lisa_record = db(db.auth_user.username == 'lisasimpson').select().first()
diff --git a/gluon/tests/test_web.py b/gluon/tests/test_web.py
index 95361fc6..33255543 100644
--- a/gluon/tests/test_web.py
+++ b/gluon/tests/test_web.py
@@ -3,6 +3,7 @@
"""
Unit tests for running web2py
"""
+from __future__ import print_function
import sys
import os
import unittest
@@ -32,22 +33,22 @@ def startwebserver():
path = os.path.abspath(os.path.join(path, '..'))
web2py_exec = os.path.join(path, 'web2py.py')
webserverprocess = subprocess.Popen([sys.executable, web2py_exec, '-a', 'testpass'])
- print 'Sleeping before web2py starts...'
+ print('Sleeping before web2py starts...')
for a in range(1, 11):
time.sleep(1)
- print a, '...'
+ print(a, '...')
try:
c = WebClient('http://127.0.0.1:8000')
c.get('/')
break
except:
continue
- print ''
+ print('')
def stopwebserver():
global webserverprocess
- print 'Killing webserver'
+ print('Killing webserver')
webserverprocess.terminate()
diff --git a/gluon/utf8.py b/gluon/utf8.py
index 0c9e4a54..24c90e31 100644
--- a/gluon/utf8.py
+++ b/gluon/utf8.py
@@ -10,6 +10,7 @@
Utilities and class for UTF8 strings managing
----------------------------------------------
"""
+from __future__ import print_function
import __builtin__
__all__ = ['Utf8']
@@ -749,8 +750,8 @@ if __name__ == '__main__':
reload(sys)
sys.setdefaultencoding("UTF-8")
import doctest
- print "DOCTESTS STARTED..."
+ print("DOCTESTS STARTED...")
doctest.testmod()
- print "DOCTESTS FINISHED"
+ print("DOCTESTS FINISHED")
doctests()
diff --git a/gluon/widget.py b/gluon/widget.py
index 631466ff..143dff36 100644
--- a/gluon/widget.py
+++ b/gluon/widget.py
@@ -9,6 +9,7 @@
The widget is called from web2py
----------------------------------
"""
+from __future__ import print_function
import datetime
import sys
@@ -118,14 +119,14 @@ def get_url(host, path='/', proto='http', port=80):
def start_browser(url, startup=False):
if startup:
- print 'please visit:'
- print '\t', url
- print 'starting browser...'
+ print('please visit:')
+ print('\t', url)
+ print('starting browser...')
try:
import webbrowser
webbrowser.open(url)
except:
- print 'warning: unable to detect your browser'
+ print('warning: unable to detect your browser')
class web2pyDialog(object):
@@ -357,16 +358,16 @@ class web2pyDialog(object):
sys.stderr.write('Sorry, -K only supported for python 2.6-2.7\n')
return
code = "from gluon import current;current._scheduler.loop()"
- print 'starting scheduler from widget for "%s"...' % app
+ print('starting scheduler from widget for "%s"...' % app)
args = (app, True, True, None, False, code)
logging.getLogger().setLevel(self.options.debuglevel)
p = Process(target=run, args=args)
self.scheduler_processes[app] = p
self.update_schedulers()
- print "Currently running %s scheduler processes" % (
- len(self.scheduler_processes))
+ print("Currently running %s scheduler processes" % (
+ len(self.scheduler_processes)))
p.start()
- print "Processes started"
+ print("Processes started")
def try_stop_scheduler(self, app):
if app in self.scheduler_processes:
@@ -950,12 +951,12 @@ def console():
content = open(os.path.join('examples', 'app.example.yaml'), 'rb').read()
open('app.yaml', 'wb').write(content.replace("yourappname", name))
else:
- print "app.yaml alreday exists in the web2py folder"
+ print("app.yaml alreday exists in the web2py folder")
if not os.path.exists('gaehandler.py'):
content = open(os.path.join('handlers', 'gaehandler.py'), 'rb').read()
open('gaehandler.py', 'wb').write(content)
else:
- print "gaehandler.py alreday exists in the web2py folder"
+ print("gaehandler.py alreday exists in the web2py folder")
sys.exit(0)
try:
@@ -1042,7 +1043,7 @@ def get_code_for_scheduler(app, options):
code = code % ("','".join(app[1:]))
app_ = app[0]
if not check_existent_app(options, app_):
- print "Application '%s' doesn't exist, skipping" % app_
+ print("Application '%s' doesn't exist, skipping" % app_)
return None, None
return app_, code
@@ -1065,7 +1066,7 @@ def start_schedulers(options):
app_, code = get_code_for_scheduler(apps[0], options)
if not app_:
return
- print 'starting single-scheduler for "%s"...' % app_
+ print('starting single-scheduler for "%s"...' % app_)
run(app_, True, True, None, False, code)
return
@@ -1077,20 +1078,20 @@ def start_schedulers(options):
app_, code = get_code_for_scheduler(app, options)
if not app_:
continue
- print 'starting scheduler for "%s"...' % app_
+ print('starting scheduler for "%s"...' % app_)
args = (app_, True, True, None, False, code)
p = Process(target=run, args=args)
processes.append(p)
- print "Currently running %s scheduler processes" % (len(processes))
+ print("Currently running %s scheduler processes" % (len(processes)))
p.start()
##to avoid bashing the db at the same time
time.sleep(0.7)
- print "Processes started"
+ print("Processes started")
for p in processes:
try:
p.join()
except (KeyboardInterrupt, SystemExit):
- print "Processes stopped"
+ print("Processes stopped")
except:
p.terminate()
p.join()
@@ -1104,13 +1105,13 @@ def start(cron=True):
(options, args) = console()
if not options.nobanner:
- print ProgramName
- print ProgramAuthor
- print ProgramVersion
+ print(ProgramName)
+ print(ProgramAuthor)
+ print(ProgramVersion)
from pydal.drivers import DRIVERS
if not options.nobanner:
- print 'Database drivers available: %s' % ', '.join(DRIVERS)
+ print('Database drivers available: %s' % ', '.join(DRIVERS))
# ## if -L load options from options.config file
if options.config:
@@ -1121,7 +1122,7 @@ def start(cron=True):
# Jython doesn't like the extra stuff
options2 = __import__(options.config)
except Exception:
- print 'Cannot import config file [%s]' % options.config
+ print('Cannot import config file [%s]' % options.config)
sys.exit(1)
for key in dir(options2):
if hasattr(options, key):
@@ -1170,7 +1171,7 @@ def start(cron=True):
# ## if --softcron use softcron
# ## use hardcron in all other cases
if cron and options.runcron and options.softcron:
- print 'Using softcron (but this is not very efficient)'
+ print('Using softcron (but this is not very efficient)')
global_settings.web2py_crontype = 'soft'
elif cron and options.runcron:
logger.debug('Starting hardcron...')
@@ -1186,7 +1187,7 @@ def start(cron=True):
options.taskbar = False
if options.taskbar and os.name != 'nt':
- print 'Error: taskbar not supported on this platform'
+ print('Error: taskbar not supported on this platform')
sys.exit(1)
root = None
@@ -1234,7 +1235,7 @@ end tell
options.password = getpass.getpass('choose a password:')
if not options.password and not options.nobanner:
- print 'no password, no admin interface'
+ print('no password, no admin interface')
# ##-X (if no tk, the widget takes care of it himself)
if not root and options.scheduler and options.with_scheduler:
@@ -1265,7 +1266,7 @@ end tell
message += 'use "taskkill /f /pid %i" to shutdown the web2py server\n\n' % os.getpid()
else:
message += 'use "kill -SIGTERM %i" to shutdown the web2py server\n\n' % os.getpid()
- print message
+ print(message)
# enhance linecache.getline (used by debugger) to look at the source file
# if the line was not found (under py2exe & when file was modified)