Categories: Coding Corner, Docbook, Summer of Code 06


Python strangeness

Could someone explain this?


list = (
    (0, 'foo'),
    (1, 'bar'),
    (2, 'baz'),

class Klass:
    def bat(self):
        print '-1'

for l in list:
    if not hasattr(Klass, l[1]):
        print '%s should print %d' % (l[1], l[0])
        def _f(self):
            print l[0]
        _f.__doc__ = 'Get %s' % l[1]
        setattr(Klass, l[1], _f)

k = Klass()
print 'Docstrings:'
print 'Foo:',
print 'Bar:',
print 'Baz:', k.baz.__doc__


print 'Executed:'
print 'bat:',
print 'foo:',
print 'bar:',
print 'baz:',


print 'Locations:'
print 'bat:', str(k.bat.im_func)
print 'foo:', str(
print 'bar:', str(
print 'baz:', str(k.baz.im_func)


foo should print 0
bar should print 1
baz should print 2

Foo: Get foo
Bar: Get bar
Baz: Get baz

bat: -1
foo: 2
bar: 2
baz: 2

bat: <function bat at 0xb7c58e2c>
foo: <function _f at 0xb7c58df4>
bar: <function _f at 0xb7c58f0c>
baz: <function _f at 0xb7c58f44>
$ python -V
Python 2.4.4

Maybe I'm just missing something... Don't flame ;-)

Permalink . Ikke . 02:13:57 am . 189 Words . Coding Corner . . 2525 views . 5 comments


More Clutter

This afternoon I wanted to implement some custom ClutterActor. I made a very basic actor which is basicly a simple rectangle, like ClutterRectangle, but allows you to define a color for every corner, which are blended by OpenGL.

Like this:

I also added a simple animation sequence which changes all corner colors over time, so you get some visual effect, and added some motion effects (a simple rotation around 2 axes). The color changing effect is badly written now, should become a ClutterBehaviour, if possible.

Code is here, it could be a good starting point to learn how to write a custom actor using OpenGL (first time I ever wrote OpenGL code myself, it's not that hard, more experimenting later).

Performance and anti-aliasing is rather sluggish now, but I don't think it's related to my code as doing the same rotations on a single-color ClutterRectangle gives the same result.

Oh: yes, this code leaks at exit.

Enjoy :-)

Permalink . Ikke . 11:16:30 pm . 156 Words . Desktop, Coding Corner . . 1696 views . Leave a comment


Clutter reflections

Clutter reflections

See src/view-reflection.c in your local gallery git clone. Suboptimal code, no slideshow (only displays the first picture for a given tag), but well.

Maybe I should try to load images (using GdkPixbuf or something alike), use GEGL to do some transforms on them (more optimized than my hackish filters :-P), then use these transformed images on a Clutter texture...

I wonder how hard it would be to play a movie using clutter-gst and add reflections of it.

Permalink . Ikke . 01:12:18 pm . 79 Words . Linux, Desktop, Coding Corner . . 3410 views . Leave a comment
Clutter, advanced UI graphics made fun

Today I looked at Clutter, a nifty "rich UI" creation library using OpenGL and the like. After playing around with some of the samples, reading some API docs and writing one dumb simple text-rotating application (think Windows' text-message screensaver, you know), I wanted to make something more advanced (hum-hum).

I decided writing some photo slideshow application would be cool. We already have several of those, obviously, remember this is just a playground.
Having some sort of F-Spot (a great photo management application) integration would be nifty too, so I started with that: loading taglists and picture-paths for one tag. In the end it turned out writing that took more time than writing the simple view I created.

Next I wrote the Clutter driver code and some system to be able to easily switch view functions. I only implemented one so far, which just fades between images (in, out, next image in, out etc) and stores the GdkPixbuf's in a ringbuffer. Not optimal, no cleanup code yet, jadajadajada.

No screenshots as a static screenshot would not be very impressive (the current application neither but hey ;-)).

Anyway, it might be useful as a sample/basic Clutter application for some people. You can find the source code, clone URL and compilation instructions here. If you implement some nifty view, share it!


Permalink . Ikke . 02:54:57 am . 219 Words . Linux, Desktop, Coding Corner . . 2906 views . 6 comments


Being a Certificate Authority made easier than ever

Lately at VTK we started to use SSL (and X509 keys) at more places than just one webserver. We figured out using a central CA (and not one per server) and managing keys centralised would be A Good Thing.

So I created a LUKS volume on one of our servers (which is only usable by us admins) to store CA data. OpenSSL is kinda tough to work with though (well, lots of commands with lots of command line parameters ;-)), so I decided to create some sort of text-based interface around it, inspired by OpenVPN's EasyRSA scripts.

I titled the end result CAAdmin. You can find a gitweb view (including pull URL) here if interested. Fixes or patches to add functionality are very welcome (email :-)).

Currently it allows you to:

  • Create a new CA
  • Generate server keys and certificates
  • Generate client keys and certificates (both password protected and without password)
  • List your CA's CRL
  • Create a CRL file to distribute to your servers
  • Revoke a certificate

Functionality to sign an incoming certificate request should be added. I'd love to figure out whether it's possible to use my (belgian) eID card (and reader): I can read the data on it and use it for SSH authentication, but I didn't figure out yet whether it's possible to pull out a signature request out of it, so I can use the private key stored on it to access some of our key-based SSL services... Any pointers?

Permalink . Ikke . 04:02:57 am . 242 Words . Technology, Coding Corner . . 934 views . 2 comments

:: Next Page >>