From 880e615505a257b6dc07eb5e5c8573849622216a Mon Sep 17 00:00:00 2001 From: Greg Darke Date: Tue, 25 Nov 2008 13:08:55 +1100 Subject: [PATCH] Force the mencoder job to run in a temp directory (this stops the divx log file from being dropped into the current directory) --- encode.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/encode.py b/encode.py index fc3b7c8..f56eb54 100755 --- a/encode.py +++ b/encode.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import commands, optparse, subprocess, sys, os +import commands, optparse, subprocess, sys, os, tempfile, shutil class MencoderCommand(object): codec2opts = { @@ -139,8 +139,14 @@ def parse_args(): parser.print_usage() sys.exit(1) - opts.input = input - opts.output = output + if '://' not in input: + opts.input = os.path.join(os.getcwd(), input) + else: + if opts.dvd: + opts.dvd = os.path.join(os.getcwd(), opts.dvd) + opts.input = input + + opts.output = os.path.join(os.getcwd(), output) return opts def run(args, dump): @@ -157,9 +163,15 @@ def main(): print >>sys.stderr, "Profile '%s' not found!" % profile_name sys.exit(1) - cmd = profile.CommandClass(profile, opts) - if run(cmd.pass1(), opts.dump) == 0 or opts.dump: - run(cmd.pass2(), opts.dump) + tempdir = tempfile.mkdtemp() + try: + os.chdir(tempdir) + cmd = profile.CommandClass(profile, opts) + if run(cmd.pass1(), opts.dump) == 0 or opts.dump: + run(cmd.pass2(), opts.dump) + finally: + os.chdir('/') + shutil.rmtree(tempdir) if __name__ == "__main__": main() -- 2.39.2