Go! Speed Racer Go!

I finally reached a point where I could start running the go version of sm-photo-tool. I finished the option validation for the list command. While I was testing it I noticed how much faster the Go version felt. Here are the python vs Go versions of the commands.

The python version took 80 milliseconds to run the validation of parameters and print out the error message. This is expected, you have to start the python VM (and if not precompiled, the code would need to be compiled). In this test, the code was precompiled.

$ time sm-photo-tool list invalid blah
ERROR: valid options are ['album', 'galleries']

real	0m0.080s
user	0m0.059s
sys	0m0.021s

Ok so how fast is the Go version? My guess was half the time, 40ms. I was way off. Try 6ms. SIX! That’s amazing to do the exact same amount of work.

$ time ./sm-photo-tool list invalid blah
ERROR: valid options are [album galleries]

real	0m0.006s
user	0m0.001s
sys	0m0.005s

tig + mutt = commit review

I spend some of my time reviewing team members commits. Typically I’d use the RSS feed from Google Reader, but it doesn’t have the actual diff to comment on.

Most of the time I use tig to view
the commits. And instinctively I’d want to email the author with my comments, so here’s how to do that. I’m sure there are easier commands but this is what worked for me, your experience may vary.

First thing I did was create a git alias which is useful by itself. It outputs the commit to a temp file, then gets the title and the author’s email address from the same commit passing that to mutt.

[alias]
    ...
    prepmail = !sh -c 'git show $1 > /tmp/commit && mutt -s \"`git show --pretty=format:\"%s\" $1 | head -n 1`\" -i /tmp/commit -- \"`git show --pretty=format:\"%ae\" $1 | head -n 1`\"' -

Now I want to be able to press a key in tig at the diff screen to reply to the author’s commit.

Simply bind a key, in my case I bound s in the diff view to call git prepmail with the commit’s SHA1.

In your $HOME/.tigrc add the following line. Checkout the tigrc man page for more information.

bind diff s !git prepmail %(commit)

Now in the diff view press ‘s’ and tig will launch mutt with the appropriate information.

The email shows up first:

Followed by the email’s subject, notice it matches the commit’s message.

And finally, the diff as an email body allowing you to comment on the changes
to the author.

So a simple git alias in $HOME/.gitconfig, a key binding for $HOME/.tigrc, and you can now review commits using tig. Enjoy!

sm-photo-tool release – 1.20

Version 1.20 of sm-photo-tool is ready to go. You can download it from github: http://github.com/jmrodri/sm-photo-tool/downloads.

The following are new configuration options:

  • square thumbs
  • hide owner
  • world searchable
  • smug searchable
  • sort method
  • max size option added to create

Bugs fixed:

  • If filename ends with +, append instead of overwriting log file
  • prompt for password if not in config file
  • invalid login no longer throws a stack trace

Thanks got Lloyd Cha for contributing the fixes for this release.

prompting for password

sm-photo-tool 1.16 released!

Hey there Smugmuggers!

I’m releasing version 1.16 of sm-photo-tool tonight. For those that don’t know, sm-photo-tool is a command line program that aids in managing your photos on smugmug.com. Given a directory of photos, you can create a new album on smugmug.com, then upload all of the pictures in the directory into that newly created album.

[jmrodri@firebird ~]$ cd myphotos
[jmrodri@firebird  myphotos]$ sm-photo-tool create 'my photos album'
[my photos album] created with id [9164554]
[jmrodri@firebird myphotos]$ sm-photo-tool update
./spaceshuttlehuge.jpg...[OK] 939321 bytes 24 seconds 38KB/sec ETA 0
24 939321 bytes 38KB/sec

This release is mainly a maintenance release but I also refactored the code from a single python file to a series of modules, and cleaned up the available commands.

REFACTOR

Version 1.15 of sm-photo-tool contained a single python script, while this is easy to use, it is a bear to maintain. All of the commands were moved into smcommands.py as new classes.  I then replaced all of the horrible option parsing from the previous script in the individual command classes. Thanks to yum and tito project for the inspiration in moving the commands to a separate module.

COMMAND LINE OPTION CHANGES

In the process of refactoring I deemed a few of the commands as redundant and merged them into other commands.

[jmrodri@firebird ~]$ sm-photo-tool 

Usage: sm-photo-tool [options] MODULENAME --help

Supported modules:

	create         creates a new gallery and uploads the given files.
	list           Lists the files in an album, or lists available galleries
	upload         Upload the given files to the given gallery_id.
	full_update    Mirror an entire directory tree.
	update         Updates gallery with any new or modified images.
  • create_upload no longer exists, it was replaced by create –upload
  • galleries merged with list
  • list gained two new options album and galleries
[jmrodri@firebird ~]$ sm-photo-tool list --help
Usage: sm-photo-tool list 

Lists the files in an album, or lists available galleries

Options:
  -h, --help           show this help message and exit
  --login=LOGIN        smugmug.com username
  --password=PASSWORD  smugmug.com password
  --quiet              Don't tell us what you are doing

README

If you download the tarball, do the following:

  • cd /opt/
  • sudo tar -zxf ~/Download/sm-photo-tool-1.16.tar.gz
  • cd sm-photo-tool-1.16/src/
  • copy the smugmugrc to $HOME/.smugmugrc
  • add your login and password to .smugmugrc
  • ./sm-photo-tool –help

Fedora users have an easier time 🙂 <pre>rpm -Uvh http://cloud.github.com/downloads/jmrodri/sm-photo-tool/sm-photo-tool-1.16-2.fc11.noarch.rpm</pre&gt;

Happy uploading! If you run into any problems, leave me a comment or write up an issue here: http://github.com/jmrodri/sm-photo-tool/issues

sm-photo-tool

I released a new version of sm-photo-tool. It’s a simple script that that was originally written by John Ruttenberg wrote. I took it and packaged it in rpm form and have been maintaining it under source control (versus a forum).

sm-photo-tool help
Usage: sm-photo-tool create gallery_name [options] [file...]
       sm-photo-tool create_upload gallery_name [options] [file...]
       sm-photo-tool update [options]
       sm-photo-tool full_update [options]
       sm-photo-tool upload gallery_id [options] file...

       sm-photo-tool --help for complete documentaton

It’s create to upload an entire directory of photos to smugmug from the command line.