Warren Falk

readers are plentiful, thinkers are rare

Archive for July, 2009

Tip: make checkinstall

Sunday, July 19th, 2009

I’ve been creating several python scripts lately for various things, and I’m installing them all right in /usr. (This is ubuntu, btw).

To keep my system clean, I’ve been creating debian packages with checkinstall and installing those. To make that easier, I’ve come up with a bit of a system. I create a make file with an install target, and then add a “checkinstall” target which runs the checkinstall command for me. This works pretty well

In addition to this, I’ve added the ability to get the subversion working copy revision and use it for the pkg version.

I put something like the following at the beginning of Makefile:

REVISION=`svn info | python -c "import re, sys;\
print [m.group(1) for m in [re.match('^Revision: ([0-9]+)', line) for line in sys.__stdin__] if m][0]"`

and then use $(REVISION) inside Makefile wherever I need the subversion revision number.

So I have something like the following, later on:

checkinstall:
    checkinstall --pkgversion r$(REVISION)\
     --pkgname trivial-backup\
     --maintainer warren@warrenfalk.com

Photo sorter

Wednesday, July 15th, 2009

I finished an EXIF-based image sorting script (in python). It’s rather trivial. It takes two folders as parameters. It reads all images from the first folder and moves them to the second folder, sorted into folders by year and then month, and then renamed all according to the date the picture was taken (from the EXIF data).

It handles things like discarding exact duplicate images (by comparing checksums) and handling images with the same time stamped on them, but that are different pictures.

It’s really nothing special, but I’m including it here for anyone looking for an example of anything like this.

Lynn downloads our pictures from the camera to our image server, then runs a script (via a shortcut on her desktop that runs an ssh command) which does the sorting.

(more…)

PicsFS: Fuse Filesystem

Thursday, July 9th, 2009

I keep our family pictures on a linux server and make them available via samba share.  I have a script that automatically sorts the pictures by date taken, via exif.  This system works quite well.  Lynn manages the family photos, and blogging, mostly, and to protect her from herself, once the pictures are sorted, permissions prevent her from deleting them by accident.  This has proved to be a good move on a couple of occasions.  Unfortunately, it also means that no Thumbs.db file is created (she uses Windows, a habit she isn’t willing to break).  This means that she has to wait for thumbnail creation over the network every visit to a folder.

There are better ways of solving this trivial problem, probably, and versions of Windows after XP don’t use the retarded thumbs.db method, so this problem will solve itself eventually when she’s upgraded (or when I break her of her windows habit).

I chose to create a user mode filesystem, because this seemed like a good way to cut my teeth on the process.  I used python-fuse, and created my “picfs” file system which simply lets you mirror another filesystem but with the added ability to specify a “thumbnails” folder.  Any file named “Thumbs.db” is stored in that folder, instead of the shared folder.  So I bind a copy of our picture share in her home directory, and specify a separate folder for her thumbnails.  Permissions prevent her from modifying the pictures or the folders they’re in, but picfs makes it look like the folder is writable.  (This is necessary because Windows won’t even attempt it if it thinks it’s read-only).  The only write that succeeds is the Thumbs.db file, and it is stored in a separate Lynn-only folder.

The source can be downloaded here: http://www.warrenfalk.com/anonrepos/picfs/trunk.  Seeing how the code works may be more useful than the code.  I’m posting it here for that reason.

(by the way, for those who want Thumbs.db on a samba share, I found the following smb.conf settings are ideal for this sort of thing:

 nt acl support = no
 writable = yes
 hide files = /.*/Desktop.ini/desktop.ini/RECYCLER/thumbs.db/Thumbs.db/
 hide unreadable = yes

)

.
Entries (RSS) and Comments (RSS).