Fixed print function to be inline with python 3

This commit is contained in:
Jim Shaver 2015-05-29 23:17:48 -04:00
parent 97c6d7ed25
commit 4fe2c069cc
10 changed files with 37 additions and 37 deletions

View File

@ -30,7 +30,7 @@ class MyMaster(flow.FlowMaster):
f = flow.FlowMaster.handle_response(self, f)
if f:
f.reply()
print f
print(f)
return f

View File

@ -231,4 +231,4 @@ def print_attributes(obj, filter_string=None, hide_privates=False):
if filter_string is not None and filter_string not in attr:
continue
value = getattr(obj, attr)
print "%s.%s" % ('obj', attr), value, type(value)
print("%s.%s" % ('obj', attr), value, type(value))

View File

@ -28,12 +28,12 @@ class Wrapper(object):
return dict([re.findall(r'([^:]+): (.*)', line)[0] for line in state])
def enable_proxy_for_service(self, service):
print 'Enabling proxy on {}...'.format(service)
print('Enabling proxy on {}...'.format(service))
for subcommand in ['-setwebproxy', '-setsecurewebproxy']:
self.run_networksetup_command(subcommand, service, '127.0.0.1', str(self.port))
def disable_proxy_for_service(self, service):
print 'Disabling proxy on {}...'.format(service)
print('Disabling proxy on {}...'.format(service))
for subcommand in ['-setwebproxystate', '-setsecurewebproxystate']:
self.run_networksetup_command(subcommand, service, 'Off')
@ -112,7 +112,7 @@ class Wrapper(object):
@classmethod
def ensure_superuser(cls):
if os.getuid() != 0:
print 'Relaunching with sudo...'
print('Relaunching with sudo...')
os.execv('/usr/bin/sudo', ['/usr/bin/sudo'] + sys.argv)
@classmethod

View File

@ -4,6 +4,6 @@ from libmproxy.script import concurrent
@concurrent # Remove this and see what happens
def request(context, flow):
print "handle request: %s%s" % (flow.request.host, flow.request.path)
print("handle request: %s%s" % (flow.request.host, flow.request.path))
time.sleep(5)
print "start request: %s%s" % (flow.request.host, flow.request.path)
print("start request: %s%s" % (flow.request.host, flow.request.path))

View File

@ -13,6 +13,6 @@ with open("logfile", "rb") as logfile:
print(f)
print(f.request.host)
json.dump(f.get_state(), sys.stdout, indent=4)
print ""
print("")
except flow.FlowReadError, v:
print "Flow file corrupted. Stopped loading."
print("Flow file corrupted. Stopped loading.")

View File

@ -40,7 +40,7 @@ Here is a program to parse "Hello, World!" (or any greeting of the form "<saluta
greet = Word( alphas ) + "," + Word( alphas ) + "!"
hello = "Hello, World!"
print hello, "->", greet.parseString( hello )
print(hello, "->", greet.parseString( hello ))
The program outputs the following::
@ -962,7 +962,7 @@ class ParserElement(object):
asList=self.saveAsList and isinstance(tokens,(ParseResults,list)),
modal=self.modalResults )
except ParseBaseException, err:
#~ print "Exception raised in user parse action:", err
#~ print("Exception raised in user parse action:", err)
if (self.debugActions[2] ):
self.debugActions[2]( instring, tokensStart, self, err )
raise
@ -2861,7 +2861,7 @@ class SkipTo(ParseElementEnhance):
while 1:
try:
loc = self.ignoreExpr.tryParse(instring,loc)
print "found ignoreExpr, advance to", loc
print("found ignoreExpr, advance to", loc)
except ParseBaseException:
break
expr._parse( instring, loc, doActions=False, callPreParse=False )

View File

@ -354,7 +354,7 @@ class TransparentProxy(object):
if server:
packet.src_addr, packet.src_port = server
else:
print "Warning: Previously unseen connection from proxy to %s:%s." % client
print("Warning: Previously unseen connection from proxy to %s:%s." % client)
packet = self.driver.update_packet_checksums(packet)
self.response_handle.send((packet.raw, metadata))

View File

@ -60,10 +60,10 @@ By default tnetstrings work only with byte strings, not unicode. If you want
unicode strings then pass an optional encoding to the various functions,
like so::
>>> print repr(tnetstring.loads("2:\\xce\\xb1,"))
>>> print(repr(tnetstring.loads("2:\\xce\\xb1,")))
'\\xce\\xb1'
>>>
>>> print repr(tnetstring.loads("2:\\xce\\xb1,","utf8"))
>>> print(repr(tnetstring.loads("2:\\xce\\xb1,","utf8")))
u'\u03b1'
"""

View File

@ -180,7 +180,7 @@ class Settings(RequestHandler):
update = {}
for k, v in self.request.arguments.iteritems():
if len(v) != 1:
print "Warning: Unknown length for setting {}: {}".format(k, v)
print("Warning: Unknown length for setting {}: {}".format(k, v))
continue
if k == "_xsrf":
@ -189,7 +189,7 @@ class Settings(RequestHandler):
self.state.set_intercept(v[0])
update[k] = v[0]
else:
print "Warning: Unknown setting {}: {}".format(k, v)
print("Warning: Unknown setting {}: {}".format(k, v))
ClientConnection.broadcast(
type="settings",