diff --git a/exporter.py b/exporter.py index d85a29e..aa6d6a0 100755 --- a/exporter.py +++ b/exporter.py @@ -44,6 +44,7 @@ arg = self.args[self.i].strip() if arg == "--": allow_opts = False + self.i += 1 continue if arg == "--port" or arg == "-p": @@ -66,23 +67,44 @@ self.i += 1 return (None, ret) -port = 7890 +def usage(): + print "usage 1: ./exporter.py [--port/-p wrapper_communication_port] [--type/-t (1,3)] [--scale/-s skeletal_scale] input_files..." + print " Exports the given file(s) with the given settings" + print + print "usage 2: ./exporter.py [--port/-p wrapper_communication_port] -" + print " Reads commands (everything after --port in usage 1) as lines from stdin" + print + print "usage 3: ./export.py --help|-h" + print " Shows this help message" + +if "-h" in sys.argv or "--help" in sys.argv: + usage() + sys.exit(0) (err, args) = ArgParser().parse_args(sys.argv[1:]) if err is not None: print err + usage() sys.exit(2) -print args +if "-" in args["input"]: + if len(args["input"]) > 1 or "type" in args or "scale" in args: + print "If reading from stdin ('-') is specified, no other input may be given" + usage() + sys.exit(2) -sys.exit(0) +if not len(args["input"]): + usage() + sys.exit(0) + +port = 7890 s = socket.socket() s.bind(("localhost", port)) -args = [os.getcwd() + "/GraphicExport.exe"] -# args = [os.getcwd() + "/GraphicExport.app/GraphicExport.exe", str(port)] -g = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +exporter_args = [os.getcwd() + "/GraphicExport.exe"] +# exporter_args = [os.getcwd() + "/GraphicExport.app/GraphicExport.exe", str(port)] +g = subprocess.Popen(exporter_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) s.settimeout(0.5) s.listen(0)