#!/usr/bin/python import datetime from time import sleep import curses, sys import yaml def strHMS(seconds): """Transforms integer seconds to HH:MM:SS""" hours,seconds = divmod(seconds,3600) minutes,seconds = divmod(seconds,60) return "%02d:%02d:%02d" % (hours,minutes,seconds) curses.setupterm() clear_string = curses.tigetstr("clear") events = yaml.load(open("events.yaml")) eventids = events.keys() eventids.sort(lambda x,y: cmp(events[x],events[y])) while True: sys.stdout.write(clear_string) now = datetime.datetime.now().replace(microsecond=0) print now.strftime("LCL %Y:%j:%H:%M:%S") print now.utcnow().strftime("UTC %Y:%j:%H:%M:%S") print "" for id in eventids: sign = "+" delta = now - events[id] if delta.days < 0: sign = "-" delta = -delta print "%6s %s %3d:%s" % (id,sign,delta.days,strHMS(delta.seconds)) # end for sys.stdout.flush() sleep(1) # end while