44
55from core import Server , Status , Coalition , utils
66from packaging .version import parse
7+ from threading import Thread
78from typing import Optional
8-
99from services .music .radios .base import RadioInitError , Radio
1010from plugins .music .utils import get_tag
1111
@@ -41,8 +41,16 @@ def exe_path() -> str:
4141 else :
4242 return os .path .join (srs_inst , "DCS-SR-ExternalAudio.exe" )
4343
44- def run_subprocess ():
45- return subprocess .Popen ([
44+ def run_subprocess () -> subprocess .Popen :
45+ def _log_output (self , p : subprocess .Popen ):
46+ for line in iter (p .stdout .readline , b'' ):
47+ self .log .debug (line .decode ('utf-8' ).rstrip ())
48+
49+ debug = self .service .get_config ().get ('debug' , False )
50+ out = subprocess .PIPE if debug else subprocess .DEVNULL
51+ err = subprocess .PIPE if debug else subprocess .DEVNULL
52+
53+ args = [
4654 exe_path (),
4755 "-f" , str (self .config ['frequency' ]),
4856 "-m" , self .config ['modulation' ],
@@ -51,7 +59,13 @@ def run_subprocess():
5159 "-p" , str (srs_port ),
5260 "-n" , self .config .get ('display_name' , 'DCSSB MusicBox' ),
5361 "-i" , file
54- ], stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
62+ ]
63+ if debug :
64+ self .log .debug (f"Running { ' ' .join (args )} " )
65+ p = subprocess .Popen (args , stdout = out , stderr = err )
66+ if debug :
67+ Thread (target = _log_output , args = (p ,), daemon = True ).start ()
68+ return p
5569
5670 self .process = await asyncio .to_thread (run_subprocess )
5771 coalition = Coalition .BLUE if int (self .config ['coalition' ]) == 2 else Coalition .RED
0 commit comments