Changeset 949
- Timestamp:
- Mar 10, 2010 3:02:01 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expgui
r944 r949 4168 4168 -command {console show} 4169 4169 } 4170 # add update commands to buffer 4171 if [CheckUpdateImplemented $scriptdir] { 4172 $expgui(fm).help.menu add command -command CheckAndDoUpdate -label "Update GSAS/CMPR" 4173 # $expgui(fm).help.menu add cascade -menu $expgui(fm).help.menu.track \ 4174 # -label "Select EXPGUI version" 4175 # menu $expgui(fm).help.menu.track 4176 # $expgui(fm).help.menu.track add radiobutton -command {SetSVNbranch trunk} -label Development -value trunk \ 4177 # -variable expgui(SVNversion) 4178 # $expgui(fm).help.menu.track add radiobutton -command {SetSVNbranch stable} -label Standard -value stable \ 4179 # -variable expgui(SVNversion) 4180 # get info about the current CMPR version on the server. Someday we might want to compare this 4181 # say every month and notify when there is a new version to update 4182 set repos [GetSVNrepository $scriptdir] 4183 # send a "p" to accept the server fingerprint in case needed on 1st access 4184 catch {set out [exec echo "p" | svn info $repos]} err 4185 set expgui(SVNversion) [lindex [split $repos '/'] end] 4186 # cleanup batch file from a previous update 4187 if {$::tcl_platform(platform) == "windows" && $::tcl_platform(os) != "Windows 95"} { 4188 catch { 4189 file delete [file normalize ~/cmpr_update.bat] 4190 } 4191 } 4192 } else { 4193 $expgui(fm).help.menu add command -label "Show update problem" -command { 4194 if {! [file exists [file join $scriptdir .svn]]} { 4195 MyMessageBox -parent . -title "No .svn" \ 4196 -message "Unable to update because the gsas/.svn directory is not present." \ 4197 -icon warning 4198 } else { 4199 MyMessageBox -parent . -title "No .svn" \ 4200 -message "Unable to update because the subversion (svn) program is not in the path." \ 4201 -icon warning 4202 } 4203 } 4204 } 4170 4205 foreach c {h H} {bind . <Alt-$c> [list showhelp]} 4171 4206 # define help actions -
trunk/gsascmds.tcl
r935 r949 3148 3148 RecordMacroEntry "# [getstring "comment for macro file"]" 0 3149 3149 } 3150 3151 #------------------------------------------------------------------------------ 3152 # Subversion support routines 3153 #------------------------------------------------------------------------------ 3154 # is there a subversion stub and can we find the svn program 3155 proc CheckUpdateImplemented {scriptdir} { 3156 #is there a svn directory in the source? 3157 if {! [file exists [file join $scriptdir .svn]]} {return 0} 3158 # can we find svn in the path? 3159 if {[auto_execok svn] != ""} {return 1} 3160 # add a locally supplied svn version, if not in the path already 3161 set localsvn [file join $scriptdir svn bin] 3162 if {[file exists $localsvn]} { 3163 if {$::tcl_platform(platform) == "windows"} { 3164 set localsvn [file nativename $localsvn] 3165 set sep {;} 3166 } else { 3167 set sep {:} 3168 } 3169 if {[lsearch [split $::env(PATH) $sep] $localsvn] == -1} { 3170 append ::env(PATH) $sep $localsvn 3171 auto_reset 3172 if {[auto_execok svn] != ""} {return 1} 3173 } 3174 } 3175 return 0 3176 } 3177 3178 proc GetSVNVersion {scriptdir} { 3179 set SVN [auto_execok svn] 3180 if {$SVN != ""} { 3181 if {! [catch {set res [exec $SVN info $scriptdir]} err]} { 3182 set infolist [split $res] 3183 set pos [lsearch $infolist "Revision:"] 3184 return "EXPGUI SVN version [lindex $infolist [incr pos]]" 3185 } 3186 } 3187 return "EXPGUI version: $::expgui(Revision)" 3188 } 3189 3190 proc GetSVNrepository {scriptdir} { 3191 set SVN [auto_execok svn] 3192 if {$SVN != ""} { 3193 if {! [catch {set res [exec $SVN info $scriptdir]} err]} { 3194 set infolist [split $res] 3195 set pos [lsearch $infolist "URL:"] 3196 return [lindex $infolist [incr pos]] 3197 } 3198 } 3199 return {} 3200 } 3201 3202 proc SetSVNbranch {branch} { 3203 # reset the track label 3204 set ::command(SVNversion) [lindex [split [GetSVNrepository $::expgui(scriptdir)] '/'] end] 3205 set SVN [auto_execok svn] 3206 if {$SVN == ""} { 3207 return 0 3208 } 3209 set curURL [GetSVNrepository $expgui(scriptdir)] 3210 set curbranch [lindex [split $curURL '/'] end] 3211 if {$curbranch == $branch} {return 0} 3212 if {$branch == "trunk"} { 3213 set newURL "https://subversion.xor.aps.anl.gov/EXPGUI/trunk" 3214 set lbl development 3215 } elseif {$branch == "stable"} { 3216 set newURL "https://subversion.xor.aps.anl.gov/EXPGUI/tags/stable" 3217 set lbl standard 3218 } else { 3219 MyMessageBox -parent . -title "Internal error" \ 3220 -message "No $branch track." -icon error 3221 return 0 3222 } 3223 set msg {Press the "Update & Restart" button to begin the update process. After the update completes, EXPGUI will be restarted.} 3224 if {[MyMessageBox -parent . -title "Ready to switch" \ 3225 -message "Ready to update to the $lbl track.\n\n$msg" \ 3226 -type {Cancel "Update & Restart"} -default cancel -icon warning 3227 ] == "cancel"} {return} 3228 if {[confirmBeforeSave] == "Cancel"} return 3229 3230 # do a quiet cleanup. Sometimes needed after install, and never hurts 3231 if [catch {set res [exec $SVN cleanup $::expgui(scriptdir)]} err] { 3232 MyMessageBox -parent . -title "Error in cleanup" \ 3233 -message "Error performing cleanup. Will try to continue anyway. Error:\n$err" \ 3234 -icon error 3235 } 3236 3237 # switch the source 3238 set cmd1 "$SVN switch $newURL $scriptdir" 3239 if [catch {set res1 [exec $SVN switch $newURL $::expgui(scriptdir)]} err] { 3240 MyMessageBox -parent . -title "Error updating" \ 3241 -message "Error performing update:\n$err" \ 3242 -icon error 3243 return 0 3244 } 3245 set msg "Results from update:\n$cmd1\n$res1" 3246 # update done, now need to "reboot" 3247 MyMessageBox -parent . -title "Updating done" -icon info \ 3248 -message "Update Complete\nPress OK to restart EXPGUI\n\n$msg" 3249 exec [info nameofexecutable] [file normalize $::expgui(script)] [file normalize $::expgui(expfile)] & 3250 exit 3251 } 3252 3253 proc CheckAndDoUpdate { } { 3254 set SVN [auto_execok svn] 3255 if {$SVN == ""} { 3256 tk_dialog .msg "Error: no svn" \ 3257 "Error: SVN not found. Should not happen." \ 3258 error 0 OK 3259 return 3260 } 3261 #set wish "[info nameofexecutable]" 3262 # check for updates 3263 if [catch {set res [exec $SVN status $::expgui(scriptdir) -u]} err] { 3264 MyMessageBox -parent . -title "Error checking status" \ 3265 -message "Error checking for updates: $err" \ 3266 -icon error 3267 return 3268 } else { 3269 if {[string first "*" $res] == -1} { 3270 MyMessageBox -parent . -title "No updates" \ 3271 -message "GSAS/EXPGUI appears up-to-date" \ 3272 -icon info 3273 return 3274 } 3275 } 3276 if {[MyMessageBox -parent . -title "Ready to Update" \ 3277 -message { 3278 Updates to GSAS/EXPGUI found. 3279 3280 Press the "Update & Restart" button to begin the update process. After the update completes, EXPGUI will be restarted.} \ 3281 -type {Cancel "Update & Restart"} -default cancel -icon warning 3282 ] == "cancel"} {return} 3283 3284 if {[confirmBeforeSave] == "Cancel"} return 3285 3286 # special upgrade for windows, where the wish exec blocks upgrade of the exe directory 3287 if {$::tcl_platform(platform) == "windows" && $::tcl_platform(os) != "Windows 95"} { 3288 # create a batch file 3289 set out [file normalize ~/expgui_update.bat] 3290 set fp [open [file normalize ~/expgui_update.bat] w] 3291 puts $fp "@echo *" 3292 puts $fp "@echo ******************************************************************" 3293 puts $fp "@echo Preparing to start upgrade of CMPR." 3294 puts $fp "@pause" 3295 puts $fp "$SVN cleanup $::expgui(scriptdir)" 3296 puts $fp "$SVN up $::expgui(scriptdir)" 3297 puts $fp "@echo *" 3298 puts $fp "@echo ******************************************************************" 3299 puts $fp "@echo Upgrade is complete. This window will close and EXPGUI will restart." 3300 puts $fp "@pause" 3301 puts $fp "$::env(COMSPEC) /c \"start [info nameofexecutable] [file normalize $::expgui(script)] [file normalize $::expgui(expfile)]\"" 3302 puts $fp "exit" 3303 close $fp 3304 #run the batch file 3305 exec $::env(COMSPEC) /c "start [file nativename [file attributes $out -shortname]]" & 3306 exit 3307 } 3308 3309 # do a quiet cleanup. Sometimes needed after install, and never hurts 3310 if [catch {set res [exec $SVN cleanup $::expgui(scriptdir)]} err] { 3311 MyMessageBox -parent . -title "Error in cleanup" \ 3312 -message "Error performing cleanup. Will try to continue anyway. Error:\n$err" \ 3313 -icon error 3314 } 3315 if [catch {set res [exec $SVN up $::expgui(scriptdir)]} err] { 3316 MyMessageBox -parent . -title "Error updating" \ 3317 -message "Error performing update:\n$err" \ 3318 -icon error 3319 return 3320 } else { 3321 MyMessageBox -parent . -title "Updating done" \ 3322 -message "Results from update:\n$res\n\nPress OK to restart EXPGUI" \ 3323 -icon info 3324 } 3325 exec [info nameofexecutable] [file normalize $::expgui(script)] [file normalize $::expgui(expfile)] & 3326 exit 3327 }
Note: See TracChangeset
for help on using the changeset viewer.