|
1 | 1 | import gradio as gr
|
| 2 | +import json |
2 | 3 |
|
3 |
| -from modules import ui_common, shared, script_callbacks, scripts, sd_models, sysinfo, timer, shared_items |
| 4 | +from modules import ui_common, shared, script_callbacks, scripts, sd_models, sysinfo, timer, shared_items, paths_internal, util |
4 | 5 | from modules.call_queue import wrap_gradio_call_no_job
|
5 | 6 | from modules.options import options_section
|
6 | 7 | from modules.shared import opts
|
7 | 8 | from modules.ui_components import FormRow
|
8 | 9 | from modules.ui_gradio_extensions import reload_javascript
|
9 | 10 | from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 11 | +from pathlib import Path |
10 | 12 |
|
11 | 13 |
|
12 | 14 | def get_value_for_setting(key):
|
@@ -172,14 +174,24 @@ def create_ui(self, loadsave, dummy_component):
|
172 | 174 | with gr.TabItem("Sysinfo", id="sysinfo", elem_id="settings_tab_sysinfo"):
|
173 | 175 | download_sysinfo = gr.Button(value='Download system info', elem_id="internal-download-sysinfo", visible=False)
|
174 | 176 | open_sysinfo = gr.Button(value='Open as text in a new page', elem_id="internal-open-sysinfo", visible=False)
|
175 |
| - sysinfo_textbox = gr.Textbox('', elem_id='internal-sysinfo-textbox', interactive=False, visible=False) |
176 | 177 | sysinfo_html = gr.HTML('''<a class="sysinfo_big_link" onclick="gradioApp().getElementById('internal-download-sysinfo').click();">Download system info</a><br/><a onclick="gradioApp().getElementById('internal-open-sysinfo').click();">(or open as text in a new page)</a>''', elem_id="sysinfo_download")
|
177 | 178 |
|
178 |
| - def get_sysinfo(): |
179 |
| - return sysinfo.get(), gr.update() |
180 |
| - |
181 |
| - download_sysinfo.click(fn=get_sysinfo, outputs=[sysinfo_textbox, sysinfo_html], show_progress=True).then(fn=None, _js='downloadSysinfo') |
182 |
| - open_sysinfo.click(fn=get_sysinfo, outputs=[sysinfo_textbox, sysinfo_html], show_progress=True).then(fn=None, _js='openTabSysinfo') |
| 179 | + sysinfo_path = Path(paths_internal.script_path) / 'tmp' / 'sysinfo.json' |
| 180 | + |
| 181 | + def create_sysinfo(): |
| 182 | + sysinfo_path.parent.mkdir(parents=True, exist_ok=True) |
| 183 | + sysinfo_path.write_text(sysinfo.get(), encoding='utf8', newline='\n') |
| 184 | + return gr.update() |
| 185 | + |
| 186 | + sysinfo_path_url = json.dumps(f"file={util.truncate_path(sysinfo_path)}") |
| 187 | + download_sysinfo.click( |
| 188 | + fn=create_sysinfo, outputs=[sysinfo_html], show_progress=True).success( |
| 189 | + fn=None, _js=f"function(){{downloadSysinfo({sysinfo_path_url});}}" |
| 190 | + ) |
| 191 | + open_sysinfo.click( |
| 192 | + fn=create_sysinfo, outputs=[sysinfo_html], show_progress=True).success( |
| 193 | + fn=None, _js=f"function(){{window.open({sysinfo_path_url}, '_blank');}}" |
| 194 | + ) |
183 | 195 |
|
184 | 196 | with gr.Row():
|
185 | 197 | with gr.Column(scale=1):
|
|
0 commit comments