- Timestamp:
- Jul 8, 2017 2:57:13 PM (8 years ago)
- Location:
- branch/2frame
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branch/2frame/GSASIIctrlGUI.py ¶
r2917 r2921 3503 3503 text='&Regress to an old GSAS-II version') 3504 3504 frame.Bind(wx.EVT_MENU, self.OnSelectVersion, helpobj) 3505 if GSASIIpath.svnTestBranch(): 3506 msg = "&Switch to back standard GSAS-II version" 3507 else: 3508 msg = "&Switch to test (2frame) GSAS-II version" 3509 helpobj = self.Append( 3510 help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL,text=msg) 3511 frame.Bind(wx.EVT_MENU, self.OnSelectBranch, helpobj) 3505 3512 # provide special help topic names for extra items in help menu 3506 3513 for lbl,indx in morehelpitems: … … 3605 3612 repos = GSASIIpath.svnGetRev(local=False) 3606 3613 wx.EndBusyCursor() 3607 if repos is None: 3614 # has the current branch disappeared? If so, switch to the trunk -- not fully tested 3615 if (repos is None and "not found" in GSASIIpath.svnLastError.lower() 3616 and "path" in GSASIIpath.svnLastError.lower()): 3617 print('Repository is gone, will switch to trunk') 3618 GSASIIpath.svnSwitch2branch() 3619 return 3620 elif repos is None: 3608 3621 dlg = wx.MessageDialog(self.frame, 3609 3622 'Unable to access the GSAS-II server. Is this computer on the internet?', … … 3664 3677 return 3665 3678 dlg.Destroy() 3666 try: 3667 self.frame.OnFileSave(event) 3668 GPX = self.frame.GSASprojectfile 3669 except AttributeError: 3670 self.frame.G2frame.OnFileSave(event) 3671 GPX = self.frame.G2frame.GSASprojectfile 3679 self.frame.OnFileSave(event) 3680 GPX = self.frame.GSASprojectfile 3672 3681 GSASIIpath.svnUpdateProcess(projectfile=GPX) 3673 3682 return … … 3727 3736 dlg.Destroy() 3728 3737 print('start regress to '+str(ver)) 3729 try: 3730 self.frame.OnFileSave(event) 3731 GPX = self.frame.GSASprojectfile 3732 except AttributeError: 3733 self.frame.G2frame.OnFileSave(event) 3734 GPX = self.frame.G2frame.GSASprojectfile 3738 self.frame.OnFileSave(event) 3739 GPX = self.frame.GSASprojectfile 3735 3740 GSASIIpath.svnUpdateProcess(projectfile=GPX,version=str(ver)) 3736 3741 return 3742 3743 def OnSelectBranch(self,event): 3744 '''Allow the user to select branch of GSAS-II or return to trunk 3745 N.B. Name of branch to use is hard-coded here. Must contain a slash 3746 ''' 3747 testbranch = '/branch/2frame' 3748 if GSASIIpath.svnTestBranch(): 3749 dlg = wx.MessageDialog(self.frame, 3750 'Switching from test to standard GSAS-II version', 3751 'Confirm Switch', 3752 wx.OK|wx.CANCEL) 3753 if dlg.ShowModal() != wx.ID_OK: return 3754 branch = testbranch 3755 else: 3756 dlg = wx.MessageDialog(self.frame, 3757 'Switching back to standard GSAS-II version', 3758 'Confirm Switch', 3759 wx.OK|wx.CANCEL) 3760 if dlg.ShowModal() != wx.ID_OK: return 3761 branch = 'trunk' 3762 print('start switch') 3763 self.frame.OnFileSave(event) 3764 GPX = self.frame.GSASprojectfile 3765 GSASIIpath.svnUpdateProcess(projectfile=GPX,branch=branch) 3737 3766 3738 3767 ################################################################################ … … 4398 4427 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER 4399 4428 wx.Dialog.__init__(self, parent, wx.ID_ANY, 'Open Tutorial', style=style) 4400 self.frame = parent 4401 # self.frame can be the tree window frame or the data editing window frame, set G2frame to the 4402 # tree either way 4403 if hasattr(self.frame,'G2frame'): 4404 self.G2frame = self.frame.G2frame 4405 else: 4406 self.G2frame = self.frame 4429 self.G2frame = self.frame = parent 4407 4430 pnl = wx.Panel(self) 4408 4431 sizer = wx.BoxSizer(wx.VERTICAL) -
TabularUnified branch/2frame/GSASIIpath.py ¶
r2912 r2921 231 231 return d 232 232 233 svnLastError = '' 233 234 def svnGetRev(fpath=os.path.split(__file__)[0],local=True): 234 235 '''Obtain the version number for the either the last update of the local version … … 243 244 :Returns: the version number as an str or 244 245 None if there is a subversion error (likely because the path is 245 not a repository or svn is not found) 246 not a repository or svn is not found). The error message is placed in 247 global variable svnLastError 246 248 ''' 247 249 … … 261 263 print 'svn failed\n',out 262 264 print 'err=',err 265 global svnLastError 266 svnLastError = err 263 267 return None 264 268 x = ET.fromstring(out) … … 342 346 print err 343 347 344 def svnUpdateProcess(version=None,projectfile=None ):348 def svnUpdateProcess(version=None,projectfile=None,branch=None): 345 349 '''perform an update of GSAS-II in a separate python process''' 346 350 if not projectfile: … … 349 353 projectfile = os.path.realpath(projectfile) 350 354 print 'restart using',projectfile 351 if not version: 355 if branch: 356 version = branch 357 elif not version: 352 358 version = '' 353 359 else: … … 493 499 svnSwitchDir('bindist','',distdir,verbose=verbose) 494 500 return os.path.join(path2GSAS2,'bindist') 501 502 def svnTestBranch(loc=None): 503 '''Returns the name of the branch directory if the installation has been switched. 504 Returns none, if not a branch 505 the test 2frame branch. False otherwise 506 ''' 507 if loc is None: loc = path2GSAS2 508 svn = whichsvn() 509 if not svn: 510 print('**** unable to load files: svn not found ****') 511 return '' 512 cmd = [svn, 'info', loc] 513 if proxycmds: cmd += proxycmds 514 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 515 res,err = p.communicate() 516 for l in res.split('\n'): 517 if "Relative URL:" in l: break 518 if "/branch/" in l: 519 return l[l.find("/branch/")+8:].strip() 520 else: 521 return None 522 523 def svnSwitch2branch(branch=None,loc=None,svnHome=None): 524 '''Switch to a subversion branch if specified. Switches to trunk otherwise. 525 ''' 526 if svnHome is None: svnHome = g2home 527 svnURL = svnHome + '/trunk' 528 if branch: 529 if svnHome.endswith('/'): 530 svnURL = svnHome[:-1] 531 else: 532 svnURL = svnHome 533 if branch.startswith('/'): 534 svnURL += branch 535 else: 536 svnURL += '/' + branch 537 svnSwitchDir('','',svnURL,loadpath=loc) 538 495 539 496 540 def IPyBreak_base(): … … 708 752 project,version = sys.argv[1:3] 709 753 loc = os.path.dirname(__file__) 710 if version: 754 if version == 'trunk': 755 svnSwitch2branch('') 756 elif '/' in version: 757 svnSwitch2branch(version) 758 elif version: 711 759 print("Regress to version "+str(version)) 712 760 svnUpdateDir(loc,version=version)
Note: See TracChangeset
for help on using the changeset viewer.