Changeset 6320
- Timestamp:
- May 11, 2016, 9:56:24 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.6/gui/scripts/analyzer.tcl
r6294 r6320 217 217 buildMenu $itk_component(help).menu $url $_appName 218 218 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 usual228 ignore -font229 rename -background -simcontrolcolor simControlColor Color230 rename -highlightbackground -simcontrolcolor simControlColor Color231 }232 pack $itk_component(about) -side top -anchor w233 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 usual240 ignore -font241 rename -background -simcontrolcolor simControlColor Color242 rename -highlightbackground -simcontrolcolor simControlColor Color243 }244 pack $itk_component(questions) -side top -anchor w245 if { $url == "" || $_appName == "" } {246 $itk_component(questions) configure -state disabled247 $itk_component(about) configure -state disabled248 } else {249 $itk_component(questions) configure -state normal250 $itk_component(about) configure -state normal251 }252 }253 219 itk_component add simstatus { 254 220 text $itk_component(simbg).simstatus -borderwidth 0 \ … … 481 447 # check to see if simulation is really needed 482 448 $_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"]} { 485 451 # not needed -- show results and return 486 452 $itk_component(notebook) current analyze … … 573 539 # check to see if simulation is really needed 574 540 $_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"]} { 577 543 # if control mode is "auto", then simulate right away 578 544 if {[string match auto* $_control]} { … … 1162 1128 # Scan through and pick out any =RAPPTURE-PROGRESS=> messages first. 1163 1129 # 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]} { 1168 1132 1169 1133 foreach {i0 i1} $percent break … … 1207 1171 # 1208 1172 $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]} { 1214 1175 foreach {i0 i1} $match break 1215 1176 set first [string range $message 0 [expr {$i0-1}]] … … 1254 1215 set name [$itk_component(viewselector) value] 1255 1216 if {[info exists _label2desc($name)] && 1256 1217 [string length $_label2desc($name)] > 0} { 1257 1218 append tip "$_label2desc($name)\n\n" 1258 1219 } … … 1521 1482 } 1522 1483 continue 1523 }1524 if 0 {1525 # Recurse over all child nodes.1526 _trajToSequence $xmlobj $current1527 1484 } 1528 1485 } … … 1692 1649 itcl::body Rappture::Analyzer::SelectSimsetNameAndSave {} { 1693 1650 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] 1697 1656 if { [file exists $fileName] } { 1698 1657 if { ![OverwriteSaveFile] } { … … 1712 1671 if { [GetSimset "share"] } { 1713 1672 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] 1715 1675 if { [catch { 1716 1676 CreateSharedPath $shareDir … … 1719 1679 return 1720 1680 } 1721 set fileName [file join $shareDir [CleanName $_saved(Name).sav]]1681 set fileName [file join $shareDir $name.sav] 1722 1682 if { [file exists $fileName] } { 1723 1683 if { ![OverwriteSaveFile] } { … … 1726 1686 } 1727 1687 WriteSimsetFile $_appName $fileName 1 1728 ExportURL $_appName $share dir1688 ExportURL $_appName $shareDir 1729 1689 } 1730 1690 } … … 1792 1752 array unset _saved 1793 1753 array set _saved [$_tree get $node] 1794 set root [file root$_saved(FileName)]1754 set saveDir [file dirname $_saved(FileName)] 1795 1755 set files {} 1796 1756 foreach file $_saved(Files) { 1797 1757 if { [file pathtype $file] == "relative" } { 1798 set file [file join $ root$file]1758 set file [file join $saveDir $file] 1799 1759 } 1800 1760 lappend files $file … … 1807 1767 # WriteSimsetFile -- 1808 1768 # 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. 1812 1775 # 1813 1776 itcl::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 1820 1780 } 1821 1781 if { [catch { 1822 1782 if { $share } { 1823 CreateSharedPath $ root1783 CreateSharedPath $saveDir 1824 1784 } else { 1825 file mkdir $ root1785 file mkdir $saveDir 1826 1786 } 1827 1787 set f [open $fileName "w"] … … 1836 1796 foreach file $_saved(Files) { 1837 1797 set tail [file tail $file] 1838 set dest [file join $ root$tail]1798 set dest [file join $saveDir $tail] 1839 1799 if { $share } { 1840 InstallSharedFile $ dest$file1800 InstallSharedFile $saveDir $file 1841 1801 } else { 1842 1802 file copy -force $file $dest … … 1863 1823 Rappture::Balloon $popup -title "Save set of simulations..." 1864 1824 set inner [$popup component inner] 1865 1825 1866 1826 label $inner.name_l -text "Simulation Set Name" 1867 1827 entry $inner.name -background white … … 1928 1888 return 0 1929 1889 } 1930 set root [file root$fileName]1890 set saveDir [file dirname $fileName] 1931 1891 foreach file $_saved(Files) { 1932 1892 if { [file pathtype $file] == "relative" } { 1933 set file [file join $ root$file]1893 set file [file join $saveDir $file] 1934 1894 } 1935 1895 if { ![file readable $file] } { … … 1952 1912 itcl::body Rappture::Analyzer::LoadSimulations { files } { 1953 1913 set loadobjs {} 1954 set root [file root$_saved(FileName)]1914 set saveDir [file dirname $_saved(FileName)] 1955 1915 foreach runfile $files { 1956 1916 if { [file pathtype $runfile] == "relative" } { 1957 set runfile [file join $ root$runfile]1917 set runfile [file join $saveDir $runfile] 1958 1918 } 1959 1919 if { ![file exists $runfile] } { … … 1973 1933 $win.pager current analyzer 1974 1934 $win.pager configure -nosim 0 1975 if 0 {1976 # Load the inputs for the very last run1977 global tool1978 $tool load $runobj1979 }1980 1935 } 1981 1936 … … 1988 1943 } 1989 1944 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 1993 1947 } 1994 1948 } … … 1998 1952 # 1999 1953 itcl::body Rappture::Analyzer::FindSimsetsForApp { appName } { 1954 if { $appName == "" } { 1955 puts stderr "No application name found" 1956 return 0 1957 } 2000 1958 $_tree delete 0 2001 foreach fileName [glob -nocomplain ~/data/saved/$appName/* .sav] {1959 foreach fileName [glob -nocomplain ~/data/saved/$appName/*/*.sav] { 2002 1960 if { [ReadSimsetFile $fileName] } { 2003 1961 if { $_revision > 0 && [info exists _saved(Revision)] && … … 2034 1992 scrollbar $inner.ys -orient vertical -command "$tv yview" 2035 1993 frame $inner.controls 2036 1994 2037 1995 $tv column insert end "Name" "Description" "Date" "Creator" 2038 1996 $tv column configure treeView -hide yes … … 2106 2064 # Create the print dialog widget and add it to the the balloon popup. 2107 2065 label $popup.title -text " " \ 2108 2109 2066 -padx 10 -pady 10 \ 2067 -background grey92 2110 2068 button $popup.yes -text "Yes" \ 2111 2112 2113 2069 -highlightthickness 0 \ 2070 -bd 2 \ 2071 -command [itcl::code $this Save] 2114 2072 button $popup.no -text "No" \ 2115 2116 2117 2073 -highlightthickness 0 \ 2074 -bd 2 \ 2075 -command [itcl::code $this Cancel] 2118 2076 blt::table $popup \ 2119 2120 2121 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 2122 2080 blt::table configure $popup r2 -height 0.125i 2123 2081 } … … 2130 2088 set popup .question 2131 2089 if { ![winfo exists $popup] } { 2132 2090 BuildQuestionDialog $popup 2133 2091 } 2134 2092 set text "Simulation set \"$_saved(Name)\" already exists. Overwrite?" … … 2168 2126 set dir "" 2169 2127 foreach file [file split $path] { 2170 2171 2172 2173 2174 2175 2176 2177 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 } 2179 2137 } 2180 2138 } … … 2184 2142 set name [file tail $installdir] 2185 2143 set f [open $fileName "w"] 2186 puts $f "https://nanohub.org/tools/$appName/invoke?params=file(simset):$installdir/$name.s ho\n"2144 puts $f "https://nanohub.org/tools/$appName/invoke?params=file(simset):$installdir/$name.sav\n" 2187 2145 close $f 2188 2146 file attributes $fileName -permissions g+rw,o+r 2189 2147 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 2193 2150 } 2194 2151 } 2195 2152 2196 2153 itcl::body Rappture::Analyzer::ExportFile { src msgFile } { 2197 set dstdir ~/. rappture/exportfile2154 set dstdir ~/.filexfer/exportfile 2198 2155 file mkdir $dstdir 2199 2156 set dst [file join $dstdir [file tail $src]] 2200 2157 if { [file exists $dst] } { 2201 2158 puts stderr "could be a problem: already waiting to export $dst" 2202 2159 } 2203 2160 file copy -force $src $dst 2204 2161 # Now export the file. 2205 2162 if { [catch { 2206 2207 set exportFileVar 0;# Kill any previous export.2208 2209 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 " 2211 2168 if { [file exists $msgFile] } { 2212 append cmd "- m$msgFile"2213 } 2214 2169 append cmd "--message $msgFile" 2170 } 2171 blt::bgexec exportFileVar /bin/sh -c $cmd & 2215 2172 } errs] != 0 } { 2216 2217 2218 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.