Ignore:
Timestamp:
May 10, 2007 7:53:32 PM (17 years ago)
Author:
mmc
Message:

Fixed the bugreport component to automatically register all "Oops!"
errors with the ticketing system on the hosting hub. When the
RAPPTURE_VERSION environment variable is set to "current", the
dialog automatically registers errors. Otherwise, it pops up a
dialog showing the error to the developer. It also registers errors
that come from launching jobs ("Problem launching job" messages).

Fixed the Makefile to install all scripts/*.tcl files, so we don't
have to modify configure each time a file is added.

File:
1 edited

Legend:

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

    r676 r724  
    1111#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1212# ======================================================================
    13 
    1413option add *BugReport*banner*foreground white startupFile
    1514option add *BugReport*banner*background #a9a9a9 startupFile
     
    1716option add *BugReport*banner*font \
    1817    -*-helvetica-bold-r-normal-*-18-* startupFile
     18option add *BugReport*Label.font \
     19    -*-helvetica-medium-r-normal-*-12-* startupFile
     20option add *BugReport*xmit*wrapLength 3i startupFile
     21option add *BugReport*expl.width 50 startupFile
    1922option add *BugReport*expl.font \
    2023    -*-helvetica-medium-r-normal-*-12-* startupFile
    21 option add *BugReport*expl.wrapLength 3i startupFile
     24option add *BugReport*expl.boldFont \
     25    -*-helvetica-bold-r-normal-*-12-* startupFile
    2226
    2327namespace eval Rappture::bugreport { # forward declaration }
     
    4246# ----------------------------------------------------------------------
    4347proc 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    }
    4588
    4689    set w [winfo reqwidth .bugreport]
     
    5396    raise .bugreport
    5497
    55     .bugreport.details.text configure -state normal
    56     .bugreport.details.text delete 1.0 end
    57     .bugreport.details.text insert end "$err\n-----\n$errorInfo"
    58     .bugreport.details.text configure -state disabled
    59     # should log the error someday too...
    60 
    6198    catch {grab set .bugreport}
     99    update
     100
     101    if {$dosubmit} {
     102        submit
     103    }
    62104}
    63105
     
    76118
    77119# ----------------------------------------------------------------------
    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# ----------------------------------------------------------------------
     126proc 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# ----------------------------------------------------------------------
     179proc 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# ----------------------------------------------------------------------
     195proc 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    }
    85203
    86204    package require http
     
    98216        set summary "[string range $summary 0 50]..."
    99217    }
    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    }
    101224
    102225    set query [http::formatQuery \
     
    104227        task create \
    105228        no_html 1 \
    106         report $stackTrace
     229        report $stackTrace \
    107230        login $tcl_platform(user) \
    108         email "" \
     231        session [Rappture::Tool::resources -session] \
    109232        hostname [info hostname] \
    110233        category rappture \
    111234        summary $summary \
    112         referrer "tool \"[Rappture::Tool::get -name]\"" \
     235        referrer "tool \"[Rappture::Tool::resources -appname]\"" \
    113236    ]
    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]
    121249    }
    122250    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]} {
    124252        return $match
    125253    }
     
    141269pack .bugreport.banner.title -side left -padx {0 8} -pady 2
    142270
    143 button .bugreport.ok -text "OK" -command Rappture::bugreport::deactivate
     271# add these frustration bindings in case the "Dismiss" button is off screen
     272bind .bugreport.banner.icon <Double-ButtonPress-1> \
     273    Rappture::bugreport::deactivate
     274bind .bugreport.banner.title <Double-ButtonPress-1> \
     275    Rappture::bugreport::deactivate
     276
     277button .bugreport.ok -text "Dismiss" -command Rappture::bugreport::deactivate
    144278pack .bugreport.ok -side bottom -pady {0 8}
    145279
    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
     280frame .bugreport.xmit
     281Rappture::Animicon .bugreport.xmit.icon -images {
     282    circle-ball1 circle-ball2 circle-ball3 circle-ball4
     283    circle-ball5 circle-ball6 circle-ball7 circle-ball8
     284}
     285pack .bugreport.xmit.icon -side left
     286label .bugreport.xmit.title -anchor w
     287pack .bugreport.xmit.title -side left -expand yes -fill x
     288
     289text .bugreport.expl -borderwidth 0 -highlightthickness 0 -wrap word
     290.bugreport.expl tag configure bold \
     291    -font [option get .bugreport.expl boldFont Font]
    148292
    149293bind .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
    153295}
    154296
    155297bind .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
     301frame .bugreport.details
     302frame .bugreport.details.cntls
     303pack .bugreport.details.cntls -side bottom -fill x
     304button .bugreport.details.cntls.ok -text "Dismiss" -command {
     305    Rappture::bugreport::deactivate
     306}
     307pack .bugreport.details.cntls.ok -side right -padx 2 -pady 4
     308button .bugreport.details.cntls.send -text "Send Trouble Report" -command {
     309    Rappture::bugreport::submit
     310}
     311pack .bugreport.details.cntls.send -side left -padx 2 -pady 4
     312button .bugreport.details.cntls.dload -text "Download" -command {
     313    Rappture::bugreport::download
     314}
     315pack .bugreport.details.cntls.dload -side left -padx 2 -pady 4
     316
     317Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto
     318text .bugreport.details.info.text -width 50 -height 15 -wrap none
     319.bugreport.details.info contents .bugreport.details.info.text
     320pack .bugreport.details.info -expand yes -fill both
    164321
    165322# this binding keeps the bugreport window on top
Note: See TracChangeset for help on using the changeset viewer.