I am running a python script from windows command prompt. It calls the function below, which converts an MP3 file to a wave file using LAME.
def convert_mp3_to_wav(input_filename, output_filename):
"""
converts the incoming mp3 file to wave file
"""
if not os.path.exists(input_filename):
raise AudioProcessingException, "file %s does not exist" % input_filename
command = ["lame", "--silent", "--decode", input_filename, output_filename]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = process.communicate()
if process.returncode != 0 or not os.path.exists(output_filename):
raise AudioProcessingException, stdout
return output_filename
Unfortunately LAME always crashes (and lives up to its name) on a certain MP3s. The Windows "Your program has crashed" dialog appears, which freezes my script. Once I close the windows dialog, the AudioProcessingException is raised.
Instead of having to tell Windows to shut up, I'd just like the script to raise the exception and then move onto the next MP3.
Is there any way around this? Preferably by altering the script rather than running it with Unix.
I am using Windows 7, and Python 2.6
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…