Home | Legal Tech | Projects | Writings

Breach Countdown

Keeps track of the time since breach.

Tasklist

  1. Install the [module] module
  2. Write the Script
  3. Initiate Timer
  4. Recall and Restart the Timer

1. Install the Module

The python modules we need to install are called 'arrow' and 'click'.

If you are unsure how to install this module, check the guide at python basics.

2. Write the Script

Open up your text editor and enter the following script:

import arrow
import click

def settime():
    utc = arrow.utcnow()
    target = utc.clone()
    target = target.replace(days=+3)
    with open("target.txt", "w") as target_file:
        target_file.write(str(target))

def printtime(target):
    utc = arrow.utcnow()
    print(target-utc)

def gettime():
    target = ""
    with open("target.txt", "r") as target_file:
        line_1 = target_file.read()
        target = arrow.get(line_1)
    printtime(target)
        
@click.command()
@click.option('-n', is_flag=True)
def time_handler(n):
    if n:
        settime()
    else:
        gettime()

if __name__ == '__main__':
    time_handler()

Save it as "breachtimer.py".

Starting and Recalling the Timer

To use the timer, either navigate in your terminal to the folder breachtimer.py is saved in, or save it in your "bin" folder and make it executable. For a reminder of how to do this, see the python basics page in the theory section.

Setting the timer

To set the timer, run breachtimer with the "-n" flag.

$ breachtimer.py -n

This will start a new timer.

Setting the timer

To recall timer the timer to see how long is left, run breachtimer.py without any flags.

$ breachtimer.py

Better get a move on with that breach report!