One of the internal tools that some of us use is a little script called getcap. Using the venerable xwd and ImageMagick, along with a bit of shell scripting it gets run by cron 8 times an hour and dumps a screen capture into a hidden folder in your home directory. As you can imagine, this is the sort of thing that if someone else was doing it would be a nasty invasion of privacy, but if you’re doing it for yourself, it becomes invaluable for accurately filling in timesheets, especially when you’re busy juggling 3-4 different projects.
I’d run into a few problems with it however, primary being that xwd doesn’t play nice with compositing, and so my Docky instance at the top of the screen looks like a big black patch across the screenshots, which occasionally blocks useful information.
I’ve therefore written a replacement, calledÂ LittleBrother,Â using primarily Python and gtk. Initially I was just following the instructions on the PyGtk FAQ on how to capture your screen, but then I figured I could do a bit more. So, we now have a little status bar icon that lets you open up the screenshots folder (using xdg-open so the right file manager gets used), and instead of having to hardcode in the times when you’re in the office, it instead uses the DBus interface of the Gnome screensaver (patches for other screensavers welcomed) to detect when the screensaver is active, and only take captures when it’s inactive. I found the D-feet DBus introspection tool particularly useful for playing around with this step.
As part of a customer project some years ago, we wrote an [implementation](http://github.com/tonyg/python-rfc3339) of the interesting parts of RFC (http://www.ietf.org/rfc/rfc3339.txt) for Python. The abstract for the RFC says
> This document defines a date and time format for use in Internet
> protocols that is a profile of the ISO 8601 standard for
> representation of dates and times using the Gregorian calendar.
Our code provides
* a standard no-frills “UTC” `tzinfo` class and singleton instance
* a standard no-frills fixed-offset `tzinfo` class
* other utilities for helping write robust timezone-aware time manipulation code
These examples are taken from the doctests/docstrings in the module source itself. See the module documentation for many more informative examples.
Parsing a timestamp, with timezone support and timestamp equivalence:
>>> midnightUTC = parse_datetime(“2008-08-24T00:00:00Z”)
>>> oneamBST = parse_datetime(“2008-08-24T01:00:00+01:00″)
>>> midnightUTC == oneamBST
Printing a timestamp:
Downloading the code
The code is [available on github](http://github.com/tonyg/python-rfc3339/). It’s [MIT-licensed](http://www.opensource.org/licenses/mit-license.php).
* Browse the code [here](http://github.com/tonyg/python-rfc3339)
* Download a [tarball](http://github.com/tonyg/python-rfc3339/tarball/master) of the latest code
You can also install the module directly from github using `pip`:
pip install -e git://github.com/tonyg/python-rfc3339.git#egg=rfc3339
You are currently browsing the LShift Ltd. blog archives for May, 2010.