Ignore:
Timestamp:
Aug 14, 2010, 7:57:16 PM (14 years ago)
Author:
mmc
Message:

Fixed the bug report dialog to give the user the option of filing a
ticket, instead of filing something automatically right away. There's
now a button to "Show Details..." so the user can see what sort of
information is being included in the bug report.

Fixed the progress bar to honor the -length option and set its overall
size properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/bugreport.tcl

    r1342 r1861  
    2626
    2727namespace eval Rappture::bugreport {
     28    # details from the current trouble report
     29    variable details
     30
    2831    # assume that if there's a problem launching a job, we should know it
    2932    variable reportJobFailures 1
     
    5053proc Rappture::bugreport::activate {err} {
    5154    global env errorInfo
     55    variable details
    5256
    5357    if {"@SHOWDETAILS" == $err} {
     58        pack propagate .bugreport yes
     59        pack forget .bugreport.expl
    5460        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
    5664        pack .bugreport.details -after .bugreport.banner \
    5765            -expand yes -fill both -padx 8 -pady 8
    58         focus .bugreport.details.cntls.ok
    5966        return
    6067    }
    6168
    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
    6397    .bugreport.details.info.text configure -state normal
    6498    .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)
    66107    .bugreport.details.info.text configure -state disabled
    67 
    68     if {[shouldReport for oops]} {
    69         pack forget .bugreport.details
    70         pack forget .bugreport.expl
    71         pack .bugreport.ok -side bottom -after .bugreport.banner -pady {0 8}
    72         pack .bugreport.xmit -after .bugreport.ok -padx 8 -pady 8
    73         focus .bugreport.ok
    74         set dosubmit 1
    75     } else {
    76         pack forget .bugreport.expl
    77         pack forget .bugreport.xmit
    78         pack forget .bugreport.ok
    79         pack .bugreport.details -after .bugreport.banner \
    80             -expand yes -fill both -padx 8 -pady 8
    81         focus .bugreport.details.cntls.ok
    82         set dosubmit 0
    83     }
    84108
    85109    set w [winfo reqwidth .bugreport]
     
    94118    catch {grab set .bugreport}
    95119    update
    96 
    97     if {$dosubmit} {
    98         submit
    99     }
    100120}
    101121
     
    123143    set info [.bugreport.details.info.text get 1.0 end]
    124144
     145    pack propagate .bugreport no
    125146    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
    128150    .bugreport.xmit.title configure -text "Sending trouble report to [Rappture::Tool::resources -hubname]..."
    129     focus .bugreport.ok
    130151
    131152    # send off the trouble report...
    132153    .bugreport.xmit.icon start
    133     set status [catch {register $info} result]
     154    set status [catch send result]
    134155    .bugreport.xmit.icon stop
    135156
     157    pack propagate .bugreport yes
    136158    pack forget .bugreport.xmit
    137     pack .bugreport.expl -after .bugreport.ok -padx 8 -pady 8
     159    pack .bugreport.expl -after .bugreport.banner -padx 8 -pady 8
    138160    .bugreport.expl configure -state normal
    139161    .bugreport.expl delete 1.0 end
     
    146168        .bugreport.details.info.text configure -state disabled
    147169
    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."
    149171    } elseif {[regexp {Ticket #([0-9]*) +\((.*?)\) +([0-9]+) +times} $result match ticket extra times]} {
    150         .bugreport.expl insert end "This tool encountered an unexpected error.  The problem 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." ""
    151173        if {[string is integer $times] && $times > 1} {
    152174            .bugreport.expl insert end "  This particular problem has been reported $times times."
    153175        }
    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!"
    155177    } 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
    166181    .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# ----------------------------------------------------------------------
     194proc 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"
    196203    if {![regexp {^([^\n]+)\n} $stackTrace match summary]} {
    197204        if {[string length $stackTrace] == 0} {
     
    246253    }
    247254
     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# ----------------------------------------------------------------------
     273proc Rappture::bugreport::send {} {
     274    variable details
     275
     276    package require http
     277    package require tls
     278    http::register https 443 ::tls::socket
     279
    248280    set query [http::formatQuery \
    249281        option com_support \
    250282        task create \
    251283        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) \
    259291    ]
    260292   
     
    266298    }
    267299
    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
     308set info "foo bar"
    276309
    277310    if {[regexp {Ticket #[0-9]* +\(.*?\) +[0-9]+ +times} $info match]} {
     
    279312    }
    280313    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# ----------------------------------------------------------------------
     322proc 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    }
    281331}
    282332
     
    304354        }
    305355        for {
    306             # is this a tool in production?
    307             if {![info exists env(RAPPTURE_VERSION)]
    308                   || $env(RAPPTURE_VERSION) != "current"} {
    309                 return 0
    310             }
    311 
    312356            # is it being run within a workspace?
    313357            set appname [Rappture::Tool::resources -appname]
     
    343387label .bugreport.banner.icon -image [Rappture::icon alert]
    344388pack .bugreport.banner.icon -side left -padx 2 -pady 2
    345 label .bugreport.banner.title -text "Oops! Unexpected Error"
     389label .bugreport.banner.title -text "Oops! Internal Error"
    346390pack .bugreport.banner.title -side left -padx {0 8} -pady 2
    347391
     
    352396    Rappture::bugreport::deactivate
    353397
    354 button .bugreport.ok -text "Dismiss" -command Rappture::bugreport::deactivate
    355 pack .bugreport.ok -side bottom -pady {0 8}
     398text .bugreport.expl -borderwidth 0 -highlightthickness 0 -wrap word
     399.bugreport.expl tag configure bold \
     400    -font [option get .bugreport.expl boldFont Font]
     401
     402frame .bugreport.cntls
     403pack .bugreport.cntls -side bottom -fill x
     404button .bugreport.cntls.ok -text "Ignore" -command {
     405    Rappture::bugreport::deactivate
     406}
     407pack .bugreport.cntls.ok -side left -padx {4 20} -pady 8
     408button .bugreport.cntls.send -text "Send Trouble Report" -command {
     409    Rappture::bugreport::submit
     410}
     411pack .bugreport.cntls.send -side right -padx 4 -pady 8
     412
     413button .bugreport.cntls.show -text "Show Details..." \
     414    -command {Rappture::bugreport::activate @SHOWDETAILS}
     415pack .bugreport.cntls.show -side right
     416
     417
     418frame .bugreport.details
     419Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto
     420text .bugreport.details.info.text -width 50 -height 15 -wrap none
     421.bugreport.details.info contents .bugreport.details.info.text
     422pack .bugreport.details.info -expand yes -fill both
    356423
    357424frame .bugreport.xmit
     
    364431pack .bugreport.xmit.title -side left -expand yes -fill x
    365432
    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
     433button .bugreport.done -text "Done" \
     434    -command Rappture::bugreport::deactivate
    398435
    399436# this binding keeps the bugreport window on top
Note: See TracChangeset for help on using the changeset viewer.