Changeset 724 for trunk/gui/scripts/bugreport.tcl
- Timestamp:
- May 10, 2007 7:53:32 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/bugreport.tcl
r676 r724 11 11 # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 12 12 # ====================================================================== 13 14 13 option add *BugReport*banner*foreground white startupFile 15 14 option add *BugReport*banner*background #a9a9a9 startupFile … … 17 16 option add *BugReport*banner*font \ 18 17 -*-helvetica-bold-r-normal-*-18-* startupFile 18 option add *BugReport*Label.font \ 19 -*-helvetica-medium-r-normal-*-12-* startupFile 20 option add *BugReport*xmit*wrapLength 3i startupFile 21 option add *BugReport*expl.width 50 startupFile 19 22 option add *BugReport*expl.font \ 20 23 -*-helvetica-medium-r-normal-*-12-* startupFile 21 option add *BugReport*expl.wrapLength 3i startupFile 24 option add *BugReport*expl.boldFont \ 25 -*-helvetica-bold-r-normal-*-12-* startupFile 22 26 23 27 namespace eval Rappture::bugreport { # forward declaration } … … 42 46 # ---------------------------------------------------------------------- 43 47 proc Rappture::bugreport::activate {err} { 44 global errorInfo 48 global env errorInfo 49 50 if {"@SHOWDETAILS" == $err} { 51 pack forget .bugreport.xmit 52 pack forget .bugreport.ok 53 pack .bugreport.details -after .bugreport.banner \ 54 -expand yes -fill both -padx 8 -pady 8 55 focus .bugreport.details.cntls.ok 56 return 57 } 58 59 # always fill in details so we can submit trouble reports later 60 .bugreport.details.info.text configure -state normal 61 .bugreport.details.info.text delete 1.0 end 62 .bugreport.details.info.text insert end "$err\n-----\n$errorInfo" 63 .bugreport.details.info.text configure -state disabled 64 65 if {[info exists env(RAPPTURE_VERSION)] 66 && $env(RAPPTURE_VERSION) == "current"} { 67 pack forget .bugreport.details 68 pack forget .bugreport.expl 69 pack .bugreport.ok -side bottom -after .bugreport.banner -pady {0 8} 70 pack .bugreport.xmit -after .bugreport.ok -padx 8 -pady 8 71 focus .bugreport.ok 72 set dosubmit 1 73 } else { 74 pack forget .bugreport.expl 75 pack forget .bugreport.xmit 76 pack forget .bugreport.ok 77 pack .bugreport.details -after .bugreport.banner \ 78 -expand yes -fill both -padx 8 -pady 8 79 focus .bugreport.details.cntls.ok 80 set dosubmit 0 81 } 82 83 if {[Rappture::filexfer::enabled]} { 84 .bugreport.details.cntls.dload configure -state normal 85 } else { 86 .bugreport.details.cntls.dload configure -state disabled 87 } 45 88 46 89 set w [winfo reqwidth .bugreport] … … 53 96 raise .bugreport 54 97 55 .bugreport.details.text configure -state normal56 .bugreport.details.text delete 1.0 end57 .bugreport.details.text insert end "$err\n-----\n$errorInfo"58 .bugreport.details.text configure -state disabled59 # should log the error someday too...60 61 98 catch {grab set .bugreport} 99 update 100 101 if {$dosubmit} { 102 submit 103 } 62 104 } 63 105 … … 76 118 77 119 # ---------------------------------------------------------------------- 78 # USAGE: submit <stackTrace> 79 # 80 # Clients use this to send bug reports back to the hub site. Errors 81 # are posted to a URL that creates a support ticket. 82 # ---------------------------------------------------------------------- 83 proc Rappture::bugreport::submit {stackTrace} { 84 global tcl_platform 120 # USAGE: submit 121 # 122 # Takes details currently stored in the panel and registers them 123 # as a support ticket on the hosting hub site. Pops up a panel 124 # during the process and informs the user of the result. 125 # ---------------------------------------------------------------------- 126 proc Rappture::bugreport::submit {} { 127 set info [.bugreport.details.info.text get 1.0 end] 128 129 pack forget .bugreport.details 130 pack .bugreport.ok -side bottom -after .bugreport.banner -pady {0 8} 131 pack .bugreport.xmit -after .bugreport.ok -padx 8 -pady 8 132 .bugreport.xmit.title configure -text "Sending trouble report to [Rappture::Tool::resources -hubname]..." 133 focus .bugreport.ok 134 135 # send off the trouble report... 136 .bugreport.xmit.icon start 137 set status [catch {register $info} result] 138 .bugreport.xmit.icon stop 139 140 pack forget .bugreport.xmit 141 pack .bugreport.expl -after .bugreport.ok -padx 8 -pady 8 142 .bugreport.expl configure -state normal 143 .bugreport.expl delete 1.0 end 144 145 # handle the result 146 if {$status != 0} { 147 # add error to the details field, so we can see it with magic clicks 148 .bugreport.details.info.text configure -state normal 149 .bugreport.details.info.text insert 1.0 "Ticket submission failed:\n$result\n-----\n" 150 .bugreport.details.info.text configure -state disabled 151 152 .bugreport.expl insert end "This tool encountered an unexpected error. We tried to submit a trouble report automatically, but that failed. If you want to report this incident, you can file your own trouble report. Look for the \"Help\" or \"Support\" links on the main navigation bar of the web site.\n\nIf you continue having trouble with this tool, please close it and launch another session." 153 } elseif {[regexp {Ticket #([0-9]+) +\((.*?)\) +([0-9]+) +times} $result match ticket extra times]} { 154 .bugreport.expl insert end "This tool encountered an unexpected error. The problem has been reported as " "" "Ticket #$ticket" bold " in our system." "" 155 if {[string is integer $times] && $times > 1} { 156 .bugreport.expl insert end " This particular problem has been reported $times times." 157 } 158 .bugreport.expl insert end "\n\nIf you continue having trouble with this tool, please close it and launch another session." 159 } else { 160 .bugreport.expl insert end "This tool encountered an unexpected error, and the problem was reported. Here is the response from the hub, which may contain information about your ticket:\n" "" $result bold "\n\nIf you continue having trouble with this tool, please close it and launch another session." "" 161 } 162 for {set h 1} {$h < 50} {incr h} { 163 .bugreport.expl configure -height $h 164 .bugreport.expl see 1.0 165 update idletasks 166 if {"" != [.bugreport.expl bbox end-1char]} { 167 break 168 } 169 } 170 .bugreport.expl configure -state disabled 171 } 172 173 # ---------------------------------------------------------------------- 174 # USAGE: download 175 # 176 # Used to download the current ticket information to the user's 177 # desktop. 178 # ---------------------------------------------------------------------- 179 proc Rappture::bugreport::download {} { 180 if {[Rappture::filexfer::enabled]} { 181 set info [.bugreport.details.info.text get 1.0 end] 182 Rappture::filexfer::download $info bugreport.txt 183 } 184 } 185 186 # ---------------------------------------------------------------------- 187 # USAGE: register <stackTrace> 188 # 189 # Low-level function used to send bug reports back to the hub site. 190 # Error details in the <stackTrace> are posted to a URL that creates 191 # a support ticket. Returns a string of the following form, 192 # representing details about the new or existing ticket: 193 # Ticket #XX (XXXXXX) XX times 194 # ---------------------------------------------------------------------- 195 proc Rappture::bugreport::register {stackTrace} { 196 global env tcl_platform 197 198 # if this is a test version, do nothing 199 if {![info exists env(RAPPTURE_VERSION)] 200 || $env(RAPPTURE_VERSION) != "current"} { 201 return 202 } 85 203 86 204 package require http … … 98 216 set summary "[string range $summary 0 50]..." 99 217 } 100 append summary " (in tool \"[Rappture::Tool::get -name]\")" 218 append summary " (in tool \"[Rappture::Tool::resources -appname]\")" 219 220 # make sure that the stack trace isn't too long 221 if {[string length $stackTrace] > 20000} { 222 set stackTrace "[string range $stackTrace 0 20000]..." 223 } 101 224 102 225 set query [http::formatQuery \ … … 104 227 task create \ 105 228 no_html 1 \ 106 report $stackTrace 229 report $stackTrace \ 107 230 login $tcl_platform(user) \ 108 email ""\231 session [Rappture::Tool::resources -session] \ 109 232 hostname [info hostname] \ 110 233 category rappture \ 111 234 summary $summary \ 112 referrer "tool \"[Rappture::Tool:: get -name]\"" \235 referrer "tool \"[Rappture::Tool::resources -appname]\"" \ 113 236 ] 114 115 puts "avoid hard-coded web site URL!" 116 set url https://zooley.nanohub.org/index2.php 117 set token [http::geturl $url -query $query] 118 119 if {[http::ncode] != 200} { 120 error [http::code] 237 238 set url [Rappture::Tool::resources -huburl] 239 if {[string index $url end] == "/"} { 240 append url "index2.php" 241 } else { 242 append url "/index2.php" 243 } 244 245 set token [http::geturl $url -query $query -timeout 60000] 246 247 if {[http::ncode $token] != 200} { 248 error [http::code $token] 121 249 } 122 250 upvar #0 $token rval 123 if {[regexp {Ticket #[0-9]+ \( (.*:?)\) [0-9]+ times} $rval(body) match]} {251 if {[regexp {Ticket #[0-9]+ \(.*?\) [0-9]+ times} $rval(body) match]} { 124 252 return $match 125 253 } … … 141 269 pack .bugreport.banner.title -side left -padx {0 8} -pady 2 142 270 143 button .bugreport.ok -text "OK" -command Rappture::bugreport::deactivate 271 # add these frustration bindings in case the "Dismiss" button is off screen 272 bind .bugreport.banner.icon <Double-ButtonPress-1> \ 273 Rappture::bugreport::deactivate 274 bind .bugreport.banner.title <Double-ButtonPress-1> \ 275 Rappture::bugreport::deactivate 276 277 button .bugreport.ok -text "Dismiss" -command Rappture::bugreport::deactivate 144 278 pack .bugreport.ok -side bottom -pady {0 8} 145 279 146 label .bugreport.expl -text "You've found a bug in this application.\n\nIf it's not a serious bug, you may be able to continue using the tool. But if the tool doesn't seem to behave properly after this, please close this session and start the tool again.\n\nYou can help us improve nanoHUB by reporting this error. Click on the \"Report Problems\" link in the web page containing this tool session, and tell us what you were doing when the error occurred." -justify left 147 pack .bugreport.expl -padx 8 -pady 8 280 frame .bugreport.xmit 281 Rappture::Animicon .bugreport.xmit.icon -images { 282 circle-ball1 circle-ball2 circle-ball3 circle-ball4 283 circle-ball5 circle-ball6 circle-ball7 circle-ball8 284 } 285 pack .bugreport.xmit.icon -side left 286 label .bugreport.xmit.title -anchor w 287 pack .bugreport.xmit.title -side left -expand yes -fill x 288 289 text .bugreport.expl -borderwidth 0 -highlightthickness 0 -wrap word 290 .bugreport.expl tag configure bold \ 291 -font [option get .bugreport.expl boldFont Font] 148 292 149 293 bind .bugreport.expl <Control-1><Control-1><Control-3><Control-3> { 150 pack forget .bugreport.expl 151 pack .bugreport.details -after .bugreport.ok \ 152 -expand yes -fill both -padx 8 -pady 8 294 Rappture::bugreport::activate @SHOWDETAILS 153 295 } 154 296 155 297 bind .bugreport.expl <Control-1><Control-1><Control-Shift-1><Control-Shift-1> { 156 pack forget .bugreport.expl 157 pack .bugreport.details -after .bugreport.ok \ 158 -expand yes -fill both -padx 8 -pady 8 159 } 160 161 Rappture::Scroller .bugreport.details -xscrollmode auto -yscrollmode auto 162 text .bugreport.details.text -wrap none 163 .bugreport.details contents .bugreport.details.text 298 Rappture::bugreport::activate @SHOWDETAILS 299 } 300 301 frame .bugreport.details 302 frame .bugreport.details.cntls 303 pack .bugreport.details.cntls -side bottom -fill x 304 button .bugreport.details.cntls.ok -text "Dismiss" -command { 305 Rappture::bugreport::deactivate 306 } 307 pack .bugreport.details.cntls.ok -side right -padx 2 -pady 4 308 button .bugreport.details.cntls.send -text "Send Trouble Report" -command { 309 Rappture::bugreport::submit 310 } 311 pack .bugreport.details.cntls.send -side left -padx 2 -pady 4 312 button .bugreport.details.cntls.dload -text "Download" -command { 313 Rappture::bugreport::download 314 } 315 pack .bugreport.details.cntls.dload -side left -padx 2 -pady 4 316 317 Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto 318 text .bugreport.details.info.text -width 50 -height 15 -wrap none 319 .bugreport.details.info contents .bugreport.details.info.text 320 pack .bugreport.details.info -expand yes -fill both 164 321 165 322 # this binding keeps the bugreport window on top
Note: See TracChangeset
for help on using the changeset viewer.