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