Spaces:
Running
Running
import tempfile | |
import gradio as gr | |
import json | |
import os | |
import subprocess | |
def predict(decompiled_code): | |
with tempfile.TemporaryDirectory() as temp_dir: | |
code_file_name = os.path.join(temp_dir, "code.decompiled") | |
field_file_name = os.path.join(temp_dir, "code.json") | |
with open(code_file_name, "w") as f: | |
f.write('#include "/home/ReSym/clang-parser/defs.hh"\n' + decompiled_code) | |
# subprocess.check_output(["python", "/home/ReSym/process_data/prep_decompiled.py", code_file_name, file_save_dir, parsed_save_dir]) | |
output = subprocess.run(["/home/ReSym/clang-parser/build/field_access", code_file_name, field_file_name], text=True, capture_output=True) | |
print(output) | |
print(output.stdout) | |
field_data = open(field_file_name).read() | |
return field_data | |
def run(): | |
demo = gr.Interface( | |
fn=predict, | |
inputs=gr.Text(), | |
outputs=gr.Text(), | |
) | |
demo.launch(server_name="0.0.0.0", server_port=7860, debug=True) | |
if __name__ == "__main__": | |
print("Starting!") | |
run() | |