Changeset 1696
- Timestamp:
- Mar 11, 2015 11:30:57 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1694 r1696 2012 2012 self._init_Macro() 2013 2013 HelpMenu=G2G.MyHelp(self,helpType='Data tree', 2014 morehelpitems=[('&Tutorials','Tutorials')]) 2015 menubar.Append(menu=HelpMenu,title='&Help') 2016 # this will eventually go away 2017 HelpMenu=G2G.MyHelp(self,helpType='Data tree', 2018 morehelpitems=[('&New Tutorials','NewTutorials')]) 2014 morehelpitems=[('&Tutorials','Tutorials'), 2015 ('&New Tutorials','NewTutorials'), # this will eventually go away 2016 ]) 2019 2017 menubar.Append(menu=HelpMenu,title='&Help') 2020 2018 -
trunk/GSASIIctrls.py
r1692 r1696 1962 1962 ['TOF Charge Flipping', 'TOF Charge Flipping', 'Charge Flipping with TOF single crystal data in GSASII.htm', 1963 1963 'Charge flipping with neutron TOF single crystal data'], 1964 ['TOF-CW Joint Refinement', 'TOF-CW Joint Refinement', 'TOF combined XN Rietveld refinement in GSAS.htm', 'Combined XN Rietveld refinement with TOF data'], 1964 1965 ['TOF Sequential Single Peak Fit', 'TOF Sequential Single Peak Fit', '', ''], 1965 1966 ['TOF Single Crystal Refinement', 'TOF Single Crystal Refinement', '', ''], 1966 ['TOF-CW Joint Refinement', 'TOF-CW Joint Refinement', '', ''],1967 1967 ) 1968 1968 if GSASIIpath.GetConfigValue('Tutorial_location'): … … 1970 1970 else: 1971 1971 tutorialPath = GSASIIpath.path2GSAS2 1972 1972 1973 1973 class OpenTutorial(wx.Dialog): 1974 1974 '''Open a tutorial, optionally copying it to the local disk. Always copy … … 2062 2062 ''' 2063 2063 self.BrowseMode = self.mode.GetSelection() 2064 #self.FillListBox()2065 #def FillListBox(self):2066 2064 if self.BrowseMode == 3: 2067 2065 import glob 2068 filelist = glob.glob( tutorialPath+'/help/*/*.htm')2066 filelist = glob.glob(os.path.join(tutorialPath,'help','*','*.htm')) 2069 2067 taillist = [os.path.split(f)[1] for f in filelist] 2070 2068 itemlist = [tut[-1] for tut in tutorialCatalog if tut[2] in taillist] … … 2095 2093 return 2096 2094 self.dataLoc.SetLabel(tutorialPath) 2095 self.EndModal(wx.ID_OK) 2097 2096 if self.BrowseMode == 0: 2098 2097 # xfer data & web page locally, then open web page … … 2116 2115 else: 2117 2116 raise Exception("How did this happen!") 2118 self.EndModal(wx.ID_OK)2119 2117 def ValidateTutorialDir(self,fullpath=tutorialPath,baseURL=G2BaseURL): 2120 2118 '''Load help to new directory or make sure existing directory looks correctly set up … … 2139 2137 def LoadTutorial(self,tutorialname,fullpath=tutorialPath,baseURL=G2BaseURL): 2140 2138 'Load a Tutorial to the selected location' 2141 if GSASIIpath.svnSwitchDir("help /"+tutorialname,baseURL+"/Tutorials/"+tutorialname,fullpath):2139 if GSASIIpath.svnSwitchDir("help",tutorialname,baseURL+"/Tutorials",fullpath): 2142 2140 return True 2143 2141 raise Exception("Problem transferring Tutorial from web") … … 2145 2143 def LoadExercise(self,tutorialname,fullpath=tutorialPath,baseURL=G2BaseURL): 2146 2144 'Load Exercise file(s) for a Tutorial to the selected location' 2147 if GSASIIpath.svnSwitchDir("Exercises /"+tutorialname,baseURL+"/Exercises/"+tutorialname,fullpath):2145 if GSASIIpath.svnSwitchDir("Exercises",tutorialname,baseURL+"/Exercises",fullpath): 2148 2146 return True 2149 2147 raise Exception("Problem transferring Exercise from web") -
trunk/GSASIIgrid.py
r1688 r1696 3511 3511 VaryListChanges = [] # histograms where there is a change 3512 3512 combinedVaryList = [] 3513 firstValue List = []3513 firstValueDict = {} 3514 3514 vallookup = {} 3515 3515 posdict = {} 3516 prevVaryList = [] 3516 3517 for i,name in enumerate(histNames): 3517 newval = False 3518 for var,val in zip(data[name]['varyList'],data[name]['variables']): 3519 svar = striphist(var,'*') 3520 if svar in combinedVaryList: continue 3521 # add variables to list as they appear 3522 combinedVaryList.append(svar) 3523 firstValueList.append(val) 3524 newval = True 3525 if newval: 3518 for var,val,sig in zip(data[name]['varyList'],data[name]['variables'],data[name]['sig']): 3519 svar = striphist(var,'*') # wild-carded 3520 if svar not in combinedVaryList: 3521 # add variables to list as they appear 3522 combinedVaryList.append(svar) 3523 firstValueDict[svar] = (val,sig) 3524 if prevVaryList != data[name]['varyList']: # this refinement has a different refinement list from previous 3525 prevVaryList = data[name]['varyList'] 3526 3526 vallookup[name] = dict(zip(data[name]['varyList'],data[name]['variables'])) 3527 3527 posdict[name] = {} … … 3617 3617 if name in posdict: 3618 3618 varsellist = [posdict[name].get(i) for i in range(varcols)] 3619 #sellist = [data[name]['varyList'].index(v) if v is not None else None for v in varsellist] 3620 sellist = [i if striphist(v,'*') in varsellist else None for i,v in enumerate(data[name]['varyList'])] 3619 # translate variable names to how they will be used in the headings 3620 vs = [striphist(v,'*') for v in data[name]['varyList']] 3621 # determine the index for each column (or None) in the data[]['variables'] and ['sig'] lists 3622 sellist = [vs.index(v) if v is not None else None for v in varsellist] 3623 #sellist = [i if striphist(v,'*') in varsellist else None for i,v in enumerate(data[name]['varyList'])] 3621 3624 if not varsellist: raise Exception() 3622 3625 vals.append([data[name]['variables'][s] if s is not None else None for s in sellist]) 3623 3626 esds.append([data[name]['sig'][s] if s is not None else None for s in sellist]) 3627 #GSASIIpath.IPyBreak() 3624 3628 colList += zip(*vals) 3625 3629 colSigs += zip(*esds) 3626 # add the variables that were refined; change from rows to columns3627 #colList += zip(*[data[name]['variables'] for name in histNames])3628 #colLabels += data[histNames[0]]['varyList']3629 #Types += len(data[histNames[0]]['varyList'])*[wg.GRID_VALUE_FLOAT]3630 #colSigs += zip(*[data[name]['sig'] for name in histNames])3631 3632 # for var in combinedVaryList:3633 # colLabels += [var]3634 # Types += [wg.GRID_VALUE_FLOAT]3635 # vals = []3636 # sigs = []3637 # for name in histNames:3638 # try:3639 # i = data[name]['varyList'].index(var)3640 # vals.append(data[name]['variables'][i])3641 # sigs.append(data[name]['sig'][i])3642 # except ValueError: # var not in list3643 # vals.append(None)3644 # sigs.append(None)3645 # colList += [vals]3646 # colSigs += [sigs]3647 3630 3648 3631 # tabulate constrained variables, removing histogram numbers if needed … … 3729 3712 3730 3713 #****************************************************************************** 3714 # create a set of values for example evaluation of pseudovars and 3731 3715 # this does not work for refinements that have differing numbers of variables. 3732 3716 #raise Exception 3733 indepVarDict = { # values in table w/o ESDs 3734 var:colList[i][0] for i,var in enumerate(colLabels) if colSigs[i] is None 3735 } 3736 # make dict of dependent vars (w/ESDs) that are not converted (Dij to Ak or dAx to Ax) 3737 depVarDict = { 3738 var:colList[i][0] for i,var in enumerate(colLabels) 3739 if colSigs[i] is not None and striphist(var) not in Dlookup 3740 } 3717 indepVarDict = {} # values in table w/o ESDs 3718 depVarDict = {} 3719 for i,var in enumerate(colLabels): 3720 if var == 'Use': continue 3721 if colList[i][0] is None: 3722 val,sig = firstValueDict.get(var,[None,None]) 3723 elif colSigs[i]: 3724 val,sig = colList[i][0],colSigs[i][0] 3725 else: 3726 val,sig = colList[i][0],None 3727 if val is None: 3728 continue 3729 elif sig is None: 3730 indepVarDict[var] = val 3731 elif striphist(var) not in Dlookup: 3732 depVarDict[var] = val 3741 3733 # add recip cell coeff. values 3742 3734 depVarDict.update({var:val for var,val in data[name].get('newCellDict',{}).values()}) -
trunk/GSASIIpath.py
r1688 r1696 153 153 return os.path.abspath(exe_file) 154 154 155 def svnVersion(): 156 '''Get the version number of the current subversion executable 157 158 :returns: a string with a version number such as "1.6.6" or None if 159 subversion is not found. 160 161 ''' 162 import subprocess 163 svn = whichsvn() 164 if not svn: return 165 166 cmd = [svn,'--version','--quiet'] 167 s = subprocess.Popen(cmd, 168 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 169 out,err = s.communicate() 170 if err: 171 print 'subversion error!\nout=',out 172 print 'err=',err 173 return None 174 return out.strip() 175 176 def svnVersionNumber(): 177 '''Get the version number of the current subversion executable 178 179 :returns: a fractional version number such as 1.6 or None if 180 subversion is not found. 181 182 ''' 183 ver = svnVersion() 184 if not ver: return 185 M,m = svnVersion().split('.')[:2] 186 return int(M)+int(m)/10. 187 155 188 def svnGetLog(fpath=os.path.split(__file__)[0],version=None): 156 '''Get the revision log information for a specific version of the 189 '''Get the revision log information for a specific version of the specified package 157 190 158 191 :param str fpath: path to repository dictionary, defaults to directory where … … 213 246 else: 214 247 cmd = [svn,'info',fpath,'--xml','-rHEAD'] 215 s = subprocess.Popen(cmd+['--non-interactive', '--trust-server-cert'], 216 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 217 out,err = s.communicate() 218 if err: 219 print 'svn failed, retry w/o --trust...\nout=',out 248 if svnVersionNumber() >= 1.6: 249 cmd += ['--non-interactive', '--trust-server-cert'] 250 s = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE) 251 out,err = s.communicate() 252 if err: 253 print 'svn failed\n',out 220 254 print 'err=',err 221 s = subprocess.Popen(cmd, 222 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 223 out,err = s.communicate() 224 if err: 225 print 'out=',out 226 print 'err=',err 227 return None 255 return None 228 256 x = ET.fromstring(out) 229 257 for i in x.iter('entry'): … … 278 306 '--non-interactive', 279 307 '--accept','theirs-conflict','--force'] 280 s = subprocess.Popen(cmd+['--trust-server-cert'], 281 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 282 out,err = s.communicate() 283 print out 284 if err: 285 s = subprocess.Popen(cmd, 286 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 287 out,err = s.communicate() 288 if err: 289 print(60*"=") 290 print ("****** An error was noted, see below *********") 291 print(60*"=") 292 print err 293 sys.exit() 294 308 if svnVersionNumber() >= 1.6: 309 cmd += ['--trust-server-cert'] 310 s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 311 out,err = s.communicate() 312 if err: 313 print(60*"=") 314 print ("****** An error was noted, see below *********") 315 print(60*"=") 316 print err 317 sys.exit() 318 319 def svnUpgrade(fpath=os.path.split(__file__)[0]): 320 '''This reformats subversion files, which may be needed if an upgrade of subversion is 321 done. 322 323 :param str fpath: path to repository dictionary, defaults to directory where 324 the current file is located 325 ''' 326 import subprocess 327 svn = whichsvn() 328 if not svn: return 329 cmd = [svn,'upgrade',fpath,'--non-interactive'] 330 s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 331 out,err = s.communicate() 332 if err: 333 print("svn upgrade did not happen (this is probably OK). Messages:") 334 print err 335 295 336 def svnUpdateProcess(version=None,projectfile=None): 296 337 '''perform an update of GSAS-II in a separate python process''' … … 309 350 sys.exit() 310 351 311 def svnSwitchDir(rpath, URL,loadpath=None):352 def svnSwitchDir(rpath,filename,baseURL,loadpath=None): 312 353 '''This performs a switch command to move files between subversion trees. 313 354 … … 324 365 svn = whichsvn() 325 366 if not svn: return 367 URL = baseURL[:] 368 if baseURL[-1] != '/': 369 URL = baseURL + '/' + filename 370 else: 371 URL = baseURL + filename 326 372 if loadpath: 327 fpath = os.path.join(loadpath,rpath )328 else: 329 fpath = os.path.join(path2GSAS2,rpath )330 cmd = [svn,'switch', '--ignore-ancestry',URL,fpath,331 '--non-interactive', 373 fpath = os.path.join(loadpath,rpath,filename) 374 else: 375 fpath = os.path.join(path2GSAS2,rpath,filename) 376 cmd = [svn,'switch',URL,fpath, 377 '--non-interactive','--trust-server-cert', 332 378 '--accept','theirs-conflict','--force'] 379 if svnVersionNumber() > 1.6: cmd += ['--ignore-ancestry'] 333 380 print("Loading files from "+URL) 334 s = subprocess.Popen(cmd+['--trust-server-cert'], 335 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 336 out,err = s.communicate() 337 if err: 338 s = subprocess.Popen(cmd, 339 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 340 out,err = s.communicate() 341 if err: 342 print(60*"=") 343 print ("****** An error was noted, see below *********") 344 print(60*"=") 345 print err 346 return False 381 s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 382 out,err = s.communicate() 383 if err: 384 print(60*"=") 385 print ("****** An error was noted, see below *********") 386 print(60*"=") 387 print 'out=',out 388 print 'err=',err 389 return False 347 390 return True 348 391 … … 360 403 raise Exception("Error: Attempting to create existing directory "+loadpath) 361 404 cmd = [svn,'co',URL,loadpath,'--non-interactive'] 405 if svnVersionNumber() >= 1.6: cmd += ['--trust-server-cert'] 362 406 print("Loading files from "+URL) 363 s = subprocess.Popen(cmd+['--trust-server-cert'], 364 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 365 out,err = s.communicate() 366 if err: 367 print out 368 s = subprocess.Popen(cmd, 369 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 370 out,err = s.communicate() 371 if err: 372 print(60*"=") 373 print ("****** An error was noted, see below *********") 374 print(60*"=") 375 print err 376 return False 407 s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 408 out,err = s.communicate() 409 if err: 410 print(60*"=") 411 print ("****** An error was noted, see below *********") 412 print(60*"=") 413 print err 414 return False 377 415 return True 378 379 416 380 417 def IPyBreak_base(): -
trunk/config_example.py
r1688 r1696 42 42 G2 is installed by an administrator, it is a good idea to use something like this: 43 43 import os.path 44 Tutorial_location = os.path. expanduser('~/G2tutorials')44 Tutorial_location = os.path.join(os.path.expanduser('~'),'G2tutorials') 45 45 This will allow users to download tutorial files into their own file space. 46 46 '''
Note: See TracChangeset
for help on using the changeset viewer.