Archive

Archive for the ‘python’ Category

python-requests package update

April 1, 2012 1 comment

The newest version of python-requests now supports python 3. The python 3 version of requests is available as python3-requests package. Thanks Rex Dieter for the patch https://bugzilla.redhat.com/show_bug.cgi?id=807525 . I have also decided to maintain python-requests for EL6, i have pushed the latest version 0.11.1 to EL6.

Though it violates the updates policy https://fedoraproject.org/wiki/Updates_Policy, i have updated python-requests from 0.6.6 to 0.10.8 in Fedora 16 as python-requests is a fast moving young project.

All the packages should land in updates-testing in a few days. Please visit https://admin.fedoraproject.org/updates/python-requests to learn more about the updates.

Trip to Sastra University – Trichy

February 6, 2012 1 comment

I was invited to visit Sastra universityTrichy for a workshop on Free Software. I joined with Aditya and Srishti at KPN office bangalore. We boarded an air-conditioned  sleeper coach by 11.30 P.M and reached Trichy by 6 AM. The road was bit bumpy, i couldn’t sleep much.  As expected Trichy was much warmer than Bangalore in the morning. Trichy main bus stand has couple of Kamaraj statues. Sristi was surprised to see the ‘Golden’ statues of kamaraj.

While we were discussing about kamaraj, our cab arrived. The Sastra university is 45 minutes drive from Trichy. It is located between Trichy and Tanjore. We were asked to stay at the Guest house.

By 10 A.M i started my session on Free Software at one of their ‘smart classrooms’. I explained students about free software and its importance. My second talk was on GNU/Linux Commands, the talk was based on Stanford universities open classroom session on PracticalUnix. Students tried various commands on their laptops as i explained them. Aditya introduced python and  Srishti introduced QT to students on the first day.

We  had a good dinner at ‘Canopy’ Sastra’s canteen which is being managed by students. We finished the dinner with a tasty creamy cold coffee sponsored by Srishti. I was very tired after travel; so i went to bed early.

After a good sleep, I started the second day by introducing Django to students. I explained Django by creating a small blogging application. Many students tried to follow my instructions and came up with the small blogging website (Yay!). Next I joined with Sristi and introduced git revision control system to students using Shakthi‘s ‘di-git-ally-managing-love-letters‘ presentation. The students loved it! Aditya did a workshop on puppet on the second day. We also met the I.T department professor and had a little talk. She presented us with a memento .

By 6.30 P.M we left the college by saying good bye. We had to board the bus at Tanjore. Tanjore is famous for its Brihadeeswarar Temple. It was built on 11th century. We visited the temple and spent some time there. After dinner , we boarded the bus back to Bangalore. Srishti took lot of pictures during the visit (will be uploaded soon)

New Package: Python-requests – HTTP for Humans

August 17, 2011 Leave a comment

According to http://docs.python-requests.org/en/latest/index.html

Most existing Python modules for sending HTTP requests are extremely verbose and cumbersome. Python’s builtin urllib2 module provides most of the HTTP capabilities you should need, but the api is thoroughly broken. It requires an enormous amount of work (even method overrides) to perform the simplest of tasks.

Things shouldn’t be this way. Not in Python

Sample code

>>> r = requests.get(‘https://api.github.com’, auth=(‘user’, ‘pass’))
>>> r.status_code
204
>>> r.headers['content-type']
‘application/json’
>>> r.content

The same sample , without using requests would look like https://gist.github.com/973705. Requests library indeed reduces the lines of code we have to write to set up HTTP requests.

The new library is available as python-requests in  Fedora. You can test the packaging using the following command

yum –enablerepo=updates-testing install python-requests

Have fun!

Categories: fedora, foss, fun, Packaging, python Tags: , ,

Presentation on basics of Django

May 1, 2011 Leave a comment

I did a presentation on basics of Django in chennai python user group (chennaipy) meeting last week. This post contains the presentation and code samples i used in the talk.

The presentation and code samples were designed to help Django newbies.  There are some differences in  the code i used in the presentation and the actual code samples , also i was not able to get the alignment of python code correct in the presentation.

The presentation can be downloaded from here

The code samples and source of the presentation (latex-beamer) are available under GNU Free documentation license  https://gitorious.org/saga-presentations . Feel free to modify them for your own needs :-)

Django , Interpolate two strings in a template

April 15, 2011 Leave a comment

While i was working on my weekend project http://downloader.zer0c00l.in/,  I had to concat  interpolate two strings inside a template,  first string was hard coded in the template and another one had to be passed from the view. Initially i tried something like

<a href="/view/logs/?page="{{ page }}> next </a>

That resulted in <a href=”/view/logs/?page=”>next</a> .  Django completely ignored the {{ page }}. After scratching my head for a long time i removed the quotes and rewrote the code into

<a href=/view/logs/?page={{ page }}> next </a>

That worked as expected.

Categories: django, fedora, foss, fun, python, webdev Tags: ,

Behaviour of ConfigParser.read() – Python

February 7, 2011 1 comment

I am playing around with python for a while. My code uses ConfigParser to parse a piece of configuration file. Now the documentation says ConfigParser.read() accepts list of file names as an argument and tries to read them one by one and returns the list of files that are read successfully.This behaviour is helpful when you have multiple configuration files all across your system.

what the documentation doesn’t tell you is, which configuration file it will use for further processing in case of multiple successful reads. ConfigParser actually uses the last read file for further processing. So prioritize your  configuration files accordingly

import ConfigParser

config_parser = ConfigParser.ConfigParser()

filenames = ['low_priority_file','medium_priority_file','high_priority_file']

config_parser.read(filenames)

Categories: fedora, foss, fun, hack, python Tags: , ,
Follow

Get every new post delivered to your Inbox.

Join 894 other followers