From fc194c9f7ab2ad7826b8e356626a21d0cbb28d2e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Aug 2012 23:54:19 +0200 Subject: [PATCH] begin initial argparser Signed-off-by: Nico Schottelius --- README | 6 ++++++ ctt.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/README b/README index f5cffb8..56e5b0d 100644 --- a/README +++ b/README @@ -3,6 +3,12 @@ ctt - time tracking for geeks ctt [list of tags] - starts time tracking press ctrl-c to stop time tracking +ctt -t|--track ctt --start "date" ctt --start "date" --stop "otherdate" + +Save to ~/.ctt/times// + +Dateformat: + YYYY-MM-DD-hh:mm diff --git a/ctt.py b/ctt.py index 7b38ad1..81af5ec 100755 --- a/ctt.py +++ b/ctt.py @@ -1,10 +1,59 @@ #!/usr/bin/env python3 +import argparse import calendar import datetime +import signal + import locale +import time -# Setup locale +import os +import os.path +import sys +#def user_datetime(when): +# """Print time for the user""" +# return when.ctime() + + +# Setup locale for calendar printing +# Setup locale to get Timezone information? print(locale.getlocale()) + +# Record project +# Record tags + +parser = argparse.ArgumentParser() +parser.add_argument("project_name", nargs=1) + +args = parser.parse_args(sys.argv[1:]) + + +sys.exit(0) + +# Setup signal handler + +# Start tracking +start = datetime.datetime.now() +print("Starting at %s" % (start.ctime())) + +time.sleep(2) + +# Stop tracking +stop = datetime.datetime.now() +print("Stopped at %s" % (stop.ctime())) + +delta = stop - start +print("%s, %s, seconds=%s, %s" % (type(delta), delta, delta.total_seconds(), start.strftime("%s"))) + +# Save stuff to our home directory + +# Prepare home directory +home = os.environ['HOME'] +ctt_home = home + os.path.join(home, ".ctt") +os.makedirs(ctt_home, mode=0o700, exist_ok=True) + +# Create datetime from userinput +# Wed Aug 1 23:35:53 2012