You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
659 B
Python
27 lines
659 B
Python
9 months ago
|
|
||
|
from jinja2 import Environment, FileSystemLoader
|
||
|
|
||
|
## Getting the data
|
||
|
import subprocess
|
||
|
|
||
|
#subprocess.run(["ls", "-l"])
|
||
|
#print(os.popen("ls -l").read())
|
||
|
thing = subprocess.run(["uptime", "-p"], capture_output=True)
|
||
|
print(thing.stdout)
|
||
|
|
||
|
## Creating the HTML
|
||
|
|
||
|
# loading the environment
|
||
|
env = Environment(loader = FileSystemLoader('templates'))
|
||
|
|
||
|
# loading the template
|
||
|
template = env.get_template('template.jinja')
|
||
|
|
||
|
# rendering the template and storing the resultant text in variable output
|
||
|
output = template.render(uptime = thing.stdout)
|
||
|
|
||
|
# printing the output on screen
|
||
|
print(output)
|
||
|
with open("renders/output.html", 'w') as f:
|
||
|
print(output, file = f)
|