<?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>Fubaredness Is Contagious &#187; python</title>
	<atom:link href="http://somic.org/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://somic.org</link>
	<description>Dmitriy Samovskiy's Blog</description>
	<lastBuildDate>Wed, 01 Sep 2010 07:55:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Extending EC2 API &#8211; ec2-describe-ipaddress-ranges</title>
		<link>http://somic.org/2010/09/01/extending-ec2-api-ec2-describe-ipaddress-ranges/</link>
		<comments>http://somic.org/2010/09/01/extending-ec2-api-ec2-describe-ipaddress-ranges/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 07:55:05 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://somic.org/?p=1669</guid>
		<description><![CDATA[Do you remember how we used to programmatically consume services on the web before proliferation of APIs? That&#8217;s right &#8211; scraping! And do you know what prevents us from using this technique now, when some piece of data you need for your application, is not available via API? That&#8217;s right &#8211; absolutely nothing!
I recently came [...]]]></description>
			<content:encoded><![CDATA[<p>Do you remember how we used to programmatically consume services on the web before proliferation of APIs? That&#8217;s right &#8211; scraping! And do you know what prevents us from using this technique now, when some piece of data you need for your application, is not available via API? That&#8217;s right &#8211; absolutely nothing!</p>
<p>I recently came across something that was not available via EC2 API &#8211; lists of IP address ranges for each EC2 region. AWS team maintain such lists in their forums &#8211; currently at <a href="http://developer.amazonwebservices.com/connect/ann.jspa?annID=735">http://developer.amazonwebservices.com/connect/ann.jspa?annID=735</a> (I say &#8220;currently&#8221; because annID has already changed at least once). I <a href="http://twitter.com/somic/status/21921693410">asked</a> for API, but in the meantime since I needed this now, I wrote a simple python script to scrape and parse the data &#8211; <a href="http://gist.github.com/559397">http://gist.github.com/559397</a> or embedded below. Enjoy! By the way, who would have thought that one would need to resort to scraping AWS, the very pioneers of infrastructure APIs, to get this simple bit of information?</p>
<style>
pre { font-size:12px; }
</style>
<p><script src="http://gist.github.com/559397.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2010/09/01/extending-ec2-api-ec2-describe-ipaddress-ranges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parallelize Your EC2 API Calls with Python, Boto and Threading</title>
		<link>http://somic.org/2010/08/03/parallelize-your-ec2-api-calls-with-python-boto-and-threading/</link>
		<comments>http://somic.org/2010/08/03/parallelize-your-ec2-api-calls-with-python-boto-and-threading/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 08:06:43 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[boto]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://somic.org/?p=1492</guid>
		<description><![CDATA[I started a small new project on Github &#8211; http://github.com/somic/ec2-multiregion. It includes several small tools that facilitate EC2 API operations that involve multiple regions at the same time.
If I were to query each endpoint one after another, I quickly discovered it would take too long. Therefore, I created a small helper class called BotoWorkerPool (in [...]]]></description>
			<content:encoded><![CDATA[<p>I started a small new project on Github &#8211; <a href="http://github.com/somic/ec2-multiregion">http://github.com/somic/ec2-multiregion</a>. It includes several small tools that facilitate EC2 API operations that involve multiple regions at the same time.</p>
<p>If I were to query each endpoint one after another, I quickly discovered it would take too long. Therefore, I created a small helper class called BotoWorkerPool (in lib/boto_worker_pool.py), which wraps Python&#8217;s standard <a href="http://docs.python.org/library/threading.html">threading</a> module around calls to <a href="http://github.com/boto/boto">boto</a> &#8211; this helps achieve some amount of parallelism without introducing significant complexity of dealing with and sharing data among multiple processes. This also allows to potentially migrate to <a href="http://pypi.python.org/pypi/processing">processing</a> or <a href="http://docs.python.org/dev/library/multiprocessing.html">multiprocessing</a> libraries in the future, which offer threading-like interfaces for a multi-process model.</p>
<p>There are 2 tools at the moment.</p>
<p><strong>onesnapshot.py</strong> creates new snapshots for all volumes that already have one snapshot marked with &#8220;__onesnapshot__&#8221; token. The rationale for this tool came in part from the following statement on <a href="http://aws.amazon.com/ebs/">AWS main page for EBS</a> about durability:</p>
<blockquote><p>The durability of your volume depends both on the size of your volume  and the percentage of the data that has changed since your last  snapshot.</p></blockquote>
<p><strong>imageequiv.py</strong> takes AMI ID, kernel ID or ramdisk ID and finds equivalent IDs in all regions, based on matching name or manifest file location. This tool is a response to the following <a href="http://twitter.com/somic/status/13735105239">tweet</a> of mine:</p>
<blockquote><p><span><span><span>wanted &#8211; equivalence lists for kernel and ramdisk images (aki-, ari-) across all ec2 regions</span></span></span></p></blockquote>
<p><span><span><span>Hope these are useful to someone.<br />
</span></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2010/08/03/parallelize-your-ec2-api-calls-with-python-boto-and-threading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I Sometimes Prefer Shell To Ruby or Python</title>
		<link>http://somic.org/2009/06/11/why-i-sometimes-prefer-shell-to-ruby-or-python/</link>
		<comments>http://somic.org/2009/06/11/why-i-sometimes-prefer-shell-to-ruby-or-python/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 16:38:02 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software engineering]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://somic.org/?p=620</guid>
		<description><![CDATA[Shell was among the first things I got familiar with when I was introduced to Linux. It&#8217;s not a typical programming language, primarily due to lack of easy-to-use high-level data structures such as hashes and arrays (anticipating your objection to this &#8211; note I said &#8220;easy-to-use&#8221;). This may explain why I often get funny looks [...]]]></description>
			<content:encoded><![CDATA[<p>Shell was among the first things I got familiar with when I was introduced to Linux. It&#8217;s not a typical programming language, primarily due to lack of easy-to-use high-level data structures such as hashes and arrays (anticipating your objection to this &#8211; note I said &#8220;easy-to-use&#8221;). This may explain why I often get funny looks from folks when I mention that I use shell quite a bit, often in quite non-trivial systems.</p>
<p>And here are my reasons.</p>
<p><strong>Memory Management</strong></p>
<p>Shell scripts are excellent in managing their memory and one has to try real hard to cause a shell script to leak memory. This makes shell a very convenient tool for long running processes, supervisors in multiple-workers models, daemons and so on. There is an easy explanation for this. In shell, there are only a handful of built-in primitives &#8211; everything else is an external command, which gets started and then finishes before giving control back to your script. If there is a memory leak in that command, it won&#8217;t damage your calling script and will usually be insignificant because it will return quickly.</p>
<p><strong>No Exceptions</strong></p>
<p>This is a double edged sword, and you need to be careful how you exploit this &#8220;weakness.&#8221; This feature allows me to write compact code which is easy to understand without enclosing every single command in &#8220;try&#8230; except&#8221;. For naysayers, I would like to point out that a strict mode exists, where every error is treated as fatal and causes the script to exit (<em>set -e</em>).</p>
<p>In general, not all unforeseen error conditions warrant a crash, like you get in Python or Ruby when an unhandled exception gets propagated all the way to the top. If a problem is transient, it may be better to ignore it temporarily.</p>
<p>To assure a Ruby or Python script doesn&#8217;t crash on some unforeseen transient problem, many people often end up enclosing their entire program in a wildcard try&#8230; except block to catch any exception &#8211; but to me this approach is dangerous, even though I sometimes end up using it myself.</p>
<p>If you are writing a daemon process to perform some action in a loop, shell is often by far the most stable alternative.</p>
<p><strong>When Not To Use Shell</strong></p>
<p>My personal rule of thumb is don&#8217;t use shell when you expect to need high-level data structures like hashes or arrays beyond what <em>for</em> loop can give you, or when you can see potential for code reuse following <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">OOP</a> patterns like inheritance, or when your program needs to participate in some orchestration schemes that go beyond creating and removing files on the filesystem.</p>
<p><strong>Conclusion</strong></p>
<p>I wouldn&#8217;t overlook shell if I were you.</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2009/06/11/why-i-sometimes-prefer-shell-to-ruby-or-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Graphite RabbitMQ Integration</title>
		<link>http://somic.org/2009/05/21/graphite-rabbitmq-integration/</link>
		<comments>http://somic.org/2009/05/21/graphite-rabbitmq-integration/#comments</comments>
		<pubDate>Thu, 21 May 2009 14:31:49 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[rabbitmq]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[data series]]></category>
		<category><![CDATA[graphite]]></category>
		<category><![CDATA[visualizatioin]]></category>
		<category><![CDATA[webops]]></category>

		<guid isPermaLink="false">http://somic.org/?p=571</guid>
		<description><![CDATA[I started a new project on github &#8211; http://github.com/somic/graphite-rabbitmq. It currently includes a couple of tools written in Python which facilitate sending data to Graphite via RabbitMQ instead of connecting directly to the service using TCP.
Graphite is a flexible and powerful tool to build charts. It&#8217;s also a data series analytics framework. It was developed [...]]]></description>
			<content:encoded><![CDATA[<p>I started a new project on github &#8211; <a href="http://github.com/somic/graphite-rabbitmq">http://github.com/somic/graphite-rabbitmq</a>. It currently includes a couple of tools written in Python which facilitate sending data to Graphite via <a href="/category/rabbitmq">RabbitMQ</a> instead of connecting directly to the service using TCP.</p>
<div class="wp-caption alignnone" style="width: 402px"><img title="Graphite CLI Screenshot" src="http://graphite.wdfiles.com/local--files/screen-shots/graphite_cli_800.png" alt="Graphite CLI Screenshot" width="392" height="221" /><p class="wp-caption-text">Graphite CLI Screenshot</p></div>
<p>Graphite is a flexible and powerful tool to build charts. It&#8217;s also a data series analytics framework. It was developed inside Orbitz by my former colleague, originally for use within a single group (of which I was a part). However, its power did not remain a secret for too long &#8211; it quickly spread to entire organization and became an irreplaceable tool for both development and engineering/operations. Graphite was then open-sourced under Apache license. It currently lives at <a href="http://graphite.wikidot.com/">http://graphite.wikidot.com/</a></p>
<p>The key to Graphite&#8217;s power, in addition to dynamic web UI, an improved RRD implementation called &#8220;whisper&#8221; (read this <a href="http://graphite.wikidot.com/faq#toc8">FAQ</a> &#8211; highly recommend!) web-based command line with auto-completion which allows you to overlay any metrics on a single chart, IMHO is the fact that you are in control what kind of data to send to it, how often, and how to set up hierarchies of your metrics &#8211; by environment, by machine type, by datacenter, etc. Graphite doesn&#8217;t do its own polling that won&#8217;t scale to hundreds or thousands of metrics. Nor does it enforce anything but the fact that your metrics are dot-separated hierarchies (as in routing keys of AMQP topic exchanges &#8211; my.metric.name) and that their values are numeric (int or float).</p>
<p>If you are still reading this but still are not convinced that it&#8217;s the way to go, I&#8217;ve got one last argument. If you already use RabbitMQ to publish and consume data, wouldn&#8217;t it be nice to get a powerful charts without touching your application AND without installing agents on your publishers or consumers? Recall the <a href="/2008/11/11/using-rabbitmq-beyond-queueing/">duplication pattern</a> of RabbitMQ &#8211; you can fork the incoming stream of messages into another queue (without impacting your original consumers and the queues to which they attach) and set up Graphite+RabbitMQ off of this new queue.</p>
<p>If you are planning to run multiple carbon instances, remember that heavy lifting (writing to disk) is actually performed by another process called carbon-persister.py (it&#8217;s started by carbon-agent, with communications over a pipe) &#8211; try to avoid multiple persisters writing data within the same hierarchy to avoid slow down and possible data corruption. RabbitMQ can help you sort out what messages go where, thus minimizing this risk.</p>
<p>I am very excited about future opportunities that a Graphite-RabbitMQ combination can deliver, and I hope someone finds my scripts useful. Both tools bring a lot of awesomeness to the table, and nicely complement each other forming a great charts and data series analytics solution you have been searching for. Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2009/05/21/graphite-rabbitmq-integration/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>One year at CohesiveFT</title>
		<link>http://somic.org/2008/04/10/one-year-at-cohesiveft/</link>
		<comments>http://somic.org/2008/04/10/one-year-at-cohesiveft/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 15:01:37 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rabbitmq]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://somic-org.homelinux.org/blog/2008/04/10/one-year-at-cohesiveft/</guid>
		<description><![CDATA[Yesterday was 1 year since I started at CohesiveFT. New things this year (in no particular order):

 Mac. I got a Macbook Pro as my work laptop. Feels great every time I sit down to work, even though I am not a very demanding desktop user &#8211; browser, email, IM, rss reader for non-public feeds, [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday was 1 year since I started at <a href="http://www.cohesiveft.com">CohesiveFT</a>. New things this year (in no particular order):</p>
<ul>
<li> <a href="http://www.apple.com">Mac</a>. I got a Macbook Pro as my work laptop. Feels great every time I sit down to work, even though I am not a very demanding desktop user &#8211; browser, email, IM, rss reader for non-public feeds, terminal, occasional Office document work, occasional PDF to read. And most importantly &#8211; VMware Fusion to run my Linux development box.</li>
<li><a href="http://www.debian.org">Debian</a>. Our paths surprisingly have not crossed until this year. Probably because I lost interest in low level OS maintenance a long time ago and was not actively looking for a new distro to try (my home server is running Red Hat Linux 7.0 with everything important upgraded to later versions &#8211; I don&#8217;t use RPMs and prefer <a href="http://www.gnu.org/software/stow/">GNU Stow</a> for package management). Overall, I can&#8217;t say I dislike it. apt-get is nice. And deb packaging format imho is superior to rpm (writing standalone rules files using GNU make is easier than writing shell within spec files). Like rpm however, apt-get does not handle edge cases, when I don&#8217;t want computer to think it&#8217;s smarter than me.</li>
<li><a href="http://www.ruby-lang.org">Ruby</a>. The second attempt to learn ruby was successful. Ruby now joined <a href="http://www.python.org">Python</a> on the list of my favorite languages. They are both equally great for doing all kinds of development, provided your project doesn&#8217;t use both at the same time &#8211; each has its own patterns and I personally find it somewhat hard to adjust when I try to write in both in parallel. I am also happy that Ruby joined Python on my list, not displaced it (several years back, Python did displace Perl on my list) &#8211; so I am kind of bi-lingual now, which mimics my real life situation with real languages.</li>
<li><a href="http://www.rubyonrails.com">Rails</a>. Yes, Ruby on Rails and Django on Python are my favorites now.</li>
<li><a href="http://www.rabbitmq.com">RabbitMQ</a>. This is a big one. For quite some time I have been searching for a highly available messaging bus as a holy grail of building and operating a scalable system. I think I found what I was looking for in RabbitMQ and its implementation of AMQP standard.</li>
</ul>
<p><a href="http://es.cohesiveft.com">Elastic Server On Demand </a>is built with each of these somehow tied to it behind the scenes. Shaping up very good so far&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2008/04/10/one-year-at-cohesiveft/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Google App Engine</title>
		<link>http://somic.org/2008/04/08/google-app-engine/</link>
		<comments>http://somic.org/2008/04/08/google-app-engine/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 16:20:20 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://somic-org.homelinux.org/blog/2008/04/08/google-app-engine/</guid>
		<description><![CDATA[ 
Google released their App Engine yesterday. Very cool python goodness, supposedly with access to their BigTable and GFS and supposedly free for use up to a certain limit.
In the meantime, Google engineers (or was it designers?) came up with a new type of aircraft. You probably have heard about flying wings, but it looks [...]]]></description>
			<content:encoded><![CDATA[<p> <img src="http://code.google.com/appengine/images/appengine_lowres.jpg" height="79" width="100" /></p>
<p>Google released their <a href="http://code.google.com/appengine/">App Engine</a> yesterday. Very cool python goodness, supposedly with access to their BigTable and GFS and supposedly free for use up to a certain limit.</p>
<p>In the meantime, Google engineers (or was it designers?) came up with a new type of aircraft. You probably have heard about <a href="http://en.wikipedia.org/wiki/Flying_wing">flying wings</a>, but it looks to me like the concept of &#8220;a flying engine&#8221; has been introduced for the first time. And it&#8217;s a very simple design too &#8211; you take a jet engine, and attach wings and a tail to it. I am not a specialist, but I don&#8217;t see a reason why it won&#8217;t fly.</p>
<p>Seriously though, Google definitely has my respect for doing things like this.</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2008/04/08/google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guido on Python 3000 and You</title>
		<link>http://somic.org/2008/03/18/guido-on-python-3000-and-you/</link>
		<comments>http://somic.org/2008/03/18/guido-on-python-3000-and-you/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 14:50:03 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://somic-org.homelinux.org/blog/2008/03/18/guido-on-python-3000-and-you/</guid>
		<description><![CDATA[Guido van Rossum, creator of Python programming language, published slides of his keynote at PyCon 2008 here.
A note to self: come back to to this link when it&#8217;s time to migrate to py3k.
]]></description>
			<content:encoded><![CDATA[<p>Guido van Rossum, creator of <a href="http://www.python.org">Python</a> programming language, published slides of his keynote at PyCon 2008 <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=227041">here</a>.</p>
<p>A note to self: come back to to this link when it&#8217;s time to migrate to py3k.</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2008/03/18/guido-on-python-3000-and-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python AMQP client and non-blocking sockets</title>
		<link>http://somic.org/2008/03/02/python-amqp-client-and-non-blocking-sockets/</link>
		<comments>http://somic.org/2008/03/02/python-amqp-client-and-non-blocking-sockets/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 23:20:27 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[rabbitmq]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://somic-org.homelinux.org/blog/2008/03/02/python-amqp-client-and-non-blocking-sockets/</guid>
		<description><![CDATA[We put together an add-on for py-amqplib that implements AMQP client with non-blocking sockets in python.
There are at least 2 scenarios where non-blocking sockets help, and both are applicable to consumers:
1) when you want to be able to interrupt consumer&#8217;s event loop without waiting for a next incoming message;
2) when you want to consume messages [...]]]></description>
			<content:encoded><![CDATA[<p>We put together an add-on for <a href="http://barryp.org/software/py-amqplib/">py-amqplib</a> that implements AMQP client with non-blocking sockets in python.</p>
<p>There are at least 2 scenarios where non-blocking sockets help, and both are applicable to consumers:<br />
1) when you want to be able to interrupt consumer&#8217;s event loop without waiting for a next incoming message;<br />
2) when you want to consume messages from multiple brokers (or over multiple connections) in a single event loop.</p>
<p>Special thanks to Barry Pederson who created py-amqplib library and made it available to the public.</p>
<p>Please see my announcement on <a href="http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2008-March/000550.html">rabbitmq-discuss mailing list</a>. If your architecture still relies on custom or proprietary messaging protocols, I strongly suggest that you take a look at <a href="http://www.amqp.org">AMQP</a> and especially <a href="http://www.rabbitmq.com/">RabbitMQ</a>.</p>
<p>UPDATED: You can download  the add-on directly from <a href="http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080302/455b87df/attachment.txt">http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080302/455b87df/attachment.txt</a></p>
<p>UPDATED x2: If you came to this post today (2009 and beyond), please note that this add-on has been out of date for some time. Non-blocking AMQP with python can be done today with <a href="https://launchpad.net/txamqp">txamqp</a> if you are using twisted, or with <a href="http://github.com/tonyg/pika">pika</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2008/03/02/python-amqp-client-and-non-blocking-sockets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
