| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """SiteCompare module for invoking, locating, and manipulating windows. | 6 """SiteCompare module for invoking, locating, and manipulating windows. |
| 7 | 7 |
| 8 This module is a catch-all wrapper for operating system UI functionality | 8 This module is a catch-all wrapper for operating system UI functionality |
| 9 that doesn't belong in other modules. It contains functions for finding | 9 that doesn't belong in other modules. It contains functions for finding |
| 10 particular windows, scraping their contents, and invoking processes to | 10 particular windows, scraping their contents, and invoking processes to |
| 11 create them. | 11 create them. |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 path: fully-qualified path of directory to ensure exists | 331 path: fully-qualified path of directory to ensure exists |
| 332 | 332 |
| 333 Returns: | 333 Returns: |
| 334 None | 334 None |
| 335 """ | 335 """ |
| 336 try: | 336 try: |
| 337 os.makedirs(path) | 337 os.makedirs(path) |
| 338 except OSError, e: | 338 except OSError, e: |
| 339 if e[0] != 17: raise e # error 17: path already exists | 339 if e[0] != 17: raise e # error 17: path already exists |
| 340 | 340 |
| 341 if __name__ == "__main__": | 341 |
| 342 def main(): |
| 342 PreparePath(r"c:\sitecompare\scrapes\ie7") | 343 PreparePath(r"c:\sitecompare\scrapes\ie7") |
| 343 # We're being invoked rather than imported. Let's do some tests | 344 # We're being invoked rather than imported. Let's do some tests |
| 344 | 345 |
| 345 # Hardcode IE's location for the purpose of this test | 346 # Hardcode IE's location for the purpose of this test |
| 346 (proc, wnd) = InvokeAndWait( | 347 (proc, wnd) = InvokeAndWait( |
| 347 r"c:\program files\internet explorer\iexplore.exe") | 348 r"c:\program files\internet explorer\iexplore.exe") |
| 348 | 349 |
| 349 # Find the browser pane in the IE window | 350 # Find the browser pane in the IE window |
| 350 browser = FindChildWindow( | 351 browser = FindChildWindow( |
| 351 wnd, "TabWindowClass/Shell DocObject View/Internet Explorer_Server") | 352 wnd, "TabWindowClass/Shell DocObject View/Internet Explorer_Server") |
| 352 | 353 |
| 353 # Move and size the window | 354 # Move and size the window |
| 354 MoveAndSizeWindow(wnd, (0, 0), (1024, 768), browser) | 355 MoveAndSizeWindow(wnd, (0, 0), (1024, 768), browser) |
| 355 | 356 |
| 356 # Take a screenshot | 357 # Take a screenshot |
| 357 i = ScrapeWindow(browser) | 358 i = ScrapeWindow(browser) |
| 358 | 359 |
| 359 i.show() | 360 i.show() |
| 360 | 361 |
| 361 EndProcess(proc, 0) | 362 EndProcess(proc, 0) |
| 362 | 363 |
| 364 |
| 365 if __name__ == "__main__": |
| 366 sys.exit(main()) |
| OLD | NEW |