<?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>Matt Thiessen &#187; Python</title>
	<atom:link href="http://matt.thiessen.us/category/coding/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt.thiessen.us</link>
	<description>Learning to make the hard things easy</description>
	<lastBuildDate>Thu, 09 Feb 2012 03:45:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>USPS Web Tools</title>
		<link>http://matt.thiessen.us/2009/03/usps-web-tools/</link>
		<comments>http://matt.thiessen.us/2009/03/usps-web-tools/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 22:06:11 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Family]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Z350]]></category>
		<category><![CDATA[shipping]]></category>

		<guid isPermaLink="false">http://matt.thiessen.us/?p=211</guid>
		<description><![CDATA[I was trying to add the USPS API into osCommerce. I received the following error when adding this shipping module: RateV3 is not a valid API name for this protocol This is because when you create an account for the Web Tools at USPS you only have access to their test server. The USPS test [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to add the <a href="http://www.usps.com/webtools/" target="_blank">USPS API</a> into <a href="http://www.oscommerce.com/" target="_blank">osCommerce</a>.  I received the following error when adding this <a href="http://www.oscommerce.com/community/contributions,487">shipping module</a>:</p>
<p><strong style="color:red">RateV3 is not a valid API name for this protocol</strong></p>
<p>This is because when you create an account for the Web Tools at USPS you only have access to their test server.  The USPS test server can only use RateV2, so test using this code below, then request to be switched to use the production server.  Then you can use RateV3 on the production server and the USPS module for osCommerce will work.</p>
<pre class="wp-code-highlight prettyprint">&lt;?php

$request1 = &lt;&lt;&lt; XMLREQUEST
&lt;RateV2Request USERID=&quot;xxxxxxxxxxxxx&quot;&gt;
&lt;Package ID=&quot;0&quot;&gt;
&lt;Service&gt;PRIORITY&lt;/Service&gt;
&lt;ZipOrigination&gt;10022&lt;/ZipOrigination&gt;
&lt;ZipDestination&gt;20008&lt;/ZipDestination&gt;
&lt;Pounds&gt;10&lt;/Pounds&gt;
&lt;Ounces&gt;5&lt;/Ounces&gt;
&lt;Container&gt;Flat Rate Box&lt;/Container&gt;
&lt;Size&gt;REGULAR&lt;/Size&gt;
&lt;/Package&gt;
&lt;/RateV2Request&gt;
XMLREQUEST;

$request = &quot;http://testing.shippingapis.com/ShippingAPITest.dll?API=RateV2&amp;XML=&quot; . rawurlencode($request1);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SLL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);
curl_close($ch);

echo($response);

?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://matt.thiessen.us/2009/03/usps-web-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Python to Save an FTP Directory List to File</title>
		<link>http://matt.thiessen.us/2009/03/use-python-to-save-an-ftp-directory-list-to-file/</link>
		<comments>http://matt.thiessen.us/2009/03/use-python-to-save-an-ftp-directory-list-to-file/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 22:05:26 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://matt.thiessen.us/?p=201</guid>
		<description><![CDATA[Written for Python 2.6 #!/usr/bin/python import ftplib ftp = ftplib.FTP(&#34;ftp.server.com&#34;) ftp.login(&#34;username&#34;, &#34;password&#34;) ftp.cwd(&#34;path/path&#34;) data = [] ftp.dir(data.append) ftp.quit() outputFile = open('dirList.txt','wb') for line in data: outputFile.write(line + &#34;\n&#34;) outputFile.close()]]></description>
			<content:encoded><![CDATA[<p>Written for <a class="zem_slink" title="Python (programming language)" rel="homepage" href="http://www.python.org/">Python</a> 2.6</p>
<pre class="wp-code-highlight prettyprint">#!/usr/bin/python

import ftplib

ftp = ftplib.FTP(&quot;ftp.server.com&quot;)
ftp.login(&quot;username&quot;, &quot;password&quot;)
ftp.cwd(&quot;path/path&quot;)

data = []

ftp.dir(data.append)

ftp.quit()

outputFile = open('dirList.txt','wb')

for line in data:
    outputFile.write(line + &quot;\n&quot;)

outputFile.close()</pre>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/c80a8ae4-6a5c-43bc-94a0-c5c01e31ed34/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=c80a8ae4-6a5c-43bc-94a0-c5c01e31ed34" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://matt.thiessen.us/2009/03/use-python-to-save-an-ftp-directory-list-to-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Python to replace spaces with underscores in filenames.</title>
		<link>http://matt.thiessen.us/2009/02/using-python-to-replace-spaces-with-underscore-in-filenames/</link>
		<comments>http://matt.thiessen.us/2009/02/using-python-to-replace-spaces-with-underscore-in-filenames/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 05:25:31 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://matt.thiessen.us/?p=179</guid>
		<description><![CDATA[Python can be used on Window, Linux and Mac. It just a simple install. download code #!/usr/bin/python import string import os import re # task: # loop thur input directory # look for .pdf # replace space with underscore # rename/move to output directory inputDir = &#34;./&#34; # Current directory outputDir = &#34;./new_location&#34; for filename [...]]]></description>
			<content:encoded><![CDATA[<p>Python can be used on Window, Linux and Mac.  It just a simple <a href="http://www.python.org/download/">install</a>.</p>
<p><a href="http://matt.thiessen.us/wp-content/uploads/2009/02/rename_move_pdfstar.gz">download code</a></p>
<pre class="wp-code-highlight prettyprint">#!/usr/bin/python

import string
import os
import re

# task:
# loop thur input directory
# look for .pdf
# replace space with underscore
# rename/move to output directory

inputDir = &quot;./&quot; # Current directory
outputDir = &quot;./new_location&quot;

for filename in os.listdir(inputDir):
    if filename[-4:] == &quot;.pdf&quot;:
        tempName = filename
        tempName = tempName.replace(' ', '_')
        os.rename(inputDir + &quot;/&quot; + filename, outputDir + &quot;/&quot; + tempName)</pre>
]]></content:encoded>
			<wfw:commentRss>http://matt.thiessen.us/2009/02/using-python-to-replace-spaces-with-underscore-in-filenames/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

