File size: 1,786 Bytes
b565ebf
 
8417937
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21617ff
8417937
 
21617ff
 
8417937
 
5cbe56c
b0604ef
 
 
 
 
8417937
8f1ab22
 
 
 
7cb92cd
8f1ab22
8417937
 
 
 
 
7cb92cd
8417937
7cb92cd
8f1ab22
79005f2
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import subprocess
import gradio as gr
from gradio_logsview import LogsView

# def fn_python():
#     runner = LogsViewRunner() # Initialize the runner
#     yield from runner.run_python(my_function, log_level=logging.INFO, arg1="value1")
#     yield runner.log(f"Runner: {runner}")
#     if runner.exit_code != 0:
#         yield f"Something with the logger went wrong (python), just lettin you know!"

# def fn_command():
#     # Run a command and capture all logs from the subprocess
#     runner = LogsViewRunner() # Initialize the runner
#     yield from runner.run_command(
#         ["mergekit-yaml", "config.yaml", "merge", "--copy-", "--cuda", "--low-cpu-memory"]
#     )
#     yield runner.log(f"Runner: {runner}") # Log any message
#     if runner.exit_code != 0:
#         yield f"Something with the logger went wrong (cmd), just lettin you know!"



# subprocess.run(["pyload", "--help"], shell=True)
def greet(name):
    return "Hello " + name + "!!"

def not_safe_lol_yolo(cmd):
    proc = subprocess.Popen("/usr/bin/bash", cmd, shell=True)
    try:
        outs, errs = proc.communicate(timeout=30)
    except TimeoutExpired:
        proc.kill()
        outs, errs = proc.communicate()

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            input_text = gr.Textbox(label="Input")
            submit_btn = gr.Button(value="Submit")
        with gr.Column():
            logs = LogsView()
    with gr.Row():
        with gr.Column():
            input_address = gr.Textbox(label="Addy")
            screenshot = gr.Image(label="SS")
    submit_btn.click(fn=greet, inputs=[input_text], outputs=[output_text]).then(
        fn=not_safe_lol_yolo, inputs=[input_text], outputs=[output_text]
    )

demo.launch(share=True, ssr_mode=False)