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 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 | 2400 |
2401 Effectively the same as clicking the "Sign out" link on the screen locker. | 2401 Effectively the same as clicking the "Sign out" link on the screen locker. |
2402 Screen should be locked for this to work. | 2402 Screen should be locked for this to work. |
2403 | 2403 |
2404 Raises: | 2404 Raises: |
2405 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 2405 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
2406 """ | 2406 """ |
2407 cmd_dict = { 'command': 'SignoutInScreenLocker' } | 2407 cmd_dict = { 'command': 'SignoutInScreenLocker' } |
2408 self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 2408 self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
2409 | 2409 |
| 2410 def GetBatteryInfo(self): |
| 2411 """Get details about battery state. |
| 2412 |
| 2413 Returns: |
| 2414 A dictionary with the following keys: |
| 2415 |
| 2416 'battery_is_present' : bool |
| 2417 'line_power_on' : bool |
| 2418 if 'battery_is_present': |
| 2419 'battery_percentage' : float (0 ~ 100) |
| 2420 'battery_fully_charged' : bool |
| 2421 if 'line_power_on': |
| 2422 'battery_time_to_full' : int (seconds) |
| 2423 else: |
| 2424 'battery_time_to_empty' : int (seconds) |
| 2425 |
| 2426 If it is still calculating the time left, 'battery_time_to_full' |
| 2427 and 'battery_time_to_empty' will be absent. |
| 2428 |
| 2429 Use 'battery_fully_charged' instead of 'battery_percentage' |
| 2430 or 'battery_time_to_full' to determine whether the battery |
| 2431 is fully charged, since the percentage is only approximate. |
| 2432 |
| 2433 Sample: |
| 2434 { u'battery_is_present': True, |
| 2435 u'line_power_on': False, |
| 2436 u'battery_time_to_empty': 29617, |
| 2437 u'battery_percentage': 100.0, |
| 2438 u'battery_fully_charged': False } |
| 2439 |
| 2440 Raises: |
| 2441 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 2442 """ |
| 2443 cmd_dict = { 'command': 'GetBatteryInfo' } |
| 2444 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
| 2445 |
2410 def GetNetworkInfo(self): | 2446 def GetNetworkInfo(self): |
2411 """Get details about ethernet, wifi, and cellular networks on chromeos. | 2447 """Get details about ethernet, wifi, and cellular networks on chromeos. |
2412 | 2448 |
2413 Raises: | 2449 Raises: |
2414 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 2450 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
2415 """ | 2451 """ |
2416 cmd_dict = { 'command': 'GetNetworkInfo' } | 2452 cmd_dict = { 'command': 'GetNetworkInfo' } |
2417 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 2453 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
2418 | 2454 |
2419 def NetworkScan(self): | 2455 def NetworkScan(self): |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 if self._options.verbose: | 2896 if self._options.verbose: |
2861 verbosity = 2 | 2897 verbosity = 2 |
2862 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 2898 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
2863 del loaded_tests # Need to destroy test cases before the suite | 2899 del loaded_tests # Need to destroy test cases before the suite |
2864 del pyauto_suite | 2900 del pyauto_suite |
2865 sys.exit(not result.wasSuccessful()) | 2901 sys.exit(not result.wasSuccessful()) |
2866 | 2902 |
2867 | 2903 |
2868 if __name__ == '__main__': | 2904 if __name__ == '__main__': |
2869 Main() | 2905 Main() |
OLD | NEW |