def cmd_crawl(args, options): if len(args) != 1: logging.error("Missing build URL") return 1 if options.to_file and not os.path.exists(options.to_file): os.mkdir(options.to_file) if options.from_file and not os.path.exists(options.from_file): os.mkdir(options.from_file) db = open_db(options) crawl = Crawl(db, options) if options.reverse: roots = crawl.reverse_crawl(args[0]) else: roots = crawl.crawl(args[0]) close_db(db) stat = roots[0].extra logging.info("Started: %s\n\tend: %s\n\telapsed: %s\n\tduration: %ss\n\tNb builds: %s\n\ttrhoughput: %s\n" % ( stat['start'], stat['stop'], stat['elapsed'], stat['duration'], stat['count'], stat['throughput'])) if not options.output: svg_file = roots[0].getId() + ".svg" else: svg_file = options.output graphviz(roots, svg_file) logging.info("%s generated." % svg_file) return 0
def dot2(prog=None, format_=None): '''Main dot2what conversion requests''' if bottle.request.method == 'POST': request_data = bottle.request.forms else: # Should be GET request_data = bottle.request.query if not prog or prog == "dot": # dot can be used as a generic term prog = request_data.get('prog', prog) # therefore allow override if not format_: format_ = request_data.get('format') text = request_data.get('text') # DOT text if not prog and not format_ and not text: return index() # Blank request, therefore return index page elif not text: #Incase of '' text that will not cause graphviz to error raise bottle.HTTPError(400, "Invalid DOT Input") try: output = graphviz(strip_external(text), prog=prog, format_=format_) except (GraphvizError, GraphvizWarning) as err: raise bottle.HTTPError(400, "GraphvizError: %s" % str(err)) mimetype, encoding = mimetypes.guess_type(' .%s' % format_) if mimetype: bottle.response['Content-Type'] = mimetype if bottle.request.method == 'POST': bottle.response['Content-Disposition'] = \ "attachment; filename=dot2.%s" % format_ return output
def write_viz_file(viz_filename, figure_type, sm_obj): if not viz_filename: raise OpenAndReadNeeded("writing") outfile = open(viz_filename, 'w') outfile.write(GenFileWarning) cmntlen = 76; outfile.write("/**%s\n"%('*' * cmntlen)) outfile.write(" **\n") outfile.write(" ** GViz dot file commands\n") outfile.write(" **\n\n"); outfile.write(sm_obj.info(cmntlen)) outfile.write(" **/\n\n\n") edict = event_dict(figure_type == SMG_FIG_EVCLEAN) g = graphviz(sm_obj.name()) g.fullpage() g.landscape() if figure_type in [SMG_FIG_PRIMARY, SMG_FIG_EVCLEAN]: g.attr('concentrate', 'true') saw_undef_trans = 0 node_role_dec = { 'Terminal' : ('shape','triangle'), 'Source' : ('shape','invtriangle'), 'Orphan' : ('shape','doublecircle') } for state in sm_obj.state_list(): n = gv_node(state.name()) if state.role() in node_role_dec.keys(): n.attr(node_role_dec[state.role()][0], node_role_dec[state.role()][1]) g.add(n) for fromstate,evname,tostate,expected in state.event_info(): if Undef_Event_Code in fromstate: if figure_type == SMG_FIG_PRIMARY: continue saw_undef_trans = 1 evlbl = edict.add_event( (fromstate,evname,tostate,expected) ) for tgt_state in state.next_states(evname): e = gv_edge(state.name(), tgt_state, evlbl) if expected: e.attr('style','bold') g.add(e) if saw_undef_trans: n = gv_node(Undef_Trans) n.attr('shape','doubleoctagon') n.color('red') n.attr('fontcolor','red') g.add(n) for nodename,lbl_prefix,lbl_list in [ ('good_ev', "EVENTS", edict.good_keys()), ('bad_ev', "BAD EVENTS", edict.error_keys()) ]: if len(lbl_list): n = gv_node(nodename) n.attr('shape','plaintext') n.label(' %s:\\l%s \\l'%(lbl_prefix, string.join( map(lambda ev,edict=edict: "%s%s = %s"%( " "*10, ev, edict.description(ev)), lbl_list), '\\l'))) g.add(n) g.autocluster() outfile.write(g.dot()) outfile.close() progress('Wrote GViz figure commands', viz_filename)
func_list = parse.parse(buf if buf[-1] == '\n' else buf + '\n', filename) if not func_list and strict: sys.exit(-1) for func_obj in func_list: try: func_name = func_obj.head.ident.name if verbose: print "\t", func_name except AttributeError: if verbose: print "\tJunk ignored" if strict: sys.exit(-1) continue fp0 = open("parse_" + func_name + ".dot", "w") if dot and dot.match(func_name) else None if fp0: graphviz.graphviz(func_obj, fp0) if options.do_resolve: G = resolve.resolve(func_obj) for func_obj in func_list: s = backend.backend(func_obj) print >> fp, s if __name__ == "__main__": main()
if options.verbose: print filename buf = open(filename).read().replace("\r\n","\n") func_list = parse.parse(buf if buf[-1]=='\n' else buf+'\n',filename) if not func_list and strict: sys.exit(-1) for func_obj in func_list: try: func_name = func_obj.head.ident.name if options.verbose: print "\t",func_name except AttributeError: if options.verbose: print "\tJunk ignored" if strict: sys.exit(-1) continue fp0 = open("parse_"+func_name+".dot","w") if dot and dot.match(func_name) else None if fp0: graphviz.graphviz(func_obj,fp0) if options.do_resolve: G = resolve.resolve(func_obj) for func_obj in func_list: s = backend.backend(func_obj) print >> fp, s if __name__ == "__main__": main()