Changeset 2379


Ignore:
Timestamp:
Jul 28, 2016 11:11:35 AM (5 years ago)
Author:
toby
Message:

fix tutorial path setting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrls.py

    r2378 r2379  
    38763876    #['ExampleDir', 'ExamplePage.html', 'Example Tutorial Title'],
    38773877    )
    3878 # Get the tutorial location if set; if not pick a default directory in a logical place
    3879 if GSASIIpath.GetConfigValue('Tutorial_location'):
    3880     tutorialPath = os.path.abspath(GSASIIpath.GetConfigValue('Tutorial_location'))
    3881 elif sys.platform.lower().startswith('win') and os.path.exists(os.path.abspath(os.path.expanduser('~/My Documents'))):
    3882     tutorialPath = os.path.abspath(os.path.expanduser('~/My Documents/G2tutorials'))
    3883 elif sys.platform.lower().startswith('win') and os.path.exists(os.path.abspath(os.path.expanduser('~/Documents'))):
    3884     tutorialPath = os.path.abspath(os.path.expanduser('~/Documents/G2tutorials'))
    3885 else:
    3886     tutorialPath = os.path.abspath(os.path.expanduser('~/G2tutorials'))
    38873878
    38883879class OpenTutorial(wx.Dialog):
     
    39223913        tutorial files installed at a shared location.
    39233914        '''
     3915        self.SetTutorialPath()
    39243916        hlp = HelpButton(pnl,msg)
    39253917        sizer1.Add((-1,-1),1, wx.EXPAND, 0)
     
    39563948        btn.Bind(wx.EVT_BUTTON, self.SelectDownloadLoc)
    39573949        sizer1.Add(btn,0,WACV)
    3958         self.dataLoc = wx.StaticText(pnl, wx.ID_ANY,tutorialPath)
     3950        self.dataLoc = wx.StaticText(pnl, wx.ID_ANY,self.tutorialPath)
    39593951        sizer1.Add(self.dataLoc,0,WACV)
    39603952        sizer.Add(sizer1)
    39613953       
    39623954        btnsizer = wx.StdDialogButtonSizer()
    3963         btn = wx.Button(pnl, wx.ID_CANCEL)
     3955        btn = wx.Button(pnl, wx.ID_CANCEL,"Done")
    39643956        btnsizer.AddButton(btn)
    39653957        btnsizer.Realize()
     
    39693961        self.topsizer=sizer
    39703962        self.CenterOnParent()
    3971    
     3963
     3964    def SetTutorialPath(self):
     3965        '''Get the tutorial location if set; if not pick a default
     3966        directory in a logical place
     3967        '''
     3968        if GSASIIpath.GetConfigValue('Tutorial_location'):
     3969            self.tutorialPath = os.path.abspath(GSASIIpath.GetConfigValue('Tutorial_location'))
     3970        elif (sys.platform.lower().startswith('win') and
     3971              os.path.exists(os.path.abspath(os.path.expanduser('~/My Documents')))):
     3972            self.tutorialPath = os.path.abspath(os.path.expanduser('~/My Documents/G2tutorials'))
     3973        elif (sys.platform.lower().startswith('win') and
     3974              os.path.exists(os.path.abspath(os.path.expanduser('~/Documents')))):
     3975            self.tutorialPath = os.path.abspath(os.path.expanduser('~/Documents/G2tutorials'))
     3976        else:
     3977            self.tutorialPath = os.path.abspath(os.path.expanduser('~/G2tutorials'))
     3978
    39723979    def SelectAndDownload(self,event):
    39733980        '''Make a list of all tutorials on web and allow user to choose one to
     
    39753982        '''
    39763983        indices = [j for j,i in enumerate(tutorialCatalog)
    3977             if not os.path.exists(os.path.join(tutorialPath,i[0],i[1]))]
     3984            if not os.path.exists(os.path.join(self.tutorialPath,i[0],i[1]))]
    39783985        if not indices:
    39793986            G2MessageBox(self,'All tutorials are downloaded','None to download')
     
    39843991        if selected is None: return
    39853992        j = indices[selected]
    3986         fullpath = os.path.join(tutorialPath,tutorialCatalog[j][0],tutorialCatalog[j][1])
    3987         fulldir = os.path.join(tutorialPath,tutorialCatalog[j][0])
     3993        fullpath = os.path.join(self.tutorialPath,tutorialCatalog[j][0],tutorialCatalog[j][1])
     3994        fulldir = os.path.join(self.tutorialPath,tutorialCatalog[j][0])
    39883995        URL = G2BaseURL+'/Tutorials/'+tutorialCatalog[j][0]+'/'
    39893996        if GSASIIpath.svnInstallDir(URL,fulldir):
     
    39974004        '''
    39984005        indices = [j for j,i in enumerate(tutorialCatalog)
    3999             if os.path.exists(os.path.join(tutorialPath,i[0],i[1]))]
     4006            if os.path.exists(os.path.join(self.tutorialPath,i[0],i[1]))]
    40004007        if not indices:
    40014008            G2MessageBox(self,'There are no downloaded tutorials','None downloaded')
     
    40054012        if selected is None: return
    40064013        j = indices[selected]
    4007         fullpath = os.path.join(tutorialPath,tutorialCatalog[j][0],tutorialCatalog[j][1])
     4014        fullpath = os.path.join(self.tutorialPath,tutorialCatalog[j][0],tutorialCatalog[j][1])
    40084015        self.EndModal(wx.ID_OK)
    40094016        ShowWebPage(fullpath,self.frame)
     
    40634070        updated = 0
    40644071        for i in tutorialCatalog:
    4065             if not os.path.exists(os.path.join(tutorialPath,i[0],i[1])): continue
     4072            if not os.path.exists(os.path.join(self.tutorialPath,i[0],i[1])): continue
    40664073            print('Updating '+i[0])
    4067             GSASIIpath.svnUpdateDir(os.path.join(tutorialPath,i[0]))
     4074            GSASIIpath.svnUpdateDir(os.path.join(self.tutorialPath,i[0]))
    40684075            updated += 0
    40694076        if not updated:
     
    40754082        fail = ''
    40764083        for i in tutorialCatalog:
    4077             if os.path.exists(os.path.join(tutorialPath,i[0],i[1])):
     4084            if os.path.exists(os.path.join(self.tutorialPath,i[0],i[1])):
    40784085                print('Updating '+i[0])
    4079                 GSASIIpath.svnUpdateDir(os.path.join(tutorialPath,i[0]))
     4086                GSASIIpath.svnUpdateDir(os.path.join(self.tutorialPath,i[0]))
    40804087            else:
    4081                 fullpath = os.path.join(tutorialPath,i[0],i[1])
    4082                 fulldir = os.path.join(tutorialPath,i[0])
     4088                fullpath = os.path.join(self.tutorialPath,i[0],i[1])
     4089                fulldir = os.path.join(self.tutorialPath,i[0])
    40834090                URL = G2BaseURL+'/Tutorials/'+i[0]+'/'
    40844091                if not GSASIIpath.svnInstallDir(URL,fulldir):
     
    40934100        Cancel resets to the default
    40944101        '''
    4095         global tutorialPath
    40964102        dlg = wx.DirDialog(self, "Choose a directory for tutorial downloads:",
    4097                            defaultPath=tutorialPath)#,style=wx.DD_DEFAULT_STYLE)
     4103                           defaultPath=self.tutorialPath)#,style=wx.DD_DEFAULT_STYLE)
    40984104                           #)
    40994105        try:
     
    41184124            print('\t'+os.path.join(pth,"Exercises"))
    41194125            print('Subdirectories in the above can be deleted to save space\n\n')
    4120         tutorialPath = pth
    4121         self.dataLoc.SetLabel(tutorialPath)
     4126        self.tutorialPath = pth
     4127        self.dataLoc.SetLabel(self.tutorialPath)
    41224128        if GSASIIpath.GetConfigValue('Tutorial_location') == pth: return
    41234129        vars = GetConfigValsDocs()
     
    41254131            vars['Tutorial_location'][1] = pth
    41264132            if GSASIIpath.GetConfigValue('debug'): print('Saving Tutorial_location: '+pth)
     4133            GSASIIpath.SetConfigValue(vars)
    41274134            SaveConfigVars(vars)
    41284135        except KeyError:
Note: See TracChangeset for help on using the changeset viewer.