Limit download (or upload) rate in PyCurl

abril 22nd, 2008 § 2 comments § permalink

I'm used to work with curl in other programming languages like php or perl, so pycurl became my first choice in python url access libraries .

Pycurl it's not a native module like urllib2, instead is a wrapper for the C library libcurl, it is not as fancy as native python modules are, but is extremely fast and you have lots of features. Also if you want to find documentation about how to use Pycurl is better to look at libcurl's documentation and examples.

And so I did. In libcurl documentation I found which options i could set for libcurl API to limit download bandwidth usage, MAX_RECV_SPEED_LARGE. Note that options in Pycurl are the same that in libcurl without the prefix CURLOPT.

Here is a simple example of how to limit download a file with a 10KB limit rate:

PYTHON:
  1. import pycurl
  2.  
  3. c = pycurl.Curl()
  4. c.setopt(c.URL, "http://python.org/ftp/python/2.5.2/Python-2.5.2.tgz")
  5. c.setopt(c.MAX_RECV_SPEED_LARGE, 10000)
  6. c.setopt(c.WRITEDATA, file("python-2.5.2.tar.gz","w"))
  7. c.perform()

And this is my story :P

Gedit Snipplr Plugin

noviembre 1st, 2007 § 0 comments § permalink

I've just released the first version of the Gedit Snipplr Plugin. This plugin for Gedit provides interaction with the snipplr.com service.

You can search your snippets in gedit, copy then into your documents or upload your favourite pieces of code to snipplr.com directly in the gedit app.

If you are interested you in this plugin visit this link or watch a simple screencast to see the plugin in action.

Cheers!

Where Am I?

You are currently browsing entries tagged with python at arde en el infierno.