Foundations of Python Network Programming
Chapter 17 ■ Ftp 323 Next, note that ntransfercmd() returns a tuple consisting of a data socket and an estimated size. Always be ...
Chapter 17 ■ Ftp 324 def main(): if len(sys.argv) != 5: print("usage:", sys.argv[0], " ") exit(2) host, username, localfile, r ...
Chapter 17 ■ Ftp 325 ftp = FTP('ftp.kernel.org') ftp.login() ftp.cwd('/pub/linux/kernel/v1.0') ftp.voidcmd("TYPE I") socket, siz ...
Chapter 17 ■ Ftp 326 One of the problems with the basic retrbinary() function is that, in order to use it easily, you will usual ...
Chapter 17 ■ Ftp 327 When you run this program, you will see output like this: $ python nlst.py 13 entries: INDEX README ephem_4 ...
Chapter 17 ■ Ftp 328 Notice that the file names are in a convenient format for automated processing—a bare list of file names—bu ...
Chapter 17 ■ Ftp 329 try: ftp.cwd(dirpath) except error_perm: return # ignore non-directores and ones we cannot enter print(dirp ...
Chapter 17 ■ Ftp 330 • rename(oldname, newname) works, essentially, like the Unix command mv: if both names are in the same d ...
331 Chapter 18 RPC Remote Procedure Call (RPC) systems let you call a function in another process or on a remote server using th ...
Chapter 18 ■ rpC 332 In both cases, however, you can see that unambiguous textual representation has become the order of the day ...
Chapter 18 ■ rpC 333 Fourth, each RPC mechanism needs to support some addressing scheme whereby you can reach out and connect to ...
Chapter 18 ■ rpC 334 import operator, math from xmlrpc.server import SimpleXMLRPCServer from functools import reduce def main(): ...
Chapter 18 ■ rpC 335 This server will need to be running before you can try any of the next three program listings, so bring up ...
Chapter 18 ■ rpC 336 For each method, you’ll attempt to retrieve its signature to learn what arguments and data types it accepts ...
Chapter 18 ■ rpC 337 Running the preceding code against the example server produces output from which you can learn several thin ...
Chapter 18 ■ rpC 338 Listing 18-4. Using XML-RPC Multicall !/usr/bin/env python3 Foundations of Python Network Programming, Thir ...
Chapter 18 ■ rpC 339 2 -4 0 The response to the preceding call looks like this: <?xml version='1.0'?> 0.0 8.0 ...
Chapter 18 ■ rpC 340 JSON-RPC is not supported in the Python Standard Library, so you will have to choose one of the several thi ...
Chapter 18 ■ rpC 341 from jsonrpclib import Server def main(): proxy = Server('http://localhost:7002') print(proxy.lengths((1,2, ...
Chapter 18 ■ rpC 342 Self-Documenting Data You have just seen that both XML-RPC and JSON-RPC appear to support a data structure ...
«
10
11
12
13
14
15
16
17
18
19
»
Free download pdf