File size: 972 Bytes
bd88e0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import io, sys, os
import gradio as gr
import time
import sys
import io

def display_log_window():
    def display_stdout():
        while True:
            yield stdout_buffer.getvalue()
            time.sleep(1)

    with gr.Blocks() as demo:
        with gr.Row():
            with gr.Column(visible=True) as sidebar:
                output = gr.Textbox(interactive=False, lines=10, max_lines=20, show_label=False, elem_classes="log-window")
                demo.load(display_stdout, outputs=output)

    demo.queue().launch(server_port=9000)

    stdout_buffer = io.StringIO()
    sys.stdout = stdout_buffer


def get_credentials(use_own_creds: bool):
	HIVEMQ_USERNAME = os.environ.get("HIVEMQ_USERNAME")
	HIVEMQ_PASSWORD = os.environ.get("HIVEMQ_PASSWORD")
	HIVEMQ_HOST = os.environ.get("HIVEMQ_HOST")
	DEVICE_ENDPOINT = os.environ.get("DEVICE_ID")
	PORT = int(os.environ.get("PORT", 8883))
	return HIVEMQ_USERNAME, HIVEMQ_PASSWORD, HIVEMQ_HOST, DEVICE_ENDPOINT, PORT