Hanvon Driver (DKMS)

To answer an ask-ubuntu question I’ve created a dkms package for the hanvon graphics table, version 0.5 for precise.

Please install from my wacom-plus ppa by following the instructions and installing the hanvon-dkms package from the command line with `sudo apt-get install havon-dkms`

Let me know in the comments below if it works and how well it works when you unplug and plug the device in.

Python Crontab 1.0

Mission Accomplished! As a programmer, if you want to write crontabs, system and user tabs and want to access them in a less hairy way; then this is the module for you!

This 1.0 release includes lots of new unit tests, fixes for SunOS and other things and clean up of examples. You can get your source code from PyPi here: Awesome Source Code Link

And here’s a taste of a script using python-crontab:


from crontab import CronTab

system_cron = CronTab()
user_cron = CronTab(user='username')
fake_cron = CronTab(fake_tab='')

Creating a new job:

job = cron.new(command='/usr/bin/echo')

job.minute.during(5,50).every(5)
job.hour.every(4)

New job for reboot:

job2 = cron.new(command='/foo/bar',comment='SomeID')
job2.every_reboot()

Finding jobs with certain commands:

list = cron.find_command('bar')

Iterating over all cronjobs:

for job5 in cron:
print job5

Launchpad project page, GPLv3

Bricked or Just Resting?

I tried to install CyangenMod on my Samsung Vibrant thanks to the suggestion of Paultag (I’ll get you for this!). Installing the ClockworkMod failed as follows:

$ heimdall flash --kernel zImage
Heimdall v1.3.2, Copyright (c) 2010-2012, Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Attempt failed. Detaching driver...
Claiming interface again...
Setting up interface...

Checking if protocol is initialised...
Protocol is not initialised.
Initialising protocol...
Handshaking with Loke...

Beginning session...
Session begun with device of type: 0

Downloading device's PIT file...
PIT file download sucessful

Uploading KERNEL
0%
ERROR: Failed to send file part packet!
KERNEL upload failed!
Ending session...
ERROR: Failed to send end session packet!
Re-attaching kernel driver...

now my phone looks like this:

And that’s all it will do now, complain with a message about the connection not working. i can’t even find any forums or communities online to ask about the problem. So in desperation I come to the Ubuntu community to see if any of you guys have seen this problem before. If you have, please comment below.

Note: Holding the power and volume buttons to get it into download mode doesn’t work any more. Removing the battery doesn’t help either.

Update: This phone is a Samsung Vibrant, many of these devices were locked on the hardware level by carriers for unknown reasons. The only way to recover them is to buy a hardware jig which connects two of the pins via a set of resistors. Thanks to all who helped in the comments below.

Audacious CSS Desktop Programming

Take a look at this video, here I show an awesome new technology for using Clutter/Gtk with Cascading Style Sheets.


Audacious Video

You can test this out for yourself with Ubuntu 12.04 (Beta) using the following:

sudo apt-get install gir1.2-gtk-3.0 gir1.2-clutter-1.0 gir1.2-gtkclutter-1.0 gir1.2-gconf-2.0
bzr branch lp:csslavie
cd csslavie
./netbook-launcher.py

Note: default clutter/cogl has a bug which prevents the background’s opacity setting, so you won’t get as cool an effect. But a fixed version of those libraries should be available eventually.

Please comment below what you think.

Introspection Introspection

I’ve written a script which I can use to get information about gobject introspection modules for use in python. It’s written in python and allows you to look at actual function names, actual object names and what really is going on.

http://paste.ubuntu.com/872138/

This is mainly a problem because the documentation for Gtk with gi.repository is so poor and not clearly described that it makes it impossible to use without great force of will.

Hopefully this script can make the job easier for others, feel free to adapt it and post your remixes.

Ubuntu TV a Case Study

Hello Community, I’ve put together a video to show my existing Ubuntu TV; the one I’ve been using with XBMC for the past year or more.


See Video Here

If you’re using a similar setup, I’d love to know how you manage your content library and do remote access. If you’re interested in my fall-over easy python modules for accessing the XBMC library database you can find the code on launchpad and the librarian code too.

