Archive for the ‘Python’ Category

Executing an external program in Python…

Wednesday, November 19th, 2008

There are several ways of executing an external program from Python, but I had
the problem to catch the standard output.

After a while I came to the following solution:

import os

# Executing a shell command
mycmd = "python"
child_stdin, child_stdout, child_stderr = os.popen3(mycmd)

# Reading the output streams
my_output =
my_error =

print "my_output:", my_output
print "my_error:", my_error


PyQt4 Tutorial

Thursday, June 26th, 2008

PyQt4 is the wrapper for Trolltech’s Qt4 libraries. On the riverbank site you can find the sources and the windows binary; ubuntu seems to ship the binary on the official release, simply look for pyqt in synaptic.

Here is a good PyQt4 tutorial: zetcode

And here another good in Italian: un tutorial facile facile

Anybody knows about the binary on mac? I’ve found something on finkproject: anybody tested it?


Scripting Second Messenger

Friday, June 13th, 2008

I’m extending the Second Messenger by adding scripting capabilities.

I already have embedded a python engine in it and I’m working on a wrapper of the client object (I can’t give you all the power, sorry ;-).

I’m currently struggling with architectural issues and I hope to have a public version soon…

…maybe so soon that will have at first the ability to automatically answer to ScriptDialog messages. What for? Many camping chairs prompts the user with questions and possible answers: why not letting an automatic script to respond instead? ;-)

The next step could be to monitor group messages and automatically ban spamming people from your group.

Nice, huh?

Xmlrpclib with cookie aware transport

Friday, June 13th, 2008

Using Python made me fall in love with XmlRPC. The python xmlrpclib is great and I’m using this protocol with C# and PHP too.

The problem
Any call to an xmlrpc server is stateless, so that you are forced to send state information back and forth through additional parameters.

The solution
So that i dediced to write a transport object that keeps track of the session id cookies sent by the server.

Here’s the code:


wxWidgets and Ubuntu

Monday, April 21st, 2008

To keep your wxwidgets up-to-date on your ubuntu, simply add

deb gutsy-wx main

to your /etc/apt/sources.list file. Then run

sudo apt-get update

to get the wx package list. Then type:

sudo apt-get install libwxgtk2.8-0 libwxgtk2.8-dev wx2.8-headers wx-common

or open synaptic to update your wx libraries.

Note that also the python bindings will be available for upgrade :)


Iron Python: the output stream.

Monday, April 7th, 2008

I needed to embed IronPython in my Second Messenger project. So i wrote a small interactive console looking like this:

Python Console

where in the upper section i write my code and sending the output stream on the bottom section.


Roberto Rocco Angeloni is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

Fatal error: Cannot access protected property ObjectMgr::$_verbose in /web/htdocs/ on line 22