NitinBot002 commited on
Commit
c9da93d
·
verified ·
1 Parent(s): 1083646

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -18
app.py CHANGED
@@ -12,23 +12,19 @@ app = Flask(__name__)
12
  # Global variable to track code-server process
13
  code_server_process = None
14
 
15
- def install_code_server():
16
- """Install code-server"""
17
  try:
18
- print("Installing code-server...")
19
- # Download and install code-server
20
- subprocess.run([
21
- "curl", "-fsSL", "https://code-server.dev/install.sh"
22
- ], check=True, capture_output=True, text=True)
23
-
24
- # Make it executable and install
25
- install_cmd = "curl -fsSL https://code-server.dev/install.sh | sh"
26
- subprocess.run(install_cmd, shell=True, check=True)
27
-
28
- print("Code-server installed successfully!")
29
  return True
30
- except subprocess.CalledProcessError as e:
31
- print(f"Error installing code-server: {e}")
32
  return False
33
 
34
  def start_code_server():
@@ -181,9 +177,9 @@ def initialize_environment():
181
  """Initialize the complete environment"""
182
  print("Initializing environment...")
183
 
184
- # Install code-server
185
- if not install_code_server():
186
- print("Failed to install code-server")
187
  return False
188
 
189
  # Setup workspace
 
12
  # Global variable to track code-server process
13
  code_server_process = None
14
 
15
+ def check_code_server():
16
+ """Check if code-server is installed"""
17
  try:
18
+ result = subprocess.run(
19
+ ["code-server", "--version"],
20
+ check=True,
21
+ capture_output=True,
22
+ text=True
23
+ )
24
+ print(f"Code-server version: {result.stdout.strip()}")
 
 
 
 
25
  return True
26
+ except (subprocess.CalledProcessError, FileNotFoundError) as e:
27
+ print(f"Code-server not found: {e}")
28
  return False
29
 
30
  def start_code_server():
 
177
  """Initialize the complete environment"""
178
  print("Initializing environment...")
179
 
180
+ # Check if code-server is installed
181
+ if not check_code_server():
182
+ print("Code-server is not installed!")
183
  return False
184
 
185
  # Setup workspace