Twitter client for Maemo in Qt + Python: call for developers and UI designers

Linux, Maemo (EN), MeeGo, Programmazione, Python, Qt 14 Comments »

Introduction

My name's Andrea Grandi, I'm italian and I'm a Maemo user/lover/contributor since the Nokia 770. I love Python as development language and few months ago I also gave some contributions to the PyMaemo project.

In these days I had the idea to start writing a Twitter client for Maemo with a precise direction in my mind. I'll try to explain all my reasons here. First of all I've to thank the author of Mauku client. I use it since its first version and I'm quite happy with it. Then, why do I want to write another one?

  1. Maemo (MeeGo) is moving to Qt and for this reason I'm going to use Qt, while Mauku uses Gtk.
  2. I'm learning Qt and what is better than writing a complete (but not too complex) application to learn better?
  3. Mauku is not free as lot of people could think. Reading the source codeyou find this "You are NOT allowed to modify or redistribute the source code.", while I want to write a client and release it under GPL2 or GPL3 license.
  4. Mauku is not updated since some months and we have no news about it.
  5. I love Python and I like to write free software in this language.
  6. I want to give to Maemo a stronger contribute.

My request for help

Before lot of people start writing their own client resulting in 4-5 twitter clients for Maemo, why don't we join our strength and work to a common project? I'm not a Python expert nor a Qt one, but I've some experience as project/team leader and since this is not a complex project, I would be glad to lead it. So, I'm looking for Python developers, Qt developers, UI designers and whoever want to contribute to this project. I still have to find a good name and logo for this application.

Who want to help me?

Writing Python bindings of existing C libraries – (3) – Building and Installing with distutils

HowTo, Igalia, Linux, Maemo (EN), Programmazione, Python 1 Comment »

In the last post of this series, we saw how to write a simple binding and we finished to build and install it manually. This is of course not a good way to manage the building/installation procedure.

In Python we can use a library called distutils that let us to automatize the building and installing process. I'll use the foo source code to create the package, so it will be easier to understand.

Using distutils

All we have to do is to write a setup.py file similar to this one:

from distutils.core import setup, Extension

foomodule = Extension('foo', sources = ['foo.c'])

setup (name = 'Foo',
       version = '1.0',
       description = 'This is a package for Foo',
       ext_modules = [foomodule])

As you can see, we have to first import needed modules with: from distutils.core import setup, Extension
then we create an entry for each module we have (in this case just one, "foomodule"). We then call the setup() method passing it all the parameters and our setup.py is complete.

Building and installing

To test it we can try to build the package in this way:

python2.5 setup.py build

if we want to install the module in our system:

python2.5 setup.py install

References

PyMaemo (Python for Maemo) second beta release for Fremantle

Igalia, Linux, Maemo (EN), Programmazione, Python 1 Comment »

The PyMaemo team is pleased to announce the second beta release of PyMaemo for Fremantle!

This new release is available through the extras-devel repository, see installation instructions in
http://pymaemo.garage.maemo.org/sdk_installation.html#fremantle

What is it?

Python for Maemo (PyMaemo for short) main objective is to make possible to use Python programming language as the scripting and development language for Maemo Platform, providing a better alternative for fast prototyping and programming in Maemo environment besides the C programming language.

Python is for serious programming and to have fun. Python has a nice syntax, it is easy to learn and powerful enough for a vast range of applications, this is why we choose Python for Maemo.

What has changed?

New packages:

  • python-mafw (0.1-1maemo1)
    • Python bindings for the Media Application Framework [1]
    • Supported API is very basic at the moment, and there are some bugs. Feedback is welcome!
  • python-hildondesktop (0.0.3-1maemo1)
    • Python bindings for the home/status widgets API
  • python-notify (0.1.1-2maemo1)
    • Python bindings for libnotify
  • pyclutter (0.8.0-1maemo2)
    • Python bindings for the Clutter API [2]
    • Experimental package, waiting for developer feedback

Updated packages:

  • gnome-python (2.26.1-1maemo1)
    • major upgrade, matching current Debian testing release;
    • feedback on this is welcome, as it replaces a fairly old version (2.18).
  • pygtk (2.12.1-6maemo7)
    • Enable glade support.
  • python2.5 (2.5.4-1maemo1)
    • Updated to latest upstream 2.5.x release.
    • add support to --install-layout=deb flag.
  • python-central (0.6.11.1maemo1)
    • dependency needed by the new python-setuptools version.
  • python-defaults (2.5.2-3maemo3)
    • Change PREVVER in debian/rules, avoiding old python2.5-minimal versions that had "/usr/bin/python" and thus conflicts with python-minimal.
  • python-hildon (0.9.0-1maemo10)
    • lots of bug fixes
  • python-setuptools (0.6c9-1maemo1)
    • add support to --install-layout=deb flag.

