def main(): # print a banner print " _ _ _ _ " print "| |_ ___ __ _ __ _| | _ __ ___ _ __ _ __ ___ __ _| (_)_______ _ __ " print "| __/ _ \ / _` |/ _` | | | '_ \ / _ \| '__| '_ ` _ \ / _` | | |_ / _ \ '__|" print "| || (_) | (_| | (_| | | | | | | (_) | | | | | | | | (_| | | |/ / __/ | " print " \__\___/ \__, |\__, |_| |_| |_|\___/|_| |_| |_| |_|\__,_|_|_/___\___|_| " print " |___/ |___/ " print "" try: # read and print options opts = options() print "" print "Days: from {0} to {1}.".format(opts.start_date, opts.end_date) print "Hours per day: {0}".format(common.secs_to_hms_str(int(round(opts.hours_per_day*60*60)))) # test toggl API connection toggl = Toggl() print "" print "Testing toggl connection...", toggl.login() print "Ok." print "" # iterate through each day from start_date to end_date and normalize each one current_day = opts.start_date while current_day <= opts.end_date: normalize_day(toggl, current_day) current_day += timedelta(days=1) print "" print "Done." except Exception, e: print "" print "Error:", e raise
def main(): try: # read and print options opts = options() print "" print "Days: from {0} to {1}.".format(opts.start_date, opts.end_date) print "Csv report: \"{0}\"".format(opts.csv_file) # test toggl API connection toggl = Toggl() print "" print "Testing toggl connection...", toggl.login() print "Ok." print "" # iterate through each day from start_date to end_date and report on each one daily_reports = [] current_day = opts.start_date while current_day <= opts.end_date: report = day_report(toggl, current_day) daily_reports.append((current_day, report)) current_day += timedelta(days=1) # generate the csv report print "" print "Generating report...", generate_report(opts.csv_file, daily_reports) print "Ok." print "" print "Done." except Exception: print "" print "Error:" raise