From afdf0eea47a3e1ef6f3a151824bb14058612a5a0 Mon Sep 17 00:00:00 2001 From: Colin McCabe Date: Wed, 27 Jan 2010 13:52:14 -0800 Subject: [PATCH] tagger.py: make sure that we have the id3v2 prog --- tagger.py | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/tagger.py b/tagger.py index bda52af..88d2b0e 100755 --- a/tagger.py +++ b/tagger.py @@ -65,6 +65,16 @@ def find_companion_script(target): print "ERROR: can't find id3v2_wrapper.sh: " + str(e) sys.exit(1) +# Verifies that a given program is installed. +def verify_program_installed(prog): + try: + proc = subprocess.Popen(prog, stdout=subprocess.PIPE) + line = proc.stdout.readline() + return True + except Exception, e: + print "failed to execute " + str(prog) + return False + # Regular expressions for parsing file names-- # which is, after all, what this program is all about music_file_re = re.compile(".*\.mp3$") @@ -252,6 +262,11 @@ class MusicFile(object): break # CODE +## Make sure that id3v2 is installed +if not verify_program_installed(["id3v2", "--version"]): + print "You must install the id3v2 program to run this script." + sys.exit(1) + ## Find id3v2_wrapper.sh id3v2_wrapper = find_companion_script('id3v2_wrapper.sh') -- 1.6.6.rc1.39.g9a42