Sculpt vs Mold Programming

I really like the idea of test suites, they give me a positive feeling that the code I’m making is probably going to do what it’s supposed to do. Not only that, but I feel far more confident about hacking the code to pieces in a random fit of creative genius if I know I can run a set of unit tests at the end and make sure all my designed APIs still work from the outside.

But why should I feel so good about tests? Isn’t writing the tests just like writing the code? except for the second time?

Well the logic of tests may mean that you have to do all the same kinds of logic, but it’s not really the same logic. You’re telling the computer what you expect to happen, not what happens. Take the analogy given in the title: If you were to carve/sculpt a masterpiece, you could be expected to gain some great notoriety for being a genius artist; alas much like code without tests it’s a one shot deal. As soon as you try and change the work, change it’s material and reproduce it for more customers you suddenly find yourself with lots of work making, remaking, fixing and refixing.

Any hired programmer will recognize the situation. Conversely software with complete testing (of all three kinds) will be much more like a mold, given any language with enough consistent code you could fill the mold many times to arrive at the same quality as before. The tests aren’t the same as the original sculpting, they’re much more like the framework that shows how to reproduce the work with ever tighter testing resulting in ever more accurate reproduction.

This assumes of course you imagine programming cycles as if they were mass production units.

Enough waffle! what do you think?

XBMC Librarian (New Addon)

Hello Community,

I’ve finished writing a new addon for xbmc (the tv media center for Ubuntu) called Librarian. She will take a look at your impressive video library and check for various inconsistencies and potential problems which you might want to look into. This 1.0 release includes the following features:

  • List Movie Files not Included in the Database
  • List Movies which have incorrect length, i.e. misidentified or corrupt (requires ffmpeg installed)
  • Lists TV Shop Episodes separately with both above features
  • Tells you which seasons and which episodes of each show you’re missing
  • Shows you which TV Show Paths are being ignored completely.

More checking can be added as good ideas come in, I’ve also written an addon module called xbmcdata which wraps sqlite3 the xbmc httpapi to give a consistant inside xbmc and outside testing/scripting interface. This makes addon development _much_ easier. For instance listing movies is now just a case of:

from xbmcdata import Movies

for movie in Movies():
    print "%s (%s)" % (unicode(movie), movie['Year'])

Please download the code here: http://divajutta.com/doctormo/doctormo-xbmc-addons.tar.gz and install in ~/.xbmc/addons/ then test, entry is available under ‘Programs’. Please report issues back to me with full logs from ~/.xbmc/temp/xbmc.log included.

Have fun.

Python List Inheritance Post Creation Pattern

One of the fun things to do with python is to use the language to bend the rules of programming. One neat way of using your resources wisely with objects is to create objects in the right places, but not generate or call costly data gathering operations until you absolutely need to.

So called ‘late data initialisation’ is useful in certain kinds of programs. I document here the best pattern I’ve found to turn a python list into a late data class:

class newList(list):
    @property
    def data(self):
        if self.populate:
            self.populate()
        return self

    def populate(self):
        print "Generating Now"
        for x in range(42):
            self.append( x )
        self.populate = None

    def __getitem__(self, key):
        return super(newList, self.data).__getitem__(key)

    def __len__(self):
        return super(newList, self.data).__len__()

    def __iter__(self):
        return super(newList, self.data).__iter__()

Basically populate can be any piece of code which calls what ever it needs in order to gather the data. It’ll only be called once and to prevent having to use an __init__ variable we just clobber the method attribute. Sneaky!

When the list is used for an iteration (for loop), or if you delve into it directly for a specific item, or need to know it’s length, then we can get the data behind our object and have it contained within the list object we’re inheriting. No need for secondary list object variables dangling off of self. Ugly! Although this pattern does require that every use you want to put the object to (i.e. string, representation, slicing, dicing, mincing or conditionalising) you’ll have to make a new super method to wrap around to make sure that the data is generated if that’s the first way the list will be used.

What are your thoughts about this pattern? Do you know how to fix the init issue with a better pattern?