OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """PyAuto: Python Interface to Chromium's Automation Proxy. | 6 """PyAuto: Python Interface to Chromium's Automation Proxy. |
7 | 7 |
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
9 For complete documentation on the functionality available, | 9 For complete documentation on the functionality available, |
10 run pydoc on this file. | 10 run pydoc on this file. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 79 |
80 # Should go after sys.path is set appropriately | 80 # Should go after sys.path is set appropriately |
81 import bookmark_model | 81 import bookmark_model |
82 import download_info | 82 import download_info |
83 import history_info | 83 import history_info |
84 import omnibox_info | 84 import omnibox_info |
85 import plugins_info | 85 import plugins_info |
86 import prefs_info | 86 import prefs_info |
87 from pyauto_errors import JavascriptRuntimeError | 87 from pyauto_errors import JavascriptRuntimeError |
88 from pyauto_errors import JSONInterfaceError | 88 from pyauto_errors import JSONInterfaceError |
89 from pyauto_errors import AutomationCommandFail | |
Nirnimesh
2012/08/15 00:11:21
sort the list
craigdh
2012/08/15 00:50:58
Done.
| |
89 from pyauto_errors import NTPThumbnailNotShownError | 90 from pyauto_errors import NTPThumbnailNotShownError |
90 import pyauto_utils | 91 import pyauto_utils |
91 import simplejson as json # found in third_party | 92 import simplejson as json # found in third_party |
92 | 93 |
93 _CHROME_DRIVER_FACTORY = None | 94 _CHROME_DRIVER_FACTORY = None |
94 _HTTP_SERVER = None | 95 _HTTP_SERVER = None |
95 _REMOTE_PROXY = None | 96 _REMOTE_PROXY = None |
96 _OPTIONS = None | 97 _OPTIONS = None |
97 _BROWSER_PID = None | 98 _BROWSER_PID = None |
98 | 99 |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1096 cmd_dict_copy = copy.copy(cmd_dict) | 1097 cmd_dict_copy = copy.copy(cmd_dict) |
1097 if 'password' in cmd_dict_copy.keys(): | 1098 if 'password' in cmd_dict_copy.keys(): |
1098 cmd_dict_copy['password'] = '**********' | 1099 cmd_dict_copy['password'] = '**********' |
1099 if 'username' in cmd_dict_copy.keys(): | 1100 if 'username' in cmd_dict_copy.keys(): |
1100 cmd_dict_copy['username'] = 'removed_username' | 1101 cmd_dict_copy['username'] = 'removed_username' |
1101 raise JSONInterfaceError('Automation call %s received empty response. ' | 1102 raise JSONInterfaceError('Automation call %s received empty response. ' |
1102 'Additional information:\n%s' % (cmd_dict_copy, | 1103 'Additional information:\n%s' % (cmd_dict_copy, |
1103 additional_info)) | 1104 additional_info)) |
1104 ret_dict = json.loads(result) | 1105 ret_dict = json.loads(result) |
1105 if ret_dict.has_key('error'): | 1106 if ret_dict.has_key('error'): |
1106 raise JSONInterfaceError(ret_dict['error']) | 1107 if ret_dict.get('is_interface_error'): |
1108 raise JSONInterfaceError(ret_dict['error']) | |
1109 else: | |
1110 raise AutomationCommandFail(ret_dict['error']) | |
1107 return ret_dict | 1111 return ret_dict |
1108 | 1112 |
1109 def NavigateToURL(self, url, windex=0, tab_index=None, navigation_count=1): | 1113 def NavigateToURL(self, url, windex=0, tab_index=None, navigation_count=1): |
1110 """Navigate the given tab to the given URL. | 1114 """Navigate the given tab to the given URL. |
1111 | 1115 |
1112 Note that this method also activates the corresponding tab/window if it's | 1116 Note that this method also activates the corresponding tab/window if it's |
1113 not active already. Blocks until |navigation_count| navigations have | 1117 not active already. Blocks until |navigation_count| navigations have |
1114 completed. | 1118 completed. |
1115 | 1119 |
1116 Args: | 1120 Args: |
(...skipping 5861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6978 successful = result.wasSuccessful() | 6982 successful = result.wasSuccessful() |
6979 if not successful: | 6983 if not successful: |
6980 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 6984 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
6981 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 6985 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
6982 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 6986 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
6983 sys.exit(not successful) | 6987 sys.exit(not successful) |
6984 | 6988 |
6985 | 6989 |
6986 if __name__ == '__main__': | 6990 if __name__ == '__main__': |
6987 Main() | 6991 Main() |
OLD | NEW |