OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
8 | 8 |
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 u'y': 44}]} | 1374 u'y': 44}]} |
1375 | 1375 |
1376 Raises: | 1376 Raises: |
1377 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 1377 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
1378 """ | 1378 """ |
1379 cmd_dict = { # Prepare command for the json interface | 1379 cmd_dict = { # Prepare command for the json interface |
1380 'command': 'GetBrowserInfo', | 1380 'command': 'GetBrowserInfo', |
1381 } | 1381 } |
1382 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 1382 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
1383 | 1383 |
1384 def GetProcessInfo(self): | |
1385 """Returns information about browser-related processes that currently exist. | |
1386 | |
1387 This will also return information about other currently-running browsers | |
1388 besides just Chrome. | |
1389 | |
1390 Returns: | |
1391 A dictionary containing browser-related process information as identified | |
1392 by class MemoryDetails in src/chrome/browser/memory_details.h. The | |
1393 dictionary contains a single key 'browsers', mapped to a list of | |
1394 dictionaries containing information about each browser process name. | |
Nirnimesh
2011/09/21 22:42:35
do you expect multiple browser processes?
dennis_jeffrey
2011/09/22 18:25:35
Yes. It doesn't seem to happen on Linux or Chrome
| |
1395 Each of those dictionaries contains a key 'processes', mapped to a list | |
1396 of dictionaries containing the specific information for each process | |
1397 with the given process name. | |
1398 | |
1399 The memory values given in |committed_mem| and |working_set_mem| are in | |
1400 KBytes. | |
1401 | |
1402 Sample: | |
1403 { 'browsers': [ { 'name': 'Chromium', | |
1404 'process_name': 'chrome', | |
1405 'processes': [ { 'child_process_type': 'Browser', | |
1406 'committed_mem': { 'image': 0, | |
1407 'mapped': 0, | |
1408 'priv': 0}, | |
1409 'is_diagnostics': False, | |
1410 'num_processes': 1, | |
1411 'pid': 7770, | |
1412 'product_name': '', | |
1413 'renderer_type': 'Unknown', | |
1414 'titles': [], | |
1415 'version': '', | |
1416 'working_set_mem': { 'priv': 43672, | |
1417 'shareable': 0, | |
1418 'shared': 59251}}, | |
1419 { 'child_process_type': 'Tab', | |
1420 'committed_mem': { 'image': 0, | |
1421 'mapped': 0, | |
1422 'priv': 0}, | |
1423 'is_diagnostics': False, | |
1424 'num_processes': 1, | |
1425 'pid': 7791, | |
1426 'product_name': '', | |
1427 'renderer_type': 'Tab', | |
1428 'titles': ['about:blank'], | |
1429 'version': '', | |
1430 'working_set_mem': { 'priv': 16768, | |
1431 'shareable': 0, | |
1432 'shared': 26256}}, | |
1433 ...<more processes>...]}]} | |
1434 | |
1435 Raises: | |
1436 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
1437 """ | |
1438 cmd_dict = { # Prepare command for the json interface. | |
1439 'command': 'GetProcessInfo', | |
1440 } | |
1441 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | |
1442 | |
1384 def GetNavigationInfo(self, tab_index=0, windex=0): | 1443 def GetNavigationInfo(self, tab_index=0, windex=0): |
1385 """Get info about the navigation state of a given tab. | 1444 """Get info about the navigation state of a given tab. |
1386 | 1445 |
1387 Args: | 1446 Args: |
1388 tab_index: The tab index, default is 0. | 1447 tab_index: The tab index, default is 0. |
1389 window_index: The window index, default is 0. | 1448 window_index: The window index, default is 0. |
1390 | 1449 |
1391 Returns: | 1450 Returns: |
1392 a dictionary. | 1451 a dictionary. |
1393 Sample: | 1452 Sample: |
(...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4475 successful = result.wasSuccessful() | 4534 successful = result.wasSuccessful() |
4476 if not successful: | 4535 if not successful: |
4477 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 4536 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
4478 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 4537 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
4479 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 4538 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
4480 sys.exit(not successful) | 4539 sys.exit(not successful) |
4481 | 4540 |
4482 | 4541 |
4483 if __name__ == '__main__': | 4542 if __name__ == '__main__': |
4484 Main() | 4543 Main() |
OLD | NEW |