<?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>bobpeers -&#62; blog &#187; python</title>
	<atom:link href="http://blog.bobpeers.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bobpeers.com</link>
	<description>Better late than never</description>
	<lastBuildDate>Fri, 24 Jun 2011 12:34:48 +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>Simple HTTP Server with Python</title>
		<link>http://blog.bobpeers.com/2009/09/24/simple-http-server-with-python/</link>
		<comments>http://blog.bobpeers.com/2009/09/24/simple-http-server-with-python/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 06:38:54 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2009/09/24/simple-http-server-with-python/</guid>
		<description><![CDATA[I came across this article on Linux Journal today about using Python to run a very simple HTTP server from any directory. I tested in on a standard install on Windows and it works perfectly. As one of the comments says there&#8217;s loads of great command line tips to be found at commandlinefu.com, including the [...]]]></description>
			<content:encoded><![CDATA[<p>I came across <a href="http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python">this article on Linux Journal</a> today about using Python to run a very simple HTTP server from any directory. I tested in on a standard install on Windows and it works perfectly.</p>
<p>As one of the comments says there&#8217;s loads of great command line tips to be found at <a href="http://www.commandlinefu.com/commands/browse/sort-by-votes">commandlinefu.com</a>, including the one <a href="http://www.commandlinefu.com/commands/view/71/serve-current-directory-tree-at-httphostname8000">I mention here</a>.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;count=none&amp;text=Simple%20HTTP%20Server%20with%20Python" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;count=none&amp;text=Simple%20HTTP%20Server%20with%20Python" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;linkname=Simple%20HTTP%20Server%20with%20Python" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2009%2F09%2F24%2Fsimple-http-server-with-python%2F&amp;title=Simple%20HTTP%20Server%20with%20Python" id="wpa2a_2"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2009/09/24/simple-http-server-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trying to Write a Shutdown Script</title>
		<link>http://blog.bobpeers.com/2008/10/21/trying-to-write-a-shutdown-script/</link>
		<comments>http://blog.bobpeers.com/2008/10/21/trying-to-write-a-shutdown-script/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 12:14:45 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shutdown]]></category>
		<category><![CDATA[upstart]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/10/21/trying-to-write-a-shutdown-script/</guid>
		<description><![CDATA[I&#8217;ve been trying to create a python script runs on shutdown or reboot. First I tried using the init system by placing the script into the /etc/init.d directory and then creating symlinks to the rc0 and rc6 directories so it runs shutdown and restart (all as root). # cp myscript.py /etc/init.d # ln -s /etc/init.d/myscript.py [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to create a python script runs on shutdown or reboot. First I tried using the <a href="http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/s1-boot-init-shutdown-process.html">init</a> system by placing the script into the /etc/init.d directory and then creating symlinks to the rc0 and rc6 directories so it runs shutdown and restart (all as root).</p>
<pre># cp myscript.py /etc/init.d
# ln -s /etc/init.d/myscript.py /etc/rc0.d/K10myscript.py
# ln -s /etc/init.d/myscript.py /etc/rc6.d/K10myscript.py
</pre>
<p>This doesn&#8217;t work, at least on Fedora, I think due to the fact that the init system checks for the <a href="http://www.redhat.com/magazine/008jun05/departments/tips_tricks/">presence of a file in /var/lock/subsys</a>. Essentially the system checks whether a service is running (the lock file exists) before deciding to run the script.</p>
<p>In this case I would have to add my script as a service using <a href="http://www.linux.com/feature/46892">chkconfig -add</a> that starts on boot and creates the lock file. This is fine but what if I just want to run a simple script and not a service.</p>
<p>Next I looked at <a href="http://upstart.ubuntu.com/">Upstart</a>, the replacement for init scripts developed by Ubuntu but now the default in Fedora 9. This is compatible with the old init system but much more flexible. Following <a href="http://www.linux.com/feature/125977">this great guide</a> I tried to implement this using Upstart. Here&#8217;s my script saved in the /etc/event.d/ directory.</p>
<pre># Run my script on shutdown, reboot and runme events
start on runlevel 0     # Shutdown
start on runlevel 6     # Reboot
start on runme          # testing event
script
exec "/home/username/network_usage.py"
end script
</pre>
<p>I tested the script by emitting the runme event.</p>
<pre># /sbin/initctl emit runme
runme
network-usage (start) waiting
network-usage (start) starting
network-usage (start) pre-start
network-usage (start) spawned, process 3673
network-usage (start) post-start, (main) process 3673
network-usage (start) running, process 3673
network-usage (stop) running
network-usage (stop) stopping
network-usage (stop) killed
network-usage (stop) post-stop
network-usage (stop) waiting
initctl: runme event failed
</pre>
<p>Basically the script fails. I tried to run a bash script that calls the python script but that also fails. Upstart seems really easy to use and it&#8217;s much easier to test since you can create fictional events but I&#8217;m frustrated by my inability to run a simple python script.</p>
<p>I realise that I could write a bash script instead of a python script and it will probably work, or I could put my script in .bash_logout but that would run on user logout and not only on shutdown and reboot.</p>
<p>If anyone has a solution I&#8217;d be happy to hear.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;count=none&amp;text=Trying%20to%20Write%20a%20Shutdown%20Script" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;count=none&amp;text=Trying%20to%20Write%20a%20Shutdown%20Script" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;linkname=Trying%20to%20Write%20a%20Shutdown%20Script" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F10%2F21%2Ftrying-to-write-a-shutdown-script%2F&amp;title=Trying%20to%20Write%20a%20Shutdown%20Script" id="wpa2a_4"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/10/21/trying-to-write-a-shutdown-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Remove DOS newlines from Python files</title>
		<link>http://blog.bobpeers.com/2008/09/17/remove-dos-newlines-from-python-files/</link>
		<comments>http://blog.bobpeers.com/2008/09/17/remove-dos-newlines-from-python-files/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 19:37:16 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[carriage return]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/09/17/remove-dos-newlines-from-python-files/</guid>
		<description><![CDATA[I&#8217;ve been working on a few python files in WIndows and then moving them to Linux but whenever I try to run them I get an error about &#8216;directory not found&#8217;. I soon discovered that the Windows carriage return messes up the files for Linux so we need to remove them all. If you open [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a few python files in WIndows and then moving them to Linux but whenever I try to run them I get an error about &#8216;directory not found&#8217;.</p>
<p>I soon discovered that the Windows carriage return messes up the files for Linux so we need to remove them all. If you open the offending file using vi you&#8217;ll see lots of ^M characters spread through the file. Fortunately these are pretty easy to remove using vi. Open the file in vi, press escape so we can enter a command, type this command press enter and save the file.</p>
<pre>%s/^M/ /g</pre>
<p>It&#8217;s very important that you create the ^M character by typing alt+v then press m while still holding down alt+v, do not paste straight from this page.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;count=none&amp;text=Remove%20DOS%20newlines%20from%20Python%20files" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;count=none&amp;text=Remove%20DOS%20newlines%20from%20Python%20files" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;linkname=Remove%20DOS%20newlines%20from%20Python%20files" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F09%2F17%2Fremove-dos-newlines-from-python-files%2F&amp;title=Remove%20DOS%20newlines%20from%20Python%20files" id="wpa2a_6"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/09/17/remove-dos-newlines-from-python-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring Wireless Channel Congestion</title>
		<link>http://blog.bobpeers.com/2008/06/16/monitoring-wireless-channel-congestion/</link>
		<comments>http://blog.bobpeers.com/2008/06/16/monitoring-wireless-channel-congestion/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 13:50:30 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[channel]]></category>
		<category><![CDATA[iwlist]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scan]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/06/16/monitoring-wireless-channel-congestion/</guid>
		<description><![CDATA[While playing around with my wireless connection it occurred to me that there&#8217;s no way to see which channels are the busiest in my area. I know the command shown below lists all the scan details including the channel number for each router, but to see the most heavily congested channels I have to search [...]]]></description>
			<content:encoded><![CDATA[<p>While playing around with my wireless connection it occurred to me that there&#8217;s no way to see which channels are the busiest in my area. I know the command shown below lists all the scan details including the channel number for each router, but to see the most heavily congested channels I have to search the list manually.</p>
<pre>$ /sbin/iwlist eth1 scan</pre>
<p>It occurred to me that a simple python script could do the job, so here it is.</p>
<pre>#! /usr/bin/python
# set to the number of channels available
MAX_CHANNEL=14
# enter your wireless device name
DEVICE="eth1"
import os
f=os.popen("/sbin/iwlist " + DEVICE + " scan")
str=f.read()
channel=range(1,MAX_CHANNEL+1,1)
for i in channel:
 if i&lt;10:
  ch="0" + `i`
 else:
  ch=`i`
 sChannel="(Channel " + `i` + ")"
 print "Channel " + ch + ":" + `str.count(sChannel)`
f.close()</pre>
<p>It simply runs the Linux command using <a href="http://docs.python.org/lib/os-newstreams.html">popen</a>, parses the output and counts the channels producing an output like this.</p>
<pre>Channel 01:3
Channel 02:2
Channel 03:2
Channel 04:0
Channel 05:0
Channel 06:2
Channel 07:1
Channel 08:0
Channel 09:1
Channel 10:0
Channel 11:0
Channel 12:0
Channel 13:4
Channel 14:0</pre>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;count=none&amp;text=Monitoring%20Wireless%20Channel%20Congestion" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;count=none&amp;text=Monitoring%20Wireless%20Channel%20Congestion" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;linkname=Monitoring%20Wireless%20Channel%20Congestion" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F06%2F16%2Fmonitoring-wireless-channel-congestion%2F&amp;title=Monitoring%20Wireless%20Channel%20Congestion" id="wpa2a_8"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/06/16/monitoring-wireless-channel-congestion/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Development tools on Windows vs Linux</title>
		<link>http://blog.bobpeers.com/2008/03/12/development-tools-on-windows-vs-linux/</link>
		<comments>http://blog.bobpeers.com/2008/03/12/development-tools-on-windows-vs-linux/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 21:33:30 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/03/12/development-tools-on-windows-vs-linux/</guid>
		<description><![CDATA[As far as desktop systems go, for email, internet and basic office functionality, there&#8217;s no denying that Windows rules the roost. I would argue that Linux is actually not difficult to set up and use, it&#8217;s just different and probably has a perception problem, but therein lies the problem. But from a developers point of [...]]]></description>
			<content:encoded><![CDATA[<p>As far as desktop systems go, for email, internet and basic office functionality, there&#8217;s no denying that Windows rules the roost. I would argue that Linux is actually not difficult to set up and use, it&#8217;s just different and probably has a perception problem, but therein lies the problem.</p>
<p>But from a developers point of view using Linux as the platform has many advantages over Windows. Try writing a simple &#8220;Hello world&#8221; program in C or C++ on a fresh Windows install an then compile and run it. You can&#8217;t.</p>
<p>Simply put, most Linux distributions come with compilers (<a href="http://gcc.gnu.org/" title="GCC, the GNU Compiler Collection">gcc</a> in this case) installed out of the box and many more are available with an &#8216;apt-get&#8217; or &#8216;yum install&#8217; command. You don&#8217;t even have to do this from the command line these days as most distributions have friendly graphical install programs that put anything Windows has to shame.</p>
<p>Want Python or <a href="http://www.perl.com/" title=" Perl.com ">Perl</a>, <a href="http://www.apache.org/" title="Apache Software Foundation Site">Apache</a> or <a href="http://www.mysql.com/" title="MySQL site">MySQL</a> again it&#8217;s a few clicks away along with hundreds (thousands?) of other tools. Plus once they&#8217;re installed the OS takes care of notifying you (and optionally installing) any updates so you&#8217;ll never be left with 3 year old, unpatched software on your computer.</p>
<p>The last time I checked my Windows install I had many applications that were way out of date but the effort required to check up and manually update each one individually was just too much effort.</p>
<p>On a related note I have been using <a href="http://www.eclipse.org/" title="Eclipse.org homepage">Eclipse</a> as my <a href="http://en.wikipedia.org/wiki/Integrated_development_environment" title="Wikipedia page on IDE">IDE</a> of choice, mainly because of it&#8217;s support of both Python and C++ using the <a href="http://pydev.sourceforge.net/" title="Python Development Environment">Pydev</a> and <a href="http://www.eclipse.org/cdt/" title="Eclipse C/C++ Development Tooling - CDT">CDT</a> modules. So I thought I&#8217;d give it a try on Windows.</p>
<p>After downloading and installing Python then <a href="http://www.rose-hulman.edu/Class/csse/resources/Eclipse/eclipse-python-configuration.htm" title="Pydev install instructions">installing the Pydev module</a>, getting Python to work was not too difficult. Next came C++ support, it involves installing MinGW following the <a href="http://www.mingw.org/download.shtml" title="MinGW download page">instructions on download page</a>, then configuring Eclipse using <a href="http://www.codeproject.com/KB/tips/CPP_Dev_eclipse_CDT.aspx" title="C++ Development using eclipse IDE– Starters guide">these instructions</a>.</p>
<p>If you&#8217;re very lucky it will all work first time, but don&#8217;t count on it. And god help you if you decide to update any packages at a later date.</p>
<p>Compared to all this the development tools on Linux are a breeze. Linux may or may not be ready for the desktop for the average user (if there is such a person) but when it comes to the power user or developer it&#8217;s already ahead in my books.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;count=none&amp;text=Development%20tools%20on%20Windows%20vs%20Linux" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;count=none&amp;text=Development%20tools%20on%20Windows%20vs%20Linux" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;linkname=Development%20tools%20on%20Windows%20vs%20Linux" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F12%2Fdevelopment-tools-on-windows-vs-linux%2F&amp;title=Development%20tools%20on%20Windows%20vs%20Linux" id="wpa2a_10"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/03/12/development-tools-on-windows-vs-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming for Performance or Simplicity</title>
		<link>http://blog.bobpeers.com/2008/03/11/programming-for-performance-or-simplicity/</link>
		<comments>http://blog.bobpeers.com/2008/03/11/programming-for-performance-or-simplicity/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 21:34:20 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/03/11/programming-for-performance-or-simplicity/</guid>
		<description><![CDATA[I was recently writing some code to be run from a command line that recursively walks through a network folder and all sub folders compiling a list of all the files, their last modified date and their size. Since writing VBScript is quick and dirty I tend to start with that and in most cases [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently writing some code to be run from a command line that recursively walks through a network folder and all sub folders compiling a list of all the files, their last modified date and their size.</p>
<p>Since writing <a href="http://msdn2.microsoft.com/en-us/library/t0aew7h6.aspx" title="Microsoft Developer Network - VBScript">VBScript</a> is quick and dirty I tend to start with that and in most cases it works just fine. However when speed really matter it&#8217;s just not up to the job.</p>
<p>The network directory contains about 35,000 files in 3,200 folders consuming 45.4GB of disk space. The script should simply gather the data required and write it to a flat text file (delimited with semi-colons). When I ran the VBScript it took 306 seconds (5 minutes and 6 seconds) to gather the data.</p>
<p>Not too bad but not fast enough. So I decided to write the same script both in <a href="http://www.python.org/" title="Python Programming Language -- Official Website">Python</a> and <a href="http://en.wikipedia.org/wiki/C%2B%2B" title="Wikipedia C++ entry">C++</a>. Python is a very high level scripting language, so nowhere near as fast as a complied language like C++, but I wanted to see how it compared to VBScript. Here&#8217;s the results for the 3 programs.</p>
<table>
<tr>
<th>Language</th>
<th>Files indexed</th>
<th>Time taken (seconds)</th>
<th>Files per Second</th>
</tr>
<tr>
<td>VBScript</td>
<td>34999</td>
<td>306</td>
<td>114.4</td>
</tr>
<tr>
<td>Python</td>
<td>35018</td>
<td>68.5</td>
<td>511.2</td>
</tr>
<tr>
<td>C++</td>
<td>35017</td>
<td>13.9</td>
<td>2519.2</td>
</tr>
</table>
<p>Of course, as expected, for real performance C++ outstrips the scripting languages by a mile but Python also fairs pretty well.</p>
<p>When I also consider how simple the code is and how long it took to develop I think Python is the clear winner unless every ounce of performance is vital. Developing real world programs in Python is extremely easy and the code is fast.</p>
<p>I use another short script in Python to parse <a href="http://www.apache.org/" title="Apache Software Foundation">Apache</a> log files and it amazes me how fast it runs. The current log is over 122,000 lines (27.1MB of data) long but the script parses the file and outputs the results to a text file in just over a second! Very impressive for an interpreted language.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;count=none&amp;text=Programming%20for%20Performance%20or%20Simplicity" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;count=none&amp;text=Programming%20for%20Performance%20or%20Simplicity" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;linkname=Programming%20for%20Performance%20or%20Simplicity" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F11%2Fprogramming-for-performance-or-simplicity%2F&amp;title=Programming%20for%20Performance%20or%20Simplicity" id="wpa2a_12"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/03/11/programming-for-performance-or-simplicity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

