FSpot::DbTool

February 20th, 2011 robin Posted in Ironman, Perl 1 Comment »

Introducing FSpot::DbTool!

F-Spot is a pretty neat photo management application which comes with the Gnome desktop.  I have been using it for a few years to manage my photos, and by now I have over 23,000 photos in it!  It has lots of handy features: tagging, versions, dates… but there are a few things it doesn’t do so well: moving files from one location to another (not all your files, just a sub-section), compacting the database, and I’m sure some more will come to mind!  The database it uses is SQLite – the perfect application for this kind of database!

I’m getting into Moose (a post-modern object system for Perl 5), so this weekend I put together a neat interface to the FSpot database: FSpot::DbTool.  It comes with a command line tool fspot-tool.

Usage:
 fspot-tool.pl [options]

Options:
 --action
    move_dir
      Requires: from, to Optional: merge, rename
    replace_path
      Requires: from, to
    find_lost
      Requires: path find_orphans
    clean_trailing_slashes
    tag_no_description
    backup_db
    check_db
    compact_db

 --from   Path from
 --to     Path to
 --path   It's a path!
 --merge  Do a merge
 --rename Rename files if necessary

Actions:
 move_dir:
 Move pictures from one directory to another. Does the move on the
 filesystem, and the corresponding move of the path in the FSpot database
 afterwards

 replace_path:
 Useful if you have already moved files in your filesystem (e.g. moved
 your entire photo folder to a new location. Will replace all instances
 of a path with a new path

 e.g.

 from = /home/clarkero/my_pictures
 to   = /home/rcl/pictures/processed

 clean_trailing_slashes:
 Clean trailing slashes off the end of paths in the database

 find_lost:
 Find files which exist in the filesystem, but do not exist in the
 database

 find_orphans:
 Find orphaned files (files which exist in in the database, but not on
 the filesystem)

 tag_no_description:
 Tag all photos which do not yet have a description

 check_db:
 Confirms you have the correct database version for this script to work
 with

 backup_db:
 Make a backup of the database This is carried out automatically for
 move_dir, replace_path and compact_db actions.

 compact_db:
 Carries out the SQLite compact function (VACUUM) on the database.

By using Moose::Roles I’ve paved the way for easily adding additional tools for the database – just add them into the lib/FSpot/DbTools directory!

I hope you have fun with FSpot, and find a use for the DbTool.


Chart::OFC2

December 30th, 2010 robin Posted in Ironman, Perl 1 Comment »

Recently I started looking at Chart::OFC2.  It’s a pretty neat module to create Open Flash Chart charts (or more importantly, the data format required for the charts).  One small problem: the y_axis_right option wasn’t completely implemented… but thankfully the creator is also a GitHub user, so I just forked, patched, and posted a pull-request.

If any one wants to get my fork before it’s merged – here you go!


Demonstrating Git with Perl

December 20th, 2010 robin Posted in Ironman, Perl 2 Comments »

Git is the latest and greatest amongst version control systems.  Git is:

a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.
Git is used for version control of files, much like tools such as Mercurial, Bazaar, Subversion, CVS, Perforce, and Visual SourceSafe.

But how do you persuade your boss, friend, co-worker, …. that it is so much better.  You can rant and rave about how quick, compact and cool it is till the cows come home, but they probably won’t be converted until they see it live in action, and that often takes time…  And in a slide show presentation you don’t want to wander off hacking at the console changing files and cd-ing directories just to show checking in/out a few files…

Along comes Git::Demo – a Perl module to allow you to write stories about Git, and then play them back to your friends, colleagues and bosses to your hearts delight, showing off the snazzy coolness of git.

A Git::Demo story is written in YAML (that’s like XML, but easier to write/read), and has characters:

characters:
- name: Bob
- name: Mary
- name: Jane
- name: Peter

It has events:

- type: print
  action: screen
  characters: ALL
  args:
  - Yippee - go-go-Git!

And those events can be print (prints to screen), “git”, or “file” events

- type: git
  action: remote
  characters: ALL_NOT origin
  args:
  - add
  - origin
  - ../origin

By writing a story of events carried out by the characters, you can show live (and with wallclock times) how quick and easy Git actions are, and you’re not just doing a “here’s one I did earlier” show: it’s happening live at that very moment, so if your viewer says “Wait a moment, what happens now if I …?”, you can pause the story, and do it right there and then.

Git::Demo is still pretty rough, and my sample scripts are short and not so cool yet… but I’m hoping that this will catch the eye of other Git-Lovers out there, and that some will help improve the code, and write more stories!

Have fun, and use Git! 🙂