| 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 3666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3677 PROXY_TYPE_DIRECT = 1 | 3677 PROXY_TYPE_DIRECT = 1 |
| 3678 PROXY_TYPE_MANUAL = 2 | 3678 PROXY_TYPE_MANUAL = 2 |
| 3679 PROXY_TYPE_PAC = 3 | 3679 PROXY_TYPE_PAC = 3 |
| 3680 | 3680 |
| 3681 def GetProxyTypeName(self, proxy_type): | 3681 def GetProxyTypeName(self, proxy_type): |
| 3682 values = { self.PROXY_TYPE_DIRECT: 'Direct Internet connection', | 3682 values = { self.PROXY_TYPE_DIRECT: 'Direct Internet connection', |
| 3683 self.PROXY_TYPE_MANUAL: 'Manual proxy configuration', | 3683 self.PROXY_TYPE_MANUAL: 'Manual proxy configuration', |
| 3684 self.PROXY_TYPE_PAC: 'Automatic proxy configuration' } | 3684 self.PROXY_TYPE_PAC: 'Automatic proxy configuration' } |
| 3685 return values[proxy_type] | 3685 return values[proxy_type] |
| 3686 | 3686 |
| 3687 def GetProxySettingsOnChromeOS(self): | 3687 def GetProxySettingsOnChromeOS(self, windex=0): |
| 3688 """Get current proxy settings on Chrome OS. | 3688 """Get current proxy settings on Chrome OS. |
| 3689 | 3689 |
| 3690 Returns: | 3690 Returns: |
| 3691 A dictionary. See SetProxySettings() below | 3691 A dictionary. See SetProxySettings() below |
| 3692 for the full list of possible dictionary keys. | 3692 for the full list of possible dictionary keys. |
| 3693 | 3693 |
| 3694 Samples: | 3694 Samples: |
| 3695 { u'ignorelist': [], | 3695 { u'ignorelist': [], |
| 3696 u'single': False, | 3696 u'single': False, |
| 3697 u'type': 1} | 3697 u'type': 1} |
| 3698 | 3698 |
| 3699 { u'ignorelist': [u'www.example.com', u'www.example2.com'], | 3699 { u'ignorelist': [u'www.example.com', u'www.example2.com'], |
| 3700 u'single': True, | 3700 u'single': True, |
| 3701 u'singlehttp': u'24.27.78.152', | 3701 u'singlehttp': u'24.27.78.152', |
| 3702 u'singlehttpport': 1728, | 3702 u'singlehttpport': 1728, |
| 3703 u'type': 2} | 3703 u'type': 2} |
| 3704 | 3704 |
| 3705 { u'ignorelist': [], | 3705 { u'ignorelist': [], |
| 3706 u'pacurl': u'http://example.com/config.pac', | 3706 u'pacurl': u'http://example.com/config.pac', |
| 3707 u'single': False, | 3707 u'single': False, |
| 3708 u'type': 3} | 3708 u'type': 3} |
| 3709 | 3709 |
| 3710 Raises: | 3710 Raises: |
| 3711 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3711 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 3712 """ | 3712 """ |
| 3713 cmd_dict = { 'command': 'GetProxySettings' } | 3713 cmd_dict = { 'command': 'GetProxySettings' } |
| 3714 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 3714 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
| 3715 | 3715 |
| 3716 def SetProxySettingsOnChromeOS(self, key, value): | 3716 def SetProxySettingsOnChromeOS(self, key, value, windex=0): |
| 3717 """Set a proxy setting on Chrome OS. | 3717 """Set a proxy setting on Chrome OS. |
| 3718 | 3718 |
| 3719 Owner must be logged in for these to persist. | 3719 Owner must be logged in for these to persist. |
| 3720 If user is not logged in or is logged in as non-owner or guest, | 3720 If user is not logged in or is logged in as non-owner or guest, |
| 3721 proxy settings do not persist across browser restarts or login/logout. | 3721 proxy settings do not persist across browser restarts or login/logout. |
| 3722 | 3722 |
| 3723 Valid settings are: | 3723 Valid settings are: |
| 3724 'type': int - Type of proxy. Should be one of: | 3724 'type': int - Type of proxy. Should be one of: |
| 3725 PROXY_TYPE_DIRECT, PROXY_TYPE_MANUAL, PROXY_TYPE_PAC. | 3725 PROXY_TYPE_DIRECT, PROXY_TYPE_MANUAL, PROXY_TYPE_PAC. |
| 3726 'ignorelist': list - The list of hosts and domains to ignore. | 3726 'ignorelist': list - The list of hosts and domains to ignore. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3758 self.SetProxySettings('pacurl', 'http://example.com/config.pac') | 3758 self.SetProxySettings('pacurl', 'http://example.com/config.pac') |
| 3759 | 3759 |
| 3760 Raises: | 3760 Raises: |
| 3761 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3761 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 3762 """ | 3762 """ |
| 3763 cmd_dict = { | 3763 cmd_dict = { |
| 3764 'command': 'SetProxySettings', | 3764 'command': 'SetProxySettings', |
| 3765 'key': key, | 3765 'key': key, |
| 3766 'value': value, | 3766 'value': value, |
| 3767 } | 3767 } |
| 3768 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 3768 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
| 3769 | 3769 |
| 3770 def ForgetWifiNetwork(self, service_path): | 3770 def ForgetWifiNetwork(self, service_path): |
| 3771 """Forget a remembered network by its service path. | 3771 """Forget a remembered network by its service path. |
| 3772 | 3772 |
| 3773 This function is equivalent to clicking the 'Forget Network' button in the | 3773 This function is equivalent to clicking the 'Forget Network' button in the |
| 3774 chrome://settings/internet page. This function does not indicate whether | 3774 chrome://settings/internet page. This function does not indicate whether |
| 3775 or not forget succeeded or failed. It is up to the caller to call | 3775 or not forget succeeded or failed. It is up to the caller to call |
| 3776 GetNetworkInfo to check the updated remembered_wifi list to verify the | 3776 GetNetworkInfo to check the updated remembered_wifi list to verify the |
| 3777 service has been removed. | 3777 service has been removed. |
| 3778 | 3778 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4767 successful = result.wasSuccessful() | 4767 successful = result.wasSuccessful() |
| 4768 if not successful: | 4768 if not successful: |
| 4769 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 4769 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 4770 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 4770 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
| 4771 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 4771 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
| 4772 sys.exit(not successful) | 4772 sys.exit(not successful) |
| 4773 | 4773 |
| 4774 | 4774 |
| 4775 if __name__ == '__main__': | 4775 if __name__ == '__main__': |
| 4776 Main() | 4776 Main() |
| OLD | NEW |