pass sys.exit(1) file = temp_file else: file = os.popen(preproc_cmd, "r") else: # No preprocessor file = name if verbose: sys.stderr.write(cmdname + ": Running front end\n") if dump_only: if verbose: sys.stderr.write(cmdname + ": Dumping\n") _omniidl.dump(file, name) if not isinstance(file, StringType): file.close() if temp_file: os.remove(temp_file) else: tree = _omniidl.compile(file, name) if not isinstance(file, StringType): if file.close(): if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") sys.exit(1) if tree is None: sys.exit(1)
def main(argv=None): global preprocessor_args, preprocessor_only, preprocessor_cmd global no_preprocessor, backend, backend_args, dump_only, cd_to global verbose, quiet, print_usage, interactive, temp_file if argv is None: argv = sys.argv files = parseArgs(argv[1:]) if _omniidl.alwaysTempFile(): temp_file = genTempFileName() if print_usage: usage() elif len(files) == 0: if not quiet: sys.stderr.write(cmdname + ": No files specified. Use '" \ + cmdname + " -u' for usage.\n") sys.exit(1) # Import back-ends, and add any pre-processor arguments bemodules = [] for backend in backends: if verbose: sys.stderr.write(cmdname + ": Importing back-end '" +\ backend + "'\n") try: be = be_import(backend) except ImportError as msg: if not quiet: sys.stderr.write(cmdname + \ ": Could not import back-end '" + \ backend + "'\n") sys.stderr.write(cmdname + \ ": Maybe you need to use the -p option?\n") sys.stderr.write(cmdname + \ ": (The error was '" + str(msg) + "')\n") sys.exit(1) if verbose: if hasattr(be, "__file__"): sys.stderr.write(cmdname + ": '" + backend + \ "' imported from '" + be.__file__ + "'\n") else: sys.stderr.write(cmdname + ": '" + backend + \ "' imported from unknown file\n") bemodules.append(be) if hasattr(be, "cpp_args"): preprocessor_args.extend(be.cpp_args) if print_usage and hasattr(be, "usage_string"): print("\nArguments for back-end '" + backend + "':\n") print(be.usage_string) if print_usage: sys.exit(0) if len(backends) == 0 and \ not (quiet or dump_only or preprocessor_only or interactive): sys.stderr.write(cmdname + ": Warning: No back-ends specified; " \ "checking IDL for validity\n") for name in files: if name != "-" and not os.path.isfile(name): if not quiet: sys.stderr.write(cmdname + ": '" + name + "' does not exist\n") sys.exit(1) if sys.platform != 'OpenVMS' or len(preprocessor_args) == 0: preproc_cmd = '%s %s "%s"' % (preprocessor_cmd, " ".join(preprocessor_args), name) else: preproc_cmd = '%s "%s" %s' % (preprocessor_cmd, '" "'.join(preprocessor_args), name) if not no_preprocessor: if verbose: sys.stderr.write(cmdname + ": Preprocessing '" +\ name + "' with '" + preproc_cmd + "'\n") if preprocessor_only: err = os.system(preproc_cmd) if err: if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") sys.exit(1) sys.exit(0) if temp_file: if verbose: sys.stderr.write(cmdname + \ ": cpp output to temporary file '" + \ temp_file + "'\n") err = os.system(preproc_cmd + " >" + temp_file) if err: if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") try: os.remove(temp_file) except: pass sys.exit(1) file = temp_file else: file = os.popen(preproc_cmd, "r") else: # No preprocessor file = name if verbose: sys.stderr.write(cmdname + ": Running front end\n") if dump_only: if verbose: sys.stderr.write(cmdname + ": Dumping\n") _omniidl.dump(file, name) if not isinstance(file, StringType): file.close() if temp_file: os.remove(temp_file) else: tree = _omniidl.compile(file, name) if not isinstance(file, StringType): if file.close(): if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") sys.exit(1) if tree is None: sys.exit(1) if cd_to is not None: old_wd = os.getcwd() os.chdir(cd_to) i = 0 for backend in backends: if verbose: sys.stderr.write(cmdname + ": Running back-end '" +\ backend + "'\n") bemodules[i].run(tree, backends_args[i]) i = i + 1 if interactive: if verbose: sys.stderr.write(cmdname + ": Entering interactive loop\n") idlast.tree = tree _omniidl.runInteractiveLoop() del idlast.tree if cd_to is not None: os.chdir(old_wd) if temp_file and not no_preprocessor: os.remove(temp_file) idlast.clear() idltype.clear() _omniidl.clear()
pass sys.exit(1) file = temp_file else: file = os.popen(preproc_cmd, "r") else: # No preprocessor file = name if verbose: sys.stderr.write(cmdname + ": Running front end\n") if dump_only: if verbose: sys.stderr.write(cmdname + ": Dumping\n") _omniidl.dump(file) if not isinstance(file, StringType): file.close() if temp_file: os.remove(temp_file) else: tree = _omniidl.compile(file) if not isinstance(file, StringType): if file.close(): if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") sys.exit(1) if tree is None: sys.exit(1)
def main(argv=None): global preprocessor_args, preprocessor_only, preprocessor_cmd global no_preprocessor, backend, backend_args, dump_only, cd_to global verbose, quiet, print_usage, interactive, temp_file if argv is None: argv = sys.argv files = parseArgs(argv[1:]) if _omniidl.alwaysTempFile(): temp_file = genTempFileName() if print_usage: usage() elif len(files) == 0: if not quiet: sys.stderr.write(cmdname + ": No files specified. Use '" \ + cmdname + " -u' for usage.\n") sys.exit(1) # Import back-ends, and add any pre-processor arguments bemodules = [] for backend in backends: if verbose: sys.stderr.write(cmdname + ": Importing back-end '" +\ backend + "'\n") try: be = be_import(backend) except ImportError as msg: if not quiet: sys.stderr.write(cmdname + \ ": Could not import back-end '" + \ backend + "'\n") sys.stderr.write(cmdname + \ ": Maybe you need to use the -p option?\n") sys.stderr.write(cmdname + \ ": (The error was '" + str(msg) + "')\n") sys.exit(1) if verbose: if hasattr(be, "__file__"): sys.stderr.write(cmdname + ": '" + backend + \ "' imported from '" + be.__file__ + "'\n") else: sys.stderr.write(cmdname + ": '" + backend + \ "' imported from unknown file\n") bemodules.append(be) if hasattr(be, "cpp_args"): preprocessor_args.extend(be.cpp_args) if print_usage and hasattr(be, "usage_string"): print("\nArguments for back-end '" + backend + "':\n") print(be.usage_string) if print_usage: sys.exit(0) if len(backends) == 0 and \ not (quiet or dump_only or preprocessor_only or interactive): sys.stderr.write(cmdname + ": Warning: No back-ends specified; " \ "checking IDL for validity\n") for name in files: if name != "-" and not os.path.isfile(name): if not quiet: sys.stderr.write(cmdname + ": '" + name + "' does not exist\n") sys.exit(1) if sys.platform != 'OpenVMS' or len(preprocessor_args)==0: preproc_cmd = '%s %s "%s"' % (preprocessor_cmd, " ".join(preprocessor_args), name) else: preproc_cmd = '%s "%s" %s' % (preprocessor_cmd, '" "'.join(preprocessor_args), name) if not no_preprocessor: if verbose: sys.stderr.write(cmdname + ": Preprocessing '" +\ name + "' with '" + preproc_cmd + "'\n") if preprocessor_only: err = os.system(preproc_cmd) if err: if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") sys.exit(1) sys.exit(0) if temp_file: if verbose: sys.stderr.write(cmdname + \ ": cpp output to temporary file '" + \ temp_file + "'\n") err = os.system(preproc_cmd + " >" + temp_file) if err: if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") try: os.remove(temp_file) except: pass sys.exit(1) file = temp_file else: file = os.popen(preproc_cmd, "r") else: # No preprocessor file = name if verbose: sys.stderr.write(cmdname + ": Running front end\n") if dump_only: if verbose: sys.stderr.write(cmdname + ": Dumping\n") _omniidl.dump(file, name) if not isinstance(file, StringType): file.close() if temp_file: os.remove(temp_file) else: tree = _omniidl.compile(file, name) if not isinstance(file, StringType): if file.close(): if not quiet: sys.stderr.write(cmdname + \ ": Error running preprocessor\n") sys.exit(1) if tree is None: sys.exit(1) if cd_to is not None: old_wd = os.getcwd() os.chdir(cd_to) i = 0 for backend in backends: if verbose: sys.stderr.write(cmdname + ": Running back-end '" +\ backend + "'\n") bemodules[i].run(tree, backends_args[i]) i = i + 1 if interactive: if verbose: sys.stderr.write(cmdname + ": Entering interactive loop\n") idlast.tree = tree _omniidl.runInteractiveLoop() del idlast.tree if cd_to is not None: os.chdir(old_wd) if temp_file and not no_preprocessor: os.remove(temp_file) idlast.clear() idltype.clear() _omniidl.clear()