Ignore:
Timestamp:
Mar 9, 2020 4:49:58 PM (3 years ago)
Author:
toby
Message:

expand proxy GUI for more lines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4346 r4352  
    21242124        '''
    21252125        h,p,e = host,port,etc = GSASIIpath.getsvnProxy()
    2126         if e:
    2127             proxyinfo = os.path.join(GSASIIpath.path2GSAS2,"proxyinfo.txt")
    2128             G2G.G2MessageBox(self,'File {} has manually-'.format(proxyinfo)+
    2129                 'entered information. Please edit this by hand',
    2130                                  'Unable to edit')
    2131             return
     2126        labels = ['Proxy address','proxy port']
     2127        values = [host,port]
     2128        i = 1
     2129        for item in etc:
     2130            i += 1
     2131            labels.append('extra svn arg #'+str(i))
     2132            values.append(item)
     2133        msg = '''This dialog allows customization of the subversion (svn)
     2134        command. If a proxy server is needed, the address/host and port
     2135        can be added supplied here. This will generate command-line options
     2136
     2137        --config-option servers:global:http-proxy-host=*host*
     2138        --config-option servers:global:http-proxy-port=*port*
     2139
     2140        Additional subversion command line options can be supplied here
     2141        by pressing the '+' button. As examples of options that might be of
     2142        value, use two extra lines to add:
     2143
     2144        --config-dir
     2145        DIR
     2146
     2147        to specify an alternate configuration location.
     2148
     2149        Or, use four extra lines to add
     2150
     2151        --config-option
     2152        servers:global:http-proxy-username=*account*
     2153        --config-option
     2154        servers:global:http-proxy-password=*password*
     2155
     2156        to specify a proxy user name and password.
     2157
     2158        Note that strings marked *value* are items that will be configured
     2159        by the user. See http://svnbook.red-bean.com for more information on
     2160        subversion.
     2161        '''
    21322162        dlg = G2G.MultiStringDialog(self,'Enter proxy values',
    2133                                         ['Proxy address','proxy port'],
    2134                                         [host,port],size=300)
     2163                            labels,values,size=300,addRows=True,hlp=msg)
    21352164        if dlg.Show():
    2136             h,p = dlg.GetValues()
     2165            values = dlg.GetValues()
     2166            h,p = values[:2]
     2167            e = values[2:]
    21372168        dlg.Destroy()
    2138         if h != host or p != port:
    2139             proxyinfo = os.path.join(GSASIIpath.path2GSAS2,"proxyinfo.txt")
    2140             GSASIIpath.setsvnProxy(h,p)
    2141             if not h.strip():
    2142                 os.remove(proxyinfo)
     2169        if h != host or p != port or etc != e:
     2170            localproxy = proxyinfo = os.path.join(
     2171                os.path.expanduser('~/.G2local/'),
     2172                "proxyinfo.txt")
     2173            if not os.path.exists(proxyinfo):
     2174                proxyinfo = os.path.join(GSASIIpath.path2GSAS2,"proxyinfo.txt")
     2175            GSASIIpath.setsvnProxy(h,p,e)
     2176            if not h.strip() and not e:
     2177                if os.path.exists(localproxy): os.remove(localproxy)
     2178                if os.path.exists(proxyinfo): os.remove(proxyinfo)
    21432179                return
    21442180            try:
    21452181                fp = open(proxyinfo,'w')
     2182            except:
     2183                fp = open(localproxy,'w')
     2184                proxyinfo = localproxy
     2185            try:
    21462186                fp.write(h.strip()+'\n')
    21472187                fp.write(p.strip()+'\n')
     2188                for i in e:
     2189                    if i.strip():
     2190                        fp.write(i.strip()+'\n')
    21482191                fp.close()
    21492192            except Exception as err:
    21502193                print('Error writing file {}:\n{}'.format(proxyinfo,err))
     2194            print('File {} written'.format(proxyinfo))
     2195               
    21512196    def _Add_ImportMenu_smallangle(self,parent):
    21522197        '''configure the Small Angle Data menus accord to the readers found in _init_Imports
Note: See TracChangeset for help on using the changeset viewer.