Staz's blog

Aller au contenu | Aller au menu | Aller à la recherche

vendredi, août 5 2011

Desktop Summit schedule for smartphones (N900 and others)

Good news for the people who want to access the Desktop Summit Schedule via their smartphone !

I just made it available the xml/pentabarf format, which in practice mean you can use import it directly in applications such as sojourner (for n900) and giggity (for android)

If you have an N900 this is directly implemented in wjt's excellent sojourner (thank afranke for the icon), so you just need to install or update sojourner and it will automatically have the schedule for the desktop summit.

For giggity and others applications (anyone know a proper application for IPhone?) you just need to input the url

I will try to keep the schedule up to date during the summit in case they are modifications (just need some time to wire the website scrapper script to cron)

Again thanks to afranke, wjt and the desktop summit organizers for their help.

Obviously, I'm going to desktop summit too ! see you all this weekend !

Update: There was an error with the favourite not being saved in sojourner once you relaunched the application, it has now been fixed in the xml but unfortunately sojourner don't update it correctly so you need to remove sojourner cache in .config/sojourner/conference/desktopsummit2011 to fix it.

samedi, mai 28 2011

Kindify

Inspired by my friend Bram's script Mobify which convert a webpage to a Kindle Ebook, I decided to made my own version in Python.

I used to keep a ton of open tabs in Firefox as a list of articles to read later. This script allowed me to transform all of them into kindle ebooks and read them later at my ease in public transportation, instead of always keeping them around and never getting the time to read them. As a result I got a lot more reading done.

The general mechanism of this script is to download the page and all its affiliated images, pass it to decruft (a python implementation of the readability algorithm to extract the content of a webpage) and convert it with kindlegen. The nicest improvement over Bram's script is that it doesn't create any files in the current directory but instead write everything in the /tmp directory and move the generated book in a common directory. It also automatically determine the name of the file.

The source code is available on GitHub

dimanche, novembre 21 2010

Error (ERROR_PLATFORM_FAILURE)

* in modules/archiveupload/classes/ArchiveExtractToolkit.class at line 63 (GalleryCoreApi::error)

Just a simple reminder to myself, hoping I see it the next time I stumble on this error in gallery2 when trying to add a zip file. This cryptic error simply means that unzip returned something on stderr.

So next time, before clearing the cache, enabling debug, reading logs and wasting time reading the code : simply verify the zip file is totally valid. You can check it using : zip -T archive.zip

