Posts Tagged ‘python’

BlackBerry SMS logger and site changes

Friday, August 21st, 2009

Firstly let me apologize for the mess, right now I have moved the WordPress installation to a standalone domain for back-end architecture reasons. There are redirects in place for most things but some things may be broken. Accept my apologies in advance for the inconvenience.

Secondly I have removed my old Gallery instance. I’ve been using Gallery 1 for ages because I don’t see a good reason to upgrade to Gallery 2 which I consider HIGHLY inferior due to the reliance on a RDBMS. As a replacement I have redirected all /gallery/ URLs to my Flickr page.

Thirdly, as a result of moving to Bazaar from CVS, much of the code that has been linked in previous entries is now over at repo.ub3rgeek.net.

Finally, for anyone with a BlackBerry that would like to get the SMS messages off the device so they can save the memory without losing the messages, or just to be able to use Unix tools to manipulate the messages I have written a small Python script which can be used, alongside the Barry Project’s btool program to extract the SMS messages to a set of files sorted by Phone Number of the person you are corresponding with.
You can get the script at http://repo.ub3rgeek.net/branches//top/bbtools/files. Feel free to let me know if you find it useful.

Revision Control Revision

Monday, June 1st, 2009

I’ve been using CVS for revision control for quite some time for a number of different things here, not the least of which being a public repository of scripts and miscellany that I have tossed into the Internet for public consumption. Recently I have started to feel the desire to change to one of the newer version control systems out there. Git and Hg smell a lot of ‘ooh shiny’ syndrome and we use Subversion at work so I was sort of naturally drawn towards Bazaar. It doesn’t help that I’m a huge fan of Canonical and Ubuntu, and as that seems to be the VCS du jour over there these days I figured that this would give me a good excuse to learn it.

The moral of this story as I’m sure no one cares why I chose which VCS is to say that any of the code hosted on my CVSweb and linked to in one of my previous posts is likely to have moved to the new loggerhead interface over at repo.ub3rgeek.net. If you happen to follow me on FriendFeed or watch the home page here, you will see updates from my bazaar commits as they happen.

Fancy, eh?

Processing my digital photos

Sunday, December 21st, 2008

I’ve finally gotten to the point where I HAD to do something about my digital photos. The ~/Photos/lumix folder has over 1100 images in it and it’s just painful loading it up anymore. Nautilus takes like 45 seconds just loading the thumbnails for the folder during which time the scroll bar is jumping all over the place making navigation impossible.

So here is how I finally made this work out in a really manageable way.
1) I wrote a Python script image-process.py that moves the image file to a place in the format of CCYY/MM_Month/CCYY-MM-DD_HH-MM-SS_Exif Make-Exif_Model.jpg, so a photo from my Panasonic Lumix called P1020411.JPG gets moved to 2008/12_December/2008-12-21_19-08-17_Panasonic-DMC-FZ7.jpg

2) Setup Gnome to run my script upon mounting of a device:
Under Ubuntu, navigate to System -> Preferences -> Removable Drives and Media then under the Digital Camera section I enabled “Import digital photographs when connected” and pointed the Command to my script using the %m macro and my script’s -d flag. This passes the location that Gnome mounted my camera at to my script as a directory and lets it do the rest.

3) My laptop is backed up periodically to an external hard drive, so all my photos are more or less safe, barring a catastrophic failure of both my laptop’s hard drive and the external drive.

I am hoping to get bbtrack working on my BlackBerry so I can save GPS tracks, then using the Exif Capture Date and the GPS track my image-process.py can geolocate the photos automatically. I’m sure I will post an update if I ever get that working.

I’d be interested to hear how other people solve this particular problem. Also any suggestions of a decent photo viewing application for Gnome that I can point at my directory hierarchy, that won’t go through and try to move the photos into it’s own crap like F-Spot does?

mutt and your gmail contacts

Sunday, December 14th, 2008

I was looking for contact sync alternatives for my BlackBerry and came across an announcement that Google Sync for the BlackBerry now includes two-way contact sync. I decided that was good enough reason to start using my GMail contacts, something I never did before since I don’t use the GMail web UI very often.

Other than the BlackBerry I use mutt as a mail user agent. I have a few scripts already written to hook mutt into GMail’s outgoing mail server and Google Calendar so I figured if I was going to use my GMail contacts on the BlackBerry I should shim it into mutt’s contacts as well. In my CVS Web is a small Python script that I wrote to do just that.

If anyone finds any of this useful I’d love to hear about it. Ditto for feature requests, bug reports, or patches.

twitterpy and lastfriends

Tuesday, October 21st, 2008

I keep forgetting to write something about these guys. I wrote a pair of Python scripts to watch my Last.FM and Twitter friends and pop up a little bubble when something new happens.

There are Ubuntu packages available in my PPA over on Launchpad for both of these guys that should work just fine on 8.04, and hopefully will be updated to 8.10.

For those of you not using Ubuntu, my CVS repository has the scripts themselves that you are welcome to try out.

~mernisse’s Launchpad PPA
my CVS web interface

Mutt and Google Calendar

Monday, October 20th, 2008

I’ve been meaning to throw this out there for a bit. I wrote a little python shim to connect mutt to Google Calendar. My particular use-case is as follows. I use fetchmail to connect to a Microsoft Exchange Server at work which delivers mail into an IMAP account that I check with mutt. Appointments and conference calls show up as .ics files attached to messages. I use Google Calendar connected to my BlackBerry to keep track of all the stuff I do so I need a quick and easy way to get those events out of mutt into my Google Calendar.

Enter ics-gcal.py.

I associate this script to the ics / vcs files and simply exec the attachment from within mutt. This adds it to my Google Calendar.

You can find the script in my CVS web repository.

I’d be super interested if anyone else finds this useful.

mutt and Gmail

Monday, July 7th, 2008

So I have been using gmail more and more lately because one of my friend’s work blocks my normal outgoing mail server. I really dislike webmail interfaces though and usually use mutt(1) as my MUA.
I can use the Gmail’s imap service to read mail, but sending mail is the whole reason I am not using my normal @ub3rgeek.net mail address and it would be nice for the SPF records to match up.

By default mutt(1) uses sendmail(8) to ship your message off to the local MTA, which then takes care of delivering your message. Now I don’t want to smarthost ALL my mail through Gmail’s servers otherwise that would be the easy way out, so the quick and dirty method was to whip up a quick little python program that would act as a SMTP client in place of sendmail(8).

Bits:


# gmail
account-hook imaps://imap.gmail.com/ 'set imap_user=""'
account-hook imaps://imap.gmail.com/ 'set imap_pass=""'
account-hook imaps://imap.gmail.com/ 'set sendmail="/home/mernisse/bin/smtpc.py -s -h smtp.gmail.com -u you@gmail.com -p your_password -f you@gmail.com"'
folder-hook imaps://imap.gmail.com/ 'set from="mernisse@gmail.com"'
folder-hook imaps://imap.gmail.com/ 'set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"'

This is the important part (it is in the imap file in my config), this overrides the other account settings and sets my Gmail username and password for the imaps driver and sets the sendmail binary to my smtpc.py script, passing the arguments for ssl, host smtp.gmail.com, my username and password, as well as the From address. Mutt puts the To: addresses on the command line after all options, since that is what sendmail(8) expects.

You could of course use this to relay to just about any mail server if you like. I continue to set the correct envelope sender, as well as the Sent folder so that the Gmail web interface gets copies of all the replies I send which it happily stuffs into the conversation view.