Version 1 (modified by 9 years ago) ( diff ) | ,
---|
If you've ever used the xmlrpc utility tool from the xmlrpc-c project, then you'll recognize this as the equivalent except that it sends xmlrpc requests over scgi instead of http. It also follows the same command line argument syntax as xmlrpc.
For example:
~# ./xmlrpc2scgi.py -p 'scgi://localhost:33000' d.get_name s/1BEB405E5066392CDAE96EEF9F82F7D83C2343E9 Gotan Project - Lunatico (2006)
~# ./xmlrpc2scgi.py 'scgi://localhost:33000' d.get_name s/1BEB405E5066392CDAE96EEF9F82F7D83C2343E9 <?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param><value><string>Gotan Project - Lunatico (2006)</string></value></param> </params> </methodResponse>
So this can be a tool for testing that xmlrpc is setup and working as well as for scripting in bash or some other scripting language.
But if you're using python then you get something extra:
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import xmlrpc2scgi as xs >>> rtc = xs.RTorrentXMLRPCClient('scgi://localhost:33000') >>> infohash = rtc.download('completed')[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "xmlrpc2scgi.py", line 175, in __call__ return do_scgi_xmlrpc_request_py(self.url, self.methodname, args) File "xmlrpc2scgi.py", line 157, in do_scgi_xmlrpc_request_py return xmlrpclib.loads(xmlresp)[0][0] File "/usr/lib/python2.5/xmlrpclib.py", line 1132, in loads return u.close(), u.getmethodname() File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close raise Fault(**self._stack[0]) xmlrpclib.Fault: <Fault -506: "Method 'download' not defined"> >>> infohash = rtc.download_list('completed')[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "xmlrpc2scgi.py", line 175, in __call__ return do_scgi_xmlrpc_request_py(self.url, self.methodname, args) File "xmlrpc2scgi.py", line 157, in do_scgi_xmlrpc_request_py return xmlrpclib.loads(xmlresp)[0][0] File "/usr/lib/python2.5/xmlrpclib.py", line 1132, in loads return u.close(), u.getmethodname() File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close raise Fault(**self._stack[0]) xmlrpclib.Fault: <Fault -503: 'Could not find view.'> >>> infohash = rtc.download_list('complete')[0] >>> print rtc.d.get_name(infohash), 'is on host', rtc.system.hostname() Apoptygma Berzerk - 7 [2002 'digitally remastered'] is on host datastore
So scripting becomes much easier in python as well as error/exception control.
Download xmlrpc2scgi here: xmlrpc2scgi.py
Note:
See TracWiki
for help on using the wiki.