(yes I had tried unziping it but since the error was at the start of a very long list of files that extracted properly I didn't see it)

dimanche, octobre 10 2010

Integrating FlatBlocks with FrontEndAdmin (django)

FrontEndAdmin is a nice Django application allowing you to easily edit/create/delete object directly from your site. By the inclusion of a simple tag into your template, you can bring the power of the admin interface directly into your website. It works pretty well once you have merged some patches

FlatBlocks is similar to FlatPages as it allow to have block of HTML as Django Objects, but works as blocks embeddable in your template instead of complete page.

Here is how to allow editing FlatBlocks directly in your pages [2]. I will commence with the two wrong ways I first did.

The wrong (ie non working) way

Using in your templates :

{% flatblock "myblock" %}
{% frontendadmin_change "myblock" %}

And getting the error :

'myblock' argument must be a model-instance

This doesn't work since myblock is juste a slug name and not a object in your context and FrontEndAdmin need that.

The Bad Way

Dive into FrontEndAdmin code for a few hours. Patch it to add a template tag allowing the edition of any objects.

@register.inclusion_tag('frontendadmin/link_edit.html', takes_context=True)
def frontendadmin_changeblock(context, slug_id, app_model_label, label=None):
    app_label, model_label = app_model_label.split('.')
    model = models.get_model(app_label, model_label)
    model_object = model.objects.get(slug=slug_id)
    return frontendadmin_change(context, model_object, label)


and use it in every template with every block:
{% load frontendadmin_tags %}
{% flatblock "myblock" %} {% frontendadmin_changeblock flatblocks.flatblock "myblock" %}

Working but kind of hacky and now you have to maintain a patch. You also have to add the tag for every block you have in your website.

The Good Way

Copy the flatblock templates' directory in your project's templates dir, Edit the flatblock.html file and add:

{% load frontendadmin_tags %}
{% frontendadmin_change flatblock %}

And that's it. Simple and now all your flatblocks become editable (you can use a separate template if you want some non-editable blocks)

Footnotes :

[1] There are a lot of variations of django-flatblocks, to names a few : django-chunks, django-better-chunks, django-generic-flatblocks, etc... this technique probably works with most of them.

[2] FlatBocks offer some feature to edit blocks in your pages but it require more works than FrontEndAdmin and since I already use FrontEndAdmin for everything else, I prefer to remain consistent

mercredi, septembre 8 2010

Brad Taylor's Snowy talk @Guadec

I've been to Guadec this year thanks to my previous employer Collabora who generously sponsored me to attend. Unfortunately I missed Brad Taylor's talk on Snowy, the web companion for Tomboy.

Fortunately, this year presentations have been recorded, streamed and made available to download by Flumotion. However they are given as hours long video and not splited correctly by talk. So I used Pitivi (with the help of twi) to cut correctly Brad's talk.

You can download it in WebM format here : guadec_snowy_brad_taylor.webm (35 MB).

Here is the abstract of the talk from the Guadec website

Snowy is a web application for synchronizing, viewing, sharing, and editing your Tomboy notes online. It is designed to power an upcoming Tomboy Online free web service where any Tomboy user can make an account.
Tomboy Online will be one of the first web applications deployed by GNOME targeted toward end-users. We will explore the current state of Snowy as a project, the state of Tomboy Online and the various issues encountered during our Alpha and Beta stage deployments, and what the GNOME community can do to contribute.

samedi, septembre 4 2010

Python unit test and vim

Summary : How to get a nice green/red bar for you python unit tests in vim

Recently I have started following my friend Bram advice to do units testing for my python programming. Obviously, I soon wanted to have those unit tests run into vim and get that nice bar that go green or red depending if the code pass or not, the one you see in the nice Gary Bernhardt's screencasts.

Fortunately ReinH made the work easier by already extracting the code to make the red/green bar in a plugin called vim-makegreen (originally RubyRedGreen as it was for ruby)

Here is how I made it works with my python's unit tests, note that I'm using the standard python unit test module but that it work with nose-type tests too.

Pre-requisites

You will need to install nose, a unit testing framework for Python which more importantly provide a nosetests command that detect all the tests in the current directory and run them, this avoid having us create our own python script to do the testing as Tip 280 suggests.

On debian based system it's a simple matter of apt-get install python-nose or you can use easy_install nose

Note that if you don't want to install nose you can still use the Tip 280 way and modify the makeprg option

PyFlakes interference

I use pyflakes-vim to automatically check my python code constantly, if you don't do it too you should it's awesome and make you gain a lot of time. Unfortunately this plugin use the quickfix list too and so always hide the errors list from the unit test which is quite annoying (and it took me a lot of time to find out was wrong with my quickfix).

Fortunately the release tarball provide a patch to disable the quickfix integration, which you can apply with patch -p1 -R <quickfix.diff - just ignore the error about the readme.rst.

The proper way to fix this in the future would be to have an option to disable populating the quickfix, see Issue 13 of pyflakes-vim

Update : This have been fixed in upstream pyflakes-vim, now you just need to put let g:pyflakes_use_quickfix = 0 in your .vimrc

Compiler file

We are going to handle nosetests in Vim as if it was a compiler since Vim integrate them well. For that we need a 'compiler file' which tell Vim what program to run and hot to parse it's output to detect errors.

I made one for nosetests, based on the pyunit one and which you can download here and install by copying the nose.vim file in '.vim/compiler'

Inside Vim use :compiler nose to select it then running :make will run all the tests nosetests find in the current directory and jump you to the first error.

There is also a git repository for the compiler file.

Vim-makegreen

The last piece to install is vim-makegreen. You will need the latest git version as it contain my patch to make it works with nosetests. Download it in zip format or retrieve it via git and install it like any other vim plugin.

If you now press \t (or rather <Leader>t) all your tests will be run and a red or green bar will be displayed depending if they fail. (Don't forget to set :compiler)

Automatically set nose as compiler (Optional)

If you don't want to set the :compiler every-time you edit a file you can have it set automatically for all python file by adding the following line to your .vimrc :

 autocmd BufNewFile,BufRead *.py compiler nose

Mini quickfix primer (Appendix)

Since this use quickfix you can use the regular quickfix commands, here are the most useful ones:

  • :cl display the list of error
  • :cn jump to the next error
  • :cp jump to the previous error
  • :copen open a buffer with the list of error
  • :cw close it

See also the :help quickfix for more information on it.

Mendatory screenshot:

makegreenpython.png

jeudi, août 19 2010

Some updates

Telepathy-butterfly and papyon

I haven't done a lot of work theses lasts months on telepathy-butterfly and papyon but Jonny Lamb and Louis-Francis Ratté-Boulianne did some greats progress and are maintaining them well.

Papyon is now it's own project, hosted on the Freedesktop.org infrastructure, the git repository has moved and it gained a mailing list in the process (actually two if you count the bugs ml). I hope this move will encourage more people to contribute to and use papyon.

On the novelties front, notably Jonny Lamb has implemented HTTP and proxy support in Butterfly, proxy detection require python-libproxy (as a run time dependency)

The great news is that Louis Francis implemented P2Pv2 support in papyon. This big preliminary works allowed him to implement MPOP which mean you can now connect from multiple computers at the same time. This also permitted to re-enable video-conferencing support in Butterfly ! He also merged and improved the long-awaited File Transfer branch.

Theses new shiny features are in the new papyon 0.5.0 release used with the latest telepathy-butterfly 0.5.13. These releases also contain your usual load of bug fixes and random improvements. Check them out.

Vim-fr

Vim-fr.org, your friendly French-speaking Vim community has gained a mailing-list. Don't hesitate to ask questions on it ! (in French obviously) You can also say hi or idle around in our IRC channel #vim-fr on Freenode or our Jabber MUC #vim-fr on chat.jabberfr.org.

Collabora

I'm no longer working at Collabora, working there was fantastic, especially the people there who are really great, I'm wishing them well and hope we will be able to met again some time around a good beer.

mercredi, mars 10 2010

Telepathy-butterfly 0.5.5 released

Hello,

Telepathy-butterfly 0.5.5 has just been released, along with telepathy-python 0.15.16 and papyon 0.4.5.

Butterfly is the MSN connection manager, the "back-end" for MSN, for the Telepathy IM and VoIP framework. Telepathy python is a convenience module to use telepathy and papyon is a python MSN library.

Sadly in this release we had to disable the Audio/Video calls which were broken since Microsoft removed the necessary servers. For more informations on the subject I invite you to read Kakaroto's post

On the good news this release should resolve the issues with the lost messages thanks to William Grant excellent investigation of the issue and it should also fix some other annoying bugs.

This new papyon release don't display the password in the logs any more so I recommend using this version if you want to submit bug reports.

Hopefully the next butterfly release will bring you the long awaited File Transfer support. We will also have proper multi-user chat thanks to Jonny Lamb implementing the conference interface.

lundi, mars 1 2010

Hello world

Hello,

looks like it's time for me to start yet another new blog, let's see how long I can keep this up this time. I'm planing to talk about personals projects and my work at Collabora.