Spaces:
Running
Running
Commit Β·
39f65bf
1
Parent(s): b617b0d
command fix
Browse files
app.py
CHANGED
|
@@ -55,8 +55,15 @@ def run_space_interface():
|
|
| 55 |
|
| 56 |
def terminal_logic(command):
|
| 57 |
output_buffer = io.StringIO()
|
| 58 |
-
#
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
import cli_app.command_handler as handler
|
| 62 |
old_console = getattr(handler, 'console', None)
|
|
@@ -65,6 +72,7 @@ def run_space_interface():
|
|
| 65 |
try:
|
| 66 |
result = handler.handle_command(command)
|
| 67 |
captured = output_buffer.getvalue()
|
|
|
|
| 68 |
return captured if not result else f"{captured}\n{result}"
|
| 69 |
except Exception as e:
|
| 70 |
return f"Error: {str(e)}"
|
|
@@ -72,15 +80,16 @@ def run_space_interface():
|
|
| 72 |
if old_console:
|
| 73 |
handler.console = old_console
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
| 84 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 85 |
|
| 86 |
if __name__ == "__main__":
|
|
|
|
| 55 |
|
| 56 |
def terminal_logic(command):
|
| 57 |
output_buffer = io.StringIO()
|
| 58 |
+
# width=80 is safer for mobile/small screens
|
| 59 |
+
# color_system=None is CRITICAL to stop the [3m junk
|
| 60 |
+
temp_console = Console(
|
| 61 |
+
file=output_buffer,
|
| 62 |
+
force_terminal=True,
|
| 63 |
+
width=80,
|
| 64 |
+
color_system=None,
|
| 65 |
+
legacy_windows=False
|
| 66 |
+
)
|
| 67 |
|
| 68 |
import cli_app.command_handler as handler
|
| 69 |
old_console = getattr(handler, 'console', None)
|
|
|
|
| 72 |
try:
|
| 73 |
result = handler.handle_command(command)
|
| 74 |
captured = output_buffer.getvalue()
|
| 75 |
+
# If your handler already prints, we just return the captured text
|
| 76 |
return captured if not result else f"{captured}\n{result}"
|
| 77 |
except Exception as e:
|
| 78 |
return f"Error: {str(e)}"
|
|
|
|
| 80 |
if old_console:
|
| 81 |
handler.console = old_console
|
| 82 |
|
| 83 |
+
with gr.Blocks(title="EDA Explorer Terminal", theme="monochrome") as demo:
|
| 84 |
+
gr.Markdown("# π EDA Explorer Terminal")
|
| 85 |
+
gr.Markdown("Type `help` to see commands or `list` to see datasets.")
|
| 86 |
+
|
| 87 |
+
input_box = gr.Textbox(label="Command", placeholder="Type here...", autofocus=True)
|
| 88 |
+
# gr.Code forces the Monospace font so the table lines (βββ) align!
|
| 89 |
+
output_box = gr.Code(label="Console Output", language="text", lines=20)
|
| 90 |
+
|
| 91 |
+
input_box.submit(fn=terminal_logic, inputs=input_box, outputs=output_box)
|
| 92 |
+
|
| 93 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 94 |
|
| 95 |
if __name__ == "__main__":
|