From: James Bunton Date: Sun, 1 Mar 2009 12:03:20 +0000 (+1100) Subject: Ensure output files do not exist before starting X-Git-Url: https://code.delx.au/transcoding/commitdiff_plain/4ac0fd33e2fa427335ec5c9e5dad9cf4ad166737 Ensure output files do not exist before starting --- diff --git a/encode.py b/encode.py index 1bc6c3a..cdc733c 100755 --- a/encode.py +++ b/encode.py @@ -26,6 +26,10 @@ class Command(object): return if subprocess.Popen(["which", cmd], stdout=open("/dev/null", "w")).wait() != 0: raise FatalException("Command '%s' is required" % cmd) + + def check_no_file(self, path): + if os.path.exists(path): + raise FatalException("Output file '%s' exists." % path) def do_exec(self, args): if self.opts.dump: @@ -45,6 +49,7 @@ class MP4Box(Command): def check(self): self.check_command("mencoder") self.check_command("MP4Box") + self.check_no_file(self.opts.output + ".mp4") def run(self): p = self.profile @@ -122,6 +127,7 @@ class Mencoder(Command): def check(self): self.check_command("mencoder") + self.check_no_file(self.opts.output + ".avi") def run(self): self.do_exec(self.pass1())