Sculpt vs Mold Programming

Posted in Hat Talk, Programming and Technical, Ubuntu on January 2nd, 2012 by doctormo

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?

New Release: Lab Session Manager

Posted in Free and Open Source Software, Programming and Technical, Ubuntu on September 2nd, 2011 by doctormo

Over on launchpad, I’ve released version 1.4 of the lab-session-manager, included in this release is:

  • Bug fixes for administrators and other infinate time periods
  • Uses gnome’s SessionManager API to logout instead of SIGKILL
  • Pauses a logout until logging of logout event has completed
  • Correctly logs methods of logging out (session timeout, logoff button, off switch)

You can get your hands on the PPA and give it try here: DoctorMo’s Greeter PPA, Let me know what you think below in the comments.

Tags: , , , , , , , , , ,

XBMC Librarian (New Addon)

Posted in Free and Open Source Software, Programming and Technical, Ubuntu on August 31st, 2011 by doctormo

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.

Tags: , , , , , , , ,

Python List Inheritance Post Creation Pattern

Posted in Programming and Technical, Ubuntu on July 31st, 2011 by doctormo

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?

Tags: , ,

Lab Session Manager, New Release 1.2

Posted in Free and Open Source Software, Programming and Technical, Ubuntu on July 21st, 2011 by doctormo

I’m pleased to release a new version of the lab session manager.

The Lab Session Manager is a indicator which times how long you can be on the computer for, notifies you when you’re running out of time and then logs you off when your time is over. It replaces the old and unmaintained timed functionality with a modern, gtk based system tray icon and logging functionality for generating reports about who is using the computer for how long. See previous blog post here.

This version includes a successful upgrade of the code to python modualisation which will help future bug fixing. plus a big upgrade to the logging functionality to allow logs to be read back and sorted and reported on. New reporting mechanisms are in the works for the next version too.

You can find this release’s ppa here or the source packages in the above link. Please give the PPA time to build everything.

The next release should also include more fixes and some custom icons, so we can guarentee the style and design of the dialogs no matter what theme you’re using.

If you find any bugs, please report them in launchpad here.

Tags: , , , ,

Letter to: Creative Industry

Posted in Free and Open Source Software, Programming and Technical, Ubuntu on July 19th, 2011 by doctormo

This is the letter I sent to the petition organiser to try and get apple’s final cut reinstated.

Dear Andrew Landini,

I read with great interest the petition of a great many creative people who have built their work around the Final Cut product line. Of course, I feel your pain and wish to offer my sympathies.

But I also wish to share with you what I have learned about software and the importance of ownership and control. It is true that there are a great number of good, solid software packages being made by companies like Adobe and Apple which artists and businesses regularly use to get their work done in the best way possible.

The problem with these packages is that they take away effective ownership and with that any sense of control over the direction of the development of the tools in use. These programs are known as proprietary software[1], because they use trade secretes to hide their source code, strong copyright to sell products in a box and even go so far as to implement anti-features[2] to ensure stratification of their market money earning potential.

This isn’t necessarily at issue, but it does put users (and more importantly businesses) at a huge disadvantage. Instead of investing into an ecosystem that requires it take control away from your business, I would like to propose supporting Free and Open Source[3] business models for the furthering of creative tools.

This new way of creating software doesn’t require programmers keep secretes from their users. Development is done in the open, multiple different parties generally pay into development of the same features and we end up with free software that every participant gets full rights to use, modify, and basically do with as they wish for their own business needs.

Tools such as Gimp, Inkscape and Blender are not always first with features or even the best technical tool at the moment. But what they offer is something far more important, they give every user Freedom, Ownership and Control to take the software and fully define how they want to see the software developed further. They require no loyalty to any one set of developers, there is no one company you must go to for support. Despite marginal investment from the creative industry, these tools are already quite powerful.

With most artists and creative businesses understanding and supporting Free and Open Source as a good business strategy, I think we can prevent, in the future, ever having to write an petition begging a mischievous company from putting small creative businesses out of work because they decided to develop for the lowest common denominator.

Best Regards, Martin Owens (Artist, Programmer, Teacher)

[1] http://en.wikipedia.org/wiki/Proprietary_software
[2] http://wiki.mako.cc/Antifeatures
[3] http://en.wikipedia.org/wiki/Free_software

Tags: , , , , ,

Packaging: Need Help!

Posted in Free and Open Source Software, Programming and Technical, Ubuntu on July 11th, 2011 by doctormo

I haven’t had much time to blog about interesting things, sorry guys. But I did want to take an opportunity to share a problem I’m having.

