Changeset 1861 for trunk/gui/scripts/bugreport.tcl
- Timestamp:
- Aug 14, 2010, 7:57:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/bugreport.tcl
r1342 r1861 26 26 27 27 namespace eval Rappture::bugreport { 28 # details from the current trouble report 29 variable details 30 28 31 # assume that if there's a problem launching a job, we should know it 29 32 variable reportJobFailures 1 … … 50 53 proc Rappture::bugreport::activate {err} { 51 54 global env errorInfo 55 variable details 52 56 53 57 if {"@SHOWDETAILS" == $err} { 58 pack propagate .bugreport yes 59 pack forget .bugreport.expl 54 60 pack forget .bugreport.xmit 55 pack forget .bugreport.ok 61 pack forget .bugreport.done 62 pack forget .bugreport.cntls.show 63 pack .bugreport.cntls -after .bugreport.banner -side bottom -fill x 56 64 pack .bugreport.details -after .bugreport.banner \ 57 65 -expand yes -fill both -padx 8 -pady 8 58 focus .bugreport.details.cntls.ok59 66 return 60 67 } 61 68 62 # always fill in details so we can submit trouble reports later 69 pack propagate .bugreport yes 70 pack forget .bugreport.details 71 pack forget .bugreport.xmit 72 pack forget .bugreport.done 73 pack .bugreport.cntls.show -side right 74 pack .bugreport.cntls -after .bugreport.banner -side bottom -fill x 75 pack .bugreport.expl -after .bugreport.banner \ 76 -expand yes -fill both -padx 8 -pady 8 77 78 .bugreport.expl configure -state normal 79 .bugreport.expl delete 1.0 end 80 81 set url [Rappture::Tool::resources -huburl] 82 if {"" != $url} { 83 .bugreport.expl insert end "Something went wrong with this tool. Help us understand what happened by submitting a trouble report, so we can fix the problem. If you continue having trouble with this tool, please close it and restart." 84 .bugreport.cntls.send configure -state normal 85 focus .bugreport.cntls.send 86 } else { 87 .bugreport.expl insert end "Something went wrong with this tool. We would ask you to submit a trouble report about the error, but we can't tell what hub it should be submitted to. If you continue having trouble with this tool, please close it and restart." 88 .bugreport.cntls.send configure -state disabled 89 focus .bugreport.cntls.ok 90 } 91 fixTextHeight .bugreport.expl 92 .bugreport.expl configure -state disabled 93 94 # gather details so we can submit trouble reports later 95 register $err 96 63 97 .bugreport.details.info.text configure -state normal 64 98 .bugreport.details.info.text delete 1.0 end 65 .bugreport.details.info.text insert end "$err\n-----\n$errorInfo" 99 .bugreport.details.info.text insert end " USER: $details(login)\n" 100 .bugreport.details.info.text insert end "HOSTNAME: $details(hostname)\n" 101 .bugreport.details.info.text insert end " TOOL: $details(referrer)\n" 102 .bugreport.details.info.text insert end " SESSION: $details(session)\n" 103 .bugreport.details.info.text insert end "CATEGORY: $details(category)\n" 104 .bugreport.details.info.text insert end " SUMMARY: $details(summary)\n" 105 .bugreport.details.info.text insert end "---------\n" 106 .bugreport.details.info.text insert end $details(stackTrace) 66 107 .bugreport.details.info.text configure -state disabled 67 68 if {[shouldReport for oops]} {69 pack forget .bugreport.details70 pack forget .bugreport.expl71 pack .bugreport.ok -side bottom -after .bugreport.banner -pady {0 8}72 pack .bugreport.xmit -after .bugreport.ok -padx 8 -pady 873 focus .bugreport.ok74 set dosubmit 175 } else {76 pack forget .bugreport.expl77 pack forget .bugreport.xmit78 pack forget .bugreport.ok79 pack .bugreport.details -after .bugreport.banner \80 -expand yes -fill both -padx 8 -pady 881 focus .bugreport.details.cntls.ok82 set dosubmit 083 }84 108 85 109 set w [winfo reqwidth .bugreport] … … 94 118 catch {grab set .bugreport} 95 119 update 96 97 if {$dosubmit} {98 submit99 }100 120 } 101 121 … … 123 143 set info [.bugreport.details.info.text get 1.0 end] 124 144 145 pack propagate .bugreport no 125 146 pack forget .bugreport.details 126 pack .bugreport.ok -side bottom -after .bugreport.banner -pady {0 8} 127 pack .bugreport.xmit -after .bugreport.ok -padx 8 -pady 8 147 pack forget .bugreport.expl 148 pack forget .bugreport.cntls 149 pack .bugreport.xmit -after .bugreport.banner -padx 8 -pady 8 128 150 .bugreport.xmit.title configure -text "Sending trouble report to [Rappture::Tool::resources -hubname]..." 129 focus .bugreport.ok130 151 131 152 # send off the trouble report... 132 153 .bugreport.xmit.icon start 133 set status [catch {register $info}result]154 set status [catch send result] 134 155 .bugreport.xmit.icon stop 135 156 157 pack propagate .bugreport yes 136 158 pack forget .bugreport.xmit 137 pack .bugreport.expl -after .bugreport. ok-padx 8 -pady 8159 pack .bugreport.expl -after .bugreport.banner -padx 8 -pady 8 138 160 .bugreport.expl configure -state normal 139 161 .bugreport.expl delete 1.0 end … … 146 168 .bugreport.details.info.text configure -state disabled 147 169 148 .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."170 .bugreport.expl insert end "Oops! Ticket submission failed:\n$result\n\nIf you want to report the original problem, you can file your own trouble report by going to the web site and clicking on the \"Help\" or \"Support\" link on the main navigation bar. If you continue having trouble with this tool, please close it and restart." 149 171 } elseif {[regexp {Ticket #([0-9]*) +\((.*?)\) +([0-9]+) +times} $result match ticket extra times]} { 150 .bugreport.expl insert end "This tool encountered an unexpected error. Theproblem has been reported as " "" "Ticket #$ticket" bold " in our system." ""172 .bugreport.expl insert end "This problem has been reported as " "" "Ticket #$ticket" bold " in our system." "" 151 173 if {[string is integer $times] && $times > 1} { 152 174 .bugreport.expl insert end " This particular problem has been reported $times times." 153 175 } 154 .bugreport.expl insert end "\n\nIf you continue having trouble with this tool, please close it and launch another session."176 .bugreport.expl insert end "\n\nIf you continue having trouble with this tool, please close it and restart. Thanks for reporting the problem and helping us improve things!" 155 177 } else { 156 .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." "" 157 } 158 for {set h 1} {$h < 50} {incr h} { 159 .bugreport.expl configure -height $h 160 .bugreport.expl see 1.0 161 update idletasks 162 if {"" != [.bugreport.expl bbox end-1char]} { 163 break 164 } 165 } 178 .bugreport.expl insert end "This problem has been 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 restart. Thanks for reporting the problem and helping us improve things!" "" 179 } 180 fixTextHeight .bugreport.expl 166 181 .bugreport.expl configure -state disabled 167 } 168 169 # ---------------------------------------------------------------------- 170 # USAGE: download 171 # 172 # Used to download the current ticket information to the user's 173 # desktop. 174 # ---------------------------------------------------------------------- 175 proc Rappture::bugreport::download {} { 176 set info [.bugreport.details.info.text get 1.0 end] 177 Rappture::filexfer::download $info bugreport.txt 178 } 179 180 # ---------------------------------------------------------------------- 181 # USAGE: register <stackTrace> 182 # 183 # Low-level function used to send bug reports back to the hub site. 184 # Error details in the <stackTrace> are posted to a URL that creates 185 # a support ticket. Returns a string of the following form, 186 # representing details about the new or existing ticket: 187 # Ticket #XX (XXXXXX) XX times 188 # ---------------------------------------------------------------------- 189 proc Rappture::bugreport::register {stackTrace} { 190 global env tcl_platform 191 192 package require http 193 package require tls 194 http::register https 443 ::tls::socket 195 182 pack .bugreport.done -side bottom -padx 8 -pady 8 183 focus .bugreport.done 184 } 185 186 # ---------------------------------------------------------------------- 187 # USAGE: register <err> 188 # 189 # Low-level function used to capture information about a bug report 190 # prior to calling "send", which actually sends the ticket. We usually 191 # let the user preview the information and decide whether or not to 192 # send the ticket. 193 # ---------------------------------------------------------------------- 194 proc Rappture::bugreport::register {err} { 195 global errorInfo tcl_platform 196 variable details 197 198 # 199 # Figure out exactly what we'll send if the bug report is 200 # submitted, so we can show the user. 201 # 202 set stackTrace "$err\n---------\n$errorInfo" 196 203 if {![regexp {^([^\n]+)\n} $stackTrace match summary]} { 197 204 if {[string length $stackTrace] == 0} { … … 246 253 } 247 254 255 set details(summary) $summary 256 set details(category) $category 257 set details(stackTrace) $stackTrace 258 set details(login) $tcl_platform(user) 259 set details(hostname) [info hostname] 260 set details(session) [Rappture::Tool::resources -session] 261 set details(referrer) "tool \"[Rappture::Tool::resources -appname]\"" 262 } 263 264 # ---------------------------------------------------------------------- 265 # USAGE: send 266 # 267 # Low-level function used to send bug reports back to the hub site. 268 # Error details gathered by a previous call to "register" are sent 269 # along as a support ticket. Returns a string of the following form, 270 # representing details about the new or existing ticket: 271 # Ticket #XX (XXXXXX) XX times 272 # ---------------------------------------------------------------------- 273 proc Rappture::bugreport::send {} { 274 variable details 275 276 package require http 277 package require tls 278 http::register https 443 ::tls::socket 279 248 280 set query [http::formatQuery \ 249 281 option com_support \ 250 282 task create \ 251 283 no_html 1 \ 252 report $ stackTrace\253 login $ tcl_platform(user) \254 sesstoken [Rappture::Tool::resources -session]\255 hostname [info hostname]\256 category $ category\257 summary $ summary\258 referrer "tool \"[Rappture::Tool::resources -appname]\""\284 report $details(stackTrace) \ 285 login $details(login) \ 286 sesstoken $details(session) \ 287 hostname $details(hostname) \ 288 category $details(category) \ 289 summary $details(summary) \ 290 referrer $details(referrer) \ 259 291 ] 260 292 … … 266 298 } 267 299 268 set token [http::geturl $url -query $query -timeout 60000] 269 270 if {[http::ncode $token] != 200} { 271 error [http::code $token] 272 } 273 upvar #0 $token rval 274 set info $rval(body) 275 http::cleanup $token 300 # set token [http::geturl $url -query $query -timeout 60000] 301 302 # if {[http::ncode $token] != 200} { 303 # error [http::code $token] 304 # } 305 # upvar #0 $token rval 306 # set info $rval(body) 307 # http::cleanup $token 308 set info "foo bar" 276 309 277 310 if {[regexp {Ticket #[0-9]* +\(.*?\) +[0-9]+ +times} $info match]} { … … 279 312 } 280 313 error "Report received, but ticket may not have been filed. Here's the result...\n$info" 314 } 315 316 # ---------------------------------------------------------------------- 317 # USAGE: fixTextHeight <widget> 318 # 319 # Used internally to adjust the height of a text widget so it is just 320 # tall enough to show the info within it. 321 # ---------------------------------------------------------------------- 322 proc Rappture::bugreport::fixTextHeight {widget} { 323 for {set h 1} {$h < 50} {incr h} { 324 $widget configure -height $h 325 $widget see 1.0 326 update idletasks 327 if {"" != [$widget bbox end-1char]} { 328 break 329 } 330 } 281 331 } 282 332 … … 304 354 } 305 355 for { 306 # is this a tool in production?307 if {![info exists env(RAPPTURE_VERSION)]308 || $env(RAPPTURE_VERSION) != "current"} {309 return 0310 }311 312 356 # is it being run within a workspace? 313 357 set appname [Rappture::Tool::resources -appname] … … 343 387 label .bugreport.banner.icon -image [Rappture::icon alert] 344 388 pack .bugreport.banner.icon -side left -padx 2 -pady 2 345 label .bugreport.banner.title -text "Oops! UnexpectedError"389 label .bugreport.banner.title -text "Oops! Internal Error" 346 390 pack .bugreport.banner.title -side left -padx {0 8} -pady 2 347 391 … … 352 396 Rappture::bugreport::deactivate 353 397 354 button .bugreport.ok -text "Dismiss" -command Rappture::bugreport::deactivate 355 pack .bugreport.ok -side bottom -pady {0 8} 398 text .bugreport.expl -borderwidth 0 -highlightthickness 0 -wrap word 399 .bugreport.expl tag configure bold \ 400 -font [option get .bugreport.expl boldFont Font] 401 402 frame .bugreport.cntls 403 pack .bugreport.cntls -side bottom -fill x 404 button .bugreport.cntls.ok -text "Ignore" -command { 405 Rappture::bugreport::deactivate 406 } 407 pack .bugreport.cntls.ok -side left -padx {4 20} -pady 8 408 button .bugreport.cntls.send -text "Send Trouble Report" -command { 409 Rappture::bugreport::submit 410 } 411 pack .bugreport.cntls.send -side right -padx 4 -pady 8 412 413 button .bugreport.cntls.show -text "Show Details..." \ 414 -command {Rappture::bugreport::activate @SHOWDETAILS} 415 pack .bugreport.cntls.show -side right 416 417 418 frame .bugreport.details 419 Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto 420 text .bugreport.details.info.text -width 50 -height 15 -wrap none 421 .bugreport.details.info contents .bugreport.details.info.text 422 pack .bugreport.details.info -expand yes -fill both 356 423 357 424 frame .bugreport.xmit … … 364 431 pack .bugreport.xmit.title -side left -expand yes -fill x 365 432 366 text .bugreport.expl -borderwidth 0 -highlightthickness 0 -wrap word 367 .bugreport.expl tag configure bold \ 368 -font [option get .bugreport.expl boldFont Font] 369 370 bind .bugreport.expl <Control-1><Control-1><Control-3><Control-3> { 371 Rappture::bugreport::activate @SHOWDETAILS 372 } 373 374 bind .bugreport.expl <Control-1><Control-1><Control-Shift-1><Control-Shift-1> { 375 Rappture::bugreport::activate @SHOWDETAILS 376 } 377 378 frame .bugreport.details 379 frame .bugreport.details.cntls 380 pack .bugreport.details.cntls -side bottom -fill x 381 button .bugreport.details.cntls.ok -text "Dismiss" -command { 382 Rappture::bugreport::deactivate 383 } 384 pack .bugreport.details.cntls.ok -side right -padx 2 -pady 4 385 button .bugreport.details.cntls.send -text "Send Trouble Report" -command { 386 Rappture::bugreport::submit 387 } 388 pack .bugreport.details.cntls.send -side left -padx 2 -pady 4 389 button .bugreport.details.cntls.dload -text "Download" -command { 390 Rappture::bugreport::download 391 } 392 pack .bugreport.details.cntls.dload -side left -padx 2 -pady 4 393 394 Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto 395 text .bugreport.details.info.text -width 50 -height 15 -wrap none 396 .bugreport.details.info contents .bugreport.details.info.text 397 pack .bugreport.details.info -expand yes -fill both 433 button .bugreport.done -text "Done" \ 434 -command Rappture::bugreport::deactivate 398 435 399 436 # this binding keeps the bugreport window on top
Note: See TracChangeset
for help on using the changeset viewer.