Spaces:
Running
Running
File size: 1,087 Bytes
d469baf 66f8fc1 5c884f3 d469baf 66f8fc1 d469baf e55b49e d469baf 5cd1f1d d469baf 5cd1f1d cf1b7f7 2cd3737 d469baf e55b49e 66f8fc1 329f9c0 54d4aaf 329f9c0 66f8fc1 30f4df6 329f9c0 651ebc2 329f9c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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()
|