<?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>Answer My Searches &#187; Python</title>
	<atom:link href="http://www.answermysearches.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.answermysearches.com</link>
	<description>Answers to everything I search for, every day</description>
	<lastBuildDate>Wed, 25 Aug 2010 10:00:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Round Up to the Nearest Quarter in Python</title>
		<link>http://www.answermysearches.com/how-to-round-up-to-the-nearest-quarter-in-python/2212/</link>
		<comments>http://www.answermysearches.com/how-to-round-up-to-the-nearest-quarter-in-python/2212/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 18:46:33 +0000</pubDate>
		<dc:creator>Greg Pinero (Primary Searcher)</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.answermysearches.com/?p=2212</guid>
		<description><![CDATA[This seems to work for me:
math.ceil(val*4)/4
]]></description>
			<content:encoded><![CDATA[<p>This seems to work for me:<br />
<code>math.ceil(val*4)/4</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.answermysearches.com/how-to-round-up-to-the-nearest-quarter-in-python/2212/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>XMLRPC Server Slow in Python &#8211; How to Fix</title>
		<link>http://www.answermysearches.com/xmlrpc-server-slow-in-python-how-to-fix/2140/</link>
		<comments>http://www.answermysearches.com/xmlrpc-server-slow-in-python-how-to-fix/2140/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:05:26 +0000</pubDate>
		<dc:creator>Greg Pinero (Primary Searcher)</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.answermysearches.com/?p=2140</guid>
		<description><![CDATA[Background:
I had set up a Python XML-RPC server on one machine.  When accessing the web services from other machines it would sometimes take up to 20 seconds to get a response.  The strange thing was that this only happened when accessing the web service from some machines but not others.
Problem and Solution:
It turns [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Background:</strong><br />
I had set up a Python XML-RPC server on one machine.  When accessing the web services from other machines it would sometimes take up to 20 seconds to get a response.  The strange thing was that this only happened when accessing the web service from some machines but not others.</p>
<p><strong>Problem and Solution:</strong><br />
It turns out that Python&#8217;s BaseHTTPRequestHandler was trying to log the fully qualified domain name of each request&#8217;s IP address.  Thus when we connected from machines that didn&#8217;t have a fully qualified domain name, it would take a long time to not find the FQDN.  <a href="http://bugs.python.org/issue6085">There is actually a bug for this.</a></p>
<p>Below is a simple fix that solved the problem for me (in Python 2.4).  This would probably work in future versions too.</p>
<p><strong>Assume this is your basic XMLRPC Server set up in Python:</strong></p>
<pre class="Python">
import SimpleXMLRPCServer

class FuncGroup:
    """Just hold the funcs to be used in web service"""
    def hi(self,val):
        return "hi there"

#create server and start it
server_address = ('localhost',8000) # (address, port)
server = SimpleXMLRPCServer.SimpleXMLRPCServer(server_address)
server.register_instance(FuncGroup()) #reg. functions/class instance
server.serve_forever()
</pre>
<p>&#8212;<br />
<strong>Here is the fixed version.  I added in an override for the trouble function:</strong><br />
&#8212;</p>
<pre class="Python">
import SimpleXMLRPCServer

#new code
import BaseHTTPServer
def not_insane_address_string(self):
    host, port = self.client_address[:2]
    return '%s (no getfqdn)' % host #used to call: socket.getfqdn(host)
BaseHTTPServer.BaseHTTPRequestHandler.address_string = \
    not_insane_address_string
#end new code

class FuncGroup:
    """Just hold the funcs to be used in web service"""
    def hi(self,val):
        return "hi there"

#create server and start it
server_address = ('localhost',8000) # (address, port)
server = SimpleXMLRPCServer.SimpleXMLRPCServer(server_address)
server.register_instance(FuncGroup()) #reg. functions/class instance
server.serve_forever()
</pre>
<p>&#8212;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.answermysearches.com/xmlrpc-server-slow-in-python-how-to-fix/2140/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making py2exe Work with Paramiko</title>
		<link>http://www.answermysearches.com/making-py2exe-work-with-paramiko/437/</link>
		<comments>http://www.answermysearches.com/making-py2exe-work-with-paramiko/437/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 00:49:42 +0000</pubDate>
		<dc:creator>Greg Pinero (Primary Searcher)</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.answermysearches.com/making-py2exe-work-with-paramiko/437/</guid>
		<description><![CDATA[When running py2exe with a script importing Paramiko I noticed this in the output:
The following modules appear to be missing ... paramiko ...
And then in the log file created when I run the exe I saw this:

Traceback (most recent call last):
 ...
ImportError: No module named paramiko

This has to do with py2exe not being able to [...]]]></description>
			<content:encoded><![CDATA[<p>When running py2exe with a script importing Paramiko I noticed this in the output:</p>
<p><code>The following modules appear to be missing ... paramiko ...</code></p>
<p>And then in the log file created when I run the exe I saw this:</p>
<pre>
Traceback (most recent call last):
 ...
ImportError: No module named paramiko
</pre>
<p>This has to do with py2exe not being able to handle egg files.  So what I did is pulled out the paramiko directory from the egg, and placed that in my site-packages directory, and then deleted the egg.  It works now though the setup function still tells me this:</p>
<p><code>The following modules appear to be missing<br />
['Crypto.PublicKey._fastmath', 'Crypto.Util.winrandom', '_ssl', 'r_hmac']</code></p>
<p>Luckily as far as I can tell, I don&#8217;t use those modules anywhere.</p>
<p>This guy had the same problem and  <a href="http://blog.vyperlogix.com/index.php/2008/08/29/py2exe-and-eggs-with-importerrors-fixed/"><br />
made some sort of programmatic solution</a> but it didn&#8217;t work for me.  Since when I ran the setup function, it didn&#8217;t throw an ImportError.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.answermysearches.com/making-py2exe-work-with-paramiko/437/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for Using the Paramiko SFTP Client</title>
		<link>http://www.answermysearches.com/tips-for-using-the-paramiko-sftp-client/435/</link>
		<comments>http://www.answermysearches.com/tips-for-using-the-paramiko-sftp-client/435/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 03:53:41 +0000</pubDate>
		<dc:creator>Greg Pinero (Primary Searcher)</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.answermysearches.com/tips-for-using-the-paramiko-sftp-client/435/</guid>
		<description><![CDATA[The Paramiko library seems to be the best way to do an SFTP client in Python.
Here is a good example of set up and usage.
However in connecting to a WS FTP server, I was still hitting some problems.
When I tried to do:
sftp.get(remotepath='setup.py',localpath='setup.py')
I got:
*** IOError: Folder not found: setup.py
and when I tried:
sftp.sftp.get(remotepath='./setup.py',localpath='setup.py')
I got:
*** IOError: [Errno 13] [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.lag.net/paramiko/">Paramiko</a> library seems to be the best way to do an SFTP client in Python.</p>
<p><a href="http://commandline.org.uk/python/sftp-python/">Here is a good example of set up and usage.</a></p>
<p>However in connecting to a WS FTP server, I was still hitting some problems.</p>
<p>When I tried to do:</p>
<p><code>sftp.get(remotepath='setup.py',localpath='setup.py')</code></p>
<p>I got:</p>
<p><code>*** IOError: Folder not found: setup.py</code></p>
<p>and when I tried:</p>
<p><code>sftp.sftp.get(remotepath='./setup.py',localpath='setup.py')</code></p>
<p>I got:</p>
<p><code>*** IOError: [Errno 13] Permission Denied!</code></p>
<p>It turns out the trick for working with WS FTP Server, you need to reference your files as current_directory/filename.  (no idea why!)</p>
<p>So the correct command is:</p>
<p><code>sftp.sftp.get(remotepath='greg/setup.py',localpath='setup.py')</code></p>
<p>where <code>greg</code> is my current working directory (yes, even though I&#8217;m already in that directory!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.answermysearches.com/tips-for-using-the-paramiko-sftp-client/435/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyCrypto &#8211; Fixing Setup script exited with error: The .NET Framework SDK needs to be instal led before building extensions for Python</title>
		<link>http://www.answermysearches.com/pycrypto-fixing-setup-script-exited-with-error-the-net-framework-sdk-needs-to-be-instal-led-before-building-extensions-for-python/434/</link>
		<comments>http://www.answermysearches.com/pycrypto-fixing-setup-script-exited-with-error-the-net-framework-sdk-needs-to-be-instal-led-before-building-extensions-for-python/434/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 17:30:00 +0000</pubDate>
		<dc:creator>Greg Pinero (Primary Searcher)</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.answermysearches.com/pycrypto-fixing-setup-script-exited-with-error-the-net-framework-sdk-needs-to-be-instal-led-before-building-extensions-for-python/434/</guid>
		<description><![CDATA[So here&#8217;s this horrible thing that happening to me when trying to install Paramiko  on Windows XP:

C:\Documents and Settings\gpinero>easy_install paramiko
Searching for paramiko
Best match: paramiko 1.7.4
Processing paramiko-1.7.4-py2.4.egg
paramiko 1.7.4 is already the active version in easy-install.pth

Using c:\python24\lib\site-packages\paramiko-1.7.4-py2.4.egg
Processing dependencies for paramiko
Searching for pycrypto>=1.9
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.amk.ca/python/code/crypto
Best match: pycrypto 2.0.1
Downloading http://www.amk.ca/files/python/crypto/pycrypto-2.0.1.tar.gz
Processing pycrypto-2.0.1.tar.gz
Running pycrypto-2.0.1\setup.py -q bdist_egg --dist-dir c:\docume~1\gpinero\loca
ls~1\temp\easy_install-gpdsc5\pycrypto-2.0.1\egg-dist-tmp-8dcze9
error: Setup [...]]]></description>
			<content:encoded><![CDATA[<p>So here&#8217;s this horrible thing that happening to me when trying to install <a href="http://www.lag.net/paramiko/">Paramiko </a> on Windows XP:</p>
<pre>
C:\Documents and Settings\gpinero>easy_install paramiko
Searching for paramiko
Best match: paramiko 1.7.4
Processing paramiko-1.7.4-py2.4.egg
paramiko 1.7.4 is already the active version in easy-install.pth

Using c:\python24\lib\site-packages\paramiko-1.7.4-py2.4.egg
Processing dependencies for paramiko
Searching for pycrypto>=1.9
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.amk.ca/python/code/crypto
Best match: pycrypto 2.0.1
Downloading http://www.amk.ca/files/python/crypto/pycrypto-2.0.1.tar.gz
Processing pycrypto-2.0.1.tar.gz
Running pycrypto-2.0.1\setup.py -q bdist_egg --dist-dir c:\docume~1\gpinero\loca
ls~1\temp\easy_install-gpdsc5\pycrypto-2.0.1\egg-dist-tmp-8dcze9
error: Setup script exited with error: The .NET Framework SDK needs to be instal
led before building extensions for Python.
</pre>
<p>I heard it&#8217;s a bear to install the .NET framework SDK, and supposedly the install still won&#8217;t work.  So what you do instead is <a href="http://www.voidspace.org.uk/python/modules.shtml#pycrypto">download this prebuilt pycrypto binary from here</a>, and install it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.answermysearches.com/pycrypto-fixing-setup-script-exited-with-error-the-net-framework-sdk-needs-to-be-instal-led-before-building-extensions-for-python/434/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
