Sunday, January 30, 2005

Weekend hacking summary

As I learn GNOME Python programming by way of Google, I come to realize that I need to document what I've learned so that future coders can use Google easier. My intent is to write a summary each weekend that I hack; we'll see how that really goes.

My hacking was cut short Friday night (well, 3AM Saturday) by a hard drive failure in my mail server (and Web server, and database server, et.c). I did an emergency hard drive replacement and recovered what I could from the old one (causing two kernel panics on the way), finishing up at 7AM with a working Exim. I just now got Apache going again (there was a party in between, you see) and will get PostgreSQL going in a minute. Future plans (next weekend, or maybe this week if I need it sooner) include Subversion.

Despite all that, here are some tips:

gnome.init

If you get the error message:
(guploadr.py:33062): Gnome-CRITICAL **: file gnome-program.c: line 870 (gnome_program_locate_file): assertion `program != NULL' failed

That means that you forgot to do this before calling gtk.glade.XML:
import gnome.ui

gnome.init('guploadr','0.01')


GNOME File Selector Dialog

To use the file selector dialog use this callback:
def on_open1_activate(self, widget, *args):

chooser = gtk.FileChooserDialog(
title="Select an image",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
if gtk.RESPONSE_OK == chooser.run():
print chooser.get_filename()
chooser.destroy()


About Dialog

To show a dialog window, such as the About dialog, in your constructor create an instance of it:
self.about_dialog = self.widgets.get_widget('about2')

Then in your callback just show it:
def on_about1_activate(self, widget, *args):

self.about_dialog.show()


Unsolved

I don't fully understand drag-and-drop yet. I'm reading example code at the API Web site, but I'll need to check out real code soon.

Speaking of real code, I need to use the thumbnail viewer from gthumb. It's a bonobo component, I think. How do I do this?

Other Software Ideas

  • A good-looking, working, easy-to-use Web log publishing software for GNOME.

  • A syndication aggregator for GNOME with a Planet-like view.

  • GNOME Flickr Organizr.


A lonely goldfish on the cold linoleum floor

Saturday, January 29, 2005

More upcoming things to go to

Who wants to join me on these?

February 5th; 9PM
Sam Bisbee
TOAD (someplace in Cambridge, MA, apparently)

February 3rd, 4th, or 5th; 8PM
The Who's Tommy
MIT

A Marine drinking from another Marine's stream

Friday, January 28, 2005

Weekend guploadr plans

It's the weekend again; time to hack!

My fake plans: write test cases for all the testable guploadr functions. This will fless out the API and help me know when I'm done. Before writing any non-GUI code I will write tests.

My real plans: play with the GUI. I figured out Glade and how to use it with Python and now need to figure out more of how to use it. That is:
  • Drag and drop

  • Dialogs (About, Publish, and Open File)

I might not have a lot left to write, but I still need to learn this stuff. Easier said than done, but Google is helping.

Next weekend I'll write the tests. I have my Flickr API key (stored on two computers so I "won't" lose it). Maybe I can interest a friend in some programming tennis.

Fred Howland in Dunkin' Donuts with his best Inbred Fred look

Wednesday, January 26, 2005

Python/guploadr update

I talked with Peter Markowsky about my Python questions. He pointed to PyUnit for unit testing. Testing GUIs is obviously not easy, so I suspect that no such library exists for Python. He also told me about Distutils. Thanks, P. Laurence Markowsky-von Brown!

I also talked with Michele Campeotto, the author of FlickrUploadr. My plan is now to build my prototype, mostly to learn how to use Python with the GNOME libraries and Flickr backend, then abstract my code to be useful for both projects, then develop either FlickrUploadr or guploadr. Since I'm a Schemer my code will be drastically different and a lot of other Python won't make sense to me, so I'll probably just stick with my code for a while.

Peter Markowsky sticks his tongue out

Tuesday, January 25, 2005

What I ended up coding

I had all sorts of plans involving RSS and RDF and PLT Scheme, but I ended up teaching myself a little Python and coming up with the grandest idea that I might be able to follow through with: guploadr. That is, the GNOME Flickr photo upload program.

I've switched to Python because I do not have the time or the patience to write the GNOME and Flickr (and GTK+, REST, libglade, and so on) libraries for PLT Scheme. My plan is to use Glade to generate the user interface and James Clarke's Python Flickr module to handle the backend, leaving me with nothing but glue code.

So far I'm trying to learn Python (and by "learn" I mean writing code like:
def reverse (l):

q = l
q.reverse()
return q
) and Glade. Next up I'll apply for my Flickr API key and spit out the program.

The common use case is extremely simple: drag images onto guploadr, select a bunch of images, edit their tags, select more images, edit their descriptions, then publish the images. The first time this will ask for your email address and password; after that it will save it.

I do have some pending Python and Glade questions:

  • How do I test units?

  • How do I test GUIs?

  • How do I package this all up?

  • Why are so many Python procedures destructive?!


I've created a mock-up of what I think I want it to look like. Next I have to read the HIG and apply that.

Update: I should Google first, think later. Mine intends to be quite different, so I will persist regardless.

Dunkin' Donuts

Saturday, January 22, 2005

Upcoming Shows

I hate going to shows alone. Who's with me for either of these?

Sunday February 27th, 2005
Middle East Downstairs
Rachel's and Invert
$15 in advance, $18 at the door
8:00PM

Thursday March 3rd, 2005
Middle East Downstairs
Irepress and Subtle
$12
8:00PM

My bookshelf of CDs

New digital camera

I got my new digital camera, an Olympus D-580. Not exactly what I wanted, but I really just wanted to get out of Best Buy. I never realized how much salespeople piss me off until today.

Regardless, it worked flawlessly under FreeBSD 5.3. Here's my /etc/fstab:

/dev/da0s1    /camera    msdos   rw,noauto       0       0


And, for automounting, here's what I added to /etc/usbd.conf:

## Olympus Digital Camera

device "Olympus D-580"
devname "umass0"
vendor 0x07b4
product 0x0105
release 0x0100
class 0x0000
attach "sleep 1; chmod 0666 /dev/da0*; /usr/local/bin/sudo -u netgeek /sbin/mount /camera"
detach "/sbin/umount /camera"


I don't think the detach line works. Also note that I manually chmod the device, because I couldn't get devfs to work properly for da0. The user netgeek owns /camera, so that it's user-mountable.

The automounting plus Nautilus makes getting photos as simple as plugging the camera in.

My mom doing taxes on my bed

Relevant weekend plans

I need to work on my PLaneT modules this weekend. To be exact, I want to update my RSS module to handle Atom and verify that it produces correct RSS 1.0. It should also default to producing RSS 1.0 for now.

Also on my list is my PLaneT RDF library, to be modeled after Python's rdflib. Ideally this would be used as a back-end to the RSS library, so that the RSS library can produce RDF/XML or n3 in a way that can be reused for the FOAF and DOAP libraries I plan to make. So, maybe I'll restart work on my RDF library this weekend.

This all got inspired because Matthias refuses to publish the course 'blog in a syndication format, so I undertook the responsibility of scraping and producing my own. I have something but I don't want to link to it yet in case I want to change the URL later.

On a totally different topic, I bought a Pro account at Flickr, which would seem stupid since I don't have a digital camera, but tomorrow I am purchasing one—hopefully an Olympus Stylus 300 Digital.

A distracted Mike Burns snapping his fingers

Wednesday, January 19, 2005

Web services

I'm getting into Web services lately, even those with a community around it. No, I'm not signing up for LiveJournal, but I want to make announcements that survive past the change of an away message.

So, I'm now on Flickr, Freshmeat, and Blogger. I mainly use my real Web site as a central place to find me and my resources.

Photograph of Mike Burns doing his best metal face at the New Year's Eve Party 2004