From d402281dc16b311c83124e4f350b340a10e1de26 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Wed, 15 Sep 2021 09:29:18 -0400 Subject: [PATCH] moved the python tools into the python directory --- python/convert-epoch | 27 ++++++++++++++ fake-logs => python/fake-logs | 0 python/how-long-since | 35 +++++++++++++++++++ python-web-server => python/python-web-server | 0 .../quarantine-day-counter | 0 speedtest => python/speedtest | 0 6 files changed, 62 insertions(+) create mode 100755 python/convert-epoch rename fake-logs => python/fake-logs (100%) create mode 100755 python/how-long-since rename python-web-server => python/python-web-server (100%) rename quarantine-day-counter => python/quarantine-day-counter (100%) rename speedtest => python/speedtest (100%) diff --git a/python/convert-epoch b/python/convert-epoch new file mode 100755 index 0000000..3234e2a --- /dev/null +++ b/python/convert-epoch @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import argparse +import time +import color + +def parse_args(): + argp = argparse.ArgumentParser() + argp.add_argument('epoch_time', help="Epoch time value") + return argp.parse_args() + + +def convert_time(epoch): + local_time = time.strftime("%c", time.localtime(epoch)) + zulu_time = time.strftime("%c", time.gmtime(epoch)) + return (local_time, zulu_time) + + +if __name__ == "__main__": + args = parse_args() + + local_time, zulu_time = convert_time(float(args.epoch_time)) + + print(f"\nEpoch time: {color.red(args.epoch_time)}") + print(f"Local time: {color.yellow(local_time)}") + print(f"Zulu time: {color.yellow(zulu_time)}\n") + diff --git a/fake-logs b/python/fake-logs similarity index 100% rename from fake-logs rename to python/fake-logs diff --git a/python/how-long-since b/python/how-long-since new file mode 100755 index 0000000..157ad71 --- /dev/null +++ b/python/how-long-since @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +""" +Calculates the number of actual days since everyone +went into hiding (quarantine). +""" + +import argparse +import datetime +import dateutil.parser +import color + + +def parse_args(): + argp = argparse.ArgumentParser() + argp.add_argument('starting_date', help="Provide a starting date as a string") + argp.add_argument('--utc', '-u', action='store_true', help="From UTC perspective") + return argp.parse_args() + + +if __name__ == "__main__": + args = parse_args() + + if args.utc: + right_now = datetime.datetime.utcnow() + else: + right_now = datetime.datetime.now() + + delta = right_now - dateutil.parser.parse(args.starting_date) + + total_days = delta.days + years = total_days / 365.25 + weeks = (total_days % 365.25) / 7 + + diff --git a/python-web-server b/python/python-web-server similarity index 100% rename from python-web-server rename to python/python-web-server diff --git a/quarantine-day-counter b/python/quarantine-day-counter similarity index 100% rename from quarantine-day-counter rename to python/quarantine-day-counter diff --git a/speedtest b/python/speedtest similarity index 100% rename from speedtest rename to python/speedtest