source: branches/1.6/gui/scripts/bugreport.tcl @ 6131

Last change on this file since 6131 was 6131, checked in by gah, 8 years ago

initial changes for instant-on

File size: 27.6 KB
RevLine 
[5679]1# -*- mode: tcl; indent-tabs-mode: nil -*-
[462]2# ----------------------------------------------------------------------
3#  UTILITY: bugreport
4#
5#  This redefines the usual Tcl bgerror command to install a nicer
[1904]6#  looking bug handler.  Bug reports can be submitted back to a
7#  HUBzero-based site as support tickets.  Additional information
8#  can be obtained by defining procedures as bugreport::instrumented
9#  proc (captures entrance/exit from proc) and by calling
10#  bugreport::remark with extra info along the way.
[462]11# ======================================================================
12#  AUTHOR:  Michael McLennan, Purdue University
[3177]13#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
[462]14#
15#  See the file "license.terms" for information on usage and
16#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17# ======================================================================
[1864]18option add *BugReport*Label.font {Helvetica -12} startupFile
[462]19option add *BugReport*banner*foreground white startupFile
20option add *BugReport*banner*background #a9a9a9 startupFile
21option add *BugReport*banner*highlightBackground #a9a9a9 startupFile
[1864]22option add *BugReport*banner.title.font {Helvetica -18 bold} startupFile
[724]23option add *BugReport*xmit*wrapLength 3i startupFile
24option add *BugReport*expl.width 50 startupFile
[1864]25option add *BugReport*expl.font {Helvetica -12} startupFile
26option add *BugReport*expl.boldFont {Helvetica -12 bold} startupFile
27option add *BugReport*comments.l.font {Helvetica -12 italic} startupFile
28option add *BugReport*comments.info.text.font {Helvetica -12} startupFile
29option add *BugReport*details*font {Courier -12} startupFile
[462]30
[728]31namespace eval Rappture::bugreport {
[1904]32    # details from the current trouble report, which user may decide to submit
[1861]33    variable details
34
[1904]35    # status from bugreport::instrumented/remark in case a bug occurs
36    variable extraStack ""
37    variable extraInfo ""
38
[728]39    # assume that if there's a problem launching a job, we should know it
40    variable reportJobFailures 1
[1904]41
42    # submit these kinds of tickets by default
43    variable settings
44    set settings(user) $::tcl_platform(user)
45    set settings(type) "automatic"
46    set settings(group) ""
47    set settings(category) "Rappture"
[728]48}
[462]49
50# ----------------------------------------------------------------------
51# USAGE: install
52#
53# Called once in the main program to install this bug reporting
54# facility.  Any unexpected errors after this call will be handled
55# by this mechanism.
56# ----------------------------------------------------------------------
57proc Rappture::bugreport::install {} {
[1904]58    ::proc ::bgerror {err} { ::Rappture::bugreport::activate $err }
[5679]59    # Load tls early to prevent error in tls::initlib and [pwd]
60    package require http
61    package require tls
[462]62}
63
64# ----------------------------------------------------------------------
65# USAGE: activate <error>
66#
67# Used internally to pop up the bug handler whenver a bug is
68# encountered.  Tells the user that there is a bug and logs the
69# problem, so it can be fixed.
70# ----------------------------------------------------------------------
71proc Rappture::bugreport::activate {err} {
[724]72    global env errorInfo
[1861]73    variable details
[1904]74    variable settings
[462]75
[724]76    if {"@SHOWDETAILS" == $err} {
[1861]77        pack propagate .bugreport yes
[1929]78        pack forget .bugreport.expl
79        pack forget .bugreport.xmit
80        pack forget .bugreport.done
[1861]81        pack forget .bugreport.cntls.show
[1929]82        pack .bugreport.cntls -after .bugreport.banner -side bottom -fill x
83        pack .bugreport.details -after .bugreport.banner \
84            -expand yes -fill both -padx 8 -pady 8
85        pack .bugreport.comments -after .bugreport.details \
86            -expand yes -fill both -padx 8 -pady {0 8}
[1906]87
88        update idletasks
89        set w [winfo reqwidth .bugreport]
90        set h [winfo reqheight .bugreport]
[4512]91
[4571]92        set x [winfo rootx .main]
93        set y [winfo rooty .main]
94
95        set mw [winfo width .main]
96        if { $mw == 1 } {
97            set mw [winfo reqwidth .main]
[5679]98        }
[4571]99        set mh [winfo height .main]
100        if { $mh == 1 } {
101            set mh [winfo reqwidth .main]
[5679]102        }
[4571]103        if { $mw > $w } {
104            set x [expr { $x + (($mw-$w)/2) }]
105        }
106        if { $mh > $h } {
107            set y [expr { $y + (($mh-$h)/2) }]
108        }
[4457]109        wm geometry .bugreport +$x+$y
[1906]110        raise .bugreport
[1929]111        return
[724]112    }
113
[1868]114    # gather details so we can submit trouble reports later
115    # do this now, before we do anything with "catch" down below
116    # that might mask the errorInfo
117    register $err
118
[1861]119    pack propagate .bugreport yes
120    pack forget .bugreport.details
121    pack forget .bugreport.xmit
122    pack forget .bugreport.done
123    pack .bugreport.cntls.show -side right
124    pack .bugreport.cntls -after .bugreport.banner -side bottom -fill x
125    pack .bugreport.expl -after .bugreport.banner \
126        -expand yes -fill both -padx 8 -pady 8
[1864]127    pack .bugreport.comments -after .bugreport.expl \
128        -expand yes -fill both -padx 8 -pady {0 8}
[1861]129
130    .bugreport.expl configure -state normal
131    .bugreport.expl delete 1.0 end
132
133    set url [Rappture::Tool::resources -huburl]
134    if {"" != $url} {
135        .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."
136        .bugreport.cntls.send configure -state normal
[1929]137        focus .bugreport.cntls.send
[1861]138    } else {
139        .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."
[1864]140        pack forget .bugreport.comments
[1861]141        .bugreport.cntls.send configure -state disabled
[1929]142        focus .bugreport.cntls.ok
[1861]143    }
144    fixTextHeight .bugreport.expl
145    .bugreport.expl configure -state disabled
146
[724]147    .bugreport.details.info.text configure -state normal
148    .bugreport.details.info.text delete 1.0 end
[1904]149    .bugreport.details.info.text insert end "    USER: $settings(user)\n"
[1861]150    .bugreport.details.info.text insert end "HOSTNAME: $details(hostname)\n"
[1904]151    .bugreport.details.info.text insert end "PLATFORM: $details(platform)\n"
152    .bugreport.details.info.text insert end "CATEGORY: $details(category)\n"
[1861]153    .bugreport.details.info.text insert end "    TOOL: $details(referrer)\n"
154    .bugreport.details.info.text insert end " SESSION: $details(session)\n"
155    .bugreport.details.info.text insert end " SUMMARY: $details(summary)\n"
156    .bugreport.details.info.text insert end "---------\n"
157    .bugreport.details.info.text insert end $details(stackTrace)
[724]158    .bugreport.details.info.text configure -state disabled
159
[462]160    set w [winfo reqwidth .bugreport]
161    set h [winfo reqheight .bugreport]
[4512]162
[4571]163    set x [winfo rootx .main]
164    set y [winfo rooty .main]
[4512]165
[4571]166    set mw [winfo width .main]
167    if { $mw == 1 } {
168        set mw [winfo reqwidth .main]
[5679]169    }
[4571]170    set mh [winfo height .main]
171    if { $mh == 1 } {
172        set mh [winfo reqwidth .main]
[5679]173    }
[462]174
[4571]175    if { $mw > $w } {
176        set x [expr { $x + (($mw-$w)/2) }]
177    }
178    if { $mh > $h } {
179        set y [expr { $y + (($mh-$h)/2) }]
180    }
181
[462]182    wm geometry .bugreport +$x+$y
183    wm deiconify .bugreport
184    raise .bugreport
185
[2606]186    catch {grab set .bugreport}
[724]187    update
[462]188}
189
190# ----------------------------------------------------------------------
191# USAGE: deactivate
192#
193# Used internally to take down the bug handler dialog.
194# ----------------------------------------------------------------------
195proc Rappture::bugreport::deactivate {} {
196    grab release .bugreport
197    wm withdraw .bugreport
198
199    # reset the grab in case it's hosed
200    Rappture::grab::reset
201}
202
203# ----------------------------------------------------------------------
[1904]204# USAGE: instrumented <what> <name> <arglist> <body>
205#
206# Used instead of the usual Tcl "proc" or itcl::body to define a
207# procedure that will automatically register information about its
208# execution in the bugreport mechanism.  The <what> parameter should
209# be either "proc" or "itcl::body" or something like that.  When the
210# procedure starts, it pushes its call information onto the stack,
211# then invokes the procedure body, then adds information about the
212# return code.
213# ----------------------------------------------------------------------
214proc Rappture::bugreport::instrumented {what name arglist body} {
215    set avals ""
216    foreach term $arglist {
217        set aname [lindex $term 0]
218        append avals "\$$aname "
219    }
220    uplevel [list $what $name $arglist [format {
221        Rappture::bugreport::remark -enter "PROC %s: %s"
222        set __status [catch {%s} __result]
223        Rappture::bugreport::remark -leave "PROC %s: code($__status) => $__result"
224        switch -- $__status {
225            0 - 2 {
226                return $__result
227            }
228            3 {
229                set __result "invoked \"break\" outside of a loop"
230            }
231            4 {
232                set __result "invoked \"continue\" outside of a loop"
233            }
234        }
235        error $__result $::errorInfo
236    } $name $avals $body $name]]
237}
238
239# ----------------------------------------------------------------------
240# USAGE: remark ?-enter|-leave? <message>
241#
242# Adds the <message> to the current "extraInfo" being kept about the
243# program.  This adds useful debugging info to the report that gets
244# sent back when an unexpected error is trapped.  The -enter and -leave
245# options are used when a bugreport::instrumented proc starts/exits to
246# change the indent level for future messages.
247# ----------------------------------------------------------------------
248proc Rappture::bugreport::remark {args} {
249    variable extraStack
250    variable extraInfo
251
252    if {[llength $args] > 1} {
253        set option [lindex $args 0]
254        set args [lrange $args 1 end]
255        switch -- $option {
256            -enter {
257                if {[llength $args] != 1} {
258                    error "wrong # args: should be \"remark -enter message\""
259                }
260                set mesg [lindex $args 0]
261                if {[llength $extraStack] == 0} {
262                    set extraInfo ""
263                }
264                append extraInfo [remark -indent ">> $mesg"]
265                set extraStack [linsert $extraStack 0 $mesg]
266                return
267            }
268            -leave {
269                if {[llength $args] != 1} {
270                    error "wrong # args: should be \"remark -leave message\""
271                }
272                set mesg [lindex $args 0]
273                set extraStack [lrange $extraStack 1 end]
274                append extraInfo [remark -indent "<< $mesg"]
275                return
276            }
277            -indent {
278                if {[llength $args] != 1} {
279                    error "wrong # args: should be \"remark -indent message\""
280                }
281            }
282            default {
283                error "bad option \"$option\": should be -enter, -leave, -indent"
284            }
285        }
286    }
287    set mesg [lindex $args 0]
288    set nlevel [llength $extraStack]
289    set indent [string repeat { } [expr {2*$nlevel}]]
290    foreach line [split $mesg \n] {
291        append extraInfo "$indent$line\n"
292        set prefix "   "
293    }
294}
295
296# ----------------------------------------------------------------------
[2599]297# USAGE: sanitize <string> ?<replacement>?
298#
299# Removes any sensitive information in the bug report.  This is useful
300# for things such as passwords that should be scrubbed out before any
301# ticket is filed.  Replaces the <string> with an optional <replacement>
302# string (or ******** by default).  This is usually called in some sort
303# of "catch" before forwarding the error on to the usual bgerror routine.
304# ----------------------------------------------------------------------
305proc Rappture::bugreport::sanitize {str {repl ********}} {
306    global errorInfo
307    variable extraInfo
308
309    set map [list $str $repl]
310    set errorInfo [string map $map $errorInfo]
311    set extraInfo [string map $map $extraInfo]
312}
313
314# ----------------------------------------------------------------------
[2611]315# USAGE: attach <name> <string>
316#
317# Removes any sensitive information in the bug report.  This is useful
318# for things such as passwords that should be scrubbed out before any
319# ticket is filed.  Replaces the <string> with an optional <replacement>
320# string (or ******** by default).  This is usually called in some sort
321# of "catch" before forwarding the error on to the usual bgerror routine.
322# ----------------------------------------------------------------------
323proc Rappture::bugreport::attach {str {repl ********}} {
324    global errorInfo
325    variable extraInfo
326
327    set map [list $str $repl]
328    set errorInfo [string map $map $errorInfo]
329    set extraInfo [string map $map $extraInfo]
330}
331
332
333# ----------------------------------------------------------------------
[724]334# USAGE: submit
[676]335#
[724]336# Takes details currently stored in the panel and registers them
337# as a support ticket on the hosting hub site.  Pops up a panel
338# during the process and informs the user of the result.
[676]339# ----------------------------------------------------------------------
[724]340proc Rappture::bugreport::submit {} {
341    set info [.bugreport.details.info.text get 1.0 end]
[676]342
[1861]343    pack propagate .bugreport no
[724]344    pack forget .bugreport.details
[1861]345    pack forget .bugreport.expl
[1864]346    pack forget .bugreport.comments
[1861]347    pack forget .bugreport.cntls
348    pack .bugreport.xmit -after .bugreport.banner -padx 8 -pady 8
[724]349    .bugreport.xmit.title configure -text "Sending trouble report to [Rappture::Tool::resources -hubname]..."
350
351    # send off the trouble report...
352    .bugreport.xmit.icon start
[1861]353    set status [catch send result]
[724]354    .bugreport.xmit.icon stop
355
[1861]356    pack propagate .bugreport yes
[724]357    pack forget .bugreport.xmit
[1861]358    pack .bugreport.expl -after .bugreport.banner -padx 8 -pady 8
[724]359    .bugreport.expl configure -state normal
360    .bugreport.expl delete 1.0 end
361
362    # handle the result
363    if {$status != 0} {
[1929]364        # add error to the details field, so we can see it with magic clicks
365        .bugreport.details.info.text configure -state normal
366        .bugreport.details.info.text insert 1.0 "Ticket submission failed:\n$result\n-----\n"
367        .bugreport.details.info.text configure -state disabled
[724]368
[1929]369        .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."
[727]370    } elseif {[regexp {Ticket #([0-9]*) +\((.*?)\) +([0-9]+) +times} $result match ticket extra times]} {
[1929]371        .bugreport.expl insert end "This problem has been reported as " "" "Ticket #$ticket" bold " in our system." ""
372        if {[string is integer $times] && $times > 1} {
373            .bugreport.expl insert end "  This particular problem has been reported $times times."
374        }
375        .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!"
[724]376    } else {
[1929]377        .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!" ""
[724]378    }
[1861]379    fixTextHeight .bugreport.expl
[724]380    .bugreport.expl configure -state disabled
[1861]381    pack .bugreport.done -side bottom -padx 8 -pady 8
382    focus .bugreport.done
[724]383}
384
385# ----------------------------------------------------------------------
[1861]386# USAGE: register <err>
[724]387#
[1861]388# Low-level function used to capture information about a bug report
389# prior to calling "send", which actually sends the ticket.  We usually
390# let the user preview the information and decide whether or not to
391# send the ticket.
[724]392# ----------------------------------------------------------------------
[1861]393proc Rappture::bugreport::register {err} {
394    global errorInfo tcl_platform
395    variable details
[1904]396    variable settings
397    variable extraInfo
[724]398
[1861]399    #
400    # Figure out exactly what we'll send if the bug report is
401    # submitted, so we can show the user.
402    #
[1904]403    set stackTrace "$err\n---------\n$errorInfo\n---------\n$extraInfo"
[676]404    if {![regexp {^([^\n]+)\n} $stackTrace match summary]} {
[1929]405        if {[string length $stackTrace] == 0} {
406            set summary "Unexpected error from Rappture"
407        } else {
408            set summary $stackTrace
409        }
[676]410    }
[743]411    if {[string length $summary] > 200} {
[1929]412        set summary "[string range $summary 0 200]..."
[676]413    }
[743]414    if {[string match {Problem launching job*} $summary]} {
[1929]415        append summary " (in tool \"[Rappture::Tool::resources -appname]\")"
416        set category "Tools"
[743]417    } else {
[1929]418        set category $settings(category)
[743]419    }
[676]420
[724]421    # make sure that the stack trace isn't too long
[733]422    set toolong 20000
423    if {[string length $stackTrace] > $toolong} {
[1929]424        #
425        # If this came from "Problem launching job", then it will have
426        # a "== RAPPTURE INPUT ==" part somewhere in the middle.  Try
427        # to show the first part, this middle part, and the very last
428        # part, cutting out whatever we have to in the middle.
429        #
430        if {[regexp -indices {\n== RAPPTURE INPUT ==\n} $stackTrace match]} {
431            foreach {smid0 smid1} $match break
432            set quarter [expr {$toolong/4}]
433            set s0 $quarter
434            set smid0 [expr {$smid0-$quarter}]
435            set smid1 [expr {$smid1+$quarter}]
436            set s1 [expr {[string length $stackTrace]-$quarter}]
[733]437
[1929]438            if {$smid0 < $s0} {
439                # first part is short -- truncate last part
440                set stackTrace "[string range $stackTrace 0 $smid1]\n...\n[string range $stackTrace [expr {[string length $stackTrace]-($toolong-$smid1)}] end]"
441            } elseif {$smid1 > $s1} {
442                # last part is short -- truncate first part
443                set tailsize [expr {[string length $stackTrace]-$smid0}]
444                set stackTrace "[string range $stackTrace 0 [expr {$toolong-$tailsize}]]\n...\n[string range $stackTrace $smid0 end]"
445            } else {
446                # rappture input line is right about in the middle
447                set stackTrace "[string range $stackTrace 0 $s0]\n...\n[string range $stackTrace $smid0 $smid1]\n...\n[string range $stackTrace $s1 end]"
448            }
449        } else {
450            # no Rappture input -- just show first part and last part
451            set half [expr {$toolong/2}]
452            set stackTrace "[string range $stackTrace 0 $half]\n...\n[string range $stackTrace [expr {[string length $stackTrace]-$half}] end]"
453        }
[724]454    }
455
[1861]456    set details(summary) $summary
457    set details(category) $category
458    set details(stackTrace) $stackTrace
459    set details(hostname) [info hostname]
460    set details(session) [Rappture::Tool::resources -session]
[1904]461    set details(referrer) [Rappture::Tool::resources -appname]
462    set details(platform) [array get tcl_platform]
[3188]463
464    Rappture::Logger::log oops! $summary
[1861]465}
466
467# ----------------------------------------------------------------------
[2686]468# USAGE: attachment <string>
469#
470# Low-level function used to capture information about a bug report
471# prior to calling "send", which actually sends the ticket.  We usually
472# let the user preview the information and decide whether or not to
473# send the ticket.
474# ----------------------------------------------------------------------
475proc Rappture::bugreport::attachment { string } {
476    variable details
477    set details(attachment) $string
478}
479
480# ----------------------------------------------------------------------
[1861]481# USAGE: send
482#
483# Low-level function used to send bug reports back to the hub site.
484# Error details gathered by a previous call to "register" are sent
485# along as a support ticket.  Returns a string of the following form,
486# representing details about the new or existing ticket:
487#   Ticket #XX (XXXXXX) XX times
488# ----------------------------------------------------------------------
489proc Rappture::bugreport::send {} {
490    variable details
[1904]491    variable settings
[1861]492
493    package require http
494    package require tls
[4797]495    http::register https 443 [list ::tls::socket -tls1 1]
[1861]496
[1864]497    set report $details(stackTrace)
498    set cmts [string trim [.bugreport.comments.info.text get 1.0 end]]
499    if {[string length $cmts] > 0} {
[2611]500        set report "$cmts\n\n[string repeat = 72]\n$report"
[1864]501    }
[2686]502    set toolFile ""
503    if { [info exists details(attachment)] } {
[2744]504        set toolFile "/tmp/tool[pid].xml"
505        set f [open $toolFile "w"]
506        puts $f $details(attachment)
507        close $f
508        unset details(attachment)
[2686]509    }
[676]510    set query [http::formatQuery \
[1929]511        option com_support \
[2686]512        controller tickets \
513        upload $toolFile \
[1929]514        task create \
515        no_html 1 \
516        report $report \
517        sesstoken $details(session) \
518        hostname $details(hostname) \
519        os $details(platform) \
520        category $details(category) \
521        summary $details(summary) \
522        referrer $details(referrer) \
523        login $settings(user) \
524        group $settings(group) \
525        type $settings(type) \
[676]526    ]
[724]527    set url [Rappture::Tool::resources -huburl]
[1943]528    if { $url == "" } {
[2744]529        set url "http://hubzero.org"
[1943]530    }
[724]531    if {[string index $url end] == "/"} {
[1929]532        append url "index.php"
[724]533    } else {
[1929]534        append url "/index.php"
[724]535    }
[676]536
[1864]537    set token [http::geturl $url -query $query -timeout 60000]
[676]538
[1864]539    if {[http::ncode $token] != 200} {
[1929]540        error [http::code $token]
[1864]541    }
542    upvar #0 $token rval
543    set info $rval(body)
544    http::cleanup $token
[1274]545
[2686]546    if { $toolFile != "" } {
[2744]547        file delete $toolFile
[2686]548    }
[1274]549    if {[regexp {Ticket #[0-9]* +\(.*?\) +[0-9]+ +times} $info match]} {
[1929]550        return $match
[676]551    }
[1274]552    error "Report received, but ticket may not have been filed.  Here's the result...\n$info"
[676]553}
554
555# ----------------------------------------------------------------------
[1861]556# USAGE: fixTextHeight <widget>
557#
558# Used internally to adjust the height of a text widget so it is just
559# tall enough to show the info within it.
560# ----------------------------------------------------------------------
561proc Rappture::bugreport::fixTextHeight {widget} {
[1864]562    #
563    # HACK ALERT!  In Tk8.5, we can count display lines directly.
564    #   But for earlier versions, we have to cook up something
565    #   similar.
566    #
567    if {[catch {$widget count -displaylines 1.0 end} h] == 0 && $h > 0} {
568        $widget configure -height $h
569    } else {
570        for {set h 1} {$h < 15} {incr h} {
[1929]571            $widget configure -height $h
572            $widget see 1.0
573            update idletasks
574            if {"" != [$widget bbox end-1char]} {
575                break
576            }
[1864]577        }
[1861]578    }
579}
580
581# ----------------------------------------------------------------------
[728]582# USAGE: shouldReport jobfailures <boolean>
583# USAGE: shouldReport for ?oops|jobs?
584#
585# Used internally to determine whether or not this system should
586# automatically report errors back to the hosting hub.  Returns 1
587# if the tool should, and 0 otherwise.  The decision is made based
588# on whether this is a current tool in production, whether it is
589# being tested in a workspace, and whether the tool commonly generates
590# problems (by pilot error in its input deck).
591# ----------------------------------------------------------------------
592proc Rappture::bugreport::shouldReport {option value} {
593    global env
594
595    switch -- $option {
[1929]596        jobfailures {
597            variable reportJobFailures
598            if {![string is boolean $value]} {
599                error "bad value \"$value\": should be boolean"
600            }
601            set reportJobFailures $value
602        }
603        for {
604            # is it being run within a workspace?
605            set appname [Rappture::Tool::resources -appname]
606            if {[string match {[Ww]orkspace*} $appname]} {
607                return 0
608            }
[6131]609            set url [Rappture::Tool::resources -huburl]
610            if { $url == "" } {
611                return 0
612            }
[1929]613            # if this is a problem launching a job and the tool
614            # expects this, then don't bother with automatic reports.
615            variable reportJobFailures
616            if {"jobs" == $value && !$reportJobFailures} {
617                return 0
618            }
[728]619
[1929]620            # this is a real problem -- report it!
621            return 1
622        }
623        default {
624            error "bad option \"$option\": should be jobfailures or for"
625        }
[728]626    }
627}
628
629# ----------------------------------------------------------------------
[462]630# Build the bug reporting dialog
631# ----------------------------------------------------------------------
632toplevel .bugreport -class BugReport -borderwidth 1 -relief solid
633wm overrideredirect .bugreport 1
634wm withdraw .bugreport
635
636frame .bugreport.banner -background #a9a9a9
637pack .bugreport.banner -side top -fill x
638label .bugreport.banner.icon -image [Rappture::icon alert]
639pack .bugreport.banner.icon -side left -padx 2 -pady 2
[1861]640label .bugreport.banner.title -text "Oops! Internal Error"
[464]641pack .bugreport.banner.title -side left -padx {0 8} -pady 2
[462]642
[724]643# add these frustration bindings in case the "Dismiss" button is off screen
644bind .bugreport.banner.icon <Double-ButtonPress-1> \
645    Rappture::bugreport::deactivate
646bind .bugreport.banner.title <Double-ButtonPress-1> \
647    Rappture::bugreport::deactivate
[2057]648bind .bugreport <KeyPress-Escape> \
649    Rappture::bugreport::deactivate
[724]650
[1864]651set bg [.bugreport cget -background]
652text .bugreport.expl -borderwidth 0 -highlightthickness 0 -background $bg \
653    -height 3 -wrap word
[724]654.bugreport.expl tag configure bold \
655    -font [option get .bugreport.expl boldFont Font]
[1864]656#
657# HACK ALERT!  We have problems with fixTextHeight working correctly
658#   on Windows for Tk8.4 and earlier.  To make it work properly, we
659#   add the binding below.  At some point, we'll ditch 8.4 and we can
660#   use the new "count -displaylines" option in Tk8.5.
661#
662bind .bugreport.expl <Map> {Rappture::bugreport::fixTextHeight %W}
[724]663
[1864]664frame .bugreport.comments
665label .bugreport.comments.l -text "What were you doing just before this error?" -anchor w
666pack .bugreport.comments.l -side top -anchor w
667Rappture::Scroller .bugreport.comments.info -xscrollmode none -yscrollmode auto
668text .bugreport.comments.info.text -width 30 -height 3 -wrap word
669.bugreport.comments.info contents .bugreport.comments.info.text
670bind .bugreport.comments.info.text <ButtonPress> {focus %W}
671pack .bugreport.comments.info -expand yes -fill both
672
[1861]673frame .bugreport.cntls
674pack .bugreport.cntls -side bottom -fill x
675button .bugreport.cntls.ok -text "Ignore" -command {
[724]676    Rappture::bugreport::deactivate
677}
[1861]678pack .bugreport.cntls.ok -side left -padx {4 20} -pady 8
679button .bugreport.cntls.send -text "Send Trouble Report" -command {
[724]680    Rappture::bugreport::submit
681}
[1861]682pack .bugreport.cntls.send -side right -padx 4 -pady 8
[465]683
[1861]684button .bugreport.cntls.show -text "Show Details..." \
685    -command {Rappture::bugreport::activate @SHOWDETAILS}
686pack .bugreport.cntls.show -side right
687
688
689frame .bugreport.details
[724]690Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto
691text .bugreport.details.info.text -width 50 -height 15 -wrap none
692.bugreport.details.info contents .bugreport.details.info.text
693pack .bugreport.details.info -expand yes -fill both
694
[1861]695frame .bugreport.xmit
696Rappture::Animicon .bugreport.xmit.icon -images {
697    circle-ball1 circle-ball2 circle-ball3 circle-ball4
698    circle-ball5 circle-ball6 circle-ball7 circle-ball8
699}
700pack .bugreport.xmit.icon -side left
701label .bugreport.xmit.title -anchor w
702pack .bugreport.xmit.title -side left -expand yes -fill x
703
704button .bugreport.done -text "Done" \
705    -command Rappture::bugreport::deactivate
706
[462]707# this binding keeps the bugreport window on top
708bind BugReportOnTop <ButtonPress> {
709    wm deiconify %W
710    raise %W
711}
712set btags [bindtags .bugreport]
713bindtags .bugreport [linsert $btags 0 BugReportOnTop]
[2686]714
Note: See TracBrowser for help on using the repository browser.