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!")