Changeset 981 for trunk/GSASIIgrid.py
- Timestamp:
- Jul 7, 2013 9:58:08 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r978 r981 1151 1151 1152 1152 ################################################################################ 1153 class downdate(wx.Dialog): 1154 '''Dialog to allow a user to select a version of GSAS-II to install 1155 ''' 1156 def __init__(self,parent=None): 1157 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER 1158 wx.Dialog.__init__(self, parent, wx.ID_ANY, 'Select Version', style=style) 1159 pnl = wx.Panel(self) 1160 sizer = wx.BoxSizer(wx.VERTICAL) 1161 insver = GSASIIpath.svnGetRev(local=True) 1162 curver = int(GSASIIpath.svnGetRev(local=False)) 1163 label = wx.StaticText( 1164 pnl, wx.ID_ANY, 1165 'Select a specific GSAS-II version to install' 1166 ) 1167 sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) 1168 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 1169 sizer1.Add( 1170 wx.StaticText(pnl, wx.ID_ANY, 1171 'Currently installed version: '+str(insver)), 1172 0, wx.ALIGN_CENTRE|wx.ALL, 5) 1173 sizer.Add(sizer1) 1174 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 1175 sizer1.Add( 1176 wx.StaticText(pnl, wx.ID_ANY, 1177 'Select GSAS-II version to install: '), 1178 0, wx.ALIGN_CENTRE|wx.ALL, 5) 1179 self.spin = wx.SpinCtrl(pnl, wx.ID_ANY) 1180 self.spin.SetRange(1, curver) 1181 self.spin.SetValue(curver) 1182 self.Bind(wx.EVT_SPINCTRL, self._onSpin, self.spin) 1183 self.Bind(wx.EVT_KILL_FOCUS, self._onSpin, self.spin) 1184 sizer1.Add(self.spin) 1185 sizer.Add(sizer1) 1186 1187 line = wx.StaticLine(pnl,-1, size=(-1,3), style=wx.LI_HORIZONTAL) 1188 sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10) 1189 1190 self.text = wx.StaticText(pnl, wx.ID_ANY, "") 1191 sizer.Add(self.text, 0, wx.ALIGN_LEFT, 5) 1192 1193 btnsizer = wx.StdDialogButtonSizer() 1194 btn = wx.Button(pnl, wx.ID_OK, "Install") 1195 btn.SetDefault() 1196 btnsizer.AddButton(btn) 1197 btn = wx.Button(pnl, wx.ID_CANCEL) 1198 btnsizer.AddButton(btn) 1199 btnsizer.Realize() 1200 sizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) 1201 pnl.SetSizer(sizer) 1202 sizer.Fit(self) 1203 self.topsizer=sizer 1204 self.CenterOnParent() 1205 self._onSpin(None) 1206 1207 def _onSpin(self,event): 1208 'Called to load info about the selected version in the dialog' 1209 ver = self.spin.GetValue() 1210 d = GSASIIpath.svnGetLog(version=ver) 1211 date = d.get('date','?').split('T')[0] 1212 s = '(Version '+str(ver)+' created '+date 1213 s += ' by '+d.get('author','?')+')' 1214 msg = d.get('msg') 1215 if msg: s += '\n\nComment: '+msg 1216 self.text.SetLabel(s) 1217 self.topsizer.Fit(self) 1218 1219 def getVersion(self): 1220 'Get the version number in the dialog' 1221 return self.spin.GetValue() 1222 1223 ################################################################################ 1153 1224 class MyHelp(wx.Menu): 1154 1225 ''' … … 1181 1252 text='&Check for updates') 1182 1253 frame.Bind(wx.EVT_MENU, self.OnCheckUpdates, helpobj) 1254 helpobj = self.Append( 1255 help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, 1256 text='&Regress to an old GSAS-II version') 1257 frame.Bind(wx.EVT_MENU, self.OnSelectVersion, helpobj) 1183 1258 for lbl,indx in morehelpitems: 1184 1259 helpobj = self.Append(text=lbl, … … 1268 1343 'You have version '+local+ 1269 1344 ' of GSAS-II installed, but the current version is '+repos+ 1270 '. However, you have modified'+str(len(mods))+1345 '. However, '+str(len(mods))+ 1271 1346 ' file(s) on your local computer have been modified.' 1272 ' Updating could wipe out your local changes. Press OK to start an update:',1347 ' Updating could cause you to lose your changes, if conflicts arise. Press OK to start an update if this is acceptable:', 1273 1348 'Local GSAS-II Mods', 1274 1349 wx.OK|wx.CANCEL) … … 1294 1369 dlg.ShowModal() 1295 1370 return 1296 modsbytype = {} 1297 for key in moddict: 1298 typ = moddict[key] 1299 if modsbytype.get(typ) is None: 1300 modsbytype[typ] = [] 1301 modsbytype[typ].append(key) 1302 msg = 'Update was completed. Changes will take effect when GSAS-II is next updated. The following files were updated, ordered by status:' 1303 for key in modsbytype: 1304 msg += '\n' + key + ':\n\t' 1305 for fil in modsbytype: 1306 msg += fil + ', ' 1371 msg = 'Update was completed. Changes will take effect when GSAS-II is restarted.\n\nThe following files were affected, ordered by change,' 1372 for key in sorted(moddict.keys()): 1373 msg += '\n\n' + key + ': '+moddict[key] 1374 dlg = wx.MessageDialog(self.frame,msg, 'Update Completed', wx.OK) 1375 dlg.ShowModal() 1376 return 1377 1378 def OnSelectVersion(self,event): 1379 '''Allow the user to select a specific version of GSAS-II 1380 ''' 1381 if not GSASIIpath.whichsvn(): 1382 dlg = wx.MessageDialog(self,'No Subversion','Cannot update GSAS-II because subversion (svn) '+ 1383 'was not found.' 1384 ,wx.OK) 1385 dlg.ShowModal() 1386 return 1387 local = GSASIIpath.svnGetRev() 1388 if local is None: 1389 dlg = wx.MessageDialog(self.frame, 1390 'Unable to run subversion on the GSAS-II current directory. Is GSAS-II installed correctly?', 1391 'Subversion error', 1392 wx.OK) 1393 dlg.ShowModal() 1394 return 1395 mods = GSASIIpath.svnFindLocalChanges() 1396 if mods: 1397 dlg = wx.MessageDialog(self.frame, 1398 'You have version '+local+ 1399 ' of GSAS-II installed. However, '+str(len(mods))+ 1400 ' file(s) on your local computer have been modified.' 1401 ' Downdating is not encouraged as this could cause you to lose these changes. Press OK to continue anyway:', 1402 'Local GSAS-II Mods', 1403 wx.OK|wx.CANCEL) 1404 if dlg.ShowModal() != wx.ID_OK: return 1405 dlg = downdate(parent=self.frame) 1406 if dlg.ShowModal() == wx.ID_OK: 1407 ver = dlg.getVersion() 1408 print('start update to '+str(ver)) 1409 wx.BeginBusyCursor() 1410 moddict = GSASIIpath.svnUpdateDir(version=ver) 1411 wx.EndBusyCursor() 1412 dlg.Destroy() 1413 else: 1414 dlg.Destroy() 1415 return 1416 if moddict is None: 1417 dlg = wx.MessageDialog(self.frame, 1418 'Error accessing the GSAS-II server or performing the update. '+ 1419 'Try again later or perform a manual update', 1420 'Update Error', 1421 wx.OK) 1422 dlg.ShowModal() 1423 return 1424 msg = 'Update was completed. Changes will take effect when GSAS-II is restarted.\n\nThe following files were affected, ordered by change,' 1425 for key in sorted(moddict.keys()): 1426 msg += '\n\n' + key + ': '+moddict[key] 1307 1427 dlg = wx.MessageDialog(self.frame,msg, 'Update Completed', wx.OK) 1308 1428 dlg.ShowModal()
Note: See TracChangeset
for help on using the changeset viewer.