]> code.delx.au - transcoding/blobdiff - encode.py
--dump no longer quotes things unless they need to be quoted
[transcoding] / encode.py
index 28767bf546de98f81e6465be011024c4ffe86dc6..a6f0cd863335ad1c24e6e4335577a77447bd8345 100755 (executable)
--- a/encode.py
+++ b/encode.py
@@ -2,6 +2,7 @@
 
 import commands
 import optparse
+import shlex
 import subprocess
 import sys
 import os
@@ -11,6 +12,14 @@ import shutil
 class FatalException(Exception):
        pass
 
+def mkarg(arg):
+       quoted_arg = commands.mkarg(arg)
+       arg = quoted_arg[2:-1]
+       if len(shlex.split(arg)) == 1:
+               return arg
+       else:
+               return quoted_arg[1:]
+
 class Command(object):
        def __init__(self, profile, opts):
                self.profile = profile
@@ -33,7 +42,7 @@ class Command(object):
 
        def do_exec(self, args):
                if self.opts.dump:
-                       print "".join(map(commands.mkarg, args))[1:]
+                       print " ".join(map(mkarg, args))
                else:
                        if subprocess.Popen(args).wait() != 0:
                                raise FatalException("Failure executing command: %s" % args)