From 5f9bd1cd3ae8068e89275bcd1f2f45b01e1a9b2f Mon Sep 17 00:00:00 2001 From: z3rOR0ne Date: Wed, 27 Jul 2022 04:50:23 -0700 Subject: [PATCH] :tada: Added python test scripts for prep of bgit --- scripts/python/test.py | 12 ++++++++++++ scripts/python/timer | 17 +++++++++++++++++ scripts/python/timer.py | 13 +++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 scripts/python/test.py create mode 100755 scripts/python/timer create mode 100644 scripts/python/timer.py diff --git a/scripts/python/test.py b/scripts/python/test.py new file mode 100644 index 00000000..0d156623 --- /dev/null +++ b/scripts/python/test.py @@ -0,0 +1,12 @@ +# https://www.simplilearn.com/tutorials/python-tutorial/subprocess-in-python + +from subprocess import Popen, PIPE + +process = Popen(['cat', 'example.txt'], stdout=PIPE, stderr=PIPE) + +stdout,stderr = process.communicate() + +print(stdout) + +# import subprocess +# subprocess.call(["git", "status"]) diff --git a/scripts/python/timer b/scripts/python/timer new file mode 100755 index 00000000..93b5946f --- /dev/null +++ b/scripts/python/timer @@ -0,0 +1,17 @@ +#!/bin/python + +# https://realpython.com/python-subprocess/ + +import subprocess +from argparse import ArgumentParser +from time import sleep + +parser = ArgumentParser() +parser.add_argument("time", type=int) +args = parser.parse_args() +print(f"Starting timer of {args.time} seconds") +for _ in range(args.time): + print(".", end="", flush=True) + sleep(1) +# print("Done!") +subprocess.call(["notify-send", "Done!"]) diff --git a/scripts/python/timer.py b/scripts/python/timer.py new file mode 100644 index 00000000..05f51f37 --- /dev/null +++ b/scripts/python/timer.py @@ -0,0 +1,13 @@ +# https://realpython.com/python-subprocess/ + +from argparse import ArgumentParser +from time import sleep + +parser = ArgumentParser() +parser.add_argument("time", type=int) +args = parser.parse_args() +print(f"Starting timer of {args.time} seconds") +for _ in range(args.time): + print(".", end="", flush=True) + sleep(1) +print("Done!")