-
-
Save mfa/4267856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# frwd to other interested parties at the institute | |
# | |
import datetime, time, sys | |
leave_at = datetime.datetime(2012, 12, 13, 12, 00) | |
first = True | |
while True: | |
delta = leave_at - datetime.datetime.now() | |
if abs(delta.seconds) < 120: | |
raise SystemExit, u"Immediately leave for *xmas market Esslingen*, " +\ | |
u"12:14 S-Bahn UNIVERSITÄT, 13th Dec. 2012" | |
elif delta.seconds > 0: | |
if first: | |
sys.stdout.write("Leave for *xmas market Esslingen* in xxh xxm xxs") | |
first = False | |
hh = delta.seconds / 3600 | |
mm = (delta.seconds % 3600) / 60 | |
ss = delta.seconds % 60 | |
timestr = "%02dh %02dm %02ds" % (hh, mm, ss) | |
sys.stdout.write('\b' * len(timestr)) | |
sys.stdout.write(timestr) | |
sys.stdout.flush() | |
else: | |
raise ValueError, "Too late, you missed joining us!" | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment