@@ -33,22 +33,22 @@ def start_lsl():
33
33
34
34
try :
35
35
if sys .platform == "win32" :
36
- lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , creationflags = subprocess .CREATE_NO_WINDOW , text = True )
36
+ lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , creationflags = subprocess .CREATE_NO_WINDOW , text = True , bufsize = 1 )
37
37
else :
38
- lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True )
38
+ lsl_process = subprocess .Popen (["python" , "chords.py" , "--lsl" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True , bufsize = 1 )
39
39
40
40
output = lsl_process .stderr .readline ().strip ()
41
41
print (output )
42
42
43
43
if "No" in output :
44
44
lsl_running = False
45
- return jsonify ({ "lsl_started" : False , " lsl_status" : "Failed to Start" , " lsl_color" : "red" } )
45
+ return render_template ( "index.html" , lsl_started = False , lsl_status = "Failed to Start" , lsl_color = "red" , apps_enabled = False )
46
46
else :
47
47
lsl_running = True
48
- return jsonify ({ "lsl_started" : True , " lsl_status" : "Running" , " lsl_color" : "green" } )
48
+ return render_template ( "index.html" , lsl_started = True , lsl_status = "Running" , lsl_color = "green" , apps_enabled = True )
49
49
50
50
except Exception as e :
51
- return jsonify ({ "lsl_started" : False , " lsl_status" : f"Error: { e } " , " lsl_color" : "red" } )
51
+ return render_template ( "index.html" , lsl_started = False , lsl_status = f"Error: { e } " , lsl_color = "red" )
52
52
53
53
def read_npg_output ():
54
54
global npg_process
@@ -73,8 +73,9 @@ def start_npg():
73
73
# Start a separate thread to read npg.py output
74
74
threading .Thread (target = read_npg_output , daemon = True ).start ()
75
75
76
- npg_running = True
77
- return render_template ("index.html" , npg_started = True , npg_status = "Running" , npg_color = "green" , apps_enabled = True )
76
+ if "NPG WebSocket connected!" in npg_process .stdout .readline ().strip ():
77
+ npg_running = True
78
+ return render_template ("index.html" , npg_started = True , npg_status = "Running" , npg_color = "green" , apps_enabled = True )
78
79
79
80
except Exception as e :
80
81
npg_running = False
0 commit comments