File size: 875 Bytes
dab2de2
4c04f50
 
dab2de2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
"""Talk to spaces VM via subprocess.check_output."""
# pylint: disable=unused-variable, invalid-name

# 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",
    ],
    title="probe the system",
    description="talk to the system via subprocess.check_output ",
)

# iface.launch(share=True, debug=True)
iface.launch(debug=True)