asynchronousai commited on
Commit
0d2fbdc
·
verified ·
1 Parent(s): fb40c59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -16,7 +16,29 @@ CSharpOptions:
16
  EntryPointName: Game
17
  MainMethodName: Main
18
  AssemblyName: ExampleProject""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
20
  def compile(cs):
21
  # Create file
22
  with open(file_path, 'w') as file:
@@ -25,7 +47,7 @@ def compile(cs):
25
  # Run command
26
  try:
27
  result = subprocess.run(
28
- ['dotnet', 'run', '--project roblox-cs-master/RobloxCS.CLI/RobloxCS.CLI.csproj']
29
  capture_output=True,
30
  text=True,
31
  check=True
@@ -37,5 +59,7 @@ def compile(cs):
37
 
38
  return 'ha'
39
 
 
 
40
  demo = gr.Interface(fn=compile, inputs="text", outputs="text")
41
  demo.launch()
 
16
  EntryPointName: Game
17
  MainMethodName: Main
18
  AssemblyName: ExampleProject""")
19
+ def check_dotnet_installed():
20
+ try:
21
+ result = subprocess.run(['dotnet', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
22
+ if result.returncode == 0:
23
+ print(f".NET is already installed. Version: {result.stdout.strip()}")
24
+ return True
25
+ else:
26
+ print("Unable to find .NET installed.")
27
+ return False
28
+ except FileNotFoundError:
29
+ print(".NET is not installed.")
30
+ return False
31
+
32
+ def install_dotnet():
33
+ print("Installing .NET SDK...")
34
+
35
+ subprocess.run(["wget", "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb", "-O", "packages-microsoft-prod.deb"], check=True)
36
+ subprocess.run(["sudo", "dpkg", "-i", "packages-microsoft-prod.deb"], check=True)
37
+
38
+ subprocess.run(["sudo", "apt-get", "update"], check=True)
39
+ subprocess.run(["sudo", "apt-get", "install", "-y", "dotnet-sdk-8.0"], check=True)
40
 
41
+ print(".NET SDK has been installed.")
42
  def compile(cs):
43
  # Create file
44
  with open(file_path, 'w') as file:
 
47
  # Run command
48
  try:
49
  result = subprocess.run(
50
+ ['dotnet', 'run', '--project roblox-cs-master/RobloxCS.CLI/RobloxCS.CLI.csproj'],
51
  capture_output=True,
52
  text=True,
53
  check=True
 
59
 
60
  return 'ha'
61
 
62
+ if not check_dotnet_installed():
63
+ install_dotnet()
64
  demo = gr.Interface(fn=compile, inputs="text", outputs="text")
65
  demo.launch()