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 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2364 | 2364 |
2365 Effectively the same as clicking the "Sign out" link on the screen locker. | 2365 Effectively the same as clicking the "Sign out" link on the screen locker. |
2366 Screen should be locked for this to work. | 2366 Screen should be locked for this to work. |
2367 | 2367 |
2368 Raises: | 2368 Raises: |
2369 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 2369 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
2370 """ | 2370 """ |
2371 cmd_dict = { 'command': 'SignoutInScreenLocker' } | 2371 cmd_dict = { 'command': 'SignoutInScreenLocker' } |
2372 self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 2372 self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
2373 | 2373 |
2374 def GetBatteryInfo(self): | |
2375 """Get details about battery state. | |
2376 | |
2377 Returns: | |
2378 A dictionary. | |
2379 Sample: | |
2380 { u'battery': True, | |
2381 u'line_power': False, | |
2382 u'time_left': 29617, # 0 if the time left is still being calculated. | |
Nirnimesh
2011/03/29 01:29:39
Using 0 for 'still being calculated' case is incor
dtu
2011/03/29 02:21:22
Done. Key will be absent in the 'still being calcu
| |
2383 u'percentage': 100.0, | |
2384 u'charged': False } | |
2385 | |
2386 Use 'charged' instead of 'percentage' to determine whether the | |
2387 battery is fully charged, since the percentage is only approximate. | |
2388 | |
krisr
2011/03/29 01:02:01
I actually had to look at the device to see how th
dtu
2011/03/29 02:21:22
Comment expanded. I also changed it so fields only
| |
2389 Raises: | |
2390 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
2391 """ | |
2392 cmd_dict = { 'command': 'GetBatteryInfo' } | |
2393 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | |
2394 | |
2374 def GetNetworkInfo(self): | 2395 def GetNetworkInfo(self): |
2375 """Get details about ethernet, wifi, and cellular networks on chromeos. | 2396 """Get details about ethernet, wifi, and cellular networks on chromeos. |
2376 | 2397 |
2377 Raises: | 2398 Raises: |
2378 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 2399 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
2379 """ | 2400 """ |
2380 cmd_dict = { 'command': 'GetNetworkInfo' } | 2401 cmd_dict = { 'command': 'GetNetworkInfo' } |
2381 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 2402 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
2382 | 2403 |
2383 def NetworkScan(self): | 2404 def NetworkScan(self): |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2824 if self._options.verbose: | 2845 if self._options.verbose: |
2825 verbosity = 2 | 2846 verbosity = 2 |
2826 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 2847 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
2827 del loaded_tests # Need to destroy test cases before the suite | 2848 del loaded_tests # Need to destroy test cases before the suite |
2828 del pyauto_suite | 2849 del pyauto_suite |
2829 sys.exit(not result.wasSuccessful()) | 2850 sys.exit(not result.wasSuccessful()) |
2830 | 2851 |
2831 | 2852 |
2832 if __name__ == '__main__': | 2853 if __name__ == '__main__': |
2833 Main() | 2854 Main() |
OLD | NEW |