From 4ebc5237d09bb20f37b83515f0d8ac6a8b81e668 Mon Sep 17 00:00:00 2001 From: Jakob Schnitzer Date: Mon, 15 Oct 2012 16:01:01 +0200 Subject: [PATCH] replaygain: Fix TypeError if command option is not set --- beetsplug/replaygain.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 3092077f6..35fa7853e 100755 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -61,14 +61,16 @@ class ReplayGainPlugin(BeetsPlugin): 'targetlevel', DEFAULT_REFERENCE_LOUDNESS)) self.gain_offset = int(target_level-DEFAULT_REFERENCE_LOUDNESS) self.command = ui.config_val(config,'replaygain','command', None) - if not os.path.isfile(self.command): - raise ui.UserError('no valid rgain command filepath given') - if not self.command: + if self.command: + if not os.path.isfile(self.command): + raise ui.UserError('no valid rgain command filepath given') + else: for cmd in ['mp3gain','aacgain']: - proc = subprocess.Popen([cmd,'-v']) - retcode = proc.poll() - if not retcode: + try: + subprocess.call([cmd,'-v'], stderr=subprocess.PIPE) self.command = cmd + except OSError: + pass if not self.command: raise ui.UserError('no valid rgain command found')