... hab' ich mitzuteilen - L's blog

... with a touch of python - Didaktik der Informatik, Informatische Bildung, ...
Sat, 10 Dec 2005
weitere Funktionalitäten hinzugefügt [ 20:54 Uhr ] [ 267 Worte ]

Am Freitag, 9. Dezember 2005 habe ich - nach kurzer vorheriger Testphase (inkl. Trail & Error) und Rückfragen bei Entwicklern - die Umstellung von Kategorien auf Kennzeichnungen (engl. tags) durchgeführt.

Das Problem der Kategorien besteht darin, dass jeder Beitrag genau (und nur) einer Kategorie zugeordnet werden kann/muss. Die Lösung besteht darin, dass jedem Eintrag nun Kennzeichnungen in Form von Schlagworten mit auf den Weg gegeben werden. In der automatischen Auswertung ergeben sich so indirekt Kategorien, das sind diejenigen Schlagworte, die entsprechend ihrer Häufigkeit in einer sogenannten »Wolke« (siehe linke Spalte oben) angezeigt werden.

Darüber hinaus können mit einem einfachen Algorithmus zu jedem Beitrag die Beiträge als ähnlich angezeigt werden, die bzgl. der Kennzeichnungen möglichst »gut« zusammenpassen (also viele Übereinstimmungen aufweisen).

Mittel, die zur Realisierung eingesetzt werden

Um das Unterfangen im laufenden Betrieb einzusetzen, sind alle Beiträge initial mittels eines Scripts mit der Kennzeichung alte Kategorie versehen worden. Anschließend habe ich etliche Beiträge um zusätzliche Kennzeichungen erweitert, so dass auch die Verbindungen zwischen den Beiträgen inzwischen angezeigt werden.

Die grundlegende Erweiterung für die Funktionalität stellt das plugin folksonomy zur Verfügung. Auf der Webseite des Autors findet sich das zur Migration benutzte Python-Script.

Enrico schickte mir seine überarbeiteten »plugin«s, die ich benutze, um auch meine (wenigen) *.rst-Dateien mit Kennzeichnungen zu versehen. Allerdings werden diese nicht als »related« ausgewiesen (aber das ist zu verschmerzen). Nachdem ich diese Bemerkung geschrieben habe, fand ich die Möglichkeit, mit der »Umgebungsvariable« taggable_files die erlaubten/erwünschten Dateiendungen einzustellen. py['taggable_files']=["txt","rst"] Daraufhin funktioniert nun auch die Kennzeichnung von *.rst-Dateien.

Fri, 09 Dec 2005
Enrico Zini: Making a film out of vncrec output [ 10:48 Uhr ] [ 565 Worte ]

I have a vncrec output and I need to encode a film out of it.

transcode won't work: tried everything, googled a lot: either it exits right away, or I use the dvd delay option and it shows an error from vncrec and does nothing.

vncrec can generate xpm files, one per frame. However, imagemagick won't grok them complaining they have an illegal header. And xpmtoppm will complain that there is a line inside the file which is too long. The only thing that can load them is gimp.

So, let's script gimp. I came up with this python script that kinda does the trick:

 
from gimpfu import * 
def process (file): 
    img=pdb.file_xpm_load('/home/enrico/tmp/cazzeggio/'+file+'.xpm', file+'.xpm') 
    pdb.file_png_save_defaults(img, img.active_layer, '/home/enrico/tmp/cazzeggio/'+file+'.png', file+'.png') 
    # (update) added to dispose of the image to avoid gimp swap to 
    grow pdb.gimp_image_delete(img) 
for i in range(1, 10000): 
    process('img_%05d'%i) 

Tested in the gimp python-fu console, it works, with the save and load progress bar popping up all the time grabbing the focus from whatever I was doing.

There is a run_mode that can be passed to those file_xpm_load and file_png_save_defaults, however python-fu is happy to let me know that I don't need to bother about it. I searched, searched searched and I found out that this really means that there's no findable way to tell Gimp functions to STFU with python-fu.

Now, how do I run that script AND be still able to use my computer?

gimp has a nice --batch commandline option, from which it seems to only understand scheme. It has a --batch-interpreter option, but I couldn't find out any possible value that could make --batch understand python.

So, it seems that the only way to run python is to either register a plugin, or type it in the python console. And no STFU.

So I tried Xnest, so that I could at least iconise the whole thing out of my way. But it seems that xnest is denying connection from all clients I try to run in it.

So I've run a VNC server. In the VNC server I run Gimp. Then I fire up the Python console inside that Gimp. Then I paste the script in the Python console. Then it starts working and I close the VNC client to get rid of the popups.

Finally, this script helps me delete the big XPM files after they've been converted to PNG:

 
#!/bin/sh 
for i in *.xpm 
do 
    if [ -e `basename $i .xpm`.png ]
    then 
        echo rm $i 
        rm $i 
    fi 
done 

If there were easier ways to do what I did, please mail me and I'll document them: no matter how I searched, I couldn't find any.

Update: it seems that in the Gimp python script, the image doesn't get automatically garbage collected. As a result, the file ~/.gimp-2.2/gimpswap.whatever keeps inflating, so space is not really saved by converting the XPM files to PNG, unless I restart Gimp from time to time.

Update: I found a function to deallocate the image: maybe that avoids the growth of the Gimp swap.

Thu, 08 Dec 2005 22:57:34 +0000
[ rss20 Feed ] http://planet.debian.net/rss20.xml [ Verweis - Nachrichtenkanal ]

[ xhtml ] http://www.enricozini.org/blog/eng/vncrec-film.html [ Verweis - Eintrag ]

Sun, 04 Dec 2005
Die letzten Kommentare [ 23:52 Uhr ] [ 137 Worte ]
python

Eher durch Zufall -- latest_comments

Beim Stöbern stieß ich durch Zufall (eXcuse me Uche Ogbujis) auf eine geradezu unglaubliche Menge an Hinweisen zu XML und Python und nicht zuletzt auch auf PyBlosxom gestoßen: copia

Die Farben sind m.E. zwar ein wenig gewöhnungsbedürftig, aber die Inhalte kompetent, ...

Dort fand ich eine Erweiterung für PyBlosxom, die hier sogleich eingebunden wurde: zur Anzeige der letzten Kommentare, die in diesem Blog angebracht werden (Kommentarspammer blieben mir bisher erspart) installierte ich daraufhin die Erweiterung (== das Plugin)

latest_comments

und: es läuft. Der von mir leicht angepasste Quellcode findet sich unter:

Fri, 02 Dec 2005
Louie-1.0b2 - Signal dispatching mechanism [ 15:11 Uhr ] [ 87 Worte ]

Louie-1.0b2 - Signal dispatching mechanism [«Louie 1.0b2 is available: Louie provides Python programmers with a straightforward way to dispatch signals between objects in a wide variety of contexts.»]
[ rss20 Feed ] http://www.pythonware.com/daily/rss2.xml [ Verweis - Nachrichtenkanal ]

[ xhtml ] http://www.pythonware.com/daily/index.htm#113351143881393529 [ Verweis - Eintrag ]

Wed, 30 Nov 2005
Erich Schubert: PIDA - a really sweet Python IDE [ 10:55 Uhr ] [ 140 Worte ]

I just discovered the PIDA python IDE. It's really really nice...

What I love best with this IDE: It embeds VIM. The first IDE ever with a reasonable editor within! ;-)

You can use other 'editors', too, of course. ;-)

Actually I didn't use much of the IDE features except the file list, which I could have obtained with dozens of VIM macros as well. And probably I'll continue to use plain VIM mostly. But it's nice to see this development.

Wed, 30 Nov 2005 03:15:23 +0000
[ rss20 Feed ] http://planet.debian.net/rss20.xml [ Verweis - Nachrichtenkanal ]

[ xhtml ] http://blog.drinsama.de/erich/en/2005113002-pida-python-ide [ Verweis - Eintrag ]

COREBlog kann nun Plone [ 10:35 Uhr ] [ 135 Worte ]

Der Schockwellenreiter teilt mit:

Atsushi Shibata verkündet stolz des Release von COREBlog2 0.7b. COREBlog2 ist ein Blog-Produkt für Plone 2.1 und höher. Das »klassische« COREBlog für Zope-User wird aber ebenfalls noch weiter gepflegt. Die Veteranen unter Euch werden sich daran erinnern, daß COREBlog das Weblogsystem war, mit dem ich von Oktober 2003 bis zum Februar dieses Jahres den Schockwellenreiter geführt habe. Es war ein schönes System, für Zope- oder Plone-User ist es daher auf jeden Fall einen Test wert. [ATS per Email.]
[ rss20 Feed ] http://www.schockwellenreiter.de/xml/rss.xml [ Verweis - Nachrichtenkanal ]

[ xhtml ] http://www.schockwellenreiter.de/2005/11/30.html#coreblogKannNunPlone [ Verweis - Eintrag ]

<<  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [32] 33 34 35  >>


Inhalte unterliegen dem Copyright von L. Humbert.
Creative Commons License
Die Inhalte stehen unter einer Creative Commons License.