| 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 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3625 PROXY_TYPE_DIRECT = 1 | 3625 PROXY_TYPE_DIRECT = 1 |
| 3626 PROXY_TYPE_MANUAL = 2 | 3626 PROXY_TYPE_MANUAL = 2 |
| 3627 PROXY_TYPE_PAC = 3 | 3627 PROXY_TYPE_PAC = 3 |
| 3628 | 3628 |
| 3629 def GetProxyTypeName(self, proxy_type): | 3629 def GetProxyTypeName(self, proxy_type): |
| 3630 values = { self.PROXY_TYPE_DIRECT: 'Direct Internet connection', | 3630 values = { self.PROXY_TYPE_DIRECT: 'Direct Internet connection', |
| 3631 self.PROXY_TYPE_MANUAL: 'Manual proxy configuration', | 3631 self.PROXY_TYPE_MANUAL: 'Manual proxy configuration', |
| 3632 self.PROXY_TYPE_PAC: 'Automatic proxy configuration' } | 3632 self.PROXY_TYPE_PAC: 'Automatic proxy configuration' } |
| 3633 return values[proxy_type] | 3633 return values[proxy_type] |
| 3634 | 3634 |
| 3635 def GetProxySettingsOnChromeOS(self): | 3635 def GetProxySettingsOnChromeOS(self, windex=0): |
| 3636 """Get current proxy settings on Chrome OS. | 3636 """Get current proxy settings on Chrome OS. |
| 3637 | 3637 |
| 3638 Returns: | 3638 Returns: |
| 3639 A dictionary. See SetProxySettings() below | 3639 A dictionary. See SetProxySettings() below |
| 3640 for the full list of possible dictionary keys. | 3640 for the full list of possible dictionary keys. |
| 3641 | 3641 |
| 3642 Samples: | 3642 Samples: |
| 3643 { u'ignorelist': [], | 3643 { u'ignorelist': [], |
| 3644 u'single': False, | 3644 u'single': False, |
| 3645 u'type': 1} | 3645 u'type': 1} |
| 3646 | 3646 |
| 3647 { u'ignorelist': [u'www.example.com', u'www.example2.com'], | 3647 { u'ignorelist': [u'www.example.com', u'www.example2.com'], |
| 3648 u'single': True, | 3648 u'single': True, |
| 3649 u'singlehttp': u'24.27.78.152', | 3649 u'singlehttp': u'24.27.78.152', |
| 3650 u'singlehttpport': 1728, | 3650 u'singlehttpport': 1728, |
| 3651 u'type': 2} | 3651 u'type': 2} |
| 3652 | 3652 |
| 3653 { u'ignorelist': [], | 3653 { u'ignorelist': [], |
| 3654 u'pacurl': u'http://example.com/config.pac', | 3654 u'pacurl': u'http://example.com/config.pac', |
| 3655 u'single': False, | 3655 u'single': False, |
| 3656 u'type': 3} | 3656 u'type': 3} |
| 3657 | 3657 |
| 3658 Raises: | 3658 Raises: |
| 3659 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3659 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 3660 """ | 3660 """ |
| 3661 cmd_dict = { 'command': 'GetProxySettings' } | 3661 cmd_dict = { 'command': 'GetProxySettings' } |
| 3662 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 3662 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
| 3663 | 3663 |
| 3664 def SetProxySettingsOnChromeOS(self, key, value): | 3664 def SetProxySettingsOnChromeOS(self, key, value, windex=0): |
| 3665 """Set a proxy setting on Chrome OS. | 3665 """Set a proxy setting on Chrome OS. |
| 3666 | 3666 |
| 3667 Owner must be logged in for these to persist. | 3667 Owner must be logged in for these to persist. |
| 3668 If user is not logged in or is logged in as non-owner or guest, | 3668 If user is not logged in or is logged in as non-owner or guest, |
| 3669 proxy settings do not persist across browser restarts or login/logout. | 3669 proxy settings do not persist across browser restarts or login/logout. |
| 3670 | 3670 |
| 3671 Valid settings are: | 3671 Valid settings are: |
| 3672 'type': int - Type of proxy. Should be one of: | 3672 'type': int - Type of proxy. Should be one of: |
| 3673 PROXY_TYPE_DIRECT, PROXY_TYPE_MANUAL, PROXY_TYPE_PAC. | 3673 PROXY_TYPE_DIRECT, PROXY_TYPE_MANUAL, PROXY_TYPE_PAC. |
| 3674 'ignorelist': list - The list of hosts and domains to ignore. | 3674 'ignorelist': list - The list of hosts and domains to ignore. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3706 self.SetProxySettings('pacurl', 'http://example.com/config.pac') | 3706 self.SetProxySettings('pacurl', 'http://example.com/config.pac') |
| 3707 | 3707 |
| 3708 Raises: | 3708 Raises: |
| 3709 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3709 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 3710 """ | 3710 """ |
| 3711 cmd_dict = { | 3711 cmd_dict = { |
| 3712 'command': 'SetProxySettings', | 3712 'command': 'SetProxySettings', |
| 3713 'key': key, | 3713 'key': key, |
| 3714 'value': value, | 3714 'value': value, |
| 3715 } | 3715 } |
| 3716 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 3716 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
| 3717 | 3717 |
| 3718 def ForgetWifiNetwork(self, service_path): | 3718 def ForgetWifiNetwork(self, service_path): |
| 3719 """Forget a remembered network by its service path. | 3719 """Forget a remembered network by its service path. |
| 3720 | 3720 |
| 3721 This function is equivalent to clicking the 'Forget Network' button in the | 3721 This function is equivalent to clicking the 'Forget Network' button in the |
| 3722 chrome://settings/internet page. This function does not indicate whether | 3722 chrome://settings/internet page. This function does not indicate whether |
| 3723 or not forget succeeded or failed. It is up to the caller to call | 3723 or not forget succeeded or failed. It is up to the caller to call |
| 3724 GetNetworkInfo to check the updated remembered_wifi list to verify the | 3724 GetNetworkInfo to check the updated remembered_wifi list to verify the |
| 3725 service has been removed. | 3725 service has been removed. |
| 3726 | 3726 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4715 successful = result.wasSuccessful() | 4715 successful = result.wasSuccessful() |
| 4716 if not successful: | 4716 if not successful: |
| 4717 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 4717 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 4718 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 4718 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
| 4719 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 4719 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
| 4720 sys.exit(not successful) | 4720 sys.exit(not successful) |
| 4721 | 4721 |
| 4722 | 4722 |
| 4723 if __name__ == '__main__': | 4723 if __name__ == '__main__': |
| 4724 Main() | 4724 Main() |
| OLD | NEW |