Changeset 5251ec6 in sasview for src/sas/sasgui/guiframe/proxy.py
- Timestamp:
- Oct 11, 2018 12:20:56 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- 98b9f32
- Parents:
- 67ed543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/proxy.py
r20fa5fe r5251ec6 3 3 from __future__ import print_function 4 4 5 import urllib26 5 import sys 7 6 import json … … 9 8 import re 10 9 10 try: 11 # CRUFT: python 3 uses urllib.request instead of urllib2 12 import urllib2 13 except ImportError: 14 from urllib import request as urllib2 11 15 12 16 logger = logging.getLogger(__name__) … … 50 54 this_name, this_val, this_type = winreg.EnumValue(net, i) 51 55 subkeys[this_name] = this_val 52 if 'AutoConfigURL' in subkeys .keys()and len(subkeys['AutoConfigURL']) > 0:56 if 'AutoConfigURL' in subkeys and len(subkeys['AutoConfigURL']) > 0: 53 57 pac_files.append(subkeys['AutoConfigURL']) 54 58 elif sys.platform == 'darwin': … … 61 65 # the first part is a long identifier 62 66 net_key, network = network 63 if 'ProxyAutoConfigURLString' in network['Proxies'] .keys():67 if 'ProxyAutoConfigURLString' in network['Proxies']: 64 68 pac_files.append( 65 69 network['Proxies']['ProxyAutoConfigURLString']) … … 127 131 logger.debug("Trying Direct connection to %s..."%self.url) 128 132 response = urllib2.urlopen(req, timeout=self.timeout) 129 except Exception , e:133 except Exception as exc: 130 134 logger.debug("Failed!") 131 logger.debug(e )135 logger.debug(exc) 132 136 try: 133 137 logger.debug("Trying to use system proxy if it exists...") 134 138 self._set_proxy() 135 139 response = urllib2.urlopen(req, timeout=self.timeout) 136 except Exception , e:140 except Exception as exc: 137 141 logger.debug("Failed!") 138 logger.debug(e )142 logger.debug(exc) 139 143 pac_urls = self._get_addresses_of_proxy_pac() 140 144 proxy_urls = self._parse_proxy_pac(pac_urls) … … 144 148 self._set_proxy(proxy) 145 149 response = urllib2.urlopen(req, timeout=self.timeout) 146 except Exception , e:150 except Exception as exc: 147 151 logger.debug("Failed!") 148 logger.debug(e )152 logger.debug(exc) 149 153 if response is not None: 150 154 logger.debug("The connection to %s was successful."%self.url)
Note: See TracChangeset
for help on using the changeset viewer.