示例#1
0
文件: mobster.py 项目: Vicas/mobster
def open_browser(file_path):
  """
  Open the specified file in the default web browser. Only works in Mac OS
  and Linux
  """
  if cmd_exists(LINUX_BROWSER_OPEN_CMD):
    browser_open_cmd = LINUX_BROWSER_OPEN_CMD
  else:
    browser_open_cmd = MAC_BROWSER_OPEN_CMD
  
  commands.getstatusoutput('{0} {1}'.format(browser_open_cmd, file_path))
示例#2
0
def open_browser(file_path):
    """
  Open the specified file in the default web browser. Only works in Mac OS
  and Linux
  """
    if cmd_exists(LINUX_BROWSER_OPEN_CMD):
        browser_open_cmd = LINUX_BROWSER_OPEN_CMD
    else:
        browser_open_cmd = MAC_BROWSER_OPEN_CMD

    commands.getstatusoutput('{0} {1}'.format(browser_open_cmd, file_path))
示例#3
0
  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

    commands.getstatusoutput('%s %s' % (browser_open_cmd, os.sep.join([output_dir, filename])))