<?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>ArunRocks &#187; Python</title>
	<atom:link href="http://www.arunrocks.com/blog/archives/category/technical/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.arunrocks.com/blog</link>
	<description>Representing Anti-Monotonistic Tendencies</description>
	<pubDate>Sat, 22 Nov 2008 05:49:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Workaround to Easy Install PIL on Windows</title>
		<link>http://www.arunrocks.com/blog/archives/2008/08/30/workaround-to-easy-install-pil-on-windows/</link>
		<comments>http://www.arunrocks.com/blog/archives/2008/08/30/workaround-to-easy-install-pil-on-windows/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 17:43:54 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[Python]]></category>

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/?p=133</guid>
		<description><![CDATA[     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: Python" href="http://www.arunrocks.com/blog/archives/category/technical/python/feed/" />
     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: django" href="http://www.arunrocks.com/blog/archives/category/technical/python/django/feed/" />
This is a quick workaround for people who are using easy_install to install Python Imaging Library on Windows. Many people faced issues while doing this. I found a simple workaround for this.
You must have tried the following


    C:> easy_install PIL
    Searching for PIL
    ...
   [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick workaround for people who are using <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a> to install Python Imaging Library on Windows. Many people faced issues while doing this. I found a simple workaround for this.</p>
<p>You must have tried the following</p>
<div>
<textarea name="code" class="css:nogutter" cols="60" rows="10">
    C:> easy_install PIL
    Searching for PIL
    ...
    Finished processing dependencies for PIL
    C:> python
    Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import Image
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named Image

    </module></stdin></textarea>
</div>
<p>Now you will need to go to your site-packages directory (typically at C:\Python\Lib\site-packages) and change one line that starts with <code>./PIL-1.1.6-py2.5-win32.egg</code> to simply <code>./PIL</code> and change the sub-directory named similarly to <code>PIL</code></p>
<p>Now your imports should work <img src='http://www.arunrocks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F&#038;title=Workaround+to+Easy+Install+PIL+on+Windows" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F&#038;title=Workaround+to+Easy+Install+PIL+on+Windows" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F&#038;t=Workaround+to+Easy+Install+PIL+on+Windows" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F&#038;T=Workaround+to+Easy+Install+PIL+on+Windows" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F&#038;title=Workaround+to+Easy+Install+PIL+on+Windows" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F08%2F30%2Fworkaround-to-easy-install-pil-on-windows%2F&#038;title=Workaround+to+Easy+Install+PIL+on+Windows" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/08/30/workaround-to-easy-install-pil-on-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learning Pylons Through Tutorials</title>
		<link>http://www.arunrocks.com/blog/archives/2008/06/26/learning-pylons-through-tutorials/</link>
		<comments>http://www.arunrocks.com/blog/archives/2008/06/26/learning-pylons-through-tutorials/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 17:18:50 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[Python]]></category>

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/?p=128</guid>
		<description><![CDATA[Web Development is now getting dominated by frameworks. After the initial hype of Rails, Python based frameworks are getting more popularity especially after the release of Google App Engine. Nobody seems to be interested in building websites using PHP, even if they are highly experienced in PHP. This could mean two things:

There will be more [...]]]></description>
			<content:encoded><![CDATA[<p>Web Development is now getting dominated by frameworks. After the initial hype of Rails, Python based frameworks are getting more popularity especially after the release of Google App Engine. Nobody seems to be interested in building websites using PHP, even if they are highly experienced in PHP. This could mean two things:</p>
<ol>
<li>There will be more demand in Indian IT companies for PHP skills similar to Perl scripting skills these days  <img src='http://www.arunrocks.com/blog/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /> </li>
<li>There will be soon be a viable competitor to the immensely popular Wordpress blogging platform from the Python/Ruby world</li>
</ol>
<p>I have nothing against Wordpress. In fact, it is one of the easiest tools to deploy. But with tools like cPanel, deployment could be no longer a deciding factor for blogging platforms.</p>
<p>Coming back to the topic of Python Web Frameworks, there is a multitude of options. I have used some of these framworks and found them to be &#8216;pythonic&#8217; in different ways:</p>
<ul>
<li><strong>Django</strong> Well documented. Tightly Coupled and &#8216;Batteries Included&#8217;</li>
<li><strong>Pylons</strong> Extremely flexibility to Plug and Play components. &#8216;Fun to Hack&#8217;</li>
<li><strong>web.py</strong> Great for beginners. Entire framework &#8216;fits in your head&#8217;</li>
</ul>
<p>Pylons looks most appealing to me. So far it looks like the underdog largely overshadowed by Django&#8217;s presence lacking the <a href="http://www.jacobian.org/writing/2006/jan/27/why-django/">marketing</a> or <a href="http://www.djangoproject.com/weblog/2006/aug/07/guidointerview/">love</a> it deserves. A few weeks back I would have complained about the lack of Pylons tutorials on the web. A google search brought up several links pointing to the wiki tutorial. As many have pointed out, the wiki tutorial is too long and complicated for beginners. It would easily put off a beginner. It took me quite some time to realise that the best place to start learning Pylons is the <a href="http://bel-epa.com/pylonsdocs/">Pylons Documentation</a> itself and the best Pylons tutorial is the <a href="http://bel-epa.com/pylonsdocs/tutorials/flickr_search_tutorial.html">Flickr Search</a>. Going through the documentation is almost feels like reading a book with every concept explained in detail.</p>
<p>Pylons currently seems to the having an edge over Django for enterprise application due to its well tested interface with SQLAlchemy. Django seems to be having a fairly recent <a href="http://code.google.com/p/django-sqlalchemy/">branch</a> for SQLAlchemy integration. Pylons typically uses Python eggs and VirtualEnv for deployment which is might seem a little complex to beginners, but once you try it once it is actually quite convenient. Most of the installation can be done from the command-line and it will be nearly an independent sandbox for Pylons development. However it might take sometime to understand other aspects of using python eggs such as uninstallation and creation of new eggs. I haven&#8217;t had much success with making a portable version of my Pylons installation on Windows though <img src='http://www.arunrocks.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>My favourite templating engine is Genshi because it is very designer friendly(which also means it works with the tools a Designer has, not just that it is easy for a Designer to learn). I can easily do all HTML designing directly on my Genshi templates because they are valid HTML or XML documents. Almost all of Genshi&#8217;s logic can be hidden away as attributes which is a great idea. In fact, the templates are even valid XML which makes the creation of valid HTML pages a much more natural experience. Almost all XML tools and even HTML tools like Tidy will work flawlessly on Genshi templates due to these reasons.</p>
<p>Once you get used to Genshi&#8217;s templates, you might even use them for static web site designing. I am sure it will save you a lot of time whenever those last minute &#8217;sidebar redesigns for every page&#8217; pops up.</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F&#038;title=Learning+Pylons+Through+Tutorials" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F&#038;title=Learning+Pylons+Through+Tutorials" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F&#038;t=Learning+Pylons+Through+Tutorials" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F&#038;T=Learning+Pylons+Through+Tutorials" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F&#038;title=Learning+Pylons+Through+Tutorials" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F06%2F26%2Flearning-pylons-through-tutorials%2F&#038;title=Learning+Pylons+Through+Tutorials" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/06/26/learning-pylons-through-tutorials/feed/</wfw:commentRss>
		</item>
		<item>
		<title>V-day Special</title>
		<link>http://www.arunrocks.com/blog/archives/2008/02/17/v-day-special/</link>
		<comments>http://www.arunrocks.com/blog/archives/2008/02/17/v-day-special/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 07:35:12 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/archives/2008/02/17/v-day-special/</guid>
		<description><![CDATA[Here is a belated valentine&#8217;s day greeting from both of us. 

For all my readers, I recommend visiting the microsite I had made earlier. Now it is written entirely in web.py. Thanks to my new website host, A Small Orange, I can create and host python based applications. I agree that there is no need [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a belated valentine&#8217;s day greeting from both of us. </p>
<p><a href="http://www.flickr.com/photos/arun_ravindran/2270952086/" title="Valentines Day by ArunClickClick, on Flickr"><img src="http://farm3.static.flickr.com/2301/2270952086_c28e0af5be.jpg" width="500" height="333" alt="This photo is a macro taken by Arun" /></a></p>
<p>For all my readers, I recommend visiting the <a href="http://www.arunrocks.com/wedding/">microsite</a> I had made earlier. Now it is written entirely in <a href="http://webpy.org/">web.py</a>. Thanks to my new website host, <a href="http://refer.asmallorange.com/15934">A Small Orange</a>, I can create and host python based applications. I agree that there is no need to design a new blog in python again, but it is a great way to learn a new (anti-) framework. Web.py applications are really small and easy to understand and <a href="http://www.paulgraham.com/head.html">therefore, has less bugs</a>.</p>
<p>Guess what, <a href="http://www.codinghorror.com/blog/archives/000624.html">Jeff Atwood owns an ASUS</a> laptop model (W3J) that is similar to <a href="http://www.flickr.com/photos/arun_ravindran/2215166942/">mine</a> (F3J). He is full of praise about the decision. Considering I took at least 2 months (the standard duration for yours truly to zero into an buying decision) to arrive at the decision, it seems well worth now :).</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F&#038;title=V-day+Special" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F&#038;title=V-day+Special" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F&#038;t=V-day+Special" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F&#038;T=V-day+Special" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F&#038;title=V-day+Special" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F02%2F17%2Fv-day-special%2F&#038;title=V-day+Special" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/02/17/v-day-special/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Work Faster in Windows With Launchy and a few Python Scripts</title>
		<link>http://www.arunrocks.com/blog/archives/2007/12/04/work-faster-in-windows-with-launchy-and-a-few-python-scripts/</link>
		<comments>http://www.arunrocks.com/blog/archives/2007/12/04/work-faster-in-windows-with-launchy-and-a-few-python-scripts/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 05:39:23 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

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

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

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/archives/2007/12/04/work-faster-in-windows-with-launchy-and-a-few-python-scripts/</guid>
		<description><![CDATA[
Launchy is a great productivity tool and a cool way to impress your friends. You can launch any application by pressing a hotkey (say Alt+Space) and the first few letters of the application for eg: typing &#8216;gi&#8217; will display the GIMP icon and pressing Enter will launch GIMP. You can download Launchy from its website [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm1.static.flickr.com/133/414218839_e89ef7791d_m_d.jpg" width="240" height="160" alt="Eating the Mouse" class="alignright" /></p>
<p><a href="http://www.launchy.net/">Launchy</a> is a great productivity tool and a cool way to impress your friends. You can launch any application by pressing a hotkey (say Alt+Space) and the first few letters of the application for eg: typing &#8216;gi&#8217; will display the GIMP icon and pressing Enter will launch GIMP. You can <a href="http://downloads.sourceforge.net/launchy/LaunchySetup125.exe?modtime=1177060449&amp;big_mirror=0">download Launchy</a> from its website and its <a href="http://www.launchy.net/LaunchySetup199_1.exe">beta</a> is pretty stable (and gorgeous) on my XP laptop too.</p>
<p>Using Launchy gets pretty addictive and soon you will hate using the Start menu or even Explorer on Windows for opening applications or files. So I took the red pill and started automating the following things with a little help from Python:</p>
<ul>
<li>Launching Intranet applications inside Internet Explorer (even if Firefox is your default browser)</li>
<li>Bringing minimized or overlapped windows to the foreground</li>
</ul>
<h3>Some Necessary Evil</h3>
<p>Don&#8217;t get me wrong, I hate IE as much as you do. But the fact of life is that many web apps out there &#8220;Work best when viewed in IE&#8221; (TM). Even if you have launchy plugins to launch the web app, if your default browser is Firefox, it might show incorrectly. Here is the solution:</p>
<ol>
<li>Install <a href="http://www.python.org/download/releases/">Python</a> and <a href="http://sourceforge.net/project/platformdownload.php?group_id=78018<!--a356f40d910087cee9142fddb0a224fb--><!--e9c7a4b871b077caf3e685ae3481471e--">Pywin32</a></li>
<li>Copy the following script to the Utilities directory (it will be in the path where you installed Launchy) and save it with a <strong>.pyw</strong> extension not a <strong>.py</strong> extension</li>
</ol>
<div>
<textarea name="code" class="python:nogutter" cols="60" rows="10">
    from win32com.client import Dispatch
    ie = Dispatch("InternetExplorer.Application")
    ie.Visible = True
    ie.Navigate(r"http://intranetapp/home")
    </textarea>
</div>
<p>In the above code replace the URL <strong>http://intranetapp/home</strong> with the URL of your choice.</p>
<p>Finally, open Launchy, right-click and say &#8216;Rebuild Index&#8217;.</p>
<h3>No more Alt-Tabbing around</h3>
<p>If you are like me, you&#8217;ll have a lot of windows open at the same time. I have tried increasing the task bar height and grouping similar windows feature in XP to manage them. But I always wish I could invoke commonly used open applications like my chat window in just a few keystrokes. Launchy doesn&#8217;t index open programs by default, but with some python magic I can show you how to bring some commonly used windows to the foreground:</p>
<ol>
<li>As before, install <a href="http://www.python.org/download/releases/">Python</a> and <a href="http://sourceforge.net/project/platformdownload.php?group_id=78018<!--a356f40d910087cee9142fddb0a224fb--><!--e9c7a4b871b077caf3e685ae3481471e--">Pywin32</a></li>
<li>Copy the following script to the Utilities directory (it will be in the path where you installed Launchy) and save it with a <strong>.pyw</strong> extension not a <strong>.py</strong> extension</li>
</ol>
<div>
<textarea name="code" class="python:nogutter" cols="60" rows="10">
    import sys
    from win32gui import GetWindowText, EnumWindows, ShowWindow, SetForegroundWindow 
    from win32con import SW_RESTORE, SW_SHOW 

    TITLE_MATCH = "Microsoft Excel - Expenses.xls"

    def listWindowsHandles():
        res = []
        def callback(hwnd, arg):
            res.append(hwnd)
        EnumWindows(callback, 0)
        return res

    def listWindowsNamesAndHnd():
        return [(hwnd, GetWindowText(hwnd)) for hwnd in listWindowsHandles()]

    def unminimizeWindow(a_hwnd):
        ShowWindow(a_hwnd, SW_RESTORE)
        SetForegroundWindow(a_hwnd)

    def finder1():
        for hwnd, title in listWindowsNamesAndHnd(): 
            if TITLE_MATCH in title: 
                unminimizeWindow(hwnd)

    finder1()
    </textarea>
</div>
<p>In the above code change the string <strong>Microsoft Excel - Expenses.xls</strong> with the title the window you would like to summon.</p>
<p>Finally, open Launchy, right-click and say &#8216;Rebuild Index&#8217;.</p>
<p>This works even if the window was minimized.</p>
<p>I hope, finally you can throw your mouse away. Ah&#8230; What a bliss!</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F&#038;title=Work+Faster+in+Windows+With+Launchy+and+a+few+Python+Scripts" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F&#038;title=Work+Faster+in+Windows+With+Launchy+and+a+few+Python+Scripts" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F&#038;t=Work+Faster+in+Windows+With+Launchy+and+a+few+Python+Scripts" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F&#038;T=Work+Faster+in+Windows+With+Launchy+and+a+few+Python+Scripts" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F&#038;title=Work+Faster+in+Windows+With+Launchy+and+a+few+Python+Scripts" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F12%2F04%2Fwork-faster-in-windows-with-launchy-and-a-few-python-scripts%2F&#038;title=Work+Faster+in+Windows+With+Launchy+and+a+few+Python+Scripts" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2007/12/04/work-faster-in-windows-with-launchy-and-a-few-python-scripts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making Python Scripts Show Windows-friendly Errors/Stacktrace</title>
		<link>http://www.arunrocks.com/blog/archives/2007/06/20/making-python-scripts-show-windows-friendly-errorsstacktrace/</link>
		<comments>http://www.arunrocks.com/blog/archives/2007/06/20/making-python-scripts-show-windows-friendly-errorsstacktrace/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 19:33:41 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

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

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

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/archives/2007/06/20/making-python-scripts-show-windows-friendly-errorsstacktrace/</guid>
		<description><![CDATA[Most of us love to distribute our python programs to others once you have finished coding a neat little script. For Windows users we package it using Py2exe or cx_freeze. However, many of the end-users will not be happy with a black command window popping up, say, when an error is thrown.
Of course the alternative [...]]]></description>
			<content:encoded><![CDATA[<p>Most of us love to distribute our python programs to others once you have finished coding a neat little script. For Windows users we package it using <a href="http://www.py2exe.org/index.cgi/">Py2exe</a> or <a href="http://www.cxtools.net/default.aspx?nav=cxfrlb">cx_freeze</a>. However, many of the end-users will not be happy with a black command window popping up, say, when an error is thrown.</p>
<p>Of course the alternative is to write a full blown GUI application using <a href="http://www.wxpython.org/">WXPython</a> or <a href="http://pyfltk.sourceforge.net/">PyFLTK</a>. Even the latter, though quite lightweight, adds several megabytes to the distribution, when all you need is a simple message-box indicating an error or showing some informational text. Clearly, its an overkill for your throwaway python scripts.</p>
<p>This is the kind of problem I typically face and I have found a good solution. The answer is <a href="http://python.net/crew/theller/ctypes/">ctypes library</a> which comes as a part of the standard distribution from Python 2.5 onwards. It simply calls the messagebox function from user32.dll (which is always present in a windows installation). With the main problem solved, what remained was to obtain the error text and stack trace.</p>
<p>Let&#8217;s see how the code looks like:</p>
<div>
<textarea name="code" class="python:nogutter" cols="60" rows="10">
    # Importing all the works for a native Win32 Message Box        
    from ctypes import c_int, WINFUNCTYPE, windll
    from ctypes.wintypes import HWND, LPCSTR, UINT
    prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT)
    paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0)
    MessageBox = prototype(("MessageBoxA", windll.user32), paramflags)

    # For printing the stack
    import sys
    import traceback
    from time import sleep

    def show_popup(text):
        print text
        MessageBox(text=text, caption="Sample App Says...")

    def mainloop():
        raise "Uff!"
        
    if __name__ == '__main__':
        try:
            mainloop()
        except:
            type, value, sys.last_traceback = sys.exc_info()
            lines = traceback.format_exception(type, value,sys.last_traceback)
            show_popup("Aiyooooo..... there has been an error!\n" + 
                "Exception in user code:\n" +
                "".join(lines) +
                "===== Please mail a screenshot to arunvr@gmail.com ===="
                )
        finally:
            sleep(1) # show the console output for a second so that users can read it

    </textarea>
</div>
<p><em>EDIT:</em> This is how it looks like in PyMail, one of my scripts-that-grew-into-an-app <img src='http://www.arunrocks.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img src="http://i17.tinypic.com/61oz9d3.jpg" alt="Screenshot of a Python Stacktrace in a Messagebox" /><!--12850e4e5bbcaead4138d9450f16213b--></p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F&#038;title=Making+Python+Scripts+Show+Windows-friendly+Errors%2FStacktrace" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F&#038;title=Making+Python+Scripts+Show+Windows-friendly+Errors%2FStacktrace" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F&#038;t=Making+Python+Scripts+Show+Windows-friendly+Errors%2FStacktrace" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F&#038;T=Making+Python+Scripts+Show+Windows-friendly+Errors%2FStacktrace" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F&#038;title=Making+Python+Scripts+Show+Windows-friendly+Errors%2FStacktrace" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2007%2F06%2F20%2Fmaking-python-scripts-show-windows-friendly-errorsstacktrace%2F&#038;title=Making+Python+Scripts+Show+Windows-friendly+Errors%2FStacktrace" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2007/06/20/making-python-scripts-show-windows-friendly-errorsstacktrace/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Windows+Python Integration Like Unix shell</title>
		<link>http://www.arunrocks.com/blog/archives/2005/08/12/windowspython-integration-like-unix-shell/</link>
		<comments>http://www.arunrocks.com/blog/archives/2005/08/12/windowspython-integration-like-unix-shell/#comments</comments>
		<pubDate>Fri, 12 Aug 2005 11:59:52 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

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

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/?p=69</guid>
		<description><![CDATA[Remember how in UNIX how easy it was to run python scripts? Just type name of the script. No need to even type the extension .py
I got soon fed up with typing
C: > python foo.py
in windows. Digging up some Microsoft documentation, I soon found a way to simply type
C: > foo
and make it work. How? [...]]]></description>
			<content:encoded><![CDATA[<p>Remember how in UNIX how easy it was to run <a href="http://www.python.org/">python</a> scripts? Just type name of the script. No need to even type the extension .py</p>
<p>I got soon fed up with typing</p>
<pre>C: > python foo.py</pre>
<p>in windows. Digging up some <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx">Microsoft documentation</a>, I soon found a way to simply type</p>
<pre>C: > foo</pre>
<p>and make it work. How? read on&#8230;</p>
<p>All you need is to create a batchfile, say &#8217;startme.bat&#8217; with the two lines</p>
<pre>ASSOC .py=PythonScript
FTYPE PythonScript=python.exe %1 %*
set PATHEXT=.py;%PATHEXT%</pre>
<p>If you want this to be the default behaviour everywhere, put this in &#8216;autoexec.bat&#8217;. But wait, we have a better way to do this. You can make &#8217;startme.bat&#8217; work like &#8216;.bashrc&#8217; in UNIX by registry hack. Create a REG file, say &#8216;cmd-changer.reg&#8217; with the contents:</p>
<pre>REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
&#8220;AutoRun&#8221;=&#8221;startme.bat&#8221;</pre>
<p>Now opening this file will merge it to the registry. Now &#8217;startme.bat&#8217; will be run every time you open the command prompt say by typing &#8216;cmd.exe&#8217; in the Run command box. Hope this helps!</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F&#038;title=Windows%2BPython+Integration+Like+Unix+shell" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F&#038;title=Windows%2BPython+Integration+Like+Unix+shell" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F&#038;t=Windows%2BPython+Integration+Like+Unix+shell" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F&#038;T=Windows%2BPython+Integration+Like+Unix+shell" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F&#038;title=Windows%2BPython+Integration+Like+Unix+shell" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F08%2F12%2Fwindowspython-integration-like-unix-shell%2F&#038;title=Windows%2BPython+Integration+Like+Unix+shell" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2005/08/12/windowspython-integration-like-unix-shell/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is Python Intellisense Possible in Emacs?</title>
		<link>http://www.arunrocks.com/blog/archives/2005/06/14/is-intellisense-possible-in-emacs/</link>
		<comments>http://www.arunrocks.com/blog/archives/2005/06/14/is-intellisense-possible-in-emacs/#comments</comments>
		<pubDate>Tue, 14 Jun 2005 14:37:17 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

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

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

		<guid isPermaLink="false">http://www.arunrocks.com/blog/?p=58</guid>
		<description><![CDATA[Like the search for the Elixir of youth or philosopher&#8217;s stone,
I was looking for some kind of Intellisense
feature for Python in Emacs which I have grown used to since my windows
programming days. Yes I&#8217;m referring to the little drop down list
that helps you auto complete class members. I&#8217;m also referring the
tool-tip that appears which shows [...]]]></description>
			<content:encoded><![CDATA[<p>Like the search for the Elixir of youth or <a href="http://en.wikipedia.org/wiki/Alchemy" title="To Wikipedia">philosopher&#8217;s stone</a>,<br />
I was looking for some kind of <a href="http://msdn.microsoft.com/library/en-us/odc_vsto2005_ta/html/officeVSTOCodeSnippets.asp" title="A Microsoft page regarding the feature">Intellisense</a><br />
feature for <a href="python.org/" title="Python: Language">Python</a> in <a href="emacswiki.org/" title="Emacs Wiki">Emacs</a> which I have grown used to since my windows<br />
programming days. Yes I&#8217;m referring to the little drop down list<br />
that helps you auto complete class members. I&#8217;m also referring the<br />
tool-tip that appears which shows a functions signature when you are<br />
calling it. I know that <a href="http://www.python.org/windows/pythonwin/" title="A python IDE">PythonWin</a>, my python editor of choice,<br />
already does this. But I intend to use Emacs as my IDE.<br />
It seems that you have two alternatives, both have issues<br />
as you will see:</p>
<h2>py-complete - Not yet Windows ready?</h2>
<p>Firstly <a href="http://cvs.sourceforge.net/viewcvs.py/python-mode/python-mode/">py-complete</a> seems to require <a href="http://pymacs.progiciels-bpi.ca/index.html" title="Allows emacs users to automate using python">Pymacs</a>. Now, this was<br />
not very obvious. The idea of python helping in completion seems to be<br />
very cool and nearly worked without pymacs. Seems pymacs is not quite<br />
well supported in Windows. As soon as I read this I sort of gave up.</p>
<h2>Semantic Flopped</h2>
<p>Then, I installed <a href="http://cedet.sourceforge.net/" title="Collections of Emacs Development Environment Tools">CEDET 1.0 (beta 3)</a> which gives you <a href="http://www.emacswiki.org/cgi-bin/wiki/SemanticSense" title="Semantic">Semantic</a> inspired by this <a href="http://users.binary.net/thehaas/cgi-haas/blosxom.cgi/comp/emacs/semanticandtags.html">post</a>. It<br />
seemed to be a pain to install the whole thing until I discovered that<br />
you have to keep certain things in the load-path. Finally this is what<br />
I added to my <code>.emacs</code> file</p>
<pre>;; Set up load path
(setq load-path (append (list (concat use-home "site/cedet/speedbar")
(concat use-home "site/cedet/common"))
load-path))
(load-file "~/site/cedet/common/cedet.el") ;; Load CEDET
(semantic-load-enable-minimum-features)</pre>
<p>Now as the post suggests, we have a fully working speedbar but<br />
auto-completion is pretty much weird. For eg: M-x<br />
semantic-analyze-possible-completions describes the scopes you are<br />
currently in.</p>
<h2>Conclusion</h2>
<p>Both approaches are really good though quite different. They haven&#8217;t<br />
made use of the emacs tool-tip library either. Since this is a<br />
crucially lacking feature in Emacs, I might as well do a bit of R&amp;D<br />
on this before giving up the dream.</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F&#038;title=Is+Python+Intellisense+Possible+in+Emacs%3F" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F&#038;title=Is+Python+Intellisense+Possible+in+Emacs%3F" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F&#038;t=Is+Python+Intellisense+Possible+in+Emacs%3F" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F&#038;T=Is+Python+Intellisense+Possible+in+Emacs%3F" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F&#038;title=Is+Python+Intellisense+Possible+in+Emacs%3F" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2005%2F06%2F14%2Fis-intellisense-possible-in-emacs%2F&#038;title=Is+Python+Intellisense+Possible+in+Emacs%3F" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2005/06/14/is-intellisense-possible-in-emacs/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
