Changeset 3075 for trunk/GSASIIpath.py


Ignore:
Timestamp:
Sep 13, 2017 4:13:06 PM (4 years ago)
Author:
toby
Message:

Allow editing of proxy info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpath.py

    r3025 r3075  
    120120svnLocCache = None
    121121'Cached location of svn to avoid multiple searches for it'
    122 
     122def getsvnProxy():
     123    '''Loads a proxy for subversion from the file created by bootstrap.py
     124    '''
     125    proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt")
     126    if os.path.exists(proxyinfo):
     127        global proxycmds
     128        proxycmds = []
     129        fp = open(proxyinfo,'r')
     130        host = fp.readline().strip()
     131        port = fp.readline().strip()
     132        fp.close()
     133        setsvnProxy(host,port)
     134        if not host.strip(): return '',''
     135        return host,port
     136
     137def setsvnProxy(host,port):
     138    '''Sets the svn commands needed to use a proxy
     139    '''
     140    global proxycmds
     141    proxycmds = []
     142    host = host.strip()
     143    port = port.strip()
     144    if not host.strip(): return
     145    proxycmds.append('--config-option')
     146    proxycmds.append('servers:global:http-proxy-host='+host)
     147    proxycmds.append('--config-option')
     148    proxycmds.append('servers:global:http-proxy-port='+port)
     149       
    123150def whichsvn():
    124151    '''Returns a path to the subversion exe file, if any is found.
     
    136163    svnprog = 'svn'
    137164    if sys.platform.startswith('win'): svnprog += '.exe'
    138     gsaspath = os.path.split(__file__)[0]
    139     # check for a proxy
    140     proxyinfo = os.path.join(gsaspath,"proxyinfo.txt")
    141     if os.path.exists(proxyinfo):
    142         global proxycmds
    143         proxycmds = []
    144         fp = open(proxyinfo,'r')
    145         host = fp.readline().strip()
    146         port = fp.readline().strip()
    147         fp.close()
    148         proxycmds.append('--config-option')
    149         proxycmds.append('servers:global:http-proxy-host='+host)
    150         proxycmds.append('--config-option')
    151         proxycmds.append('servers:global:http-proxy-port='+port)
     165    host,port = getsvnProxy()
     166    if GetConfigValue('debug'):
     167        print('Using proxy host {} port {}'.format(host,port))
    152168    # add likely places to find subversion when installed with GSAS-II
    153169    pathlist = os.environ["PATH"].split(os.pathsep)
    154170    pathlist.append(os.path.split(sys.executable)[0])
    155     pathlist.append(gsaspath)
     171    pathlist.append(path2GSAS2)
    156172    for rpt in ('..','bin'),('..','Library','bin'),('svn','bin'),('svn',),('.'):
    157         pt = os.path.normpath(os.path.join(gsaspath,*rpt))
     173        pt = os.path.normpath(os.path.join(path2GSAS2,*rpt))
    158174        if os.path.exists(pt):
    159175            pathlist.insert(0,pt)   
Note: See TracChangeset for help on using the changeset viewer.