| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 5273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5284 Expects a private network to be active. | 5284 Expects a private network to be active. |
| 5285 | 5285 |
| 5286 Raises: | 5286 Raises: |
| 5287 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 5287 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 5288 """ | 5288 """ |
| 5289 cmd_dict = { | 5289 cmd_dict = { |
| 5290 'command': 'DisconnectFromPrivateNetwork', | 5290 'command': 'DisconnectFromPrivateNetwork', |
| 5291 } | 5291 } |
| 5292 return self._GetResultFromJSONRequest(cmd_dict, windex=None) | 5292 return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
| 5293 | 5293 |
| 5294 def IsEnterpriseDevice(self): | |
| 5295 """Check whether the device is managed by an enterprise. | |
| 5296 | |
| 5297 Returns: | |
| 5298 True if the device is managed by an enterprise, False otherwise. | |
| 5299 | |
| 5300 Raises: | |
| 5301 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
| 5302 """ | |
| 5303 cmd_dict = { | |
| 5304 'command': 'IsEnterpriseDevice', | |
| 5305 } | |
| 5306 result = self._GetResultFromJSONRequest(cmd_dict, windex=None) | |
| 5307 return result.get('enterprise') | |
| 5308 | |
| 5309 def GetEnterprisePolicyInfo(self): | |
| 5310 """Get details about enterprise policy on chromeos. | |
| 5311 | |
| 5312 Returns: | |
| 5313 A dictionary including information about the enterprise policy. | |
| 5314 Sample: | |
| 5315 {u'device_token_cache_loaded': True, | |
| 5316 u'device_cloud_policy_state': u'success', | |
| 5317 u'device_id': u'11111-222222222-33333333-4444444', | |
| 5318 u'device_mandatory_policies': {}, | |
| 5319 u'device_recommended_policies': {}, | |
| 5320 u'device_token': u'ABjmT7nqGWTHRLO', | |
| 5321 u'enterprise_domain': u'example.com', | |
| 5322 u'gaia_token': u'', | |
| 5323 u'machine_id': u'123456789', | |
| 5324 u'machine_model': u'COMPUTER', | |
| 5325 u'user_cache_loaded': True, | |
| 5326 u'user_cloud_policy_state': u'success', | |
| 5327 u'user_mandatory_policies': {u'AuthSchemes': u'', | |
| 5328 u'AutoFillEnabled': True, | |
| 5329 u'ChromeOsLockOnIdleSuspend': True} | |
| 5330 u'user_recommended_policies': {}, | |
| 5331 u'user_name': u'user@example.com'} | |
| 5332 """ | |
| 5333 cmd_dict = { 'command': 'GetEnterprisePolicyInfo' } | |
| 5334 return self._GetResultFromJSONRequest(cmd_dict, windex=None) | |
| 5335 | |
| 5336 def EnableSpokenFeedback(self, enabled): | 5294 def EnableSpokenFeedback(self, enabled): |
| 5337 """Enables or disables spoken feedback accessibility mode. | 5295 """Enables or disables spoken feedback accessibility mode. |
| 5338 | 5296 |
| 5339 Args: | 5297 Args: |
| 5340 enabled: Boolean value indicating the desired state of spoken feedback. | 5298 enabled: Boolean value indicating the desired state of spoken feedback. |
| 5341 | 5299 |
| 5342 Raises: | 5300 Raises: |
| 5343 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 5301 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 5344 """ | 5302 """ |
| 5345 cmd_dict = { | 5303 cmd_dict = { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5396 | 5354 |
| 5397 Raises: | 5355 Raises: |
| 5398 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 5356 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 5399 """ | 5357 """ |
| 5400 cmd_dict = { | 5358 cmd_dict = { |
| 5401 'command': 'SetTimezone', | 5359 'command': 'SetTimezone', |
| 5402 'timezone': timezone, | 5360 'timezone': timezone, |
| 5403 } | 5361 } |
| 5404 self._GetResultFromJSONRequest(cmd_dict, windex=None) | 5362 self._GetResultFromJSONRequest(cmd_dict, windex=None) |
| 5405 | 5363 |
| 5406 def EnrollEnterpriseDevice(self, user, password): | |
| 5407 """Enrolls an unenrolled device as an enterprise device. | |
| 5408 | |
| 5409 Expects the device to be unenrolled with the TPM unlocked. This is | |
| 5410 equivalent to pressing Ctrl-Alt-e to enroll the device from the login | |
| 5411 screen. | |
| 5412 | |
| 5413 Returns: | |
| 5414 An error string if the enrollment fails. | |
| 5415 None otherwise. | |
| 5416 | |
| 5417 Raises: | |
| 5418 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
| 5419 """ | |
| 5420 cmd_dict = { | |
| 5421 'command': 'EnrollEnterpriseDevice', | |
| 5422 'user': user, | |
| 5423 'password': password, | |
| 5424 } | |
| 5425 time.sleep(5) # TODO(craigdh): Block until Install Attributes is ready. | |
| 5426 result = self._GetResultFromJSONRequest(cmd_dict, windex=None) | |
| 5427 return result.get('error_string') | |
| 5428 | |
| 5429 def GetUpdateInfo(self): | 5364 def GetUpdateInfo(self): |
| 5430 """Gets the status of the ChromeOS updater. | 5365 """Gets the status of the ChromeOS updater. |
| 5431 | 5366 |
| 5432 Returns: | 5367 Returns: |
| 5433 a dictionary. | 5368 a dictionary. |
| 5434 Samples: | 5369 Samples: |
| 5435 { u'status': u'idle', | 5370 { u'status': u'idle', |
| 5436 u'release_track': u'beta-channel'} | 5371 u'release_track': u'beta-channel'} |
| 5437 | 5372 |
| 5438 { u'status': u'downloading', | 5373 { u'status': u'downloading', |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6318 successful = result.wasSuccessful() | 6253 successful = result.wasSuccessful() |
| 6319 if not successful: | 6254 if not successful: |
| 6320 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 6255 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 6321 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 6256 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
| 6322 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 6257 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
| 6323 sys.exit(not successful) | 6258 sys.exit(not successful) |
| 6324 | 6259 |
| 6325 | 6260 |
| 6326 if __name__ == '__main__': | 6261 if __name__ == '__main__': |
| 6327 Main() | 6262 Main() |
| OLD | NEW |