def _die(options, message): if isinstance(message, (list, tuple)): for line in message: log.error(line) else: log.error(message) tb = traceback.format_exc() log.debug('\n --- Python traceback ---\n%s ------------------------\n' % tb) sys.exit(-1)
def die(options, message): if isinstance(message, (list, tuple)): for line in message: log.error(line) else: log.error(message) tb = traceback.format_exc() log.debug('\n --- Python traceback ---\n%s ------------------------\n' % tb) sys.exit(-1)
def main(): # Parse command line arguments. options = parse_args(constants.TOOL_PARSER) log.set_verbosity(options.verbosity) # Parse each source. ast = [] if options.file: for f in options.file: s = f.read() try: ast += parse_to_ast(s, options.cpp, options.cpp_flag) if options.resolve_imports: ast, _ = resolve_imports(ast, \ os.path.dirname(f.name), options.import_path, options.cpp, options.cpp_flag) except CAmkESSyntaxError as e: e.set_column(s) log.error('%s:%s' % (f.name, str(e))) return -1 except Exception: log.exception('Error during lexing/parsing \'%s\''% f.name) return -1 finally: f.close() else: s = sys.stdin.read() try: ast += parse_to_ast(s, options.cpp, options.cpp_flag) if options.resolve_imports: ast, _ = resolve_imports(ast, \ os.curdir, options.import_path, options.cpp, options.cpp_flag) except Exception: log.exception('Error during lexing/parsing') return -1 ast = dedupe(ast) if options.resolve_references: ast = resolve_references(ast) # Generate the output and print this. out = show(ast) print pretty(out) return 0
def _die(options, message): if isinstance(message, (list, tuple)): for line in message: log.error(line) else: log.error(message) tb = traceback.format_exc() log.debug('\n --- Python traceback ---\n%s ------------------------\n' % safe_decode(tb)) if options.cache and re.search(r'^\s*File\s+".*\.pyc",\s+line\s+\d+,\s*in' r'\s*top-level\s*template\s*code$', tb, flags=re.MULTILINE) is \ not None: log.debug('If the preceding backtrace traverses a pre-compiled ' 'template, you may wish to disable the CAmkES cache and re-run ' 'for a more accurate backtrace.\n') sys.exit(-1)
def main(): args = parse_args(constants.TOOL_LINT) log.set_verbosity(args.verbosity) # Parse the input and form the AST. ast = [] for f in args.file: try: items = parser.parse_to_ast(f) except Exception as inst: log.critical('Failed to parse input: %s' % str(inst)) return CRITICAL if args.resolve_imports: try: items, _ = parser.resolve_imports(items, \ os.path.dirname(f.name), args.import_path) except Exception as inst: log.critical('Failed to resolve imports: %s' % str(inst)) return CRITICAL ast += items if args.resolve_references: try: ast = parser.resolve_references(ast) except Exception as inst: log.critical('Failed to resolve references: %s' % str(inst)) return CRITICAL # Check it for inconsistencies. ret = 0 for m in lint.check(ast): if isinstance(m, lint.ProblemWarning): log.warning(str(m)) if ret != ERROR: ret = WARNING else: # isinstance(m, lint.ProblemError) log.error(str(m)) ret = ERROR return ret
def main(): args = parse_args(constants.TOOL_LINT) log.set_verbosity(args.verbosity) # Parse the input and form the AST. ast = [] for f in args.file: try: items = parser.parse_to_ast(f) except Exception as inst: log.critical('Failed to parse input: %s' % str(inst)) return CRITICAL if args.resolve_imports: try: items, _ = parser.resolve_imports(items, \ os.path.dirname(f.name), args.import_path) except Exception as inst: log.critical('Failed to resolve imports: %s' % str(inst)) return CRITICAL ast += items if args.resolve_references: try: ast = parser.resolve_references(ast, args.allow_forward_references) except Exception as inst: log.critical('Failed to resolve references: %s' % str(inst)) return CRITICAL # Check it for inconsistencies. ret = 0 for m in lint.check(ast): if isinstance(m, lint.ProblemWarning): log.warning(str(m)) if ret != ERROR: ret = WARNING else: # isinstance(m, lint.ProblemError) log.error(str(m)) ret = ERROR return ret
def _die(debug, s): log.error(str(s)) log.debug('\n --- Python traceback ---\n%s ------------------------\n' % \ traceback.format_exc()) sys.exit(-1)