From b465eebf03b50df3afd0480a94c379623c3ea3fe Mon Sep 17 00:00:00 2001 From: Greg Darke Date: Sun, 12 Oct 2008 13:35:05 +1100 Subject: [PATCH] Added rotate_args, fixed permissions on ipod_tomp4.sh rotate_args is a small program that makes it easier to control programs like AtomicParsley from a batch run file. This is because AtomicParsley requires the filename to be the first commandline argument --- ipod_tomp4.sh | 0 rotate_args.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) mode change 100644 => 100755 ipod_tomp4.sh create mode 100755 rotate_args.py diff --git a/ipod_tomp4.sh b/ipod_tomp4.sh old mode 100644 new mode 100755 diff --git a/rotate_args.py b/rotate_args.py new file mode 100755 index 0000000..f229787 --- /dev/null +++ b/rotate_args.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import optparse, subprocess, sys, os + +def parse_args(): + parser = optparse.OptionParser(usage="%prog [options] -- args") + parser.add_option("--program_name", + action="store", dest="program_name", default=None, + help="The name of the executable to run") + parser.add_option("--dump", + action="store_true", dest="dump", + help="Print command that would be run on stdout") + parser.add_option("--count", + action="store", type="int", dest="count", + help="The number of arguments to rotate") + + opts, args = parser.parse_args(sys.argv[1:]) + + opts.args = args + return opts + +def run(args, dump): + if dump: + print "".join(map(commands.mkarg, args))[1:] + else: + return subprocess.Popen(args).wait() + +def main(): + opts = parse_args() + + newcmdline = [opts.program_name] + opts.args[-opts.count:] + opts.args[:-opts.count] + + run(newcmdline, opts.dump) + +if __name__ == "__main__": + main() + -- 2.39.2