GeekTool is awesome. Is the Tree Green? is awesome. So together they are SUPER AWESOME! + GeekTool by zpao, on Flickr


Historically, I’m a Ruby guy, but I started learning Python for a Django project I’m (barely) working on. So I picked up a book here at work & decided to flex my pythons a little bit. You can laugh, it’s punny.

The first pass of this took me ~20 minutes, and I just tidied it up this morning so it would take command line options.


If you’re reading this and actually need to know whether or not the tree is green, then you should be able to figure it out. GeekTool is OS X only, but there are similar programs for Windows and Linux.

It’s easy enough to do what I did in the image above. The program can take 2 arguments treename and output. Run it with -h for usage.


#!/usr/bin/env python
# Based on Is the Tree Green? <>
# Original Code & Concept by Justin Dolske <>
# Ported to Python by Paul O'Shannessy <>
import getopt, sys
from urllib import urlopen
def main(argv):
"""docstring for main"""
treename = "Firefox"
output = "all"
opts, args = getopt.getopt(argv, "ht:o:", ["help", "treename=", "output="])
except getopt.GetoptError:
for opt, arg in opts:
if opt in ("-h", "--help"):
elif opt in ("-t", "--treename"):
treename = arg
elif opt in ("-o", "--output"):
output = arg
is_the_tree_green(treename, output)
def usage():
"""outputs the usage of this program"""
print """
Prints the current status of tinderbox. While perhaps useful from the command
line for a quick update before checking in (in case you're too lazy to check
tinderbox). It's more fun to show it off on your desktop using GeekTool
Original concept: Justin Dolkse and his <>
-t, --trename= The tree to use, default is 'Firefox'
-o, --output= The output type. Valid options are 'status', 'message',
and 'all'. Default is 'all'
def is_the_tree_green(treename="Firefox", output="all"):
"""docstring for is_the_tree_green"""
content = urlopen("" % treename).read()
lines = content.lstrip().rstrip().split("\n")
num_boxes = num_red = num_orange = num_green = 0
for line in lines[:]:
[build, tree, ident, state, num] = line.rstrip("|").split("|")
if ident == "static-analyis-bsmedberg":
num_boxes += 1
if state == "success":
num_green += 1
elif state == "testfailed":
num_orange += 1
elif state == "busted":
num_red += 1
elif state == "open" or state == "closed":
# Ignore the overall tree status on Firefox3.0 (CVS/Bonsai)
num_boxes -= 1
status = get_status(num_boxes, num_red, num_orange, num_green)
message = get_message(num_boxes, num_red, num_orange, num_green)
if output == "status":
print status
elif output == "message":
print message
print "%s - %s" % (status, message)
def get_status(total, red, orange, green):
if not (red + orange + green) == total:
return "Maybe?"
elif green == total:
return "Yes!"
return "No."
def get_message(total, red, orange, green):
if not (red + orange + green) == total:
message = "I didn't understand the Tinderbox status..."
elif green == total:
message = "Everything is SUPER!"
if red and not orange:
message = ("1 box is" if red == 1 else "%d boxes are" % red) + " burning!"
elif not red and orange:
message = "Tests failed on" + (" 1 box!" if orange == 1 else " %d boxes!" % orange)
message = ("1 box is" if red == 1 else "%d boxes are" % red) + " burning, and"
message += " tests failed on" + (" 1 box!" if orange == 1 else " %d boxes!" % orange)
return message
if __name__ == "__main__":
view raw hosted with ❤ by GitHub

A big thanks to Justin Dolske for Is the Tree Green?. He deserves more credit for this than I.