Bugs fixed: MB#4530 [3], MB#4450 [4], MB#4629 [5], MB#4628 [6],
MB#4647 [7], MB#4632 [8],  MB#4646 [9],  MB#4750 [10],  MB#4749 [11],
MB#4791 [12]

Known issues

MB#4782 [13]: osso.Context causes segmentation fault
MB#4821 [14]: Cannot create HildonTouchSelector with single text column
MB#4824 [15]: python-mafw: source_browsing.py example does not work
MB#4839 [16]: python-mafw: mafw.Registry lacks list_plugins() method
MB#4849 [17]: python-mafw: MafwPluginDescriptorPublic structure is missing

We will not migrate to python2.6 in fremantle due to a (unresolved) bug (MB#4734 [18]), where a core SDK package explicitly conflicts with python >= 2.6, preventing any further upgrades from the 2.5.x series.

This release is supposed to be compatible with previous releases. If you have any issues regarding building your Python application on Fremantle, feel free to report it on the pymaemo-developers mailing list [19].

Acknowledgments

Thanks to everybody who helped making this release possible.

Bug reports, as always, should go to our Bugzilla [20]. Use the pymaemo-developers mailing list for help, feedback or suggestions.

References

[1] https://garage.maemo.org/projects/mafw/
[2] http://www.clutter-project.org/
[3] https://bugs.maemo.org/show_bug.cgi?id=4530
[4] https://bugs.maemo.org/show_bug.cgi?id=4450
[5] https://bugs.maemo.org/show_bug.cgi?id=4629
[6] https://bugs.maemo.org/show_bug.cgi?id=4628
[7] https://bugs.maemo.org/show_bug.cgi?id=4647
[8] https://bugs.maemo.org/show_bug.cgi?id=4632
[9] https://bugs.maemo.org/show_bug.cgi?id=4646
[10] https://bugs.maemo.org/show_bug.cgi?id=4750
[11] https://bugs.maemo.org/show_bug.cgi?id=4749
[12] https://bugs.maemo.org/show_bug.cgi?id=4791
[13] https://bugs.maemo.org/show_bug.cgi?id=4782
[14] https://bugs.maemo.org/show_bug.cgi?id=4821
[15] https://bugs.maemo.org/show_bug.cgi?id=4824
[16] https://bugs.maemo.org/show_bug.cgi?id=4839
[17] https://bugs.maemo.org/show_bug.cgi?id=4849
[18] https://bugs.maemo.org/show_bug.cgi?id=4734
[19] https://garage.maemo.org/mailman/listinfo/pymaemo-developers
[20] https://bugs.maemo.org/enter_bug.cgi?product=PyMaemo

Credits

This post was possible thanks to Anderson Lizardo, from PyMaemo team, who posted these informations on pymaemo-developers mailing list.

Writing Python bindings of existing C libraries – (2) – A simple example of binding

HowTo, Igalia, Linux, Maemo (EN), Programmazione, Python 1 Comment »

Introduction

As I promised in the preceding post, I'll provide a very easy example of a python binding. Let's suppose we don't want to use the methods included in Python to sum two integer values and we want to do it in C and then call the add method from a python script. I'll write the complete source code first and then I'll explain all the parts of it.

Source Code

#include <Python.h>

static PyObject *foo_add(PyObject *self, PyObject *args)
{
	int a;
	int b;

	if (!PyArg_ParseTuple(args, "ii", &a, &b))
	{
		return NULL;
	}

	return Py_BuildValue("i", a + b);
}

static PyMethodDef foo_methods[] = {
	    { "add", (PyCFunction)foo_add, METH_VARARGS, NULL },
	    { NULL, NULL, 0, NULL }
};

PyMODINIT_FUNC initfoo()
{
	    Py_InitModule3("foo", foo_methods, "My first extension module.");
}

How it works

First of all we have to include Python.h in our C file. This allows us to write an extension for Python language. To be able to include this header, we must have the python development packages installed in our system. For example in Debian based distributions we can install them with this command:

sudo apt-get install python2.5-dev

Every module has at least three parts. In the first part we write methods we want to call from the final python module: in this case we have a method called foo_add where "foo" is the name of the module and "add" the name of the method. Every method is declared as static PyObject. The method does anything particular except calling PyArg_ParseTuple to validate the input (we'll discuss this later), adding the two passed numbers and returning the result.

In the second part we have something like a dictionary, defined as static PyMethodDef and called foo_methods (where "foo" again is the name of the module). For each method we want to expose in our python module, we have to add something like this:

{"add", (PyCFunction)foo_add, METH_VARARGS, NULL}

where "add" is the name of the method we want to be visible in our module, (PyCFunction)foo_add is a pointer to our foo_add method, implemented in the C module, METH_VARARGS means that we want to pass some parameters to the function and the last one would be the description of the method (we can leave it NULL if we want).

Third part allows us to register the defined method/s and the module:

Py_InitModule3("foo", foo_methods, "My first extension module.");

Parsing Parameters

The PyArg_ParseTuple function extracts arguments from the PyObject passed as parameter to the current method and follows almost the sscanf syntax to parse parameters (in this case we had "ii" for two integers). You can fin the complete reference here: http://docs.python.org/c-api/arg.html

Building and installing

To build the module, we have to be in the source directory and execute this command:

gcc -shared -I/usr/include/python2.5 foo.c -o foo.so

then we've to copy the generated module to the python's modules directory:

cp foo.so /usr/lib/python2.5/site-packages/

Testing our module

Testing the module is really easy. We've to start a python shell or create a python script with the following source code:

import foo
print foo.add(2, 3)

if all is working fine, the printed result should be 5

References

python2.5-dev
python2.5-dev

MAFW and Python: asking for developers feedback

Igalia, Linux, Maemo (EN), Programmazione, Python 4 Comments »

MAFW is a new multimedia framework that will be used in Fremantle.

The PyMaemo team is currently working on writing bindings for Python
language for this library and at the moment we've released a 0.1
version of python-mafw that you can install directly from Scratchbox
repository.

Not all the methods are implemented (you can manage the Registry and
the Playlist, but nothing more), because even if we're using codegen
to generate bindings (and it's helping us a lot), we've seen that at
least 30-40 methods have to be overridden by hand so it's taking us
more time than we expected and we're trying to organize how to
continue this work.

We would like to get feedback from python application developers and
also from C application developers that are currently using MAFW so we
can work on a "roadmap" that reflects what developers want:

  • What are the functionalities you're using in your application that you think they cannot miss in the Python binding?
  • Have you already started using MAFW or even better python-mafw to develop something?
  • What is the currently missing method/methods you would like to be implemented first?

Come on developers! We're waiting for your feedback :)

Writing Python bindings of existing C libraries – (1) – Introduction

HowTo, Igalia, Linux, Maemo (EN), Programmazione, Python 2 Comments »

This summer I'm having the pleasure of working in Igalia (a spanish free software company) for a couple of months and they assigned me to an interesting project: developing Python bindings for MAFW library (a Maemo multimedia library that will be used in Fremantle release).

Having the opportunity to work both with C (yes, Python bindings are almost C code) and Python (it's a good practice to write unittest of all implemented methods) it's a good way to improve my knowledges in both languages and since I wasn't able to find much documentation about these kind of things, I'm going to share my own experiences.

What is a Binding?

A binding is a Python module, written in C language, that allows Python developers to call functions from existing C libraries from their python applications. It's just like a "bridge" from C world to Python one.

Why writing bindings?

There are a couple of reasons to write python bindings instead of writing a library in python language from scratch.

First of all I don't think is good duplicating code, so if a library already exists and it's written in C, why writing it again in another language? There's no reason. A lot of code already exist in C world and all we have to do is to create a bridge with python world.

Another good reason, in particular when a C library doesn't exist yet, is the fact that python code is slower than C code for some tasks (for example multimedia codecs). In these cases is good to implement the core library in C language and then create a python binding for it.

Coming next

As the title of this post says, this is only an introduction to the subjects I'm going to write about. If you have any particular request about any argument you would like to read, please feel free to leave me a comment. Next posts will talk about these things:

  • A simple example of binding: I'll write a simple library in C language and I'll show how to create the relative python binding, providing complete source code and an example for python developers.
  • Building and installing python bindings with distutils: I'll explain how to use distutils to build and install the binding (using the well know method "python setup.py install").
  • Defining new types: this post will be about how to write new types in C language and being able to use them from python code.
  • Using codegen to write bindings: I'll explain how to use codegen utils to automate lot of tasks, to generate the most part of binding code and how to customize the generated code using overrides.

I officially joined the PyMaemo team

Igalia, Linux, Maemo (EN), Programmazione, Python 7 Comments »

This summer I'm working for 2 months at Igalia, a spanish free software company, and they assigned me the project of writing a Python binding for MAFW (a new multimedia library that will be included in Freemantle).

After few days I discovered that PyMaemo team was already working to it, so I asked to join them and they accepted me!

I really love Python language and since I think other developers love it too, I think we should provide good bindings for every library available in Maemo, so lot of developers can start writing their applications in this language.

I'll work to this project full time until the first week of september, so I hope to be able to learn a lot and to contribute as much as I can to this project.

If anyone else want to join PyMaemo team and help us to develop Python bindings, I think he will be welcome!

Develop a GPS-aware application for the Nokia N810

HowTo, Linux, Maemo (EN), Programmazione, Python 2 Comments »

Paul Ferrill has written a serie of three articles about writing a GPS-aware application for the Nokia N810, using the Maemo SDK, Eclipse and PluThon plugin.

Here is the complete serie:

ControlEee – Control panel for EeePC

EeePC, Linux, Python, Qt 3 Comments »

ControlEee è una piccola applicazione che ho scritto utilizzando Python/Qt4 e che permette di abilitare/disabilitare i dispositivi del bluetooth, della webcam e della wlan su un Asus EeePC.

Installando una versione personalizzata di Linux sugli EeePC (come ad esempio la Ubuntu-eee), non si ha la possibilità di attivare/disattivare questi dispositivi in maniera semplice (è possibile farlo solo da riga di comando) e di conseguenza si rischia di tenere attivate queste periferiche anche se non le utilizziamo, con lo svantaggio di consumare inutilmente piu' batteria di quella di cui abbiamo bisogno.

Non trovando niente di semplice di già pronto in giro, mi sono deciso a scrivere questa utility. Al momento è in hosting presso Google Code e la potete trovare a questo indirizzo: http://code.google.com/p/controleee/

Al momento l'applicazione è stata testata soltanto su un Asus EeePC 901 con la distribuzione Ubuntu-eee 8.04.1, non è quindi garantito il funzionamento anche sugli altri modelli e/o utilizzando altre distribuzioni.

Skype SMS su Linux: grazie a Skype4Py si puo’!

Linux, Programmazione, Python, Skype 6 Comments »

Skype LogoIl client di Skype per Linux non supporta al momento l'invio degli SMS. Questa puo' essere per molti una grossa limitazione, visto che è molto conveniente come metodo per inviare gli sms (costano 10 centesimi) rispetto a molte tariffe in circolazione al momento, con i principali gestori italiani.La mancanza di questa funzionalità è però soltanto apparente! Infatti è stata già implementata a livello di librerie di Skype ed è già disponibile tramite le API.

Grazie alla libreria Skype4Py, ufficialmente supportata da Skype e sviluppata da Arkadiusz Wahlig (che ha tenuto un talk proprio su questo argomento nella giornata di ieri del PyCon Due), è possibile scrivere applicazioni multipiattaforma (Windows, Linux, Mac) che interagiscano con Skype.

Una volta installata la libreria nel proprio sistema, dobbiamo soltanto avviare il client Skype.

Le applicazioni che possiamo scrivere, per automatizzare alcune funzioni di Skype, sono moltissime. In questo caso particolare farò vedere un piccolo script Python che invia un SMS utilizzando il client (ed il credito) dell'istanza di Skype che sta girando sulla vostra macchina:

import Skype4Py

number = '+393*********'
text= 'Messaggio di prova da PySms4Skype!'

skype = Skype4Py.Skype()
skype.FriendlyName = 'PySms4Skype'

skype.Attach()

sms = skype.CreateSms(Skype4Py.smsMessageTypeOutgoing, number)
sms.Body = text
sms.Send()

Quando eseguite questo script, Skype vi chiedera' la conferma per autorizzare la vostra applicazione ad utilizzare le API, basterà quindi dare conferma per continuare. Nello script ovviamente dovrete sostituire il numero di telefono con uno valido.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in