I make software, and I make it for people. I’ve driven by people’s needs. So I tend to make lots of smaller things to fix certain problems or do something interesting on a small scale. The difficulty I’m having is with packaging and getting packages into Debian and thus into Ubuntu. I make lots of PPAs and they seem to work for users who are interested in getting what I do directly from me. But…

I feel that as the developer, designer, QA and possibly only user; that to do all the work on the packaging and being the sponsor in the upload process would deny my projects much needed oversight, not to mention being tiresome.

If you check out my launchpad list of code branches, I have A LOT of really awesome code which isn’t in the Ubuntu archive. I have a lot of interesting and useful tools which should be available to all kinds of people and just aren’t. The reason why all these code branches have failed to move anywhere is because I’m not good at asking for help on packaging and when I do I ask the wrong people. Despite on a number of projects being asked by users to get packages into Ubuntu, the answer is simply: I can’t do it myself and I need help.

If you know how to get code into Ubuntu _without_ having to be the packager and Debian maintainer: let me know you thoughts, as always below.

Tags: , , , , ,

New Session Manager

Posted in Programming and Technical, Ubuntu on July 7th, 2011 by doctormo

For community centers we need to present to the user the amount of time that their session has left and at the same time log the user off when the session timer runs out. As a nice touch we want to warn the user as the session nears it’s end.

To achieve this we use an app indicator with a menu item with the amount of time left.

For the warnings we use the libnotify and change the icon of the app indicator too:

We also want to notify the user of how much time they have, so we add a welcome:

If the program exits or is killed, the gnome pid is also killed so the user logs off.

All of this is configurable so we can say what users should have what kind of session and what warnings:


logs: /var/log/sessions/
limit_by_group:
admin: ''
users: 01:00:00
testing: false
warnings:
- message: Welcome!
description: You have %(remains)d minutes in your session.
icon: application-community
from: session-start
times: [ '00:01' ]
- message: Session Running Out
description: Your session is about to end automatically, please save all your work. %(time)d minutes remaining.
icon: gtk-quit
from: session-end
times: ['10:00', '05:00', '01:00']

For reporting we also want to log sessions, when they start, when they end and on what machine:


events:
- {date: '2011-07-07T15:36:02.734579', message: log-started}
- &id002 {date: '2011-07-07T15:36:02.763812', message: login, session-pid: 1830, tag: started}
- &id001 {date: '2011-07-07T15:36:51.898611', message: forced, tag: end}
meta: {hostname: delen, username: doctormo}

We add the program’s .desktop file to the /etc/adg/autostart directory so it launches when gnome starts.

You can find all the code here and the ppa package here.

Enlightenment Foundation Libraries 1.0 for Lucid, Maverick and Natty

Posted in Programming and Technical, Ubuntu on May 25th, 2011 by doctormo

There is a brand new stable release of the efl (Enlightenment Foundation Libraries) for Oneric, and because I want to play with python-efl, I needed to compile and build an entire PPA full of the newest stable release.

So here we have it, I invite anyone to use this PPA if you’re interested (or have a need) to use efl-1.0 in past Ubuntu releases.

sudo add-apt-repository ppa:doctormo/efl
sudo apt-get update
sudo apt-get install python-ecore ... etc

This ppa has taken me all week to build, it’s a lot of work so please do use it if you need up to date efl libraries or a newer cython build and especially if you need python-efl 0.7.3 or better.

I hope to use the code to produce the netbook-launcher effect in the logon screen, but this is very early days and it might be a fools errand. But it will be F’N awesome if successful. Report below if you know anything about programming with efl.

Tags: , , , ,

Netbook Launcher now Available for Natty!

Posted in Programming and Technical, Ubuntu on May 20th, 2011 by doctormo

Hey guys, you might remember that a few days ago I was asked to build the lucid netbook launcher functionality for maverick; enough people asked me for a natty version that I wanted to make sure you guys got access to the clutter based netbook-launcher too. So here you go!

Of course this repackaging can’t go on forever, the packages I’ve sent to my PPA have no maintainer and sooner or later there is going to be major api failure as gnome3 moves on and ubuntu doesn’t ship the libraries this interface needs.

With that caveat out of the way, you can install the netbook launcher (3D) like this:

sudo add-apt-repository ppa:doctormo/netbook-launcher
sudo apt-get update
sudo apt-get install yeold-netbook-launcher

If you would like the 2D version of netbook-launcher, then the best thing to do is to install the netbook-launcher-efl which is shipped in natty (and meverick), true it’s a daft package which sucks in unity by mistake, but it still works and unlike the 3D code, the 2D code is still being developed (if only in small ways) by mterry.

Thoughts, comments and problems, please post below…

Tags: , , , , , , ,