def main(version): if public.program.name != public.engine.name and version is not None: public.program.version = version args = getArgs() if public.verbose: log_utility.info('args = %s' % args) # Load scripts and warn about duplicates loadScripts() global duplicateFunctions if len(duplicateFunctions) > 0: duplicateFunctions.sort() for dup in duplicateFunctions: log_utility.warning('Ignoring duplicate "%s" from "%s"' % (dup.name(), dup.path())) # Display the quick start guide if running the base program with no arguments if public.engine.name and len(args) == 0: execute('help()') sys.exit(1) for argIn in args: try: execute(argIn) except public.ExcBase, e: if e.traceback: log_utility._tracebackException(None, e, 0, 0, False) else: msgs = str(e).split('\n') log_utility.error('Command: "%s"' % argIn, *msgs) except doc.ExcBase, e: msgs = str(e).split('\n') log_utility.error('Command: "%s"' % argIn, *msgs)
def getArgs(): iFirst = 1 smartArguments = True for arg in sys.argv[1:]: if arg[0] != '-': break iFirst += 1 # Only look at options preceding all other arguments so that # negative numbers, etc. aren't rejected. if arg == '-e': smartArguments = False elif arg == '-v': public.verbose = doc.verbose = True elif arg == '-d': public.debug = doc.debug = structext.debug = True elif arg[0] == '-': log_utility.warning('Ignoring unknown option "%s"' % arg) if not smartArguments: return sys.argv[iFirst:] return public._getArgsCommands(sys.argv[iFirst:])