parameters: (command)
docstring: Executes the Compare2 command.
docstring_summary: Executes the Compare2 command.
docstring_tokens: Executes the Compare2 command .
function: def ExecuteCompare2(command):
    """Executes the Compare2 command."""
    if command["--url"]:
      url_list = [command["--url"]]
    else:
      startline = command["--startline"]
      if command["--count"]:
        endline = startline+command["--count"]
      else:
        endline = command["--endline"]
      url_list = [url.strip() for url in
                  open(command["--list"], "r").readlines()[startline:endline]]
  
    log_file = open(command["--logfile"], "w")
  
    outdir = command["--outdir"]
    if not outdir: outdir = tempfile.gettempdir()
  
    scrape_info_list = []
  
    class ScrapeInfo(object):
      """Helper class to hold information about a scrape."""
      __slots__ = ["browser_path", "scraper", "outdir", "result"]
  
    for index in xrange(1, 3):
      scrape_info = ScrapeInfo()
      scrape_info.browser_path = command["--browser%d" % index]
      scrape_info.scraper = scrapers.GetScraper(
        (command["--browser"], command["--browser%dver" % index]))
  
      if command["--browser%dname" % index]:
        scrape_info.outdir = os.path.join(outdir,
                                          command["--browser%dname" % index])
      else:
        scrape_info.outdir = os.path.join(outdir, str(index))
  
      drivers.windowing.PreparePath(scrape_info.outdir)
      scrape_info_list.append(scrape_info)
  
    compare = operators.GetOperator("equals_with_mask")
  
    for url in url_list:
      success = True
  
      for scrape_info in scrape_info_list:
        scrape_info.result = scrape_info.scraper.Scrape(
          [url], scrape_info.outdir, command["--size"], (0, 0),
          command["--timeout"], path=scrape_info.browser_path)
  
        if not scrape_info.result:
          scrape_info.result = "success"
        else:
          success = False
  
      result = "unknown"
  
      if success:
        result = "equal"
  
        file1 = drivers.windowing.URLtoFilename(
          url, scrape_info_list[0].outdir, ".bmp")
        file2 = drivers.windowing.URLtoFilename(
          url, scrape_info_list[1].outdir, ".bmp")
  
        comparison_result = compare.Compare(file1, file2,
                                            maskdir=command["--maskdir"])
  
        if comparison_result is not None:
          result = "not-equal"
  
          if command["--diffdir"]:
            comparison_result[1].save(
              drivers.windowing.URLtoFilename(url, command["--diffdir"], ".bmp"))
  
      # TODO(jhaas): maybe use the logging module rather than raw file writes
      log_file.write("%s %s %s %s\n" % (url,
                                        scrape_info_list[0].result,
                                        scrape_info_list[1].result,
                                        result))
function_tokens: def ExecuteCompare2 ( command ) : if command [ "--url" ] : url_list = [ command [ "--url" ] ] else : startline = command [ "--startline" ] if command [ "--count" ] : endline = startline + command [ "--count" ] else : endline = command [ "--endline" ] url_list = [ url . strip ( ) for url in open ( command [ "--list" ] , "r" ) . readlines ( ) [ startline : endline ] ] log_file = open ( command [ "--logfile" ] , "w" ) outdir = command [ "--outdir" ] if not outdir : outdir = tempfile . gettempdir ( ) scrape_info_list = [ ] class ScrapeInfo ( object ) : """Helper class to hold information about a scrape.""" __slots__ = [ "browser_path" , "scraper" , "outdir" , "result" ] for index in xrange ( 1 , 3 ) : scrape_info = ScrapeInfo ( ) scrape_info . browser_path = command [ "--browser%d" % index ] scrape_info . scraper = scrapers . GetScraper ( ( command [ "--browser" ] , command [ "--browser%dver" % index ] ) ) if command [ "--browser%dname" % index ] : scrape_info . outdir = os . path . join ( outdir , command [ "--browser%dname" % index ] ) else : scrape_info . outdir = os . path . join ( outdir , str ( index ) ) drivers . windowing . PreparePath ( scrape_info . outdir ) scrape_info_list . append ( scrape_info ) compare = operators . GetOperator ( "equals_with_mask" ) for url in url_list : success = True for scrape_info in scrape_info_list : scrape_info . result = scrape_info . scraper . Scrape ( [ url ] , scrape_info . outdir , command [ "--size" ] , ( 0 , 0 ) , command [ "--timeout" ] , path = scrape_info . browser_path ) if not scrape_info . result : scrape_info . result = "success" else : success = False result = "unknown" if success : result = "equal" file1 = drivers . windowing . URLtoFilename ( url , scrape_info_list [ 0 ] . outdir , ".bmp" ) file2 = drivers . windowing . URLtoFilename ( url , scrape_info_list [ 1 ] . outdir , ".bmp" ) comparison_result = compare . Compare ( file1 , file2 , maskdir = command [ "--maskdir" ] ) if comparison_result is not None : result = "not-equal" if command [ "--diffdir" ] : comparison_result [ 1 ] . save ( drivers . windowing . URLtoFilename ( url , command [ "--diffdir" ] , ".bmp" ) ) # TODO(jhaas): maybe use the logging module rather than raw file writes log_file . write ( "%s %s %s %s\n" % ( url , scrape_info_list [ 0 ] . result , scrape_info_list [ 1 ] . result , result ) )