Update app.py
Browse files
app.py
CHANGED
|
@@ -74,10 +74,10 @@ def read_file(filename,cd,status):
|
|
| 74 |
|
| 75 |
def write_file(filename, thecomponent, content, lstf_dp):
|
| 76 |
fauxname=filename
|
| 77 |
-
filename=f"{
|
| 78 |
with open(filename, "w", encoding="utf-8") as f:
|
| 79 |
f.write(content)
|
| 80 |
-
return f"Saved {fauxname}", gr.Dropdown(choices=list_files(files_list, thecomponent), value=f"{
|
| 81 |
|
| 82 |
def empty(cd,crea_name,lst_fls,thecomponent):
|
| 83 |
return gr.Code(label="Step 5: Modify/Edit code.. Don't forget to save modifications..",interactive=True,lines=30), gr.Textbox(label="Optional: Filename to create", placeholder="eg: filename.txt"), gr.Textbox(label=f"{str(os.getcwd())}/{str(thecomponent)}",value=lep(thecomponent),visible=True)
|
|
@@ -88,6 +88,9 @@ def open_file(selected_file,cd,status):
|
|
| 88 |
def save_file(selected_file, thecomponent, content, lstf_dp):
|
| 89 |
return write_file(selected_file, thecomponent, content, lstf_dp)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
| 91 |
def refresh_files(lstf_dp,lst_fls):
|
| 92 |
return gr.Dropdown(choices=list_files(files_list), value=None, type="value"), gr.Textbox(label=f"{str(os.getcwd())}/{str(thecomponent)}",value=lep(thecomponent),visible=True)
|
| 93 |
|
|
@@ -146,7 +149,7 @@ with gr.Blocks() as iface:
|
|
| 146 |
create_fl=gr.Button("Optional: Create file",size="md")
|
| 147 |
lstf_dp.input(open_file, inputs=[lstf_dp,cd,status], outputs=[cd,status])
|
| 148 |
save_btn.click(save_file, inputs=[lstf_dp, cmd_input, cd, lstf_dp], outputs=[status,lstf_dp])
|
| 149 |
-
create_fl.click(
|
| 150 |
spc_btn.click(pushy,[spc_id,spc_tkn, cmd_input],[spc_id,spc_tkn]).then(fn=None,inputs=None,outputs=None,js="""()=>{ window.location.href = window.location.href; };""")
|
| 151 |
run_os_btn.click(run_command_os_system, inputs=[cmd_input,fos,lstf_dp,lst_fls], outputs=[output_os,lstf_dp,lst_fls])
|
| 152 |
iface.launch(ssr_mode=False)
|
|
|
|
| 74 |
|
| 75 |
def write_file(filename, thecomponent, content, lstf_dp):
|
| 76 |
fauxname=filename
|
| 77 |
+
filename=f"./{fauxname}"
|
| 78 |
with open(filename, "w", encoding="utf-8") as f:
|
| 79 |
f.write(content)
|
| 80 |
+
return f"Saved {fauxname}", gr.Dropdown(choices=list_files(files_list, thecomponent), value=f"{fauxname}", type="value")
|
| 81 |
|
| 82 |
def empty(cd,crea_name,lst_fls,thecomponent):
|
| 83 |
return gr.Code(label="Step 5: Modify/Edit code.. Don't forget to save modifications..",interactive=True,lines=30), gr.Textbox(label="Optional: Filename to create", placeholder="eg: filename.txt"), gr.Textbox(label=f"{str(os.getcwd())}/{str(thecomponent)}",value=lep(thecomponent),visible=True)
|
|
|
|
| 88 |
def save_file(selected_file, thecomponent, content, lstf_dp):
|
| 89 |
return write_file(selected_file, thecomponent, content, lstf_dp)
|
| 90 |
|
| 91 |
+
def sove_file(selected_file, thecomponent, content, lstf_dp):
|
| 92 |
+
return write_file(f"{os.getcwd()}/{thecomponent}/{selected_file}", thecomponent, content, lstf_dp)
|
| 93 |
+
|
| 94 |
def refresh_files(lstf_dp,lst_fls):
|
| 95 |
return gr.Dropdown(choices=list_files(files_list), value=None, type="value"), gr.Textbox(label=f"{str(os.getcwd())}/{str(thecomponent)}",value=lep(thecomponent),visible=True)
|
| 96 |
|
|
|
|
| 149 |
create_fl=gr.Button("Optional: Create file",size="md")
|
| 150 |
lstf_dp.input(open_file, inputs=[lstf_dp,cd,status], outputs=[cd,status])
|
| 151 |
save_btn.click(save_file, inputs=[lstf_dp, cmd_input, cd, lstf_dp], outputs=[status,lstf_dp])
|
| 152 |
+
create_fl.click(sove_file,[crea_name,cmd_input,cd,lstf_dp],[status,lstf_dp]).then(empty,[cd,crea_name,lst_fls,cmd_input],[cd,crea_name,lst_fls])##.then(refresh_files,[lstf_dp,lst_fls],[lstf_dp,lst_fls])
|
| 153 |
spc_btn.click(pushy,[spc_id,spc_tkn, cmd_input],[spc_id,spc_tkn]).then(fn=None,inputs=None,outputs=None,js="""()=>{ window.location.href = window.location.href; };""")
|
| 154 |
run_os_btn.click(run_command_os_system, inputs=[cmd_input,fos,lstf_dp,lst_fls], outputs=[output_os,lstf_dp,lst_fls])
|
| 155 |
iface.launch(ssr_mode=False)
|