begin transition to print being a function

This commit is contained in:
Marcos Pinto 2008-07-18 06:14:15 +00:00
parent 4ac5d43d58
commit a218f0e6a2
6 changed files with 46 additions and 50 deletions

View File

@ -541,10 +541,10 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
response = self._marshaled_dispatch(request_text)
print 'Content-Type: text/xml'
print 'Content-Length: %d' % len(response)
print
sys.stdout.write(response)
print('Content-Type: text/xml')
print('Content-Length: %d' % len(response))
print(
sys.stdout.write(response))
def handle_get(self):
"""Handle a single HTTP GET request.
@ -563,11 +563,11 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
'message' : message,
'explain' : explain
}
print 'Status: %d %s' % (code, message)
print 'Content-Type: text/html'
print 'Content-Length: %d' % len(response)
print
sys.stdout.write(response)
print('Status: %d %s' % (code, message))
print('Content-Type: text/html')
print('Content-Length: %d' % len(response))
print(
sys.stdout.write(response))
def handle_request(self, request_text = None):
"""Handle a single XML-RPC request passed through a CGI post method.
@ -588,7 +588,7 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
self.handle_xmlrpc(request_text)
if __name__ == '__main__':
print 'Running XML-RPC server on port 8000'
print('Running XML-RPC server on port 8000')
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')

View File

@ -62,10 +62,10 @@ def load_05(state_05_file, new_torrent_dir,all_paused):
state5 = PickleUpgrader(open(state_05_file)).load()
for torrent in state5.torrents:
#print [x for x in dir(torrent) if not x.startswith("_")]
print "file:%s, save_dir:%s, compact:%s, paused:%s " % (torrent.filename,torrent.save_dir,torrent.compact,torrent.user_paused)
print("file:%s, save_dir:%s, compact:%s, paused:%s " % (torrent.filename,torrent.save_dir,torrent.compact,torrent.user_paused))
new_file = os.path.join(new_torrent_dir,os.path.basename(torrent.filename))
print "copy" ,torrent.filename , new_file
print("copy" , torrent.filename , new_file)
shutil.copyfile(torrent.filename , new_file)
sclient.add_torrent_file([torrent.filename],[{

View File

@ -25,8 +25,8 @@ if False: #aclient non-core
except:
continue
print "\n'''%s(%s): '''\n" %(method_name, ", ".join(params))
print "%s" % pydoc.getdoc(func)
print("\n'''%s(%s): '''\n" %(method_name, ", ".join(params)))
print("%s" % pydoc.getdoc(func))
if True: #baseclient/core
methods = sorted([m for m in dir(Core) if m.startswith("export")]
@ -47,8 +47,8 @@ if True: #baseclient/core
and not method_name in ['add_torrent_file_binary']):
params = ["[callback]"] + params
print "\n'''%s(%s): '''\n" %(method_name, ", ".join(params))
print "%s" % pydoc.getdoc(func)
print("\n'''%s(%s): '''\n" %(method_name, ", ".join(params)))
print("%s" % pydoc.getdoc(func))
if False: #plugin-manager
import WebUi
@ -58,9 +58,5 @@ if False: #plugin-manager
func = getattr(PluginManager, m)
method_name = m
params = inspect.getargspec(func)[0][1:]
print "\n'''%s(%s): '''\n" %(method_name, ", ".join(params))
print "%s" % pydoc.getdoc(func)
print("\n'''%s(%s): '''\n" %(method_name, ", ".join(params)))
print("%s" % pydoc.getdoc(func))

View File

@ -317,56 +317,56 @@ aclient = AClient()
#------------------------------------------------------------------------------
def test_introspection():
print "*start introspection test*"
print("*start introspection test*")
sclient.set_core_uri()
print "list_methods", sclient.list_methods()
print "sig of block_ip_range", sclient.methodSignature('block_ip_range')
print "doc of block_ip_range", sclient.methodHelp('block_ip_range')
print("list_methods", sclient.list_methods())
print("sig of block_ip_range", sclient.methodSignature('block_ip_range'))
print("doc of block_ip_range", sclient.methodHelp('block_ip_range'))
def test_sync():
print "*start sync test*"
print("*start sync test*")
sclient.set_core_uri()
#get list of torrents and display the 1st.
torrent_ids = sclient.get_session_state()
print "session_state():", torrent_ids
print ("get_torrent_status(%s):" % torrent_ids[0],
print("session_state():", torrent_ids)
print("get_torrent_status(%s):" % torrent_ids[0],
sclient.get_torrent_status(torrent_ids[0], []))
sclient.pause_torrent(torrent_ids)
print "paused:", [
print("paused:", [
sclient.get_torrent_status(id, ['paused'])['paused']
for id in torrent_ids]
for id in torrent_ids])
sclient.resume_torrent(torrent_ids)
print "resumed:", [
print("resumed:", [
sclient.get_torrent_status(id, ['paused'])['paused']
for id in torrent_ids]
for id in torrent_ids])
def test_async():
print "*start async test*"
print("*start async test*")
torrent_ids = []
#callbacks:
def cb_session_state(temp_torrent_list):
print "session_state:" , temp_torrent_list
print("session_state:" , temp_torrent_list)
torrent_ids.extend(temp_torrent_list)
def cb_torrent_status_full(status):
print "\ntorrent_status_full=", status
print("\ntorrent_status_full=", status)
def cb_torrent_status_paused(torrent_state):
print "(paused=%s)," % torrent_state['paused'],
print("paused=%s" % torrent_state['paused'])
#/callbacks
aclient.set_core_uri()
aclient.get_session_state(cb_session_state)
print "force_call 1"
print("force_call 1")
aclient.force_call(block=True)
print "end force_call 1:", len(torrent_ids)
print("end force_call 1:", len(torrent_ids))
#has_callback+multicall
@ -377,13 +377,13 @@ def test_async():
aclient.get_torrent_status(cb_torrent_status_full, torrent_ids[0], [])
print "force_call 2"
print("force_call 2")
aclient.force_call(block=True)
print "end force-call 2"
print("end force-call 2")
print "resume:"
print("resume:")
aclient.resume_torrent(torrent_ids)
for id in torrent_ids:
aclient.get_torrent_status(cb_torrent_status_paused, id , ['paused'])

View File

@ -1334,7 +1334,7 @@ class Transport:
if not response:
break
if self.verbose:
print "body:", repr(response)
print("body: %s" % repr(response))
p.feed(response)
file.close()
@ -1474,18 +1474,18 @@ if __name__ == "__main__":
# server = ServerProxy("http://localhost:8000") # local server
server = ServerProxy("http://time.xmlrpc.com/RPC2")
print server
print(server)
try:
print server.currentTime.getCurrentTime()
print(server.currentTime.getCurrentTime())
except Error, v:
print "ERROR", v
print("ERROR", v)
multi = MultiCall(server)
multi.currentTime.getCurrentTime()
multi.currentTime.getCurrentTime()
try:
for response in multi():
print response
print(response)
except Error, v:
print "ERROR", v
print("ERROR", v)

View File

@ -215,13 +215,13 @@ class build_trans(cmd.Command):
if not os.path.exists(dest_path):
os.makedirs(dest_path)
if not os.path.exists(dest):
print 'Compiling %s' % src
print('Compiling %s' % src)
msgfmt.make(src, dest)
else:
src_mtime = os.stat(src)[8]
dest_mtime = os.stat(dest)[8]
if src_mtime > dest_mtime:
print 'Compiling %s' % src
print('Compiling %s' % src)
msgfmt.make(src, dest)
class build(_build):