Changeset 4987 for trunk/GSASIIpath.py


Ignore:
Timestamp:
Jul 2, 2021 2:20:10 PM (7 months ago)
Author:
toby
Message:

duplicate Seq->csv export; set svn proxy from environment variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpath.py

    r4976 r4987  
    178178               
    179179def getsvnProxy():
    180     '''Loads a proxy for subversion from the file created by bootstrap.py
     180    '''Loads a proxy for subversion from the proxyinfo.txt file created
     181    by bootstrap.py or File => Edit Proxy...; If not found, then the
     182    standard http_proxy and https_proxy environment variables are scanned
     183    (see https://docs.python.org/3/library/urllib.request.html#urllib.request.getproxies)
     184    with case ignored and that is used.
    181185    '''
    182186    global proxycmds
     
    185189    if not os.path.exists(proxyinfo):
    186190        proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt")
    187     if not os.path.exists(proxyinfo):
    188         return '','',''
    189     fp = open(proxyinfo,'r')
    190     host = fp.readline().strip()
    191     # allow file to begin with comments
    192     while host.startswith('#'):
     191    if os.path.exists(proxyinfo):
     192        fp = open(proxyinfo,'r')
    193193        host = fp.readline().strip()
    194     port = fp.readline().strip()
    195     etc = []
    196     line = fp.readline()
    197     while line:
    198         etc.append(line.strip())
     194        # allow file to begin with comments
     195        while host.startswith('#'):
     196            host = fp.readline().strip()
     197        port = fp.readline().strip()
     198        etc = []
    199199        line = fp.readline()
    200     fp.close()
    201     setsvnProxy(host,port,etc)
    202     return host,port,etc
     200        while line:
     201            etc.append(line.strip())
     202            line = fp.readline()
     203        fp.close()
     204        setsvnProxy(host,port,etc)
     205        return host,port,etc
     206    import urllib.request
     207    proxdict = urllib.request.getproxies()
     208    varlist = ("https","http")
     209    for var in proxdict:
     210        if var.lower() in varlist:
     211            proxy = proxdict[var]
     212            pl = proxy.split(':')
     213            if len(pl) < 2: continue
     214            host = ':'.join(pl[0:2])
     215            port = ''
     216            if len(pl) == 3:
     217                port = pl[2].strip('/').strip()
     218            return host,port,''
     219    return '','',''
    203220
    204221def setsvnProxy(host,port,etc=[]):
Note: See TracChangeset for help on using the changeset viewer.