Ignore:
Timestamp:
Sep 21, 2010 11:28:51 PM (11 years ago)
Author:
toby
Message:

mapexp: set expgui(mapstat) to trigger trace; move tab disable from sethistlist to StageTabUse?; trigger StageTabUse? when mapexp is used; StageTabUse?: disable tabs w/o phase or hist; simplify upgrade menu; addcmds: select a histogram after adding if none selected; revise SVN update code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/gsascmds.tcl

    r996 r1015  
    33983398# Subversion support routines
    33993399#------------------------------------------------------------------------------
    3400 # is there a subversion stub and can we find the svn program
    3401 proc CheckUpdateImplemented {scriptdir} {
    3402     #is there a svn directory in the source?
    3403     if {! [file exists [file join $scriptdir .svn]]} {return 0}
     3400
     3401proc GetSVNVersion {scriptdir} {
     3402    if {[CheckSVNinstalled]} {
     3403        set SVN [auto_execok svn]
     3404        if {! [catch {set res [eval exec $SVN info [list $scriptdir]]} err]} {
     3405            set infolist [split $res]
     3406            set pos [lsearch $infolist "Revision:"]
     3407            return "GSAS/EXPGUI SVN version [lindex $infolist [incr pos]]"
     3408        }
     3409    }
     3410    return "EXPGUI version: [lindex $::expgui(Revision) 1] ([lindex $::expgui(Revision) 4])"
     3411}
     3412
     3413# can we find the svn program?
     3414proc CheckSVNinstalled {} {
    34043415    # can we find svn in the path?
    34053416    if {[auto_execok svn] != ""} {return 1}
    3406     # add a locally supplied svn version, if not in the path already
    3407     set pathlist [list [file join $scriptdir svn bin]]
    3408     lappend pathlist "/sw/bin/"
    3409     lappend pathlist "/opt/local/bin/"
    3410     catch {lappend pathlist $::expgui(pathlist)}
    3411     foreach localsvn $pathlist {
    3412         if {[file exists $localsvn]} {
    3413             if {$::tcl_platform(platform) == "windows"} {
    3414                 set localsvn [file nativename $localsvn]
    3415                 set sep {;}
    3416             } else {
    3417                 set sep {:}
    3418             }
    3419             if {[lsearch [split $::env(PATH) $sep] $localsvn] == -1} {
    3420                 append ::env(PATH) $sep $localsvn
    3421                 auto_reset
    3422                 if {[auto_execok svn] != ""} {return 1}
    3423             }
    3424         }
    3425     }
     3417    # add a locally supplied svn version and add to path
     3418    if {$::tcl_platform(platform) == "windows"} {
     3419        set s [file attributes $::expgui(gsasdir) -shortname]
     3420    } else {
     3421        set s $::expgui(gsasdir)
     3422    }
     3423    # look for svn
     3424    set localsvn [file join $s svn bin]
     3425    if {[file exists $localsvn]} {
     3426        if {$::tcl_platform(platform) == "windows"} {
     3427            set localsvn [file nativename $localsvn]
     3428            set sep {;}
     3429        } else {
     3430            set sep {:}
     3431        }
     3432        if {[lsearch [split $::env(PATH) $sep] $localsvn] == -1} {
     3433            append ::env(PATH) $sep $localsvn
     3434            # note that auto_reset breaks the tkcon package in Windows -- not sure why
     3435            auto_reset
     3436        }
     3437    }
     3438    if {[auto_execok svn] != ""} {return 1}
    34263439    return 0
    34273440}
    34283441
    3429 proc GetSVNVersion {scriptdir} {
    3430     if {$::tcl_platform(platform) == "windows"} {
    3431         set SVN [file attributes [lindex [auto_execok svn] 0] -shortname]
    3432     } else {
    3433         set SVN [auto_execok svn]
    3434     }
    3435     if {$SVN != ""} {
    3436         if {! [catch {set res [exec $SVN info $scriptdir]} err]} {
    3437             set infolist [split $res]
    3438             set pos [lsearch $infolist "Revision:"]
    3439             return "EXPGUI SVN version [lindex $infolist [incr pos]]"
    3440         }
    3441     }
    3442     return "EXPGUI version: $::expgui(Revision)"
    3443 }
    3444 
    3445 proc GetSVNrepository {scriptdir} {
    3446     if {$::tcl_platform(platform) == "windows"} {
    3447         set SVN [file attributes [lindex [auto_execok svn] 0] -shortname]
    3448     } else {
    3449         set SVN [auto_execok svn]
    3450     }
    3451     if {$SVN != ""} {
    3452         if {! [catch {set res [exec $SVN info $scriptdir]} err]} {
    3453             set infolist [split $res]
    3454             set pos [lsearch $infolist "URL:"]
    3455             return [lindex $infolist [incr pos]]
    3456         }
    3457     }
    3458     return {}
    3459 }
    3460 
    3461 proc SetSVNbranch {branch} {
    3462     # reset the track label
    3463     set ::command(SVNversion) [lindex [split [GetSVNrepository $::expgui(scriptdir)] '/'] end]
    3464     if {$::tcl_platform(platform) == "windows"} {
    3465         set SVN [file attributes [lindex [auto_execok svn] 0] -shortname]
    3466     } else {
    3467         set SVN [auto_execok svn]
    3468     }
    3469     if {$SVN == ""} {
    3470         return 0
    3471     }
    3472     set curURL [GetSVNrepository $expgui(scriptdir)]
    3473     set curbranch [lindex [split $curURL '/'] end]
    3474     if {$curbranch == $branch} {return 0}
    3475     if {$branch == "trunk"} {
    3476         set newURL "https://subversion.xor.aps.anl.gov/EXPGUI/trunk"
    3477         set lbl development
    3478     } elseif {$branch == "stable"} {
    3479         set newURL "https://subversion.xor.aps.anl.gov/EXPGUI/tags/stable"
    3480         set lbl standard
    3481     } else {
    3482         MyMessageBox -parent . -title "Internal error" \
    3483         -message "No $branch track." -icon error
    3484         return 0
    3485     }
    3486     set msg {Press the "Update & Restart" button to begin the update process. After the update completes, EXPGUI will be restarted.}
    3487     if {[MyMessageBox -parent . -title "Ready to switch" \
    3488         -message "Ready to update to the $lbl track.\n\n$msg" \
    3489                  -type {Cancel "Update & Restart"} -default cancel -icon warning
    3490         ] == "cancel"} {return}
    3491     if {[confirmBeforeSave] == "Cancel"} return
    3492 
    3493     # do a quiet cleanup. Sometimes needed after install, and never hurts
    3494     if [catch {set res [exec $SVN cleanup $::expgui(scriptdir)]} err] {
    3495         MyMessageBox -parent . -title "Error in cleanup" \
    3496             -message "Error performing cleanup. Will try to continue anyway. Error:\n$err" \
     3442proc CheckAndDoUpdate { } {
     3443    if {! [CheckSVNinstalled]} {
     3444        MyMessageBox -parent . -title "SVN not found" \
     3445            -message "Unable to upgrade: Could not locate a copy of the subversion program. It does not appear that one of self-updating GSAS/EXPGUI releases was installed" \
    34973446            -icon error
    3498     }
    3499 
    3500     # switch the source
    3501     set cmd1 "$SVN switch $newURL $scriptdir"
    3502     if [catch {set res1 [exec $SVN switch $newURL $::expgui(scriptdir)]} err] {
    3503         MyMessageBox -parent . -title "Error updating" \
    3504             -message "Error performing update:\n$err" \
     3447        return
     3448    }
     3449    #is there a svn directory in the source?
     3450    if {! [file exists [file join $::expgui(gsasdir)  .svn]]} {
     3451        MyMessageBox -parent . -title "No .svn directory" \
     3452            -message "Unable to upgrade: It does not appear that one of self-updating GSAS/EXPGUI releases was installed" \
    35053453            -icon error
    3506         return 0
    3507     }
    3508     set msg "Results from update:\n$cmd1\n$res1"
    3509     # update done, now need to "reboot"
    3510     MyMessageBox -parent . -title "Updating done" -icon info \
    3511         -message "Update Complete\nPress OK to restart EXPGUI\n\n$msg"
    3512     exec [info nameofexecutable] [file normalize $::expgui(script)] [file normalize $::expgui(expfile)] &
    3513     exit
    3514 }
    3515 
    3516 proc CheckAndDoUpdate { } {
    3517     if {$::tcl_platform(platform) == "windows"} {
    3518         set SVN [file attributes [lindex [auto_execok svn] 0] -shortname]
    3519     } else {
    3520         set SVN [auto_execok svn]
    3521     }
    3522     if {$SVN == ""} {
    3523         tk_dialog .msg "Error: no svn" \
    3524             "Error: SVN not found. Should not happen." \
    3525             error 0 OK   
    35263454        return
    35273455    }
    3528     #set wish "[info nameofexecutable]"
    35293456    # check for updates
    3530     if [catch {
    3531         set res [exec $SVN status [file normalize $::expgui(gsasdir)] -u]
    3532     } err] {
     3457    set SVN [auto_execok svn]
     3458    if [catch {set res [eval exec $SVN status [list $::expgui(gsasdir)] -u]} err] {
    35333459        set ans [MyMessageBox -parent . -title "Error checking status" \
    35343460                     -message "Error checking for updates: $err\n\nTry to update manually?" \
     
    35393465        }
    35403466        return
    3541     } else {
     3467     } else {
    35423468        if {[string first "*" $res] == -1} {
    35433469            MyMessageBox -parent . -title "No updates" \
    3544                 -message "GSAS/EXPGUI appears up-to-date" \
     3470                -message "GSAS & EXPGUI appear up-to-date" \
    35453471                -icon info
    35463472            return
    35473473        }
    35483474    }
     3475
    35493476    if {[MyMessageBox -parent . -title "Ready to Update" \
    35503477             -message {
    3551 Updates to GSAS/EXPGUI found.
     3478Updates to GSAS/EXPGUI found on server.
    35523479                 
    35533480Press the "Update & Restart" button to begin the update process. After the update completes, EXPGUI will be restarted.} \
     
    35593486    # special upgrade for windows, where the wish exec blocks upgrade of the exe directory
    35603487    if {$::tcl_platform(platform) == "windows" && $::tcl_platform(os) != "Windows 95"} {
     3488        if {![file exists [file join $::expgui(gsasdir) update.bat]]} {
     3489            MyMessageBox -parent . -title "No update.bat" \
     3490                -message "File update.bat was not found. This should not happen. Will try to create it now."
     3491            set fp [open [file join $::expgui(gsasdir) update.bat] w]
     3492            puts $fp {@REM this script must be run from the GSAS installation directory
     3493@REM This is run to update the installation, the name of the EXP file is
     3494@REM expected as an argument
     3495@echo ****************************
     3496@echo Press return to start update
     3497@echo ****************************
     3498@pause
     3499.\svn\bin\svn cleanup .
     3500.\svn\bin\svn update .
     3501@if (%1)==() goto Install2
     3502@echo ****************************************************
     3503@echo Update has completed. Press return to restart EXPGUI
     3504@echo ****************************************************
     3505@pause
     3506%COMSPEC% /c "start exe\ncnrpack.exe expgui\expgui %1"
     3507exit
     3508:Install2
     3509@echo ****************************************************
     3510@echo Update has completed. EXPGUI starting w/o .EXP file
     3511@echo ****************************************************
     3512@pause
     3513%COMSPEC% /c "start exe\ncnrpack.exe expgui\expgui"
     3514exit
     3515            }
     3516            close $fp
     3517        }
    35613518        # split the directory and EXP file and get rid os spaces in the directory name
    35623519        set exp [file normalize $::expgui(expfile)]
     
    35693526
    35703527    # do a quiet cleanup. Sometimes needed after install, and never hurts
    3571     if [catch {set res [exec $SVN cleanup $::expgui(gsasdir)]} err] {
     3528    if [catch {set res [eval exec $SVN cleanup [list $::expgui(gsasdir)]]} err] {
    35723529        MyMessageBox -parent . -title "Error in cleanup" \
    35733530            -message "Error performing cleanup. Will try to continue anyway. Error:\n$err" \
Note: See TracChangeset for help on using the changeset viewer.