File size: 913 Bytes
08bc52f c015fd4 c33b262 7faa9af c90742c 08bc52f c015fd4 c90742c c015fd4 80c38e5 c90742c 7faa9af c33b262 7faa9af 80c38e5 c90742c 80c38e5 c90742c 78ab3ee 80c38e5 7faa9af 0bf7d6b 0c951fa 0bf7d6b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
"""Talk to spaces VM via subprocess.check_output."""
# import httpx
import subprocess as sp
from shlex import split
import gradio as gr
def greet(command):
"""Probe vm."""
try:
out = sp.check_output(split(command), encoding="utf8")
except Exception as e:
out = str(e)
# return "Hello " + name + "!!"
if not (out and out.strip()):
out = "No output, that's all we know."
return out
iface = gr.Interface(
fn=greet,
inputs="text",
outputs="text",
examples=[
"cat /proc/version",
"free # show free memory",
"uname -m",
"df -h .",
"cat /proc/cpuinfo",
"""python -c "from psutil import virtual_memory; print(virtual_memory())" """,
],
title="probe the system",
description="talk to the system via subprocess.check_output ",
)
# iface.launch(share=True, debug=True)
iface.launch(debug=True)
|