Changeset 5251ec6 in sasview for src/sas/sasgui/guiframe/proxy.py


Ignore:
Timestamp:
Oct 11, 2018 12:20:56 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
Children:
98b9f32
Parents:
67ed543
Message:

improved support for py37 in sasgui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/proxy.py

    r20fa5fe r5251ec6  
    33from __future__ import print_function 
    44 
    5 import urllib2 
    65import sys 
    76import json 
     
    98import re 
    109 
     10try: 
     11    # CRUFT: python 3 uses urllib.request instead of urllib2 
     12    import urllib2 
     13except ImportError: 
     14    from urllib import request as urllib2 
    1115 
    1216logger = logging.getLogger(__name__) 
     
    5054                this_name, this_val, this_type = winreg.EnumValue(net, i) 
    5155                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: 
    5357                pac_files.append(subkeys['AutoConfigURL']) 
    5458        elif sys.platform == 'darwin': 
     
    6165                # the first part is a long identifier 
    6266                net_key, network = network 
    63                 if 'ProxyAutoConfigURLString' in network['Proxies'].keys(): 
     67                if 'ProxyAutoConfigURLString' in network['Proxies']: 
    6468                    pac_files.append( 
    6569                        network['Proxies']['ProxyAutoConfigURLString']) 
     
    127131            logger.debug("Trying Direct connection to %s..."%self.url) 
    128132            response = urllib2.urlopen(req, timeout=self.timeout) 
    129         except Exception, e: 
     133        except Exception as exc: 
    130134            logger.debug("Failed!") 
    131             logger.debug(e) 
     135            logger.debug(exc) 
    132136            try: 
    133137                logger.debug("Trying to use system proxy if it exists...") 
    134138                self._set_proxy() 
    135139                response = urllib2.urlopen(req, timeout=self.timeout) 
    136             except Exception, e: 
     140            except Exception as exc: 
    137141                logger.debug("Failed!") 
    138                 logger.debug(e) 
     142                logger.debug(exc) 
    139143                pac_urls = self._get_addresses_of_proxy_pac() 
    140144                proxy_urls = self._parse_proxy_pac(pac_urls) 
     
    144148                        self._set_proxy(proxy) 
    145149                        response = urllib2.urlopen(req, timeout=self.timeout) 
    146                     except Exception, e: 
     150                    except Exception as exc: 
    147151                        logger.debug("Failed!") 
    148                         logger.debug(e) 
     152                        logger.debug(exc) 
    149153        if response is not None: 
    150154            logger.debug("The connection to %s was successful."%self.url) 
Note: See TracChangeset for help on using the changeset viewer.