diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 17:25:34 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 17:25:34 +0000 |
commit | cb155a802bdc49cfafea1c41e0f0a92168f1da09 (patch) | |
tree | bf0fae4855c7f4458d8e959455b9d12d6cd54d9d /tools/site_compare | |
parent | 9bec23957253b83955c4096903ad6293d1c6e1bb (diff) | |
download | chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.zip chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.gz chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.bz2 |
Fix python scripts in src/tools/
Make sure that:
- shebang is only present for executable files
- shebang is #!/usr/bin/env python
- __main__ is only present for executable files
- file's executable bit is coherent
Also fix EOF LF to be only one.
TBR=timurrrr@chromium.org
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8678023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/site_compare')
26 files changed, 93 insertions, 113 deletions
diff --git a/tools/site_compare/command_line.py b/tools/site_compare/command_line.py index 2c87fb9..de93d18 100644..100755 --- a/tools/site_compare/command_line.py +++ b/tools/site_compare/command_line.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -660,7 +660,8 @@ def DoHelpCommand(command): command.cmdline.Exit() -if __name__ == "__main__": + +def main(): # If we're invoked rather than imported, run some tests cmdline = CommandLine() @@ -797,3 +798,5 @@ if __name__ == "__main__": cmdline.ParseCommandLine(["help", "test"]) +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/commands/__init__.py b/tools/site_compare/commands/__init__.py index a699508..e69de29 100644..100755 --- a/tools/site_compare/commands/__init__.py +++ b/tools/site_compare/commands/__init__.py @@ -1,2 +0,0 @@ -#!/usr/bin/Python2.4 - diff --git a/tools/site_compare/commands/compare2.py b/tools/site_compare/commands/compare2.py index 045141b..7e15559 100644 --- a/tools/site_compare/commands/compare2.py +++ b/tools/site_compare/commands/compare2.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -169,4 +168,3 @@ def ExecuteCompare2(command): scrape_info_list[0].result, scrape_info_list[1].result, result)) - diff --git a/tools/site_compare/commands/maskmaker.py b/tools/site_compare/commands/maskmaker.py index 73b732c..8aeefcb 100644 --- a/tools/site_compare/commands/maskmaker.py +++ b/tools/site_compare/commands/maskmaker.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -271,4 +270,3 @@ def ExecuteMaskmaker(command): "reaching the giveup threshhold" % len(url_list)) for url in url_list: print " ", url.url - diff --git a/tools/site_compare/commands/measure.py b/tools/site_compare/commands/measure.py index 086fcbe..2bd71f5 100644 --- a/tools/site_compare/commands/measure.py +++ b/tools/site_compare/commands/measure.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -51,4 +50,3 @@ def ExecuteMeasure(command): # Close the log file and return. We're done. log_file.close() - diff --git a/tools/site_compare/commands/scrape.py b/tools/site_compare/commands/scrape.py index 1c47cab..8fee5a3 100644 --- a/tools/site_compare/commands/scrape.py +++ b/tools/site_compare/commands/scrape.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -58,4 +57,3 @@ def ExecuteScrape(command): # Close the log file and return. We're done. if log_file: log_file.close() - diff --git a/tools/site_compare/commands/timeload.py b/tools/site_compare/commands/timeload.py index ca5b0db..f34ee1d 100644 --- a/tools/site_compare/commands/timeload.py +++ b/tools/site_compare/commands/timeload.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -39,7 +38,8 @@ def CreateCommand(cmdline): ["-bp", "--browserpaths"], "List of paths to browsers. Comma-separated", type="string", required=False) cmd.AddArgument( - ["-bv", "--browserversions"], "List of versions of browsers. Comma-separated", + ["-bv", "--browserversions"], + "List of versions of browsers. Comma-separated", type="string", required=False) cmd.AddArgument( ["-u", "--url"], "URL to time") @@ -142,5 +142,3 @@ def ExecuteTimeLoad(command): log_file.write(url) for b in xrange(num_browsers): log_file.write(",%r" % results[url][b]) - - diff --git a/tools/site_compare/drivers/__init__.py b/tools/site_compare/drivers/__init__.py index fa9f1c2..9b46261 100644 --- a/tools/site_compare/drivers/__init__.py +++ b/tools/site_compare/drivers/__init__.py @@ -1,11 +1,9 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Imports a set of drivers appropriate to the current OS.""" -__author__ = 'jhaas@google.com (Jonathan Haas)' - import sys platform_dir = sys.platform diff --git a/tools/site_compare/drivers/win32/keyboard.py b/tools/site_compare/drivers/win32/keyboard.py index 246e14c..e3410e1 100644..100755 --- a/tools/site_compare/drivers/win32/keyboard.py +++ b/tools/site_compare/drivers/win32/keyboard.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -166,7 +166,8 @@ def TypeString(string_to_type, if ctrl_held: PressKey(False, win32con.VK_CONTROL) if alt_held: PressKey(False, win32con.VK_MENU) -if __name__ == "__main__": + +def main(): # We're being invoked rather than imported. Let's do some tests # Press command-R to bring up the Run dialog @@ -196,3 +197,5 @@ if __name__ == "__main__": time_between_keystrokes=0.05) +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/drivers/win32/mouse.py b/tools/site_compare/drivers/win32/mouse.py index bd16272..0096af9 100644..100755 --- a/tools/site_compare/drivers/win32/mouse.py +++ b/tools/site_compare/drivers/win32/mouse.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -189,7 +189,8 @@ def DoubleClickInWindow( time.sleep(time_between_clicks) ClickInWindow(hwnd, offset, button, click_time) -if __name__ == "__main__": + +def main(): # We're being invoked rather than imported. Let's do some tests screen_size = win32gui.GetClientRect(win32gui.GetDesktopWindow()) @@ -216,3 +217,6 @@ if __name__ == "__main__": MoveToLocation((0, 0), 3) ClickButton() + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/drivers/win32/windowing.py b/tools/site_compare/drivers/win32/windowing.py index fe77c56..47d63f0 100644..100755 --- a/tools/site_compare/drivers/win32/windowing.py +++ b/tools/site_compare/drivers/win32/windowing.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -338,7 +338,8 @@ def PreparePath(path): except OSError, e: if e[0] != 17: raise e # error 17: path already exists -if __name__ == "__main__": + +def main(): PreparePath(r"c:\sitecompare\scrapes\ie7") # We're being invoked rather than imported. Let's do some tests @@ -360,3 +361,6 @@ if __name__ == "__main__": EndProcess(proc, 0) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/operators/__init__.py b/tools/site_compare/operators/__init__.py index f60e8e8..5d6ffd7 100644 --- a/tools/site_compare/operators/__init__.py +++ b/tools/site_compare/operators/__init__.py @@ -1,11 +1,9 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Selects the appropriate operator.""" -__author__ = 'jhaas@google.com (Jonathan Haas)' - def GetOperator(operator): """Given an operator by name, returns its module. @@ -23,4 +21,3 @@ def GetOperator(operator): module = __import__(operator, globals(), locals(), ['']) return module - diff --git a/tools/site_compare/operators/equals.py b/tools/site_compare/operators/equals.py index 4054fa6..311f530 100644 --- a/tools/site_compare/operators/equals.py +++ b/tools/site_compare/operators/equals.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -36,6 +35,3 @@ def Compare(file1, file2, **kwargs): return ("The images differ", diff) else: return None - - - diff --git a/tools/site_compare/operators/equals_with_mask.py b/tools/site_compare/operators/equals_with_mask.py index d6abd53..e42f7e1 100644 --- a/tools/site_compare/operators/equals_with_mask.py +++ b/tools/site_compare/operators/equals_with_mask.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -56,6 +55,3 @@ def Compare(file1, file2, **kwargs): return ("The images differ", diff) else: return None - - - diff --git a/tools/site_compare/scrapers/__init__.py b/tools/site_compare/scrapers/__init__.py index cb82b2b..5f6d778 100644..100755 --- a/tools/site_compare/scrapers/__init__.py +++ b/tools/site_compare/scrapers/__init__.py @@ -1,11 +1,10 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Selects the appropriate scraper for a given browser and version.""" -__author__ = 'jhaas@google.com (Jonathan Haas)' - import types # TODO(jhaas): unify all optional scraper parameters into kwargs @@ -28,7 +27,7 @@ def GetScraper(browser): return module + # if invoked rather than imported, do some tests if __name__ == "__main__": print GetScraper("IE") - diff --git a/tools/site_compare/scrapers/chrome/__init__.py b/tools/site_compare/scrapers/chrome/__init__.py index 6342525..587a50d 100644..100755 --- a/tools/site_compare/scrapers/chrome/__init__.py +++ b/tools/site_compare/scrapers/chrome/__init__.py @@ -1,10 +1,10 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Selects the appropriate scraper for Chrome.""" -__author__ = 'jhaas@google.com (Jonathan Haas)' def GetScraper(version): """Returns the scraper module for the given version. @@ -30,9 +30,7 @@ def GetScraper(version): return __import__(scraper_version, globals(), locals(), ['']) + # if invoked rather than imported, test if __name__ == "__main__": - version = "0.1.101.0" - - print GetScraper(version).version - + print GetScraper("0.1.101.0").version diff --git a/tools/site_compare/scrapers/chrome/chrome011010.py b/tools/site_compare/scrapers/chrome/chrome011010.py index b4f816f..6f0dfb4 100644 --- a/tools/site_compare/scrapers/chrome/chrome011010.py +++ b/tools/site_compare/scrapers/chrome/chrome011010.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -41,4 +40,3 @@ def Time(urls, size, timeout, **kwargs): chromebase.GetChromeRenderPane = GetChromeRenderPane return chromebase.Time(urls, size, timeout, kwargs) - diff --git a/tools/site_compare/scrapers/chrome/chrome01970.py b/tools/site_compare/scrapers/chrome/chrome01970.py index 54bc670..2f237fa 100644 --- a/tools/site_compare/scrapers/chrome/chrome01970.py +++ b/tools/site_compare/scrapers/chrome/chrome01970.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -41,4 +40,3 @@ def Time(urls, size, timeout, **kwargs): chromebase.GetChromeRenderPane = GetChromeRenderPane return chromebase.Time(urls, size, timeout, kwargs) - diff --git a/tools/site_compare/scrapers/chrome/chromebase.py b/tools/site_compare/scrapers/chrome/chromebase.py index aba17c1..2b8f177 100644..100755 --- a/tools/site_compare/scrapers/chrome/chromebase.py +++ b/tools/site_compare/scrapers/chrome/chromebase.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -12,10 +12,12 @@ from drivers import keyboard from drivers import mouse from drivers import windowing + # TODO: this has moved, use some logic to find it. For now, # expects a subst k:. DEFAULT_PATH = r"k:\chrome.exe" + def InvokeBrowser(path): """Invoke the Chrome browser. @@ -179,7 +181,7 @@ def Time(urls, size, timeout, kwargs): return ret -if __name__ == "__main__": +def main(): # We're being invoked rather than imported, so run some tests path = r"c:\sitecompare\scrapes\chrome\0.1.97.0" windowing.PreparePath(path) @@ -190,4 +192,8 @@ if __name__ == "__main__": "http://www.google.com", "http://www.sun.com"], path, (1024, 768), (0, 0)) + return 0 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/scrapers/firefox/__init__.py b/tools/site_compare/scrapers/firefox/__init__.py index 7eb9291..34c0699 100644..100755 --- a/tools/site_compare/scrapers/firefox/__init__.py +++ b/tools/site_compare/scrapers/firefox/__init__.py @@ -1,11 +1,10 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Selects the appropriate scraper for Firefox.""" -__author__ = 'jhaas@google.com (Jonathan Haas)' - def GetScraper(version): """Returns the scraper module for the given version. @@ -23,9 +22,7 @@ def GetScraper(version): # We only have one version of the Firefox scraper for now return __import__("firefox2", globals(), locals(), ['']) + # if invoked rather than imported, test if __name__ == "__main__": - version = "2.0.0.6" - print GetScraper("2.0.0.6").version - diff --git a/tools/site_compare/scrapers/firefox/firefox2.py b/tools/site_compare/scrapers/firefox/firefox2.py index fa0d620..2181f58 100644..100755 --- a/tools/site_compare/scrapers/firefox/firefox2.py +++ b/tools/site_compare/scrapers/firefox/firefox2.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -232,7 +232,7 @@ def Time(urls, size, timeout, **kwargs): return ret -if __name__ == "__main__": +def main(): # We're being invoked rather than imported, so run some tests path = r"c:\sitecompare\scrapes\Firefox\2.0.0.6" windowing.PreparePath(path) @@ -242,4 +242,8 @@ if __name__ == "__main__": ["http://www.microsoft.com", "http://www.google.com", "http://www.sun.com"], path, (1024, 768), (0, 0)) + return 0 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/scrapers/ie/__init__.py b/tools/site_compare/scrapers/ie/__init__.py index 8fb95db..b4dab09 100644..100755 --- a/tools/site_compare/scrapers/ie/__init__.py +++ b/tools/site_compare/scrapers/ie/__init__.py @@ -1,11 +1,10 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Selects the appropriate scraper for Internet Explorer.""" -__author__ = 'jhaas@google.com (Jonathan Haas)' - def GetScraper(version): """Returns the scraper module for the given version. @@ -23,9 +22,7 @@ def GetScraper(version): # We only have one version of the IE scraper for now return __import__("ie7", globals(), locals(), ['']) + # if invoked rather than imported, test if __name__ == "__main__": - version = "7.0.5370.1" - - print GetScraper(version).version - + print GetScraper("7.0.5370.1").version diff --git a/tools/site_compare/scrapers/ie/ie7.py b/tools/site_compare/scrapers/ie/ie7.py index da26d9b..dcb83ca 100644..100755 --- a/tools/site_compare/scrapers/ie/ie7.py +++ b/tools/site_compare/scrapers/ie/ie7.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -192,7 +192,7 @@ def Time(urls, size, timeout, **kwargs): return ret -if __name__ == "__main__": +def main(): # We're being invoked rather than imported, so run some tests path = r"c:\sitecompare\scrapes\ie7\7.0.5380.11" windowing.PreparePath(path) @@ -203,4 +203,8 @@ if __name__ == "__main__": "http://www.google.com", "http://www.sun.com"], path, (1024, 768), (0, 0)) + return 0 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/site_compare/site_compare.py b/tools/site_compare/site_compare.py index 15359fa..db9216f 100644..100755 --- a/tools/site_compare/site_compare.py +++ b/tools/site_compare/site_compare.py @@ -1,5 +1,5 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -169,9 +169,8 @@ def main(): commands.scrape.CreateCommand(cmdline) cmdline.ParseCommandLine() - + return 0 if __name__ == "__main__": - main() - + sys.exit(main()) diff --git a/tools/site_compare/utils/__init__.py b/tools/site_compare/utils/__init__.py index 69f2237..e69de29 100644..100755 --- a/tools/site_compare/utils/__init__.py +++ b/tools/site_compare/utils/__init__.py @@ -1,7 +0,0 @@ -#!/usr/bin/python2.4 -# -# Copyright 2007 Google Inc. All Rights Reserved. - -"""Utilities for site_compare.""" - -__author__ = 'jhaas@google.com (Jonathan Haas)' diff --git a/tools/site_compare/utils/browser_iterate.py b/tools/site_compare/utils/browser_iterate.py index 6ea4e5f..596b475 100644 --- a/tools/site_compare/utils/browser_iterate.py +++ b/tools/site_compare/utils/browser_iterate.py @@ -1,5 +1,4 @@ -#!/usr/bin/python2.4 -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -198,4 +197,3 @@ def Iterate(command, iteration_func): # We're done DetachFromBrowser() - |