Redirected output of the player programs to /dev/null

This commit is contained in:
Dmitri Bogomolov 2017-03-11 13:33:51 +02:00
parent 91eb75b140
commit 84a903f116
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -12,13 +12,17 @@ except ImportError:
play_cmd = {} play_cmd = {}
def _subprocess(*args):
FNULL = open(os.devnull, 'wb')
subprocess.call(
args, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True)
def connect_plugin(sound_file): def connect_plugin(sound_file):
global play_cmd global play_cmd
ext = os.path.splitext(sound_file)[-1] ext = os.path.splitext(sound_file)[-1]
try: try:
subprocess.call([play_cmd[ext], sound_file]) return _subprocess(play_cmd[ext], sound_file)
return
except (KeyError, AttributeError): except (KeyError, AttributeError):
pass pass
@ -29,7 +33,7 @@ except ImportError:
programs += ['mpg123', 'mpg321', 'mpg321-mpg123'] programs += ['mpg123', 'mpg321', 'mpg321-mpg123']
for cmd in programs: for cmd in programs:
try: try:
subprocess.call([cmd, sound_file]) _subprocess(cmd, sound_file)
except OSError: except OSError:
pass # log here! pass # log here!
else: else: