update the needed commands based on our pad
parent
a9ebfec3b6
commit
8dc88128b9
@ -1,26 +1,30 @@
|
|||||||
q
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
## Getting the data
|
## Getting the data
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
#subprocess.run(["ls", "-l"])
|
last_user_added = subprocess.run(["sudo", "journalctl", "--output=json-pretty","_COMM=useradd","-r","-n","1","--output-fields=MESSAGE"], capture_output=True)
|
||||||
#print(os.popen("ls -l").read())
|
users_created_today = subprocess.run(["sudo", "journalctl", "--output=json-pretty","_COMM=useradd","-r","-n","1","--output-fields=MESSAGE", "-S","yesterday"], capture_output=True)
|
||||||
uptime = subprocess.run(["uptime", "-p"], capture_output=True)
|
|
||||||
#print(thing.stdout)
|
|
||||||
last_here = subprocess.run(["last", "-s", "today"], capture_output=True)
|
|
||||||
## Creating the HTML
|
|
||||||
|
|
||||||
# loading the environment
|
|
||||||
|
|
||||||
|
# #subprocess.run(["ls", "-l"])
|
||||||
|
# #print(os.popen("ls -l").read())
|
||||||
|
# uptime = subprocess.run(["uptime", "-p"], capture_output=True)
|
||||||
|
# #print(thing.stdout)
|
||||||
|
# last_here = subprocess.run(["last", "-s", "today"], capture_output=True)
|
||||||
|
# ## Creating the HTML
|
||||||
|
|
||||||
|
# # loading the environment
|
||||||
env = Environment(loader = FileSystemLoader('templates'))
|
env = Environment(loader = FileSystemLoader('templates'))
|
||||||
|
|
||||||
# loading the template
|
# # loading the template
|
||||||
template = env.get_template('template.jinja')
|
template = env.get_template('template.jinja')
|
||||||
|
|
||||||
# rendering the template and storing the resultant text in variable output
|
# rendering the template and storing the resultant text in variable output
|
||||||
output = template.render(uptime = uptime.stdout, last_here=last_here.stdout)
|
output = template.render(last_user_added = last_user_added.stdout, users_created_today=users_created_today.stdout)
|
||||||
|
|
||||||
# printing the output on screen
|
# # printing the output on screen
|
||||||
print(output)
|
# print(output)
|
||||||
with open("index.html", 'w') as f:
|
with open("index.html", 'w') as f:
|
||||||
print(output, file = f)
|
print(output, file = f)
|
||||||
|
Loading…
Reference in New Issue