Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -530,13 +530,19 @@ def run_vm_command(command, current_output="", command_history=""):
|
|
| 530 |
# Add color coding for common patterns
|
| 531 |
colored_output = colorize_output(output)
|
| 532 |
|
| 533 |
-
# Format terminal-style output
|
| 534 |
-
new_line = f"
|
| 535 |
if exit_code != 0:
|
| 536 |
new_line += f"\n[Exit code: {exit_code}]"
|
| 537 |
new_line += "\n$ "
|
| 538 |
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
else:
|
| 541 |
error_line = f"\n$ {command}\nError: VM API returned {response.status_code}\n$ "
|
| 542 |
return current_output + error_line, "", new_history
|
|
@@ -700,6 +706,18 @@ custom_css = """
|
|
| 700 |
border-color: #00ff00 !important;
|
| 701 |
box-shadow: 0 0 5px rgba(0, 255, 0, 0.3) !important;
|
| 702 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 703 |
"""
|
| 704 |
|
| 705 |
def create_dashboard():
|
|
@@ -902,15 +920,31 @@ def create_dashboard():
|
|
| 902 |
# VM Terminal tab - Updated to handle HTML output and command history
|
| 903 |
def run_and_clear(cmd, output, history):
|
| 904 |
new_output, _, new_history = run_vm_command(cmd, output, history)
|
| 905 |
-
#
|
| 906 |
-
|
|
|
|
|
|
|
| 907 |
<script>
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 914 |
</script>'''
|
| 915 |
return html_output, "", new_history
|
| 916 |
|
|
|
|
| 530 |
# Add color coding for common patterns
|
| 531 |
colored_output = colorize_output(output)
|
| 532 |
|
| 533 |
+
# Format terminal-style output with clean spacing
|
| 534 |
+
new_line = f"$ {command}\n{colored_output.strip()}"
|
| 535 |
if exit_code != 0:
|
| 536 |
new_line += f"\n[Exit code: {exit_code}]"
|
| 537 |
new_line += "\n$ "
|
| 538 |
|
| 539 |
+
# Clean up the output - remove extra whitespace and format nicely
|
| 540 |
+
if current_output.strip():
|
| 541 |
+
full_output = current_output.rstrip() + "\n" + new_line
|
| 542 |
+
else:
|
| 543 |
+
full_output = new_line
|
| 544 |
+
|
| 545 |
+
return full_output, "", new_history
|
| 546 |
else:
|
| 547 |
error_line = f"\n$ {command}\nError: VM API returned {response.status_code}\n$ "
|
| 548 |
return current_output + error_line, "", new_history
|
|
|
|
| 706 |
border-color: #00ff00 !important;
|
| 707 |
box-shadow: 0 0 5px rgba(0, 255, 0, 0.3) !important;
|
| 708 |
}
|
| 709 |
+
|
| 710 |
+
/* Additional CSS to ensure Gradio containers also auto-scroll */
|
| 711 |
+
.gr-html {
|
| 712 |
+
max-height: 500px !important;
|
| 713 |
+
overflow-y: auto !important;
|
| 714 |
+
scrollbar-width: none !important;
|
| 715 |
+
-ms-overflow-style: none !important;
|
| 716 |
+
}
|
| 717 |
+
|
| 718 |
+
.gr-html::-webkit-scrollbar {
|
| 719 |
+
display: none !important;
|
| 720 |
+
}
|
| 721 |
"""
|
| 722 |
|
| 723 |
def create_dashboard():
|
|
|
|
| 920 |
# VM Terminal tab - Updated to handle HTML output and command history
|
| 921 |
def run_and_clear(cmd, output, history):
|
| 922 |
new_output, _, new_history = run_vm_command(cmd, output, history)
|
| 923 |
+
# Clean up the output formatting
|
| 924 |
+
cleaned_output = new_output.replace('\n', '<br>').replace('\r', '')
|
| 925 |
+
# Create HTML with better auto-scroll
|
| 926 |
+
html_output = f'''<div class="terminal-display" id="terminal-{hash(new_output) % 10000}">{cleaned_output}</div>
|
| 927 |
<script>
|
| 928 |
+
(function() {{
|
| 929 |
+
setTimeout(() => {{
|
| 930 |
+
// Find all terminal containers and scroll them
|
| 931 |
+
const containers = document.querySelectorAll('.terminal-container');
|
| 932 |
+
containers.forEach(container => {{
|
| 933 |
+
container.scrollTop = container.scrollHeight;
|
| 934 |
+
}});
|
| 935 |
+
|
| 936 |
+
// Also try to find the parent gradio component
|
| 937 |
+
const gradioHTML = document.querySelector('[data-testid*="html"]');
|
| 938 |
+
if (gradioHTML) {{
|
| 939 |
+
const scrollable = gradioHTML.querySelector('.terminal-container') ||
|
| 940 |
+
gradioHTML.closest('.scroll-hide') ||
|
| 941 |
+
gradioHTML.parentElement;
|
| 942 |
+
if (scrollable) {{
|
| 943 |
+
scrollable.scrollTop = scrollable.scrollHeight;
|
| 944 |
+
}}
|
| 945 |
+
}}
|
| 946 |
+
}}, 50);
|
| 947 |
+
}})();
|
| 948 |
</script>'''
|
| 949 |
return html_output, "", new_history
|
| 950 |
|