<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.zugiart &#187; python</title>
	<atom:link href="http://www.zugiart.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zugiart.com</link>
	<description>Software Engineering, buddhism, and everything else in between.</description>
	<lastBuildDate>Mon, 09 Jan 2012 05:50:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Generic Python XML-RPC CLI Client (With apache extension support)</title>
		<link>http://www.zugiart.com/2011/10/generic-python-xml-rpc-cli-client-with-apache-extension-support/</link>
		<comments>http://www.zugiart.com/2011/10/generic-python-xml-rpc-cli-client-with-apache-extension-support/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 05:10:16 +0000</pubDate>
		<dc:creator>zen</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[xml-rpc]]></category>

		<guid isPermaLink="false">http://www.zugiart.com/?p=1757</guid>
		<description><![CDATA[This code snippet is a generic python xml-rpc client that supports custom extensions. This is tested with pytnon 2.6 &#8211; usage is as follow: Interactive mode # run the client like so: python client.py --url=http://serverUrl:port/path/to/serverPoint &#160; # in interactive mode, you see the CLI interface like so: &#91;timestamp&#93; http://serverUrl:port/path/to/serverPoint xmlrpc &#62;&#62; helloWorld&#40;&#34;hello zen&#34;&#41; hello zen [...]]]></description>
			<content:encoded><![CDATA[<p>This code snippet is a generic python xml-rpc client that supports custom extensions. This is tested with pytnon 2.6 &#8211; usage is as follow: </p>
<h3>Interactive mode</h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># run the client like so:</span>
python client.py <span style="color: #660033;">--url</span>=http:<span style="color: #000000; font-weight: bold;">//</span>serverUrl:port<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>serverPoint
&nbsp;
<span style="color: #666666; font-style: italic;"># in interactive mode, you see the CLI interface like so: </span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>timestamp<span style="color: #7a0874; font-weight: bold;">&#93;</span> http:<span style="color: #000000; font-weight: bold;">//</span>serverUrl:port<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>serverPoint
xmlrpc <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> helloWorld<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;hello zen&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
hello zen <span style="color: #666666; font-style: italic;">#&lt;- this is the response from the server</span></pre></div></div>

<h3>Oneliner mode</h3>
<p>You can invoke the client as a one-liner, by passing the xmlrpc function to be called using the &#8211;cmd option. Like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python client.py <span style="color: #660033;">--url</span>=http:<span style="color: #000000; font-weight: bold;">//</span>serverUrl:port<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>serverPoint <span style="color: #660033;">--cmd</span>=<span style="color: #ff0000;">'helloWorld(&quot;hello zen&quot;)'</span></pre></div></div>

<p>Which is quite powerful, because now we can include this as part of shell scripts that can invoke/leverage existing xml-rpc service. </p>
<h2>client.py script</h2>
<p>The <b>CustomXmlRpcExtensionTransport</b> is what allows xml-rpc extensions to be parsed properly via the client. Here, (limited) support for <a href="http://ws.apache.org/xmlrpc/types.html">Apache xml-rpc extension data types</a> is added. Specifically &#8211; ex:nil as None; ex:i2, ex:i4, ex:i8 as numbers/int. This approach does not override original xmlrpclib implementation, but rather extends it.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xmlrpclib</span> <span style="color: #ff7700;font-weight:bold;">import</span> Transport, ServerProxy
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">readline</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cmd</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">traceback</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">pprint</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> CustomXmlRpcExtensionTransport<span style="color: black;">&#40;</span>Transport<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    This Transport allows for the parser's dispatch object to be modified to cater for additional 
    extension tags. In case the client need to be extend to interoperate with other provider, 
    such as apache xml-rpc service points. 
    see also http://bugs.python.org/issue8792
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> getparser<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #dc143c;">parser</span>, unmarshaller = Transport.<span style="color: black;">getparser</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        dispatch = unmarshaller.<span style="color: black;">dispatch</span>.<span style="color: #dc143c;">copy</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        unmarshaller.<span style="color: black;">dispatch</span> = dispatch
        <span style="color: #808080; font-style: italic;"># Now we can add custom types</span>
        dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ex:nil&quot;</span><span style="color: black;">&#93;</span> = dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;nil&quot;</span><span style="color: black;">&#93;</span>
        dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ex:i2&quot;</span><span style="color: black;">&#93;</span>  = dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;int&quot;</span><span style="color: black;">&#93;</span>
        dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ex:i4&quot;</span><span style="color: black;">&#93;</span>  = dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;int&quot;</span><span style="color: black;">&#93;</span>
        dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ex:i8&quot;</span><span style="color: black;">&#93;</span>  = dispatch<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;int&quot;</span><span style="color: black;">&#93;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">parser</span>, unmarshaller                                                                                                                                                                                                                                                                                                                              
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> XmlRpcClientConsole<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>.<span style="color: black;">Cmd</span><span style="color: black;">&#41;</span>: 
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Generic xml rpc client console. Allows for seamlessly working with compatible xml-rpc server.
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, url<span style="color: black;">&#41;</span>:
        <span style="color: #dc143c;">cmd</span>.<span style="color: black;">Cmd</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">url</span> = url<span style="color: #66cc66;">;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">server</span> = ServerProxy<span style="color: black;">&#40;</span>url, transport=CustomXmlRpcExtensionTransport<span style="color: black;">&#40;</span>use_datetime=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">#verbose=True,)</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">pp</span> = <span style="color: #dc143c;">pprint</span>.<span style="color: black;">PrettyPrinter</span><span style="color: black;">&#40;</span>indent=<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">updatePrompt</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> updatePrompt<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">prompt</span> = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>[%s] %s<span style="color: #000099; font-weight: bold;">\n</span>xmlrpc &gt;&gt; &quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%Y.%m.%d %H:%M:%S&quot;</span><span style="color: black;">&#41;</span>,<span style="color: #008000;">self</span>.<span style="color: black;">url</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> default<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, line<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">try</span>:
            result=<span style="color: #008000;">None</span>
            <span style="color: #ff7700;font-weight:bold;">exec</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;result=self.server.%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>line<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">pp</span>.<span style="color: #dc143c;">pprint</span><span style="color: black;">&#40;</span>result<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># default formatter: pretty print the resultant data</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">Exception</span>, ex:
            <span style="color: #dc143c;">traceback</span>.<span style="color: black;">print_exc</span><span style="color: black;">&#40;</span>ex<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: #66cc66;">;</span> <span style="color: #008000;">self</span>.<span style="color: black;">updatePrompt</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> do_help<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,line<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-------------------------------------&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;GENERIC XML RPC CLIENT CONSOLE - HELP&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-------------------------------------&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Simply type in the function name on the xml-rpc service end, like you would&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;on any good ol' python program. For example, if the other side has a method&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;called helloWorld(strparam), you can invoke it like so:&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;... xmlrpc &gt;&gt; helloWorld('hello zen')&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;the client is therefore completely transparent and exposes the full capabilities&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;of the server end. have fun.&quot;</span> <span style="color: #808080; font-style: italic;"># -zen</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> 
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;&quot;Generic XML RPC Client console&quot;&quot;&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--url&quot;</span>, dest=<span style="color: #483d8b;">&quot;url&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;The XML RPC service URL to connect&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--cmd&quot;</span>, dest=<span style="color: #483d8b;">&quot;cmd&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;A one-off command to execute&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: black;">&#40;</span>options, args<span style="color: black;">&#41;</span> = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> options.<span style="color: black;">url</span> == <span style="color: #008000;">None</span> :
        <span style="color: #dc143c;">parser</span>.<span style="color: black;">print_help</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
    console = XmlRpcClientConsole<span style="color: black;">&#40;</span>options.<span style="color: black;">url</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> options.<span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span> :
        <span style="color: #808080; font-style: italic;"># run the cmd and bomb out</span>
        console.<span style="color: black;">default</span><span style="color: black;">&#40;</span>options.<span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;for help using the console, type 'help'&quot;</span>
        <span style="color: #808080; font-style: italic;"># enter into cmd loop for interactive session</span>
        console.<span style="color: black;">cmdloop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zugiart.com/2011/10/generic-python-xml-rpc-cli-client-with-apache-extension-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>zroundup, a demo</title>
		<link>http://www.zugiart.com/2009/09/zero-configuration-roundup/</link>
		<comments>http://www.zugiart.com/2009/09/zero-configuration-roundup/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 22:33:38 +0000</pubDate>
		<dc:creator>zen</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[roundup]]></category>

		<guid isPermaLink="false">http://www.zugiart.com/?p=525</guid>
		<description><![CDATA[Introducing, zero-configuration issue tracking system. Still under development :)]]></description>
			<content:encoded><![CDATA[<p>I would like to introduce a small project that I am working on atm &#8211; started this on Sunday, took me almost 4 hours to get it to this stage. I&#8217;ve just managed to capture it properly via <strong>recordMyDesktop</strong> and <strong>mencoder</strong>, before I can upload this to YouTube.</p>
<p><a href="http://pypi.python.org/pypi/roundup">Roundup</a>, as you may already know is a Python issue tracking system. <strong>zroundup</strong> stands for <strong>zero configuration roundup</strong> &#8211; I&#8217;m aiming to make an issue tracking system that you can just download and run. Preferrably I would also like to be able to put this into a thumbdrive and then carry it around with me &#8211; a portable issue tracking system, on a stick!</p>
<p>I actually thought that this sort of thing would be perfect for freelancers / contractors who are usually on the move and have a huge list of issues / tasks on multiple projects that need to be managed.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="383" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/UgHo9yMBFvs&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="383" src="http://www.youtube.com/v/UgHo9yMBFvs&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Note: Probably you&#8217;ll have to see this in full screen, I haven&#8217;t figure out how to take a screenshot of only the region within my desktop, and keep in mind that this is still a work in progress &#8211; when it&#8217;s finished, the use case would likely be:</p>
<ul>
<li>Download and install on a USB stick</li>
<li>You can run / stop the issue tracker from the USB stick</li>
<li>If you disconnect the USB stick the tracker will stop, but preserving all data</li>
<li>If you connect the USB stick on a windows machine, the tracker will run (automatically, if autoplay is enabled).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.zugiart.com/2009/09/zero-configuration-roundup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python docstring</title>
		<link>http://www.zugiart.com/2009/08/python-docstring/</link>
		<comments>http://www.zugiart.com/2009/08/python-docstring/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 00:49:21 +0000</pubDate>
		<dc:creator>zen</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.zugiart.com/2009/08/python-docstring/</guid>
		<description><![CDATA[A quick intro to python documentation string (docstrings) and means to obtain them programmatically. Snippets available - copy, paste and code away!]]></description>
			<content:encoded><![CDATA[<p>Python&#8217;s <em>docstring</em> are really the equivalent of Java&#8217;s <em>javadocs</em>. However, the neat thing about <em>docstring</em> is that it is actually a fully qualified Python object. Check out the example below.</p>
<h2>PyHelloWorld &#8211; DocString style</h2>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> TestClass:
   <span style="color: #483d8b;">&quot;&quot;&quot;
   Documentation for this test class...
   &quot;&quot;&quot;</span>
&nbsp;
   <span style="color: #ff7700;font-weight:bold;">def</span> helloWorld<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
      <span style="color: #483d8b;">&quot;&quot;&quot;
      HELLO WORLD DOCSTRING
      &quot;&quot;&quot;</span>
      func=<span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,<span style="color: #483d8b;">'helloWorld'</span><span style="color: black;">&#41;</span>
      docstr=func.__doc__ <span style="color: #808080; font-style: italic;">#&amp;lt;--- notice this?</span>
      <span style="color: #ff7700;font-weight:bold;">print</span> docstr
&nbsp;
<span style="color: #808080; font-style: italic;"># 'quickie' main block</span>
<span style="color: #dc143c;">test</span>=TestClass<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">test</span>.<span style="color: black;">helloWorld</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Running the example below should print: &#8220;HELLO WORLD DOCSTRING&#8221;.</p>
<p>Note: I&#8217;ve also added this to my <a href="/notes/python">python programming notes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zugiart.com/2009/08/python-docstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python XML-RPC</title>
		<link>http://www.zugiart.com/2009/08/python-xml-rpc/</link>
		<comments>http://www.zugiart.com/2009/08/python-xml-rpc/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 02:10:35 +0000</pubDate>
		<dc:creator>zen</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.zugiart.com/main/?p=398</guid>
		<description><![CDATA[XML-RPC in python, made easy. Copy paste and code away.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve added this snippets into my <a href="/main/notes/python">python notes</a>. Here they are for convenience.</p>
<h2>Dynamic Xml-Rpc server</h2>
<p>This server code will use python &#8220;reflection&#8221; to publish all methods whose name are prefixed with PREFIX. In this case, the prefix is xmlrpc_, so all methods within this server such as xmlrpc_hello, will get published. The code already uses options, so it can be easily started like so:</p>
<p>python server.py &#8211;host=$HOSTNAME &#8211;port=portNum</p>
<h3>Server skeleton code</h3>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">SimpleXMLRPCServer</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">SimpleXMLRPCServer</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> DynamicXMLRPCServer<span style="color: black;">&#40;</span><span style="color: #dc143c;">SimpleXMLRPCServer</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    An XMLRPC server that will register all function whose name are prefixed with PREFIX via xml-rpc
    Zen Sugiarto - 2011
    &quot;&quot;&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># this is the prefix used by this sever to decide whether a given method should be published over xml-rpc or not.</span>
    PREFIX=<span style="color: #483d8b;">&quot;xmlrpc_&quot;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># constructor</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, params<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">params</span>=params
        <span style="color: #008000;">self</span>.<span style="color: black;">host</span>=params<span style="color: black;">&#91;</span><span style="color: #483d8b;">'host'</span><span style="color: black;">&#93;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">port</span>=params<span style="color: black;">&#91;</span><span style="color: #483d8b;">'port'</span><span style="color: black;">&#93;</span>
        <span style="color: #dc143c;">SimpleXMLRPCServer</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">host</span>, <span style="color: #008000;">self</span>.<span style="color: black;">port</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #808080; font-style: italic;"># register all xmlrpc_ functions over xml-rpc</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> name <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">dir</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">if</span> name<span style="color: black;">&#91;</span>:<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>DynamicXMLRPCServer.<span style="color: black;">PREFIX</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> == DynamicXMLRPCServer.<span style="color: black;">PREFIX</span>:
                function=<span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,name<span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;registering function: %s as %s &quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span> name, name<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>DynamicXMLRPCServer.<span style="color: black;">PREFIX</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">register_function</span><span style="color: black;">&#40;</span>function, name<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>DynamicXMLRPCServer.<span style="color: black;">PREFIX</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># note: xmlrpc_ prefix is used by this server to mark that this function will be published</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> xmlrpc_hello<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,msg<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot;
        A simple hello function used for simple ping check. 
        @param msg - msg to pass to hello
        @return dictionary {&quot;hello&quot;:msg}
        &quot;&quot;&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;hello&quot;</span>:msg<span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> xmlrpc_describe<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot;
        Retrieves the description/documentation of available functions within this service.
        by the grace of python's .__doc__ object.
        @return dictionary of the following format
        { 
            'function_name' : 'documentation/description of that function '} 
        } 
        &quot;&quot;&quot;</span>
        metaDescription=<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> name <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">dir</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">if</span> name<span style="color: black;">&#91;</span>:<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>DynamicXMLRPCServer.<span style="color: black;">PREFIX</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> == DynamicXMLRPCServer.<span style="color: black;">PREFIX</span>:
                function=<span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,name<span style="color: black;">&#41;</span>
                metaDescription<span style="color: black;">&#91;</span>name<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>DynamicXMLRPCServer.<span style="color: black;">PREFIX</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>=function.__doc__
        <span style="color: #ff7700;font-weight:bold;">return</span> metaDescription<span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> xmlrpc_yourFunction<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot;
        Put in more function here!~
        &quot;&quot;&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;IMPLEMENT ME&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; main method &quot;&quot;&quot;</span>
    <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;&quot; 
        Template service object - please put your comment in here
        &quot;&quot;&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--host&quot;</span>, dest=<span style="color: #483d8b;">&quot;host&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;hostname to publish the service against&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--port&quot;</span>, dest=<span style="color: #483d8b;">&quot;port&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;port number to use&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: black;">&#40;</span>options, args<span style="color: black;">&#41;</span> = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span> options.<span style="color: black;">host</span> == <span style="color: #008000;">None</span> <span style="color: #ff7700;font-weight:bold;">or</span> options.<span style="color: black;">port</span> == <span style="color: #008000;">None</span> <span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;insufficient options provided. try --help&quot;</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    server = DynamicXMLRPCServer<span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'host'</span>:options.<span style="color: black;">host</span>,<span style="color: #483d8b;">'port'</span>:<span style="color: #008000;">int</span><span style="color: black;">&#40;</span>options.<span style="color: black;">port</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
    server.<span style="color: black;">serve_forever</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<h3>Dynamic XML-RPC Client</h3>
<p>This will invoke Hello world function via xml-rpc, this is as simple as it gets</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://localhost:8000/&quot;</span><span style="color: black;">&#41;</span>.<span style="color: black;">hello</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;zen&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>But this is even better: this is a client that will allow you to connect to any xml-rpc service (yes, even java ones in xml-rpc) and call any function as long as you know its signature.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">readline</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cmd</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">traceback</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">pprint</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> XmlRpcClientConsole<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>.<span style="color: black;">Cmd</span><span style="color: black;">&#41;</span>: 
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Generic xml rpc client console, works with any xml rpc service
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, url<span style="color: black;">&#41;</span>:
        <span style="color: #dc143c;">cmd</span>.<span style="color: black;">Cmd</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">url</span> = url<span style="color: #66cc66;">;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">server</span> = <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">pp</span> = <span style="color: #dc143c;">pprint</span>.<span style="color: black;">PrettyPrinter</span><span style="color: black;">&#40;</span>indent=<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">updatePrompt</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> updatePrompt<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">prompt</span> = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>[%s] %s<span style="color: #000099; font-weight: bold;">\n</span>xmlrpc &gt;&gt; &quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%Y.%m.%d %H:%M:%S&quot;</span><span style="color: black;">&#41;</span>,<span style="color: #008000;">self</span>.<span style="color: black;">url</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> default<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, line<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">try</span>:
            result=<span style="color: #008000;">None</span>
            <span style="color: #ff7700;font-weight:bold;">exec</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;result=self.server.%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>line<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">pp</span>.<span style="color: #dc143c;">pprint</span><span style="color: black;">&#40;</span>result<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># default formatter: pretty print the resultant data</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">Exception</span>, ex:
            <span style="color: #dc143c;">traceback</span>.<span style="color: black;">print_exc</span><span style="color: black;">&#40;</span>ex<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: #66cc66;">;</span> <span style="color: #008000;">self</span>.<span style="color: black;">updatePrompt</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> do_help<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,line<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-------------------------------------&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;GENERIC XML RPC CLIENT CONSOLE - HELP&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-------------------------------------&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Simply type in the function name on the xml-rpc service end, like you would&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;on any good ol' python program. For example, if the other side has a method&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;called helloWorld(strparam), you can invoke it like so:&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;... xmlrpc &gt;&gt; helloWorld('hello zen')&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;the client is therefore completely transparent and exposes the full capabilities&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;of the server end. have fun.&quot;</span> <span style="color: #808080; font-style: italic;"># -zen</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> 
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;&quot;Generic XML RPC Client console&quot;&quot;&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--url&quot;</span>, dest=<span style="color: #483d8b;">&quot;url&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;The XML RPC service URL to connect&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--cmd&quot;</span>, dest=<span style="color: #483d8b;">&quot;cmd&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;A one-off command to execute&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: black;">&#40;</span>options, args<span style="color: black;">&#41;</span> = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> options.<span style="color: black;">url</span> == <span style="color: #008000;">None</span> :
        <span style="color: #dc143c;">parser</span>.<span style="color: black;">print_help</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
    console = XmlRpcClientConsole<span style="color: black;">&#40;</span>options.<span style="color: black;">url</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> options.<span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span> :
        <span style="color: #808080; font-style: italic;"># run the cmd and bomb out</span>
        console.<span style="color: black;">default</span><span style="color: black;">&#40;</span>options.<span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;for help using the console, type 'help'&quot;</span>
        <span style="color: #808080; font-style: italic;"># enter into cmd loop for interactive session</span>
        console.<span style="color: black;">cmdloop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<h3>Example</h3>
<p>Starting the server:</p>
<pre>python server.py --host=localhost --port=6666 </pre>
<p>Starting the client in console mode:</p>
<pre>python client.py --url=http://localhost:6666 </pre>
<p>Within the console: </p>
<pre>
[2011.06.22 11:31:25] http://localhost:6666
xmlrpc >> hello("zen")
{ 'hello': 'zen'}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zugiart.com/2009/08/python-xml-rpc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

