Changeset 3075


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

Allow editing of proxy info

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r3056 r3075  
    22082208    :param str prompts: strings to tell use what they are inputting
    22092209    :param str values: default input values, if any
     2210    :param int size: length of the input box in pixels
    22102211    '''
    2211     def __init__(self,parent,title,prompts,values=[]):      #,size=(200,-1)?
     2212    def __init__(self,parent,title,prompts,values=[],size=-1):
    22122213       
    22132214        wx.Dialog.__init__(self,parent,wx.ID_ANY,title,
     
    22172218        self.prompts = prompts
    22182219        self.CenterOnParent()
    2219         self.panel = wx.Panel(self)
    22202220        mainSizer = wx.BoxSizer(wx.VERTICAL)
    22212221        promptSizer = wx.FlexGridSizer(0,2,5,5)
    22222222        self.Indx = {}
    22232223        for prompt,value in zip(prompts,values):
    2224             promptSizer.Add(wx.StaticText(self.panel,-1,prompt),0,WACV)
    2225             valItem = wx.TextCtrl(self.panel,-1,value=value,style=wx.TE_PROCESS_ENTER)
     2224            promptSizer.Add(wx.StaticText(self,-1,prompt),0,WACV)
     2225            valItem = wx.TextCtrl(self,-1,value=value,style=wx.TE_PROCESS_ENTER,size=(size,-1))
    22262226            self.Indx[valItem.GetId()] = prompt
    22272227            valItem.Bind(wx.EVT_TEXT,self.newValue)
    2228             promptSizer.Add(valItem,0,WACV)
    2229         mainSizer.Add(promptSizer,0)
     2228            promptSizer.Add(valItem,1,WACV|wx.EXPAND,1)
     2229        mainSizer.Add(promptSizer,1,wx.ALL|wx.EXPAND,1)
    22302230        btnsizer = wx.StdDialogButtonSizer()
    2231         OKbtn = wx.Button(self.panel, wx.ID_OK)
     2231        OKbtn = wx.Button(self, wx.ID_OK)
    22322232        OKbtn.SetDefault()
    22332233        btnsizer.AddButton(OKbtn)
    2234         btn = wx.Button(self.panel, wx.ID_CANCEL)
     2234        btn = wx.Button(self, wx.ID_CANCEL)
    22352235        btnsizer.AddButton(btn)
    22362236        btnsizer.Realize()
    22372237        mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER)
    2238         self.panel.SetSizer(mainSizer)
    2239         self.panel.Fit()
     2238        self.SetSizer(mainSizer)
    22402239        self.Fit()
    22412240       
     
    27582757        self.GBsizer.Layout()
    27592758        self.FitInside()
    2760 
     2759       
    27612760################################################################################
    27622761def GetImportFile(G2frame, message, defaultDir="", defaultFile="", style=wx.OPEN,
  • trunk/GSASIIdataGUI.py

    r3062 r3075  
    126126#### class definitions used for main GUI
    127127################################################################################
    128 
    129128               
    130129class MergeDialog(wx.Dialog):
     
    457456        item = parent.Append(wx.ID_PREFERENCES, text = "&Preferences")
    458457        self.Bind(wx.EVT_MENU, self.OnPreferences, item)
     458        if GSASIIpath.whichsvn():
     459            item = parent.Append(
     460                help='Edit proxy internet information (used for updates)', id=wx.ID_ANY,
     461                kind=wx.ITEM_NORMAL,text='Edit proxy...')
     462            self.Bind(wx.EVT_MENU, self.EditProxyInfo, id=item.GetId())
    459463        if GSASIIpath.GetConfigValue('debug'):
    460464            def OnIPython(event):
     
    462466            item = parent.Append(wx.ID_ANY, text = "IPython Console")
    463467            self.Bind(wx.EVT_MENU, OnIPython, item)
     468            def OnwxInspect(event):
     469                import wx.lib.inspection as wxeye
     470                wxeye.InspectionTool().Show()
     471            item = parent.Append(wx.ID_ANY, text = "wx inspection tool")
     472            self.Bind(wx.EVT_MENU, OnwxInspect, item)
     473           
    464474        item = parent.Append(
    465475            help='Exit from GSAS-II', id=wx.ID_ANY,
     
    19621972        dlg.Destroy()
    19631973
     1974    def EditProxyInfo(self,event):
     1975        '''Edit the proxy information used by subversion
     1976        '''
     1977        h,p = host,port = GSASIIpath.getsvnProxy()
     1978        dlg = G2G.MultiStringDialog(self,'Enter proxy values',
     1979                                        ['Proxy address','proxy port'],
     1980                                        [host,port],size=300)
     1981        #dlg.SetSize((300,-1))
     1982        if dlg.Show():
     1983            h,p = dlg.GetValues()
     1984        dlg.Destroy()
     1985        if h != host or p != port:
     1986            proxyinfo = os.path.join(GSASIIpath.path2GSAS2,"proxyinfo.txt")
     1987            GSASIIpath.setsvnProxy(h,p)
     1988            if not h.strip():
     1989                os.remove(proxyinfo)
     1990                return
     1991            try:
     1992                fp = open(proxyinfo,'w')
     1993                fp.write(h.strip()+'\n')
     1994                fp.write(p.strip()+'\n')
     1995                fp.close()
     1996            except Exception as err:
     1997                print('Error writing file {}:\n{}'.format(proxyinfo,err))
    19641998    def _Add_ImportMenu_smallangle(self,parent):
    19651999        '''configure the Small Angle Data menus accord to the readers found in _init_Imports
  • 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.