Spaces:
Sleeping
Sleeping
File size: 1,749 Bytes
918b834 8e8f958 de1f576 85550bb d5481c1 8e8f958 0d2fbdc 06bc0e5 918b834 0d2fbdc bb4c477 8e8f958 de1f576 8e8f958 0d2fbdc 8e8f958 d9557cb 8e8f958 918b834 0d2fbdc bb4c477 918b834 |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import gradio as gr
import os
import subprocess
folder_path = 'src/server'
file_name = 'main.cs'
file_path = os.path.join(folder_path, file_name)
os.makedirs(folder_path, exist_ok=True)
open('roblox-cs.yml', 'w').write("""SourceFolder: src
OutputFolder: dist
EmitNativeAttributeOnClassOrNamespaceCallbacks: true
EnabledBuiltInTransformers:
- Debug
CSharpOptions:
EntryPointRequired: false
EntryPointName: Game
MainMethodName: Main
AssemblyName: ExampleProject""")
def check_dotnet_installed():
try:
result = subprocess.run(['dotnet', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode == 0:
print(f".NET is already installed. Version: {result.stdout.strip()}")
return True
else:
print("Unable to find .NET installed.")
return False
except FileNotFoundError:
print(".NET is not installed.")
return False
def install_dotnet():
print("Installing .NET SDK...")
# Dont know what to do!?
print(".NET SDK has been installed.")
def compile(cs):
# Create file
with open(file_path, 'w') as file:
file.write(cs)
# Run command
try:
result = subprocess.run(
['dotnet', 'run', '--project roblox-cs-master/RobloxCS.CLI/RobloxCS.CLI.csproj'],
capture_output=True,
text=True,
check=True
)
except subprocess.CalledProcessError as e:
gr.Error(f"Error: `{e.stderr}`, Exit Status: {e.returncode}")
except:
gr.Error("Unknown error!")
return 'ha'
if not check_dotnet_installed():
install_dotnet()
demo = gr.Interface(fn=compile, inputs="text", outputs="text")
demo.launch()
|