コード例 #1
0
ファイル: mobster.py プロジェクト: Vicas/mobster
def write_report(args):
  """
  Autogenerates an HTML report and writes it to a file, with location and input
  specified by the given arguments.
  """
  output_html = make_html(args.har or har_file_path(args), args.debug)

  with open(report_file_path(args), 'w') as output_handle:
    output_handle.write(output_html)
  
  if args.browser:
    open_browser(report_file_path(args))
コード例 #2
0
def write_report(args):
    """
  Autogenerates an HTML report and writes it to a file, with location and input
  specified by the given arguments.
  """
    output_html = make_html(args.har or har_file_path(args), args.debug)

    with open(report_file_path(args), 'w') as output_handle:
        output_handle.write(output_html)

    if args.browser:
        open_browser(report_file_path(args))
コード例 #3
0
ファイル: make_report.py プロジェクト: haricharankr/mobster
from linkedin.mobster.utils import cmd_exists
from linkedin.mobster.har.visualization.report import make_html

LINUX_BROWSER_OPEN_CMD = 'xdg-open'
MAC_BROWSER_OPEN_CMD = 'open'

if __name__ == '__main__':
  parser = argparse.ArgumentParser()
  parser.add_argument('-d', '--outputdir', help='Directory to store result in')
  parser.add_argument('-r', '--har', required=True, help='Use specified HAR instead of generating with phantomjs')
  parser.add_argument('-b', '--browser', action='store_true', help='Open HTML in browser after creation')
  parser.add_argument('-g', '--debug', action='store_true', help='Generate in debug mode, i.e. CDN script links will not be replaced with source')
  parser.add_argument('-f', '--filename', help='Filename for report')
  args = parser.parse_args()

  output_html = make_html(args.har, args.debug)

  output_dir = args.outputdir or os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'report')
  if not os.path.isdir(output_dir):
    os.mkdir(output_dir)

  filename = args.filename or 'http_waterfall_{0}.html'.format(int(time.time()))

  with open(os.sep.join([output_dir, filename]), 'w') as output_handle:
    output_handle.write(output_html)

  if args.browser:
    if cmd_exists(LINUX_BROWSER_OPEN_CMD):
      browser_open_cmd = LINUX_BROWSER_OPEN_CMD
    else:
      browser_open_cmd = MAC_BROWSER_OPEN_CMD