diff options
Diffstat (limited to 'hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py')
-rwxr-xr-x | hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py index 88234cbf..d5b380d0 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py @@ -102,12 +102,17 @@ def main(): # An active task has just been started. if "start" in modified and "start" not in original: # Prevent this task from starting if "task +ACTIVE count" is greater than "MAX_ACTIVE". - p = subprocess.Popen(["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], stdout=subprocess.PIPE) + p = subprocess.Popen( + ["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], + stdout=subprocess.PIPE, + ) out, err = p.communicate() count = int(out.rstrip()) if count >= MAX_ACTIVE: - print("Only %d task(s) can be active at a time. " - "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE) + print( + "Only %d task(s) can be active at a time. " + "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE + ) sys.exit(1) # An active task has just been stopped. @@ -119,10 +124,18 @@ def main(): if UDA_KEY not in modified: modified[UDA_KEY] = 0 - this_duration = (end - start) - total_duration = (this_duration + duration_str_to_time_delta(str(modified[UDA_KEY]))) - print("Total Time Tracked: %s (%s in this instance)" % (total_duration, this_duration)) - modified[UDA_KEY] = str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + "seconds" + this_duration = end - start + total_duration = this_duration + duration_str_to_time_delta( + str(modified[UDA_KEY]) + ) + print( + "Total Time Tracked: %s (%s in this instance)" + % (total_duration, this_duration) + ) + modified[UDA_KEY] = ( + str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + + "seconds" + ) return json.dumps(modified, separators=(",", ":")) |