Add plays end_metrics.yml and reboot_test3.yml; Add script write_file_msg.py; Update hosts

This commit is contained in:
2025-07-25 15:54:25 -04:00
parent 49b98451a3
commit 2530c8c196
4 changed files with 151 additions and 2 deletions

66
scripts/write_file_msg.py Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/python3
import time
import os
import readline
from datetime import datetime
# Changable optonis:
message = "Testing testing testing..."
max_iterations = 5
# Autocomplete path stuffs:
def complete_path(text, state):
expanded = os.path.expanduser(os.path.expandvars(text))
if os.path.isdir(expanded):
try:
entries = os.listdir(expanded)
completion_list = [
os.path.abspath(os.path.join(expanded, entry)) + '/'
if os.path.isdir(os.path.join(expanded, entry))
else os.path.abspath(os.path.join(expanded, entry))
for entry in entries
]
except FileNotFoundError:
completion_list = []
else:
dirname = os.path.dirname(expanded)
basename = os.path.basename(expanded)
if not dirname:
dirname = '.'
try:
entries = [entry for entry in os.listdir(dirname) if entry.startswith(basename)]
completion_list = [
os.path.abspath(os.path.join(dirname, entry))
for entry in entries
]
except FileNotFoundError:
completion_list = []
completion_list.sort()
try:
return completion_list[state]
except IndexError:
return None
readline.set_completer_delims(' \t\n;')
readline.set_completer(complete_path)
readline.parse_and_bind("tab: complete")
file_path = input("File to write to: ")
try:
for i in range(max_iterations):
ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
tm = "{} -- {}: itr=>{}".format(ts, message, i)
print(f"{file_path} -> {tm}")
with open(file_path, "a") as file:
file.write(tm + '\n')
time.sleep(.2)
except KeyboardInterrupt:
print("Ctrl-C hit; exiting...")