<?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>Musings &#187; Python</title>
	<atom:link href="http://blog.fpmurphy.com/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.fpmurphy.com</link>
	<description>of an OS plumber</description>
	<lastBuildDate>Wed, 11 Jan 2012 19:14:13 +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>Programmatically Retrieve RPM Package Details</title>
		<link>http://blog.fpmurphy.com/2011/08/programmatically-retrieve-rpm-package-details.html</link>
		<comments>http://blog.fpmurphy.com/2011/08/programmatically-retrieve-rpm-package-details.html#comments</comments>
		<pubDate>Sun, 14 Aug 2011 19:18:12 +0000</pubDate>
		<dc:creator>fpmurphy</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[RPM]]></category>

		<guid isPermaLink="false">http://blog.fpmurphy.com/?p=474</guid>
		<description><![CDATA[This post shows you how to access various types of information in the RPM database and RPM package files using C and Python. ]]></description>
		<wfw:commentRss>http://blog.fpmurphy.com/2011/08/programmatically-retrieve-rpm-package-details.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IPython &#8211; A Configurable Interactive Python Shell</title>
		<link>http://blog.fpmurphy.com/2011/02/ipython.html</link>
		<comments>http://blog.fpmurphy.com/2011/02/ipython.html#comments</comments>
		<pubDate>Wed, 16 Feb 2011 05:38:59 +0000</pubDate>
		<dc:creator>fpmurphy</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[IPython]]></category>

		<guid isPermaLink="false">http://blog.fpmurphy.com/?p=415</guid>
		<description><![CDATA[IPython is an enhanced interactive shell for Python which is very popular within the scientific and research communities. This post is a brief introduction to some of the more useful features of the IPython shell. ]]></description>
		<wfw:commentRss>http://blog.fpmurphy.com/2011/02/ipython.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not your Grandfather&#8217;s dd Utility!</title>
		<link>http://blog.fpmurphy.com/2008/10/recent-article-on-red-hat-magazine-by.html</link>
		<comments>http://blog.fpmurphy.com/2008/10/recent-article-on-red-hat-magazine-by.html#comments</comments>
		<pubDate>Sat, 25 Oct 2008 16:34:00 +0000</pubDate>
		<dc:creator>fpmurphy</dc:creator>
				<category><![CDATA[dd]]></category>
		<category><![CDATA[Google Charts]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://blog.fpmurphy.com/2008/11/not-your-grandfathers-dd-utility.html</guid>
		<description><![CDATA[<p>A recent article in Red Hat Magazine by Noah Gift and Grig Gheorghiu called &#8220;This isn&#8217;t your grandpappy&#8217;d dd command demonstrated how to use Python, the dd utility and the Google Chart API to produce a bar chart showing throughput at different block sizes. However the output from the Python script was not the actual graph but a URL which you then had to paste into a Web browser to view the resulting chart.</p> <p>I though this script would be useful but did not want to have to cut and paste a URL into a Web browser so I decided to eliminate that step.</p> <p>This Python script is loosely based on their script but uses the Python urllib libraries to connect to Google Charts to generate a PNG image file which is subsequently displayed using pyGTK+ routines. #!/usr/bin/env python import sys import os import commands import re from optparse import OptionParser import urllib import urllib2 import pygtk pygtk.require('2.0') import gtk class DisplayGraph: def delete_event(self, widget, event, data=None): &#160;&#160;&#160;return False def destroy(self, widget, data=None): &#160;&#160;&#160;gtk.main_quit() def __init__(self): &#160;&#160;&#160;self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) &#160;&#160;&#160;self.window.connect("delete_event", self.delete_event) &#160;&#160;&#160;self.window.connect("destroy", self.destroy) &#160;&#160;&#160;self.window.set_border_width(10) &#160;&#160;&#160;self.window.set_position(gtk.WIN_POS_CENTER) &#160;&#160;&#160;self.window.set_title("Disk Throughput") &#160;&#160;&#160;pixbuf = gtk.gdk.pixbuf_new_from_file("/tmp/dd.png") &#160;&#160;&#160;os.remove("/tmp/dd.png") &#160;&#160;&#160;self.image = gtk.Image() &#160;&#160;&#160;self.image.set_from_pixbuf(pixbuf) &#160;&#160;&#160;self.image.show() &#160;&#160;&#160;self.window.add(self.image) &#160;&#160;&#160;self.window.show() def main(self): &#160;&#160;&#160;gtk.main() class GoogleChart: def __init__(self): &#160;&#160;&#160;self.gchart_url = "http://chart.apis.google.com/chart?" &#160;&#160;&#160;self.gchart_type = "cht=bvs" &#160;&#160;&#160;self.gchart_title = "&#38;chtt=" &#160;&#160;&#160;self.gchart_data = "&#38;chd=t:" &#160;&#160;&#160;self.gchart_labels = "&#38;chxl=0:&#124;" &#160;&#160;&#160;self.gchart_size = "&#38;chs=400x250" &#160;&#160;&#160;self.gchart_axis_labels = "&#38;chxt=x,y,x,y" &#160;&#160;&#160;self.gchart_axis_position = "&#38;chxp=2,50&#124;3,50" &#160;&#160;&#160;self.gchart_bar_settings = "&#38;chbh=30,15" def title(self,title): &#160;&#160;&#160;self.gchart_title = self.gchart_title + title def write(self, data, labels, max_t): &#160;&#160;&#160;&#160;self.gchart_data = self.gchart_data + data.rstrip(',') &#160;&#160;&#160;&#160;self.gchart_labels = self.gchart_labels \ &#160;&#160;&#160;&#160;&#160;&#160;+ labels + "2:&#124;Block%20Size&#124;3:&#124;Mb/s" &#160;&#160;&#160;&#160;self.gchart_axis_range = "&#38;chxr=1,0," + str(max_t+10.0) &#160;&#160;&#160;&#160;self.gchart_scaling = "&#38;chds=0," + str(max_t+10.0) &#160;&#160;&#160;&#160;self.gchart_url += self.gchart_type \ &#160;&#160;&#160;&#160;&#160;&#160;+ self.gchart_title + self.gchart_size &#160;&#160;&#160;&#160;self.gchart_url += self.gchart_bar_settings \ &#160;&#160;&#160;&#160;&#160;&#160;+ self.gchart_data + self.gchart_labels &#160;&#160;&#160;&#160;self.gchart_url += self.gchart_axis_labels \ &#160;&#160;&#160;&#160;&#160;&#160;+ self.gchart_axis_position &#160;&#160;&#160;&#160;self.gchart_url += self.gchart_axis_range \ &#160;&#160;&#160;&#160;&#160;&#160;+ self.gchart_scaling &#160;&#160;&#160;opener = urllib2.urlopen(self.gchart_url) &#160;&#160;&#160;if opener.headers['content-type'] != 'image/png': &#160;&#160;&#160;&#160;&#160;&#160;raise BadContentTypeException('Server responded' \ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'with a content-type of %s' \ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;% opener.headers['content-type']) &#160;&#160;&#160;open("/tmp/dd.png", 'wb').write(opener.read()) def get_disk_throughput(device, blocksize): &#160;&#160;&#160;blocksize = str(blocksize) + 'k' &#160;&#160;&#160;cmd = "dd if=/dev/zero of=%s bs=%s" % (device,blocksize) &#160;&#160;&#160;output = commands.getoutput(cmd) &#160;&#160;&#160;throughput = 0 &#160;&#160;&#160;unit = "" &#160;&#160;&#160;for line in output.split('n'): &#160;&#160;&#160;&#160;&#160;&#160;s = re.search(' copied,.*, (\S+) (\S+)$', line) &#160;&#160;&#160;&#160;&#160;&#160;if s: &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throughput = s.group(1) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;unit = s.group(2) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break &#160;&#160;&#160;return (throughput, unit) if __name__ == "__main__": &#160;&#160;&#160;usage = "Usage: %prog options" &#160;&#160;&#160;parser = OptionParser(usage=usage) &#160;&#160;&#160;parser.add_option("-d", "--device", dest="device", \ &#160;&#160;&#160;&#160;&#160;&#160;help="Device to use. Disk data will be overwritten!") &#160;&#160;&#160;(options, args) = parser.parse_args() &#160;&#160;&#160;device = options.device &#160;&#160;&#160;if not device: &#160;&#160;&#160;&#160;&#160;&#160;parser.print_help() &#160;&#160;&#160;&#160;&#160;&#160;sys.exit(1) ]]></description>
		<wfw:commentRss>http://blog.fpmurphy.com/2008/10/recent-article-on-red-hat-magazine-by.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert Date TimeZone in Apache Server Log</title>
		<link>http://blog.fpmurphy.com/2007/07/convert-date-timezone-in-apache-server-log.html</link>
		<comments>http://blog.fpmurphy.com/2007/07/convert-date-timezone-in-apache-server-log.html#comments</comments>
		<pubDate>Fri, 06 Jul 2007 00:39:42 +0000</pubDate>
		<dc:creator>fpmurphy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Apache logs]]></category>
		<category><![CDATA[Timezone]]></category>

		<guid isPermaLink="false">http://blog.fpmurphy.com/?p=433</guid>
		<description><![CDATA[This post demonstrates how to change date/time strings in an Apache web server log file from GMT/UTC to PST using the Python pytz module. ]]></description>
		<wfw:commentRss>http://blog.fpmurphy.com/2007/07/convert-date-timezone-in-apache-server-log.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

