<?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"
	>

<channel>
	<title>Lior Gradstein's Blog &#187; python</title>
	<atom:link href="http://www.gradstein.info/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gradstein.info</link>
	<description></description>
	<pubDate>Mon, 29 Sep 2008 12:39:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>TurboGears and Pylons will merge! (and CleverHarold RIP)</title>
		<link>http://www.gradstein.info/python/turbogears-and-pylons-will-be-merged/</link>
		<comments>http://www.gradstein.info/python/turbogears-and-pylons-will-be-merged/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 15:20:08 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[framework]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[web]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/python/turbogears-and-pylons-will-be-merged/</guid>
		<description><![CDATA[Mark Ramm, one of TurboGears&#8217;s core developers announced on TurboGears&#8217;s mailing list that they will merge with Pylons! To be more precise, the API of TurboGears will be implemented on top of Pylons. It seems they already made some test/proof of concept that are, as they say &#8220;a huge success&#8221;. That&#8217;s really good news for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.phptr.com/authors/bio.asp?a=304cff7b-5886-4dcf-ae59-6bbf140dd802&amp;rl=1" class="liexternal">Mark Ramm</a>, one of <a href="http://turbogears.org/" class="liexternal">TurboGears</a>&#8217;s core developers announced on <a href="http://groups.google.com/group/turbogears/browse_thread/thread/d1d2e416023e7033" class="liexternal">TurboGears&#8217;s mailing list</a> that they will merge with <a href="http://pylonshq.com/" class="liexternal">Pylons</a>! To be more precise, the API of TurboGears will be implemented on top of Pylons. It seems they already made some test/proof of concept that are, as they say &#8220;a huge success&#8221;. That&#8217;s really good news for Python web frameworks development, and a good news for me, as I&#8217;ll not have to choose between the two :-</p>
<p>As a sidenote, it seems another framework, <a href="http://www.gradstein.info/python/another-fine-new-web-framework-clever-harold/" class="liinternal">CleverHarold</a> has disappeared without anybody noticing. Its domain is parked, and today its <a href="http://groups.google.com/group/cleverharold" class="liexternal">Google Group page</a> went off (the last messages were from people asking if the project was still alive).</p>
<p><strong>Update:</strong>  <a href="http://www.oreillynet.com/pub/au/3039" class="liexternal">Noah Gift</a><span class="ISI_IGNORE"> wrote a <a href="http://www.oreillynet.com/onlamp/blog/2007/06/python_web_application_framewo.html" class="liexternal">nice article</a> about the merge. </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/turbogears-and-pylons-will-be-merged/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Videos of every presentation of Journée Python 2007 are now online!</title>
		<link>http://www.gradstein.info/python/videos-of-every-presentation-of-journee-python-2007-are-now-online/</link>
		<comments>http://www.gradstein.info/python/videos-of-every-presentation-of-journee-python-2007-are-now-online/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 00:50:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[language]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[twisted]]></category>

	<!-- AutoMeta Start -->
	<category>presentation</category>
	<category>filmed</category>
	<category>and</category>
	<category>uploaded</category>
	<category>the</category>
	<category>title</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/language/videos-of-every-presentation-of-journee-python-2007-are-now-online/</guid>
		<description><![CDATA[As the title says it, each presentation was filmed, and has just been uploaded for everyone&#8217;s pleasure! Here is the two-part video presentation of Twisted, done by Michael SCHERER.
[googlevideo]http://video.google.com/videoplay?docid=8739163173039026567[/googlevideo]
[googlevideo]http://video.google.com/videoplay?docid=1837647658089311574[/googlevideo]
Oh, by the way, please take a minute to vote for your favourite Internet Engine!


]]></description>
			<content:encoded><![CDATA[<p>As the title says it, each <a href="http://journees.afpy.org/programme" class="liexternal">presentation was filmed</a>, and has just been uploaded for everyone&#8217;s pleasure! Here is the two-part video presentation of Twisted, done by Michael SCHERER.</p>
<p>[googlevideo]http://video.google.com/videoplay?docid=8739163173039026567[/googlevideo]<br />
[googlevideo]http://video.google.com/videoplay?docid=1837647658089311574[/googlevideo]</p>
<p>Oh, by the way, please take a minute to vote for your favourite Internet Engine!</p>
<p align="center">
<iframe src="http://jyte.com/widget/claim/twistedmatrix.com-is-the-engine-of-your-internet" style="width:400px;height:60px;border:1px solid #777;" scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/videos-of-every-presentation-of-journee-python-2007-are-now-online/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Journées Python Francophone 2007 Conference at La Villette, France</title>
		<link>http://www.gradstein.info/python/22/</link>
		<comments>http://www.gradstein.info/python/22/#comments</comments>
		<pubDate>Sun, 03 Jun 2007 20:35:17 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[python]]></category>

	<!-- AutoMeta Start -->
	<category>today</category>
	<category>the</category>
	<category>journée</category>
	<category>python</category>
	<category>2007</category>
	<category>conference</category>
	<category>prepare</category>
	<category>advanced</category>
	<category>twisted</category>
	<category>presentation</category>
	<category>half</category>
	<category>the</category>
	<category>twisted</category>
	<category>intro</category>
	<category>finely</category>
	<category>presented</category>
	<category>alas</category>
	<category>lightning</category>
	<category>talks</category>
	<category>year</category>
	<category>conference</category>
	<category>there</category>
	<category>introductory</category>
	<category>type</category>
	<category>and</category>
	<category>the</category>
	<category>afternoon</category>
	<category>presentations</category>
	<category>thanks</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/python/22/</guid>
		<description><![CDATA[I went today to the Journée Python 2007 Conference in France. I managed to see half of the Twisted intro, some lightning talks, and most of the afternoon presentations (thanks to Ido&#8217;s mid-day nap).
Most of the talks were introductory type, but they were finely presented (alas most of the audience already knew python). I hope [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gradstein.info/wp-content/uploads/image5.jpg"  rel="lightbox"><img src="http://www.gradstein.info/wp-content/uploads/.thumbs/.image5.jpg" alt="Journee Python Conference 2007" align="right" border="0" height="72" width="96" /></a>I went today to the Journée Python 2007 Conference in France. I managed to see half of the Twisted intro, some lightning talks, and most of the afternoon presentations (thanks to Ido&#8217;s mid-day nap).</p>
<p>Most of the talks were introductory type, but they were finely presented (alas most of the audience already knew python). I hope I&#8217;ll find the time to prepare some more advanced Twisted presentation for next year&#8217;s Conference (there&#8217;s one, right?)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/22/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Nice introduction article on Pylons</title>
		<link>http://www.gradstein.info/python/nice-introduction-article-on-pylons/</link>
		<comments>http://www.gradstein.info/python/nice-introduction-article-on-pylons/#comments</comments>
		<pubDate>Mon, 07 May 2007 08:37:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[framework]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[web]]></category>

	<!-- AutoMeta Start -->
	<category>turbogears</category>
	<category>django</category>
	<category>the</category>
	<category>mailing</category>
	<category>list</category>
	<category>a</category>
	<category>reference</category>
	<category>pylons</category>
	<category>a</category>
	<category>cool</category>
	<category></category>
	<category>posted</category>
	<category>framework</category>
	<category>one</category>
	<category>zope</category>
	<category>etc</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/nice-introduction-article-on-pylons/</guid>
		<description><![CDATA[Pylons is a cool web framework (one more, besides TurboGears, Django, Zope, etc.). Someone posted on the mailing list a reference to a nice introduction.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://pylonshq.com/" class="liexternal">Pylons</a> is a cool web framework (one more, besides TurboGears, Django, Zope, etc.). Someone posted on the mailing list a reference to a <a href="http://www.rexx.com/%7Edkuhlman/" class="liexternal">nice introduction</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/nice-introduction-article-on-pylons/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Troll of the day: Why Ruby sucks and why Python rocks!</title>
		<link>http://www.gradstein.info/python/troll-of-the-day-why-ruby-sucks-and-why-python-rocks/</link>
		<comments>http://www.gradstein.info/python/troll-of-the-day-why-ruby-sucks-and-why-python-rocks/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 15:06:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[twisted]]></category>

	<!-- AutoMeta Start -->
	<category>ruby</category>
	<category>can’t</category>
	<category>compete</category>
	<category>turntide’s</category>
	<category>competitor</category>
	<category>ironport</category>
	<category>twisted</category>
	<category>and</category>
	<category>stackless</category>
	<category>python</category>
	<category>the</category>
	<category>powerful</category>
	<category>smtp</category>
	<category>testing</category>
	<category>tool</category>
	<category>and</category>
	<category>the</category>
	<category>ruby</category>
	<category>written</category>
	<category>a</category>
	<category>ruby</category>
	<category>user</category>
	<category>ironport</category>
	<category>python</category>
	<category>a</category>
	<category>nicely</category>
	<category>written</category>
	<category>article</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/troll-of-the-day-why-ruby-sucks-and-why-python-rocks/</guid>
		<description><![CDATA[I found a nicely written article about the problems with Ruby, written by a Ruby user, and why he found Python to be really good. There&#8217;s even a quote about Twisted!
And, there are a bunch of things available to a Python guy that Ruby just can’t compete with that are of particular interest to me. [...]]]></description>
			<content:encoded><![CDATA[<p>I found a <a href="http://blog.cbcg.net/articles/2007/04/22/python-up-ruby-down-if-that-runtime-dont-work-then-its-bound-to-drizzown" class="liexternal">nicely written article</a> about the problems with Ruby, written by a Ruby user, and why he found Python to be really good. There&#8217;s even a quote about Twisted!<br />
<blockquote>And, there are a bunch of things available to a Python guy that Ruby just can’t compete with that are of particular interest to me. Two that come to mind immediately are <a href="http://twistedmatrix.com/trac/" class="liexternal">Twisted</a> and <a href="http://www.stackless.com/" class="liexternal">Stackless Python</a>. The former was used by others at TurnTide for creating a really powerful <span class="caps">SMTP</span> testing tool and the latter was used by TurnTide’s competitor <a href="http://www.ironport.com/" class="liexternal">IronPort</a> to build one of the industry’s best MTAs.</p></blockquote>
<p>I didn&#8217;t knew that IronPort was done in Python, even in Stackless Python!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/troll-of-the-day-why-ruby-sucks-and-why-python-rocks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Apache module for integrating WSGI apps</title>
		<link>http://www.gradstein.info/python/new-apache-module-for-integrating-wsgi-apps/</link>
		<comments>http://www.gradstein.info/python/new-apache-module-for-integrating-wsgi-apps/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 07:05:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[web]]></category>

	<!-- AutoMeta Start -->
	<category>modded</category>
	<category>wsgi</category>
	<category>aware</category>
	<category>moinmoin</category>
	<category>similar</category>
	<category>wsgi python</category>
	<category>projects</category>
	<category>moinmoin</category>
	<category>scgi</category>
	<category>complex</category>
	<category>fastcgi</category>
	<category>complex</category>
	<category>a</category>
	<category>specific</category>
	<category>interface</category>
	<category>moinmoin</category>
	<category>wsgi</category>
	<category>aware</category>
	<category>machine</category>
	<category>and</category>
	<category>eventually</category>
	<category>configure</category>
	<category>configure</category>
	<category>lighttpd</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/new-apache-module-for-integrating-wsgi-apps/</guid>
		<description><![CDATA[Finally, after such painful setups, I really never could find a really suitable configuration that could satisfy me. Here are the different methods I tried to implement TurboGears/Pylons or similar WSGI/Python projects (MoinMoin for example):

FastCGI: So complex to setup, crashes on its own so often, and leaves running processes in memory so have to kill [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, after such painful setups, I really never could find a really suitable configuration that could satisfy me. Here are the different methods I tried to implement <a href="http://www.turbogears.org/" class="liexternal">TurboGears</a>/<a href="http://pylonshq.com/" class="liexternal">Pylons</a> or similar WSGI/Python projects (<a href="http://moinmoin.wikiwikiweb.de/" class="liexternal">MoinMoin </a>for example):</p>
<ul>
<li>FastCGI: So complex to setup, crashes on its own so often, and leaves running processes in memory so have to kill them each time manually to start again with a clean environment. I have to admit it is easier to configure on <a href="http://www.lighttpd.net/" class="liexternal">Lighttpd</a>.</li>
<li><a href="http://www.mems-exchange.org/software/scgi/" class="liexternal">SCGI</a>: As complex as FastCGI and not so used in the world, but not bad. Too few options.</li>
<li>Proxy: Redirecting on a local different port gives nore work, and as soon as you have several other virtual hosts, you&#8217;ll have to keep a registry of all your allocated ports. Painful, but easy to setup. Maybe be hard to configure if you&#8217;re using Zope, and if you need some remote information (ip address of the user for example), you&#8217;re dead!</li>
<li>Direct Access: Configuring you app to run on a local ip alias on your machine and eventually configure your firewall to DNAT on it. Not that complex to setup, but requires access to you OS confiugration and many apps don&#8217;t allow you to only listen on a specific interface (MoinMoin allows it, that&#8217;s cool)</li>
<li>mod_python: Loads Python into memory. Everybody shares the same namespace. Dangerous.</li>
</ul>
<p>Now here&#8217;s a new contender, <a href="http://code.google.com/p/modwsgi/" class="liexternal">mod_wsgi</a> written by <a href="http://blog.dscpl.com.au/" class="liexternal">Graham Dumpleton</a>. That&#8217;s right, it will not work for every app. Zope, not being WSGI aware, is out of the way, except for <a href="http://blog.d2m.at/2006/09/23/zope3-and-wsgi-integration/" class="liexternal">Zope 3.x</a>. But most of Python apps can be modded to be WSGI aware (<a href="http://moinmoin.wikiwikiweb.de/WsgiRequestPatch" class="liexternal">MoinMoin is an example</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/new-apache-module-for-integrating-wsgi-apps/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PyPy 1.0 has been announced!</title>
		<link>http://www.gradstein.info/python/pypy-10-has-been-announced/</link>
		<comments>http://www.gradstein.info/python/pypy-10-has-been-announced/#comments</comments>
		<pubDate>Wed, 28 Mar 2007 08:08:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[language]]></category>

		<category><![CDATA[python]]></category>

	<!-- AutoMeta Start -->
	<category>learn</category>
	<category>pypy</category>
	<category>and</category>
	<category>pypy</category>
	<category>version</category>
	<category>1 0</category>
	<category>production</category>
	<category>that     please</category>
	<category>read</category>
	<category>the</category>
	<category>announcement</category>
	<category>and</category>
	<category>the</category>
	<category>python</category>
	<category>community</category>
	<category>and</category>
	<category>the</category>
	<category>rest</category>
	<category>change</category>
	<category>life     python</category>
	<category>available</category>
	<category>a</category>
	<category>great</category>
	<category>news</category>
	<category>the</category>
	<category>links</category>
	<category>referenced</category>
	<category>the</category>
	<category>programming</category>
	<category>world</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/pypy-10-has-been-announced/</guid>
		<description><![CDATA[PyPy version 1.0 is now available. That&#8217;s really a great news, and a milestone for the Python community (and the rest of the programming world). It&#8217;s not yet recommended to use it in production, but we&#8217;re not that far from that.
Please read the announcement and go in the different links referenced there to learn more [...]]]></description>
			<content:encoded><![CDATA[<p>PyPy version 1.0 is now available. That&#8217;s really a great news, and a milestone for the Python community (and the rest of the programming world). It&#8217;s not yet recommended to use it in production, but we&#8217;re not that far from that.</p>
<p>Please read the <a href="http://codespeak.net/pypy/dist/pypy/doc/release-1.0.0.html" class="liexternal">announcement</a> and go in the different links referenced there to learn more about PyPy and what it will change in your life.</p>
<p>Python is so cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/pypy-10-has-been-announced/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to understand the ARP queries and replies fields with pypcap</title>
		<link>http://www.gradstein.info/python/how-to-understand-the-arp-queries-and-replies-fields-with-pypcap/</link>
		<comments>http://www.gradstein.info/python/how-to-understand-the-arp-queries-and-replies-fields-with-pypcap/#comments</comments>
		<pubDate>Wed, 21 Mar 2007 21:36:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[network]]></category>

		<category><![CDATA[python]]></category>

	<!-- AutoMeta Start -->
	<category>pc</category>
	<category>packet</category>
	<category></category>
	<category>dpkt ethernet ethernet pkt</category>
	<category>object</category>
	<category>oriented   pypcap</category>
	<category>includes</category>
	<category>a</category>
	<category>huge</category>
	<category>quantity</category>
	<category>cool</category>
	<category>includes</category>
	<category>a</category>
	<category>network</category>
	<category>packet</category>
	<category>capture</category>
	<category>method</category>
	<category>print</category>
	<category>arp</category>
	<category>packet</category>
	<category>received</category>
	<category></category>
	<category>packet data op</category>
	<category>print</category>
	<category>pcapfrom</category>
	<category>socket</category>
	<category>import</category>
	<category>inet_ntoa    def</category>
	<category>ether_decode p</category>
	<category></category>
	<category>ether_decode packet data tha</category>
	<category></category>
	<category>ether_decode packet data sha</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/how-to-understand-the-arp-queries-and-replies-fields-with-pypcap/</guid>
		<description><![CDATA[I had a hard time understanding the function of each field in an ARP packet. The problem is that the fields change of meaning, depending on the opcode field. The two useful ones are for ARP queries (what is the ethernet address of the ip address I&#8217;m giving now) and ARP replies (that ip address [...]]]></description>
			<content:encoded><![CDATA[<p>I had a hard time understanding the function of each field in an ARP packet. The problem is that the fields change of meaning, depending on the opcode field. The two useful ones are for ARP queries (<span style="font-style: italic">what is the ethernet address of the ip address I&#8217;m giving now</span>) and ARP replies (<span style="font-style: italic">that ip address is located at this ethernet address</span>).</p>
<p>So to fix this problem once for all, I decided to write a python script that shows the different field values when an ARP packet is captured.</p>
<p>There are several libraries available to the pythonista to manipulate network packets. The most known is certainly <a href="http://pylibpcap.sourceforge.net/" class="liexternal">pylibpcap</a> which is quite old now, and not really object oriented. It is more an adaptation one-to-one of the C libpcap library, which may be useful for some people.<br />
Another library is <a href="http://code.google.com/p/pypcap/" class="liexternal">pypcap</a>, which is like pylibpcap, but <span style="font-weight: bold">much much</span> more object oriented.<br />
pypcap includes a huge quantity of protocols definitions, so it&#8217;s really cool to use, especially because it also includes a network packet capture method. There is no included method to send packets, but there are examples of how to do this in the test files.<br />
Another possibility is <a href="http://www.secdev.org/projects/scapy/" class="liexternal">scapy</a>, which is an extremely complete program (more a program than a library, even though you can use it as a module). The fact that it&#8217;s not that easy to include scapy in my own program, even though there&#8217;s now a <a href="http://www.secdev.org/projects/scapy/build_your_own_tools.html" class="liexternal">howto</a>. My program doesn&#8217;t need all the bells and whistles given by scapy, so I settled on pypcap.</p>
<p class="code">
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #ff7700;font-weight:bold;">import</span> dpkt, pcapfrom <span style="color: #dc143c;">socket</span> <span style="color: #ff7700;font-weight:bold;">import</span> inet_ntoa</p>
<p><span style="color: #ff7700;font-weight:bold;">def</span> ether_decode<span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span>: &nbsp; <br />
&nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&#8216;:&#8217;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&#8216;%02x&#8217;</span> % <span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></p>
<p><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&#8216;__main__&#8217;</span>:<br />
&nbsp; &nbsp;iface_name = <span style="color: #483d8b;">&#8216;eth1&#8242;</span> &nbsp;<span style="color: #808080; font-style: italic;"># Here set your listening interface</span><br />
&nbsp; &nbsp;pc = pcap.<span style="color: black;">pcap</span><span style="color: black;">&#40;</span>iface_name<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp;pc.<span style="color: black;">setfilter</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&#8216;arp&#8217;</span><span style="color: black;">&#41;</span></p>
<p>&nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">for</span> ts,pkt <span style="color: #ff7700;font-weight:bold;">in</span> pc:<br />
&nbsp; &nbsp; &nbsp; packet = dpkt.<span style="color: black;">ethernet</span>.<span style="color: black;">Ethernet</span><span style="color: black;">&#40;</span>pkt<span style="color: black;">&#41;</span></p>
<p>&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;ARP packet received:&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;op=%d&quot;</span> % packet.<span style="color: black;">data</span>.<span style="color: black;">op</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;src=%s&quot;</span> % ether_decode<span style="color: black;">&#40;</span>packet.<span style="color: black;">src</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;dst=%s&quot;</span> % ether_decode<span style="color: black;">&#40;</span>packet.<span style="color: black;">dst</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;spa=%s&quot;</span> % inet_ntoa<span style="color: black;">&#40;</span>packet.<span style="color: black;">data</span>.<span style="color: black;">spa</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;tpa=%s&quot;</span> % inet_ntoa<span style="color: black;">&#40;</span>packet.<span style="color: black;">data</span>.<span style="color: black;">tpa</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;tha=%s&quot;</span> % ether_decode<span style="color: black;">&#40;</span>packet.<span style="color: black;">data</span>.<span style="color: black;">tha</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;sha=%s&quot;</span> % ether_decode<span style="color: black;">&#40;</span>packet.<span style="color: black;">data</span>.<span style="color: #dc143c;">sha</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span></div>
</p>
<p>That&#8217;s it. Now, for example, 192.168.4.3 wants to get 192.168.4.254&#8217;s ethernet address (192.168.4.254 has 00:90:4c:49:00:2a address and 192.168.4.3 has 00:50:70:b4:19:0c), here is the output:</p>
<p class="code">
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">ARP packet received:op=<span style="color: #ff4500;">1</span> src=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">50</span>:<span style="color: #ff4500;">70</span>:b4:<span style="color: #ff4500;">19</span>:0c dst=ff:ff:ff:ff:ff:ff <br />
spa=<span style="color: #ff4500;">192.168</span><span style="color: #ff4500;">.4</span><span style="color: #ff4500;">.3</span> tpa=<span style="color: #ff4500;">192.168</span><span style="color: #ff4500;">.4</span><span style="color: #ff4500;">.254</span> tha=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">00</span>:00sha=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">50</span>:<span style="color: #ff4500;">70</span>:b4:<span style="color: #ff4500;">19</span>:0c<br />
ARP packet received:op=<span style="color: #ff4500;">2</span> src=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">90</span>:4c:<span style="color: #ff4500;">49</span>:<span style="color: #ff4500;">00</span>:2a dst=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">50</span>:<span style="color: #ff4500;">70</span>:b4:<span style="color: #ff4500;">19</span>:0c<br />
spa=<span style="color: #ff4500;">192.168</span><span style="color: #ff4500;">.4</span><span style="color: #ff4500;">.254</span> tpa=<span style="color: #ff4500;">192.168</span><span style="color: #ff4500;">.4</span><span style="color: #ff4500;">.3</span> tha=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">50</span>:<span style="color: #ff4500;">70</span>:b4:<span style="color: #ff4500;">19</span>:0csha=<span style="color: #ff4500;">00</span>:<span style="color: #ff4500;">90</span>:4c:<span style="color: #ff4500;">49</span>:<span style="color: #ff4500;">00</span>:2a</div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/how-to-understand-the-arp-queries-and-replies-fields-with-pypcap/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Extension for Twisted AMP to support dictionaries and lists</title>
		<link>http://www.gradstein.info/python/extension-for-twisted-amp-to-support-dictionaries-and-lists/</link>
		<comments>http://www.gradstein.info/python/extension-for-twisted-amp-to-support-dictionaries-and-lists/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 09:28:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/var/www/GRADSTEIN/wordpress/wp-content/plugins/autometa/autometa.php</b> on line <b>364</b><br />

		<category><![CDATA[python]]></category>

		<category><![CDATA[twisted]]></category>

	<!-- AutoMeta Start -->
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/extension-for-twisted-amp-to-support-dictionaries-and-lists/</guid>
		<description><![CDATA[Henrik Thostrup Jensen announced on the Twisted Users mailing list he made two extensions for the Twisted AMP protocol.
Currently there are two types: A dictionary and a list. The types of the element must be specified (key and value can be different in the dictionary), otherwise they are free form, i.e., the keys in the [...]]]></description>
			<content:encoded><![CDATA[<p>Henrik Thostrup Jensen announced on the Twisted Users mailing list he made two extensions for the Twisted AMP protocol.<br />
<blockquote>Currently there are two types: A dictionary and a list. The types of the element must be specified (key and value can be different in the dictionary), otherwise they are free form, i.e., the keys in the dictionary can have any name, and the list can be of any size. The types can be nested, e.g., you can create a list of list of strings. I use (or will) the latter to return a query result, for which I do not know the row size. This is currently impossible (AFAICT), in the otherwise excellent AMP protocol.</p></blockquote>
<p>You can get them on <a href="http://www.cs.aau.dk/%7Ehtj/code/amptypes-0.1.tar.gz" class="liexternal">http://www.cs.aau.dk/~htj/code/amptypes-0.1.tar.gz</a></p>
<p>For people that live under a rock, AMP is a new communication protocol for Twisted (added in Twisted 2.5) much lighter/simpler than PB. It is just a request/response protocol over a persistent connection.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/extension-for-twisted-amp-to-support-dictionaries-and-lists/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Adding automatically ez_setup in your SVN repository</title>
		<link>http://www.gradstein.info/python/adding-automatically-ez_setup-in-your-svn-repository/</link>
		<comments>http://www.gradstein.info/python/adding-automatically-ez_setup-in-your-svn-repository/#comments</comments>
		<pubDate>Wed, 13 Sep 2006 08:49:00 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
		
		<category><![CDATA[python]]></category>

	<!-- AutoMeta Start -->
	<category>project</category>
	<category>explicitely</category>
	<category>exclude</category>
	<category>the</category>
	<category>ez_setup</category>
	<category>folder</category>
	<category>add</category>
	<category>setup        packages</category>
	<category></category>
	<category>find_packages exclude</category>
	<category>svn eby sarna com svnroot ez_setup  then</category>
	<category>a</category>
	<category>svn</category>
	<category>ez_setup py</category>
	<category>package</category>
	<category>distribution</category>
	<category>users</category>
	<category>setuptools</category>
	<category>installed</category>
	<category>or</category>
	<category>a</category>
	<category>line</category>
	<category>ez_setup</category>
	<category>svn</category>
	<category>project</category>
	<category>and</category>
	<category>edit</category>
	<category>the</category>
	<category>properties</category>
	<category>set   note</category>
	<category>the</category>
	<category>find_packages</category>
	<category>method</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.gradstein.info/uncategorized/adding-automatically-ez_setup-in-your-svn-repository/</guid>
		<description><![CDATA[For users that don&#8217;t yet have setuptools installed (or a too old version) or who want to include a copy of ez_setup.py in their package distribution, here is the one-true-way. This method is already documented on Phillip J. Eby&#8217;s setuptools pages, but it&#8217;s buried in the middle, and I keep forgetting how to do it. [...]]]></description>
			<content:encoded><![CDATA[<p>For users that don&#8217;t yet have setuptools installed (or a too old version) or who want to include a copy of ez_setup.py in their package distribution, here is the one-true-way. This method is already documented on <a href="http://dirtsimple.org/" class="liexternal">Phillip J. Eby</a>&#8217;s <a href="http://peak.telecommunity.com/DevCenter/setuptools" class="liexternal">setuptools pages</a>, but it&#8217;s buried in the middle, and I keep forgetting how to do it. So here it is:</p>
<p>First, go to the root (trunk) of your project, and edit the properties of your SVN folder using the following command:</p>
<blockquote><p>svn propedit svn:externals .</p></blockquote>
<p>This will open your favorite text editor where you&#8217;ll put the following line:</p>
<blockquote><p>ez_setup svn://svn.eby-sarna.com/svnroot/ez_setup</p></blockquote>
<p>Then do a svn ci, and then svn update, you&#8217;re all set!<br />
Note: If you use the find_packages method in your project, you&#8217;ll have to explicitely exclude the ez_setup folder. You can edit your setup.py file to add:</p>
<blockquote><p>setup(<br />
&#8230;<br />
packages = find_packages(exclude=['ez_setup']),<br />
)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/adding-automatically-ez_setup-in-your-svn-repository/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
