summaryrefslogtreecommitdiffstats
path: root/tools/site_compare/site_compare.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 12:46:38 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 12:46:38 +0000
commitf0a51fb571f46531025fa09240bbc3e1af925e84 (patch)
tree558b4f0e737fda4b9ab60f252c9c23b8a4ca523e /tools/site_compare/site_compare.py
parent6390be368205705f49ead3cec40396519f13b889 (diff)
downloadchromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.zip
chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.gz
chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.bz2
Fixes CRLF and trailing white spaces.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/site_compare/site_compare.py')
-rw-r--r--tools/site_compare/site_compare.py58
1 files changed, 29 insertions, 29 deletions
diff --git a/tools/site_compare/site_compare.py b/tools/site_compare/site_compare.py
index 976f0ef..15359fa 100644
--- a/tools/site_compare/site_compare.py
+++ b/tools/site_compare/site_compare.py
@@ -37,7 +37,7 @@ import commands.scrape # scrape a URL or series of URLs to a bitmap
def Scrape(browsers, urls, window_size=(1024, 768),
window_pos=(0, 0), timeout=20, save_path=None, **kwargs):
"""Invoke one or more browsers over one or more URLs, scraping renders.
-
+
Args:
browsers: browsers to invoke with optional version strings
urls: URLs to visit
@@ -49,43 +49,43 @@ def Scrape(browsers, urls, window_size=(1024, 768),
kwargs: miscellaneous keyword args, passed to scraper
Returns:
None
-
+
@TODO(jhaas): more parameters, or perhaps an indefinite dictionary
parameter, for things like length of time to wait for timeout, speed
of mouse clicks, etc. Possibly on a per-browser, per-URL, or
per-browser-per-URL basis
"""
-
+
if type(browsers) in types.StringTypes: browsers = [browsers]
-
+
if save_path is None:
# default save path is "scrapes" off the current root
save_path = os.path.join(os.path.split(__file__)[0], "Scrapes")
-
+
for browser in browsers:
# Browsers should be tuples of (browser, version)
if type(browser) in types.StringTypes: browser = (browser, None)
scraper = scrapers.GetScraper(browser)
-
+
full_path = os.path.join(save_path, browser[0], scraper.version)
drivers.windowing.PreparePath(full_path)
-
+
scraper.Scrape(urls, full_path, window_size, window_pos, timeout, kwargs)
-
-
+
+
def Compare(base, compare, ops, root_path=None, out_path=None):
"""Compares a series of scrapes using a series of operators.
-
+
Args:
base: (browser, version) tuple of version to consider the baseline
compare: (browser, version) tuple of version to compare to
ops: list of operators plus operator arguments
root_path: root of the scrapes
out_path: place to put any output from the operators
-
+
Returns:
None
-
+
@TODO(jhaas): this method will likely change, to provide a robust and
well-defined way of chaining operators, applying operators conditionally,
and full-featured scripting of the operator chain. There also needs
@@ -95,28 +95,28 @@ def Compare(base, compare, ops, root_path=None, out_path=None):
if root_path is None:
# default save path is "scrapes" off the current root
root_path = os.path.join(os.path.split(__file__)[0], "Scrapes")
-
+
if out_path is None:
out_path = os.path.join(os.path.split(__file__)[0], "Compares")
-
+
if type(base) in types.StringTypes: base = (base, None)
if type(compare) in types.StringTypes: compare = (compare, None)
if type(ops) in types.StringTypes: ops = [ops]
-
+
base_dir = os.path.join(root_path, base[0])
compare_dir = os.path.join(root_path, compare[0])
-
+
if base[1] is None:
# base defaults to earliest capture
base = (base[0], max(os.listdir(base_dir)))
-
+
if compare[1] is None:
# compare defaults to latest capture
compare = (compare[0], min(os.listdir(compare_dir)))
-
+
out_path = os.path.join(out_path, base[0], base[1], compare[0], compare[1])
drivers.windowing.PreparePath(out_path)
-
+
# TODO(jhaas): right now we're just dumping output to a log file
# (and the console), which works as far as it goes but isn't nearly
# robust enough. Change this after deciding exactly what we want to
@@ -126,10 +126,10 @@ def Compare(base, compare, ops, root_path=None, out_path=None):
(base[0], base[1], compare[0], compare[1]))
out_file.write(description_string)
print description_string
-
+
base_dir = os.path.join(base_dir, base[1])
compare_dir = os.path.join(compare_dir, compare[1])
-
+
for filename in os.listdir(base_dir):
out_file.write("%s: " % filename)
@@ -137,15 +137,15 @@ def Compare(base, compare, ops, root_path=None, out_path=None):
out_file.write("Does not exist in target directory\n")
print "File %s does not exist in target directory" % filename
continue
-
+
base_filename = os.path.join(base_dir, filename)
compare_filename = os.path.join(compare_dir, filename)
-
+
for op in ops:
if type(op) in types.StringTypes: op = (op, None)
-
+
module = operators.GetOperator(op[0])
-
+
ret = module.Compare(base_filename, compare_filename)
if ret is None:
print "%s: OK" % (filename,)
@@ -154,24 +154,24 @@ def Compare(base, compare, ops, root_path=None, out_path=None):
print "%s: %s" % (filename, ret[0])
out_file.write("%s\n" % (ret[0]))
ret[1].save(os.path.join(out_path, filename))
-
+
out_file.close()
def main():
"""Main executable. Parse the command line and invoke the command."""
cmdline = command_line.CommandLine()
-
+
# The below two commands are currently unstable so have been disabled
# commands.compare2.CreateCommand(cmdline)
# commands.maskmaker.CreateCommand(cmdline)
commands.measure.CreateCommand(cmdline)
commands.scrape.CreateCommand(cmdline)
-
+
cmdline.ParseCommandLine()
if __name__ == "__main__":
main()
-
+