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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 for item in os.listdir(chronos_dir): | 435 for item in os.listdir(chronos_dir): |
436 if item != 'user' and not item.startswith('.'): | 436 if item != 'user' and not item.startswith('.'): |
437 pyauto_utils.RemovePath(os.path.join(chronos_dir, item)) | 437 pyauto_utils.RemovePath(os.path.join(chronos_dir, item)) |
438 | 438 |
439 @staticmethod | 439 @staticmethod |
440 def CleanupFlimflamDirsOnChromeOS(): | 440 def CleanupFlimflamDirsOnChromeOS(): |
441 """Clean the contents of flimflam profiles and restart flimflam.""" | 441 """Clean the contents of flimflam profiles and restart flimflam.""" |
442 PyUITest.RunSuperuserActionOnChromeOS('CleanFlimflamDirs') | 442 PyUITest.RunSuperuserActionOnChromeOS('CleanFlimflamDirs') |
443 | 443 |
444 @staticmethod | 444 @staticmethod |
| 445 def RemoveAllCryptohomeVaultsOnChromeOS(): |
| 446 """Remove any existing cryptohome vaults.""" |
| 447 PyUITest.RunSuperuserActionOnChromeOS('RemoveAllCryptohomeVaults') |
| 448 |
| 449 @staticmethod |
445 def _IsInodeNew(path, old_inode): | 450 def _IsInodeNew(path, old_inode): |
446 """Determine whether an inode has changed. POSIX only. | 451 """Determine whether an inode has changed. POSIX only. |
447 | 452 |
448 Args: | 453 Args: |
449 path: The file path to check for changes. | 454 path: The file path to check for changes. |
450 old_inode: The old inode number. | 455 old_inode: The old inode number. |
451 | 456 |
452 Returns: | 457 Returns: |
453 True if the path exists and its inode number is different from old_inode. | 458 True if the path exists and its inode number is different from old_inode. |
454 False otherwise. | 459 False otherwise. |
(...skipping 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3667 Profiles will be listed in the same order as visible in preferences. | 3672 Profiles will be listed in the same order as visible in preferences. |
3668 | 3673 |
3669 Raises: | 3674 Raises: |
3670 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3675 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
3671 """ | 3676 """ |
3672 cmd_dict = { # Prepare command for the json interface | 3677 cmd_dict = { # Prepare command for the json interface |
3673 'command': 'GetMultiProfileInfo' | 3678 'command': 'GetMultiProfileInfo' |
3674 } | 3679 } |
3675 return self._GetResultFromJSONRequest(cmd_dict, windex=None) | 3680 return self._GetResultFromJSONRequest(cmd_dict, windex=None) |
3676 | 3681 |
3677 def SetPolicies(self, managed_platform=None, recommended_platform=None, | |
3678 managed_cloud=None, recommended_cloud=None): | |
3679 """Sets the policies on the browser. Always fails on official builds. | |
3680 | |
3681 Args: | |
3682 managed_platform: a dictionary with the policy values for the managed | |
3683 platform provider. | |
3684 recommended_platform: a dictionary with the policy values for the | |
3685 recommended platform provider. | |
3686 managed_cloud: a dictionary with the policy values for the managed | |
3687 cloud provider. | |
3688 recommended_cloud: a dictionary with the policy values for the recommended | |
3689 cloud provider. | |
3690 | |
3691 Leaving an argument to None will restore the default behavior for that | |
3692 provider. | |
3693 """ | |
3694 assert not self.GetBrowserInfo()['properties']['is_official'] | |
3695 cmd_dict = { | |
3696 'command': 'SetPolicies', | |
3697 'managed_cloud': managed_cloud, | |
3698 'managed_platform': managed_platform, | |
3699 'recommended_cloud': recommended_cloud, | |
3700 'recommended_platform': recommended_platform | |
3701 } | |
3702 return self._GetResultFromJSONRequest(cmd_dict) | |
3703 | |
3704 def GetPolicyDefinitionList(self): | 3682 def GetPolicyDefinitionList(self): |
3705 """Gets a dictionary of existing policies mapped to their definitions. | 3683 """Gets a dictionary of existing policies mapped to their definitions. |
3706 | 3684 |
3707 SAMPLE OUTPUT: | 3685 SAMPLE OUTPUT: |
3708 { | 3686 { |
3709 'ShowHomeButton': ['bool', false], | 3687 'ShowHomeButton': ['bool', false], |
3710 'DefaultSearchProviderSearchURL': ['str', false], | 3688 'DefaultSearchProviderSearchURL': ['str', false], |
3711 ... | 3689 ... |
3712 } | 3690 } |
3713 | 3691 |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5253 successful = result.wasSuccessful() | 5231 successful = result.wasSuccessful() |
5254 if not successful: | 5232 if not successful: |
5255 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 5233 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
5256 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 5234 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
5257 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 5235 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
5258 sys.exit(not successful) | 5236 sys.exit(not successful) |
5259 | 5237 |
5260 | 5238 |
5261 if __name__ == '__main__': | 5239 if __name__ == '__main__': |
5262 Main() | 5240 Main() |
OLD | NEW |