@@ -27,14 +27,20 @@ def start_lsl():
27
27
try :
28
28
# Start the LSL stream as a subprocess
29
29
if sys .platform == "win32" :
30
- lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ], creationflags = subprocess .CREATE_NO_WINDOW )
31
- else :
32
- lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ])
33
-
34
- if lsl_process .poll () is None :
35
- return render_template ("index.html" , lsl_started = True , lsl_status = "Running" , lsl_color = "green" )
30
+ lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ],stdout = subprocess .PIPE ,stderr = subprocess .PIPE , creationflags = subprocess .CREATE_NO_WINDOW )
36
31
else :
32
+ lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ],stdout = subprocess .PIPE ,stderr = subprocess .PIPE )
33
+ output = lsl_process .stderr .readline ().decode ().strip () # Read the initial stderr line
34
+
35
+ print (output )
36
+ if output == "No" :
37
37
return render_template ("index.html" , lsl_started = False , lsl_status = "Failed to Start" , lsl_color = "red" )
38
+ else :
39
+ return render_template ("index.html" , lsl_started = True , lsl_status = "Running" , lsl_color = "green" )
40
+ except subprocess .TimeoutExpired :
41
+ return render_template (
42
+ "index.html" , lsl_started = False , lsl_status = "Timeout Error" , lsl_color = "red"
43
+ )
38
44
except Exception as e :
39
45
return render_template ("index.html" , lsl_started = False , lsl_status = f"Error: { e } " , lsl_color = "red" )
40
46
0 commit comments