Archive

Archive for the ‘Python’ Category

My first XChat plugin :)

March 28th, 2008 rohitj 2 comments

Recently I started using IRC a lot. As I was doing some django, PyQT and KDE/C++ development. Yes, its lot of development. And then whenever I want to ask some question on IRC, I have to use pastebin/dpaste. ( dpaste is developed upon django framework. :) ). Now, to dpaste any code, I have to switch to Firefox, I have to use mouse as well. I have to copy paste the link to xchat. This was tedious task for me. So, I started making a plugin for xchat so that I could easily paste my code. Fortunately XChat has python plugin interface.

This plugin runs with the command:

/dpaste language

If you keep <language> empty, it will assume it to be “Plain”. You can use any language supported by dpaste.com. The command will open a gtk window, in which you can paste your code. And then “dpaste” button will copy paste the link (containing your code) on your xchat input box. :) . As of now I am sure, it works fine in IITK proxy system. I am pretty much sure it will work fine if you are behind no proxy.

Before using the proxy, you will need to change few parameters in the script, namely “proxy_username”, “proxy_password”, “proxy_server”, “proxy_port”. If you are not behind proxy, just keep “proxy_server” empty.

Also, you should install python module “ClientForm”, “pygtk”, and “urllib2″.

aptitude install python-clientform python python-gtk2

To load the script, a simple way is /load <path to plugin file> . Or you can copy the script in ~/.xchat2 folder. That way the script will be loaded whenever you open xchat.

You can download the code from here. As of now I haven’t made docs, but its an easy plugin, and some commenting as well. :)

Updates : Download the plugin version 0.6, and you don’t need to change anything in it. The plugin uses xchat proxy settings by itself. :)   As of now, http proxy and no proxy is supported.
http://rohitj.net/myscripts/xchat_plugin_dpaste

Categories: FOSS, Fun, GTK, Python, dpaste, xchat Tags:

How to run feedparser behind proxy

March 13th, 2008 admin No comments

So, I had to change the feedparser code to run it behind proxy. Basically the idea is that python by default doesn’t user environment variables http proxy. You have to specify it in the python code.

In feedparser code, url is accessed at the line # 1895. Now, opener has to have http settings so that it could access the url. For that, I added 2 lines before calling opener:

proxy_support = urllib2.ProxyHandler({"http" : "http://<username>:<passwd>@<proxyserver>:<proxyport>"});
opener = urllib2.build_opener(proxy_support)

Here is the final feedparser : FeedParser With Proxy Support

Categories: FeedParser, Proxy, Python Tags:

I will let you feel jealous!!!

January 26th, 2008 admin 3 comments

Linux Stickers on Laptop

Categories: Debian, Firefox, Linux, Python Tags: