running libfuturize.fixes.fix_print_with_import
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.</p>
|
||||
|
||||
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())
|
||||
|
||||
@@ -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
|
||||
<https://github.com/trentm/python-markdown2/wiki/Extras>.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
cmdln_desc = """A fast and complete Python implementation of Markdown, a
|
||||
text-to-HTML conversion tool for web writers.
|
||||
|
||||
@@ -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$$"))
|
||||
<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]]\]]")
|
||||
@@ -1494,17 +1495,17 @@ if __name__ == '__main__':
|
||||
pre { background-color: #E0E0E0; padding: 5px; }
|
||||
</style>""")[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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
:license: LGPLv3
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
+42
-41
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Only Python 2.6 and up, because of NamedTuple.
|
||||
import time
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user