Changeset 6320 for branches


Ignore:
Timestamp:
May 11, 2016, 9:56:24 AM (8 years ago)
Author:
gah
Message:

fixes for sharing simulations w/ url

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.6/gui/scripts/analyzer.tcl

    r6294 r6320  
    217217    buildMenu $itk_component(help).menu $url $_appName
    218218   
    219     if 0 {
    220         # To be eliminated with menu changes.
    221     itk_component add about {
    222         button $itk_component(hubcntls).about \
    223             -text "About this tool" \
    224             -command [list Rappture::filexfer::webpage \
    225                           "$url/tools/$_appName"]
    226     } {
    227         usual
    228         ignore -font
    229         rename -background -simcontrolcolor simControlColor Color
    230         rename -highlightbackground -simcontrolcolor simControlColor Color
    231     }
    232     pack $itk_component(about) -side top -anchor w
    233    
    234     itk_component add questions {
    235         button $itk_component(hubcntls).questions -text Questions? \
    236             -command [list Rappture::filexfer::webpage \
    237                           "$url/resources/$_appName/questions"]
    238     } {
    239         usual
    240         ignore -font
    241         rename -background -simcontrolcolor simControlColor Color
    242         rename -highlightbackground -simcontrolcolor simControlColor Color
    243     }
    244     pack $itk_component(questions) -side top -anchor w
    245     if { $url == "" || $_appName == "" } {
    246         $itk_component(questions) configure -state disabled
    247         $itk_component(about) configure -state disabled
    248     } else {
    249         $itk_component(questions) configure -state normal
    250         $itk_component(about) configure -state normal
    251     }       
    252     }
    253219    itk_component add simstatus {
    254220        text $itk_component(simbg).simstatus -borderwidth 0 \
     
    481447        # check to see if simulation is really needed
    482448        $_tool sync
    483         if {[$_resultset contains [$_tool xml object]]
    484               && ![string equal $_control "manual-resim"]} {
     449        if {[$_resultset contains [$_tool xml object]] &&
     450            ![string equal $_control "manual-resim"]} {
    485451            # not needed -- show results and return
    486452            $itk_component(notebook) current analyze
     
    573539    # check to see if simulation is really needed
    574540    $_tool sync
    575     if {![$_resultset contains [$_tool xml object]]
    576           || [string equal $_control "manual-resim"]} {
     541    if {![$_resultset contains [$_tool xml object]] ||
     542        [string equal $_control "manual-resim"]} {
    577543        # if control mode is "auto", then simulate right away
    578544        if {[string match auto* $_control]} {
     
    11621128    # Scan through and pick out any =RAPPTURE-PROGRESS=> messages first.
    11631129    #
    1164 
    1165     while {[regexp -indices \
    1166                {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \
    1167                 match percent mesg]} {
     1130    set pattern {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)}
     1131    while {[regexp -indices $pattern $message match percent mesg]} {
    11681132
    11691133        foreach {i0 i1} $percent break
     
    12071171    #
    12081172    $itk_component(runinfo) configure -state normal
    1209 
    1210     while {[regexp -indices \
    1211                {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)} $message \
    1212                 match type mesg]} {
    1213 
     1173    set pattern {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)}
     1174    while {[regexp -indices $pattern $message match type mesg]} {
    12141175        foreach {i0 i1} $match break
    12151176        set first [string range $message 0 [expr {$i0-1}]]
     
    12541215    set name [$itk_component(viewselector) value]
    12551216    if {[info exists _label2desc($name)] &&
    1256          [string length $_label2desc($name)] > 0} {
     1217        [string length $_label2desc($name)] > 0} {
    12571218        append tip "$_label2desc($name)\n\n"
    12581219    }
     
    15211482            }
    15221483            continue
    1523         }
    1524         if 0 {
    1525         # Recurse over all child nodes.
    1526         _trajToSequence $xmlobj $current
    15271484        }
    15281485    }
     
    16921649itcl::body Rappture::Analyzer::SelectSimsetNameAndSave {} {
    16931650    if { [EditSimset] } {
    1694         set appDir [file normalize ~/data/saved/$_appName]
    1695         file mkdir $appDir
    1696         set fileName [file join $appDir [CleanName $_saved(Name).sav]]
     1651        set name [CleanName $_saved(Name)]
     1652        set saveDir [file join ~/data/saved $_appName $name]
     1653        set saveDir [file normalize $saveDir]
     1654        file mkdir $saveDir
     1655        set fileName [file join $saveDir $name.sav]
    16971656        if { [file exists $fileName] } {
    16981657            if { ![OverwriteSaveFile] } {
     
    17121671    if { [GetSimset "share"] } {
    17131672        global env
    1714         set shareDir [file join /data/tools/shared $_appName $env(USER)]
     1673        set name [CleanName $_saved(Name)]
     1674        set shareDir [file join /data/tools/shared $env(USER) $_appName $name]
    17151675        if { [catch {
    17161676            CreateSharedPath $shareDir
     
    17191679            return
    17201680        }
    1721         set fileName [file join $shareDir [CleanName $_saved(Name).sav]]
     1681        set fileName [file join $shareDir $name.sav]
    17221682        if { [file exists $fileName] } {
    17231683            if { ![OverwriteSaveFile] } {
     
    17261686        }
    17271687        WriteSimsetFile $_appName $fileName 1
    1728         ExportURL $_appName $sharedir
     1688        ExportURL $_appName $shareDir
    17291689    }
    17301690}
     
    17921752    array unset _saved
    17931753    array set _saved [$_tree get $node]
    1794     set root [file root $_saved(FileName)]
     1754    set saveDir [file dirname $_saved(FileName)]
    17951755    set files {}
    17961756    foreach file $_saved(Files) {
    17971757        if { [file pathtype $file] == "relative" } {
    1798             set file [file join $root $file]
     1758            set file [file join $saveDir $file]
    17991759        }
    18001760        lappend files $file
     
    18071767# WriteSimsetFile --
    18081768#
    1809 #       Write the .sav file and the runfiles in the ~/data/saved/$_appName
    1810 #       directory.  The subdirectory where the runfiles are written is
    1811 #       the root of the .save file name.
     1769#       Write the .sav file and the runfiles in the
     1770#            ~/data/saved/$_appName/$name
     1771#       directory. 
     1772# The run files will be in the same directory as the .sav file. 
     1773# For example, if the simset file is /path/to/appName/myName/myName.sav,
     1774# the runfile directory is /path/to/appName/myName.
    18121775#
    18131776itcl::body Rappture::Analyzer::WriteSimsetFile { appName fileName share } {
    1814     # The runfiles directory is the root of the filename.  For example, if
    1815     # the simset file is /path/to/myName.sav, the runfile directory is
    1816     # /path/to/myName
    1817     set root [file root $fileName]
    1818     if { [file exists $root] } {
    1819         file delete -force $root
     1777    set saveDir [file dirname $fileName]
     1778    if { [file exists $saveDir] } {
     1779        file delete -force $saveDir
    18201780    }
    18211781    if { [catch {
    18221782        if { $share } {
    1823             CreateSharedPath $root
     1783            CreateSharedPath $saveDir
    18241784        } else {
    1825             file mkdir $root
     1785            file mkdir $saveDir
    18261786        }
    18271787        set f [open $fileName "w"]
     
    18361796        foreach file $_saved(Files) {
    18371797            set tail [file tail $file]
    1838             set dest [file join $root $tail]
     1798            set dest [file join $saveDir $tail]
    18391799            if { $share } {
    1840                 InstallSharedFile $dest $file
     1800                InstallSharedFile $saveDir $file
    18411801            } else {
    18421802                file copy -force $file $dest
     
    18631823    Rappture::Balloon $popup -title "Save set of simulations..."
    18641824    set inner [$popup component inner]
    1865    
     1825
    18661826    label $inner.name_l -text "Simulation Set Name"
    18671827    entry $inner.name -background white
     
    19281888        return 0
    19291889    }
    1930     set root [file root $fileName]
     1890    set saveDir [file dirname $fileName]
    19311891    foreach file $_saved(Files) {
    19321892        if { [file pathtype $file] == "relative" } {
    1933             set file [file join $root $file]
     1893            set file [file join $saveDir $file]
    19341894        }
    19351895        if { ![file readable $file] } {
     
    19521912itcl::body Rappture::Analyzer::LoadSimulations { files } {
    19531913    set loadobjs {}
    1954     set root [file root $_saved(FileName)]
     1914    set saveDir [file dirname $_saved(FileName)]
    19551915    foreach runfile $files {
    19561916        if { [file pathtype $runfile] == "relative" } {
    1957             set runfile [file join $root $runfile]
     1917            set runfile [file join $saveDir $runfile]
    19581918        }
    19591919        if { ![file exists $runfile] } {
     
    19731933    $win.pager current analyzer
    19741934    $win.pager configure -nosim 0
    1975    if 0 {
    1976     # Load the inputs for the very last run
    1977     global tool
    1978     $tool load $runobj
    1979 }
    19801935}
    19811936
     
    19881943    }
    19891944    if { [GetSimset "delete"] } {
    1990         set root [file root $_saved(FileName)]
    1991         file delete -force $root
    1992         file delete -force $_saved(FileName)
     1945        set saveDir [file dirname $_saved(FileName)]
     1946        file delete -force $saveDir
    19931947    }
    19941948}
     
    19981952#
    19991953itcl::body Rappture::Analyzer::FindSimsetsForApp { appName } {
     1954    if { $appName == "" } {
     1955        puts stderr "No application name found"
     1956        return 0
     1957    }
    20001958    $_tree delete 0
    2001     foreach fileName [glob -nocomplain ~/data/saved/$appName/*.sav] {
     1959    foreach fileName [glob -nocomplain ~/data/saved/$appName/*/*.sav] {
    20021960        if { [ReadSimsetFile $fileName] } {
    20031961            if { $_revision > 0 && [info exists _saved(Revision)] &&
     
    20341992    scrollbar $inner.ys -orient vertical -command "$tv yview"
    20351993    frame $inner.controls
    2036        
     1994   
    20371995    $tv column insert end "Name" "Description" "Date" "Creator"
    20381996    $tv column configure treeView -hide yes
     
    21062064    # Create the print dialog widget and add it to the the balloon popup.
    21072065    label $popup.title -text " " \
    2108         -padx 10 -pady 10 \
    2109         -background grey92
     2066        -padx 10 -pady 10 \
     2067        -background grey92
    21102068    button $popup.yes -text "Yes" \
    2111         -highlightthickness 0 \
    2112         -bd 2  \
    2113         -command [itcl::code $this Save]
     2069        -highlightthickness 0 \
     2070        -bd 2  \
     2071        -command [itcl::code $this Save]
    21142072    button $popup.no -text "No" \
    2115         -highlightthickness 0 \
    2116         -bd 2 \
    2117         -command [itcl::code $this Cancel]
     2073        -highlightthickness 0 \
     2074        -bd 2 \
     2075        -command [itcl::code $this Cancel]
    21182076    blt::table $popup \
    2119         0,0 $popup.title -cspan 2  -fill x -pady 4 \
    2120         1,0 $popup.yes -width { 0 1i .6i } -pady 4 \
    2121         1,1 $popup.no -width { 0 1i .6i }  -pady 4
     2077        0,0 $popup.title -cspan 2  -fill x -pady 4 \
     2078        1,0 $popup.yes -width { 0 1i .6i } -pady 4 \
     2079        1,1 $popup.no -width { 0 1i .6i }  -pady 4
    21222080    blt::table configure $popup  r2 -height 0.125i
    21232081}
     
    21302088    set popup .question
    21312089    if { ![winfo exists $popup] } {
    2132         BuildQuestionDialog $popup
     2090        BuildQuestionDialog $popup
    21332091    }
    21342092    set text "Simulation set \"$_saved(Name)\" already exists. Overwrite?"
     
    21682126    set dir ""
    21692127    foreach file [file split $path] {
    2170         set dir [file join $dir $file]
    2171         if { [file exists $dir] } {
    2172             if { ![file isdirectory $dir] } {
    2173                 error "error in path \"$path\": \"$dir\" is not a directory."
    2174             }
    2175         } else {
    2176             file mkdir $dir
    2177             file attributes $dir -permissions g+rwx,o+rx
    2178         }
     2128        set dir [file join $dir $file]
     2129        if { [file exists $dir] } {
     2130            if { ![file isdirectory $dir] } {
     2131                error "error in path \"$path\": \"$dir\" is not a directory."
     2132            }
     2133        } else {
     2134            file mkdir $dir
     2135            file attributes $dir -permissions g+rwx,o+rx
     2136        }
    21792137    }
    21802138}
     
    21842142    set name [file tail $installdir]
    21852143    set f [open $fileName "w"]
    2186     puts $f "https://nanohub.org/tools/$appName/invoke?params=file(simset):$installdir/$name.sho\n"
     2144    puts $f "https://nanohub.org/tools/$appName/invoke?params=file(simset):$installdir/$name.sav\n"
    21872145    close $f
    21882146    file attributes $fileName -permissions g+rw,o+r
    21892147    if { [file exists /usr/bin/exportfile] } {
    2190         puts stderr installdir=$::Rappture::installdir
    2191         set msgFile [file join $::Rappture::installdir export.html]
    2192         ExportFile $fileName $msgFile
     2148        set msgFile [file join $::Rappture::installdir export.html]
     2149        ExportFile $fileName $msgFile
    21932150    }
    21942151}
    21952152
    21962153itcl::body Rappture::Analyzer::ExportFile { src msgFile } {
    2197     set dstdir ~/.rappture/exportfile
     2154    set dstdir ~/.filexfer/exportfile
    21982155    file mkdir $dstdir
    21992156    set dst [file join $dstdir [file tail $src]]
    22002157    if { [file exists $dst] } {
    2201         puts stderr "could be a problem: already waiting to export $dst"
     2158        puts stderr "could be a problem: already waiting to export $dst"
    22022159    }
    22032160    file copy -force $src $dst
    22042161    # Now export the file.
    22052162    if { [catch {
    2206         global exportFileVar
    2207         set exportFileVar 0;            # Kill any previous export.
    2208         set mesg "Select file to export to desktop/laptop"
    2209         update
    2210         set cmd "/usr/bin/exportfile -d $dst "
     2163        global exportFileVar
     2164        set exportFileVar 0;            # Kill any previous export.
     2165        set mesg "Select file to export to desktop/laptop"
     2166        update
     2167        set cmd "/usr/bin/exportfile --delete $dst --timeout 3 "
    22112168        if { [file exists $msgFile] } {
    2212             append cmd "-m $msgFile"
    2213         }
    2214         blt::bgexec exportFileVar /bin/sh -c $cmd &
     2169            append cmd "--message $msgFile"
     2170        }
     2171        blt::bgexec exportFileVar /bin/sh -c $cmd &
    22152172    } errs]  != 0 } {
    2216         global errorInfo
    2217         puts stderr "err: $errorInfo"
    2218         file delete -force $dst
    2219     }
    2220 }
    2221 
     2173        global errorInfo
     2174        puts stderr "err: $errorInfo"
     2175        file delete -force $dst
     2176    }
     2177}
     2178
Note: See TracChangeset for help on using the changeset viewer.