Created
May 10, 2016 20:42
-
-
Save pekkavaa/a81ed09f79dd7814919a2d7a69d8d095 to your computer and use it in GitHub Desktop.
A "timetracker" "application"
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
import readline | |
import datetime | |
logpath = "times.txt" | |
lines = [] | |
try: | |
with open(logpath, "r") as f: | |
lines = f.readlines() | |
except: | |
print "%s doesn't exist yet, no problem." % logpath | |
for l in lines[-3:]: | |
p = l.split(";") | |
print "%s\t%s" % (p[0], p[1].strip()) | |
line = raw_input("> ") | |
print line | |
date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') | |
with open(logpath, "a") as f: | |
msg = "%s; %s\n" % (date, line) | |
f.write(msg) | |
print msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment