summaryrefslogtreecommitdiff
path: root/cheetah/Utils
diff options
context:
space:
mode:
authorR. Tyler Ballance <tyler@monkeypox.org>2009-11-08 15:22:10 -0800
committerR. Tyler Ballance <tyler@monkeypox.org>2009-11-16 00:04:04 -0800
commit0b8c21f8f3cc5f95f2184bf717b62f2888ed4935 (patch)
treef8450c987a3b178936b5d62a8820d1a803788c49 /cheetah/Utils
parenta23cfe7fc38af7f38a5d032592456152f635f995 (diff)
downloadpython-cheetah-0b8c21f8f3cc5f95f2184bf717b62f2888ed4935.tar.gz
Refactor raw print statements in accordance with 2to3
Removed prints in a couple places entirely, some of this code should likely use the `logging` module instead
Diffstat (limited to 'cheetah/Utils')
-rw-r--r--cheetah/Utils/memcache.py39
-rw-r--r--cheetah/Utils/statprof.py16
2 files changed, 26 insertions, 29 deletions
diff --git a/cheetah/Utils/memcache.py b/cheetah/Utils/memcache.py
index ee9678d..029f621 100644
--- a/cheetah/Utils/memcache.py
+++ b/cheetah/Utils/memcache.py
@@ -177,7 +177,6 @@ class Client:
for i in range(Client._SERVER_RETRIES):
server = self.buckets[serverhash % len(self.buckets)]
if server.connect():
- #print "(using server %s)" % server,
return server, key
serverhash = hash(str(serverhash) + str(i))
return None, None
@@ -555,10 +554,9 @@ def _doctest():
return doctest.testmod(memcache, globs=globs)
if __name__ == "__main__":
- print "Testing docstrings..."
+ print("Testing docstrings...")
_doctest()
- print "Running tests:"
- print
+ print("Running tests:")
#servers = ["127.0.0.1:11211", "127.0.0.1:11212"]
servers = ["127.0.0.1:11211"]
mc = Client(servers, debug=1)
@@ -568,14 +566,14 @@ if __name__ == "__main__":
return "%s (%s)" % (val, type(val))
return "%s" % val
def test_setget(key, val):
- print "Testing set/get {'%s': %s} ..." % (to_s(key), to_s(val)),
+ print("Testing set/get {'%s': %s} ..." % (to_s(key), to_s(val)))
mc.set(key, val)
newval = mc.get(key)
if newval == val:
- print "OK"
+ print("OK")
return 1
else:
- print "FAIL"
+ print("FAIL")
return 0
class FooStruct:
@@ -591,34 +589,33 @@ if __name__ == "__main__":
test_setget("a_string", "some random string")
test_setget("an_integer", 42)
if test_setget("long", long(1<<30)):
- print "Testing delete ...",
+ print("Testing delete ...")
if mc.delete("long"):
- print "OK"
+ print("OK")
else:
- print "FAIL"
- print "Testing get_multi ...",
- print mc.get_multi(["a_string", "an_integer"])
+ print("FAIL")
+ print("Testing get_multi ...")
+ print(mc.get_multi(["a_string", "an_integer"]))
- print "Testing get(unknown value) ...",
- print to_s(mc.get("unknown_value"))
+ print("Testing get(unknown value) ...")
+ print(to_s(mc.get("unknown_value")))
f = FooStruct()
test_setget("foostruct", f)
- print "Testing incr ...",
+ print("Testing incr ...")
x = mc.incr("an_integer", 1)
if x == 43:
- print "OK"
+ print("OK")
else:
- print "FAIL"
+ print("FAIL")
- print "Testing decr ...",
+ print("Testing decr ...")
x = mc.decr("an_integer", 1)
if x == 42:
- print "OK"
+ print("OK")
else:
- print "FAIL"
-
+ print("FAIL")
# vim: ts=4 sw=4 et :
diff --git a/cheetah/Utils/statprof.py b/cheetah/Utils/statprof.py
index 55638eb..d6d64d6 100644
--- a/cheetah/Utils/statprof.py
+++ b/cheetah/Utils/statprof.py
@@ -277,15 +277,15 @@ class CallStats(object):
self.cum_secs_per_call = None
def display(self):
- print '%6.2f %9.2f %9.2f %s' % (self.pcnt_time_in_proc,
+ print('%6.2f %9.2f %9.2f %s' % (self.pcnt_time_in_proc,
self.cum_secs_in_proc,
self.self_secs_in_proc,
- self.name)
+ self.name))
def display():
if state.sample_count == 0:
- print 'No samples recorded.'
+ print('No samples recorded.')
return
l = [CallStats(x) for x in call_data.itervalues()]
@@ -293,12 +293,12 @@ def display():
l.sort(reverse=True)
l = [x[2] for x in l]
- print '%5.5s %10.10s %7.7s %-8.8s' % ('% ', 'cumulative', 'self', '')
- print '%5.5s %9.9s %8.8s %-8.8s' % ("time", "seconds", "seconds", "name")
+ print('%5.5s %10.10s %7.7s %-8.8s' % ('% ', 'cumulative', 'self', ''))
+ print('%5.5s %9.9s %8.8s %-8.8s' % ("time", "seconds", "seconds", "name"))
for x in l:
x.display()
- print '---'
- print 'Sample count: %d' % state.sample_count
- print 'Total time: %f seconds' % state.accumulated_time
+ print('---')
+ print('Sample count: %d' % state.sample_count)
+ print('Total time: %f seconds' % state.accumulated_time)