def Main(args): project = tracing_project.TracingProject() parser = argparse.ArgumentParser( description='Run tracing development server') parser.add_argument('-d', '--data-dir', default=os.path.abspath( os.path.join(project.test_data_path))) parser.add_argument('-s', '--skp-data-dir', default=os.path.abspath( os.path.join(project.skp_data_path))) parser.add_argument('-p', '--port', default=8003, type=int) args = parser.parse_args(args=args) server = dev_server.DevServer(port=args.port, project=project) server.data_dir = os.path.abspath(args.data_dir) server.skp_data_dir = os.path.abspath(args.skp_data_dir) project.source_paths.append(server.data_dir) server.AddPathHandler('/json/examples', do_GET_json_examples) server.AddPathHandler('/tr/json/tests', do_GET_json_tests) server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp) server.AddSourcePathMapping(project.tracing_root_path) server.AddPathHandler('/test_automation/notify_test_result', do_POST_report_test_results, supports_post=True) server.AddPathHandler('/test_automation/notify_completion', do_POST_report_test_completion, supports_post=True) server.serve_forever()
def WriteTraceViewer(output_file, config_name=None, minify=False, report_sizes=False, report_deps=False, output_html_head_and_body=True, extra_search_paths=None, extra_module_names_to_load=None): project = tracing_project.TracingProject() if extra_search_paths: for p in extra_search_paths: project.source_paths.append(p) if config_name is None: config_name = project.GetDefaultConfigName() module_names = [project.GetModuleNameForConfigName(config_name)] if extra_module_names_to_load: module_names += extra_module_names_to_load load_sequence = project.CalcLoadSequenceForModuleNames(module_names) if report_deps: sys.stdout.write(project.GetDepsGraphFromModuleNames(module_names)) generate.GenerateStandaloneHTMLToFile( output_file, load_sequence, minify=minify, report_sizes=report_sizes, output_html_head_and_body=output_html_head_and_body)
def WriteHTMLForTraceDataToFile(trace_data_list, title, output_file, config_name=None): project = tracing_project.TracingProject() if config_name is None: config_name = project.GetDefaultConfigName() modules = [ 'trace2html', 'extras.importer.gzip_importer', # Must have this regardless of config. project.GetModuleNameForConfigName(config_name) ] load_sequence = project.CalcLoadSequenceForModuleNames(modules) scripts = [] for trace_data in trace_data_list: # If the object was previously decoded from valid JSON data (e.g., in # WriteHTMLForTracesToFile), it will be a JSON object at this point and we # should re-serialize it into a string. Other types of data will be already # be strings. if not isinstance(trace_data, basestring): trace_data = json.dumps(trace_data) mime_type = 'application/json' else: mime_type = 'text/plain' scripts.append(ViewerDataScript(trace_data, mime_type)) generate.GenerateStandaloneHTMLToFile(output_file, load_sequence, title, extra_scripts=scripts)
def CheckCommon(file_name, listed_files): tracing_project.TracingProject() known_files = GetKnownFiles() u = set(listed_files).union(set(known_files)) i = set(listed_files).intersection(set(known_files)) diff = list(u - i) if len(diff) == 0: return '' error = 'Entries in ' + file_name + ' do not match files on disk:\n' in_file_only = list(set(listed_files) - set(known_files)) in_known_only = list(set(known_files) - set(listed_files)) if len(in_file_only) > 0: error += ' In file only:\n ' + '\n '.join(sorted(in_file_only)) if len(in_known_only) > 0: if len(in_file_only) > 0: error += '\n\n' error += ' On disk only:\n ' + '\n '.join(sorted(in_known_only)) if in_file_only: error += ( '\n\n' ' Note: only files actually used in about:tracing should\n' ' be listed in the build files. Try running build/update_gyp_and_gn\n' ' to update the files automatically.') return error
def GetKnownFiles(): p = tracing_project.TracingProject() m = p.loader.LoadModule( module_name='ui.extras.about_tracing.about_tracing') absolute_filenames = m.GetAllDependentFilenamesRecursive( include_raw_scripts=False) return list( set([ os.path.relpath(f, p.tracing_root_path) for f in absolute_filenames ]))
def main(): project = tracing_project.TracingProject() sys.path.append(os.path.join( project.tracing_third_party_path, 'python_gflags')) sys.path.append(os.path.join( project.tracing_third_party_path, 'closure_linter')) from closure_linter import fixjsstyle os.chdir(project.tracing_src_path) fixjsstyle.main()
def Main(args): parser = optparse.OptionParser( usage="%prog <options>", epilog="""Produces a standalone html import that contains the trace viewer.""") project = tracing_project.TracingProject() project.AddConfigNameOptionToParser(parser) parser.add_option('--no-min', dest='no_min', default=False, action='store_true', help='skip minification') parser.add_option('--report-sizes', dest='report_sizes', default=False, action='store_true', help='Explain what makes tracing big.') parser.add_option('--report-deps', dest='report_deps', default=False, action='store_true', help='Print a dot-formatted deps graph.') parser.add_option("--output", dest="output", help='Where to put the generated result. If not ' + 'given, $TRACING/tracing/bin/trace_viewer.html is used.') options, args = parser.parse_args(args) if len(args) != 0: parser.error('No arguments needed.') tracing_dir = os.path.relpath( os.path.join(os.path.dirname(__file__), '..', '..')) if options.output: output_filename = options.output else: output_filename = os.path.join( tracing_dir, 'tracing/bin/trace_viewer_%s.html' % options.config_name) with codecs.open(output_filename, 'w', encoding='utf-8') as f: WriteTraceViewer(f, config_name=options.config_name, minify=not options.no_min, report_sizes=options.report_sizes, report_deps=options.report_deps) return 0
def Main(paths_to_lint): project = tracing_project.TracingProject() new_paths = [ os.path.abspath( os.path.join(project.tracing_third_party_path, 'python_gflags')), os.path.abspath( os.path.join(project.tracing_third_party_path, 'closure_linter')) ] sys.path += new_paths try: _MainImpl(paths_to_lint) finally: for p in new_paths: sys.path.remove(p)
def main(args): parser = optparse.OptionParser(usage="%prog --outdir=<directory>") parser.add_option("--outdir", dest="out_dir", help="Where to place generated content") parser.add_option('--no-min', dest='no_min', default=False, action='store_true', help='skip minification') options, args = parser.parse_args(args) if not options.out_dir: sys.stderr.write("ERROR: Must specify --outdir=<directory>") parser.print_help() return 1 names = ["ui.extras.about_tracing.about_tracing"] project = tracing_project.TracingProject() load_sequence = project.CalcLoadSequenceForModuleNames(names) olddir = os.getcwd() try: if not os.path.exists(options.out_dir): os.makedirs(options.out_dir) o = codecs.open(os.path.join(options.out_dir, "about_tracing.html"), 'w', encoding='utf-8') try: tvcm.GenerateStandaloneHTMLToFile(o, load_sequence, title='chrome://tracing', flattened_js_url='tracing.js', minify=not options.no_min) except tvcm.module.DepsException, ex: sys.stderr.write("Error: %s\n\n" % str(ex)) return 255 o.close() o = codecs.open(os.path.join(options.out_dir, "about_tracing.js"), 'w', encoding='utf-8') assert o.encoding == 'utf-8' tvcm.GenerateJSToFile(o, load_sequence, use_include_tags_for_scripts=False, dir_for_include_tag_root=options.out_dir, minify=not options.no_min) o.close()
def Main(args): parser = optparse.OptionParser( usage="%prog <options> trace_file1 [trace_file2 ...]", epilog="""Takes the provided trace file and produces a standalone html file that contains both the trace and the trace viewer.""") project = tracing_project.TracingProject() project.AddConfigNameOptionToParser(parser) parser.add_option( "--output", dest="output", help='Where to put the generated result. If not ' + 'given, the trace filename is used, with an html suffix.') parser.add_option("--quiet", action='store_true', help='Dont print the output file name') options, args = parser.parse_args(args) if len(args) == 0: parser.error('At least one trace file required') if options.output: output_filename = options.output elif len(args) > 1: parser.error('Must specify --output if >1 trace file') else: namepart = os.path.splitext(args[0])[0] output_filename = namepart + '.html' with codecs.open(output_filename, mode='w', encoding='utf-8') as f: WriteHTMLForTracesToFile(args, f, config_name=options.config_name) if not options.quiet: print output_filename return 0
def UpdateGypi(): tvp = tracing_project.TracingProject() _UpdateBuildFile( os.path.join(tvp.tracing_root_path, 'trace_viewer.gypi'), GypiFile)