Update app.py
Browse files
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
|
| 16 |
-
"""
|
| 17 |
try:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 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"
|
| 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 |
-
#
|
| 185 |
-
if not
|
| 186 |
-
print("
|
| 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
|