1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 __id__ = "$Id: errorreportdialog.py 3050 2009-04-10 01:35:53Z juhas $"
24 __revision__ = "$Revision: 3050 $"
25
26 import wx
27 import wx.lib.hyperlink
28
29 from diffpy.pdfgui.control.controlerrors import ControlError
30 from diffpy.pdfgui import __version__
31
32
33 queryPDFguiTickets = ''.join(["http://danse.us/trac/diffraction/query",
34 '?status=new&status=assigned&status=reopened',
35 '&component=pdfgui&component=pdffit2&order=priority'])
36 diffpyUsers = "http://groups.google.com/group/diffpy-users"
37 _authdata = '99.77.79.61.111.82.67.112'
38
41
42 kwds["style"] = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX|wx.THICK_FRAME
43 wx.Dialog.__init__(self, *args, **kwds)
44 self.label_header = wx.StaticText(self, -1, "PDFgui has encountered a problem. We are sorry for the inconvenience.")
45 self.label_text = wx.StaticText(self, -1, "To help us improve this software, please provide at least a short summary of the problem. When you click the Send Error Report button, the short summary, full description, error log and the version of the software will be sent to developers.")
46 self.label_view_ticket = wx.StaticText(self, -1, "You can view current bug reports and feature requests ")
47 self.ticketlink = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "here.")
48 self.label_view_community = wx.StaticText(self, -1, "Discuss PDFgui and learn about new developments and features")
49 self.communitylink = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "here.")
50 self.label_email = wx.StaticText(self, -1, "Your email address (optional):")
51 self.text_ctrl_reporter = wx.TextCtrl(self, -1, "")
52 self.label_summary = wx.StaticText(self, -1, "Short summary:")
53 self.text_ctrl_summary = wx.TextCtrl(self, -1, "")
54 self.label_description = wx.StaticText(self, -1, "Full description:")
55 self.text_ctrl_description = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
56 self.label_log = wx.StaticText(self, -1, "Error log:")
57 self.text_ctrl_log = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY)
58 self.static_line_1 = wx.StaticLine(self, -1)
59 self.button_send = wx.Button(self, -1, "Send Report")
60 self.button_close = wx.Button(self, wx.ID_CANCEL, "Close")
61
62 self.__set_properties()
63 self.__do_layout()
64
65 self.Bind(wx.EVT_TEXT, self.onSummaryText, self.text_ctrl_summary)
66 self.Bind(wx.EVT_BUTTON, self.onSend, self.button_send)
67
68 self.__customProperties()
69 return
70
72
73 self.SetTitle("Problem Report for PDFgui")
74 self.SetSize((540, 600))
75 self.button_send.Enable(False)
76
77
79
80 sizer_main = wx.BoxSizer(wx.VERTICAL)
81 sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
82 sizer_email = wx.BoxSizer(wx.HORIZONTAL)
83 sizer_ticket_copy = wx.BoxSizer(wx.HORIZONTAL)
84 sizer_ticket = wx.BoxSizer(wx.HORIZONTAL)
85 sizer_main.Add(self.label_header, 0, wx.ALL|wx.EXPAND, 5)
86 sizer_main.Add(self.label_text, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5)
87 sizer_ticket.Add(self.label_view_ticket, 0, wx.ALL|wx.EXPAND, 5)
88 sizer_ticket.Add(self.ticketlink, 1, wx.TOP|wx.BOTTOM, 5)
89 sizer_main.Add(sizer_ticket, 0, wx.TOP|wx.BOTTOM, 5)
90 sizer_ticket_copy.Add(self.label_view_community, 0, wx.ALL|wx.EXPAND, 5)
91 sizer_ticket_copy.Add(self.communitylink, 1, wx.TOP|wx.BOTTOM, 5)
92 sizer_main.Add(sizer_ticket_copy, 0, wx.TOP|wx.BOTTOM, 5)
93 sizer_email.Add(self.label_email, 0, wx.ALL, 5)
94 sizer_email.Add(self.text_ctrl_reporter, 1, wx.ALIGN_CENTER_VERTICAL, 0)
95 sizer_main.Add(sizer_email, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 10)
96 sizer_main.Add(self.label_summary, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5)
97 sizer_main.Add(self.text_ctrl_summary, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
98 sizer_main.Add(self.label_description, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5)
99 sizer_main.Add(self.text_ctrl_description, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
100 sizer_main.Add(self.label_log, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5)
101 sizer_main.Add(self.text_ctrl_log, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
102 sizer_main.Add(self.static_line_1, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5)
103 sizer_buttons.Add((20, 20), 1, 0, 0)
104 sizer_buttons.Add(self.button_send, 0, wx.ALL, 5)
105 sizer_buttons.Add(self.button_close, 0, wx.ALL, 5)
106 sizer_main.Add(sizer_buttons, 0, wx.EXPAND, 0)
107 self.SetSizer(sizer_main)
108 self.Layout()
109
110
112 """Set custom properties."""
113
114 self.errorReport = True
115
116 self.ticketlink.SetURL(queryPDFguiTickets)
117 self.ticketlink.SetToolTip(wx.ToolTip(queryPDFguiTickets))
118 self.communitylink.SetURL(diffpyUsers)
119 self.communitylink.SetToolTip(wx.ToolTip(diffpyUsers))
120 return
121
123
124 if self.text_ctrl_log.GetValue().strip() == "":
125 self.SetTitle("Feature Request / Bug Report")
126 self.label_header.SetLabel("Share you thoughts about PDFgui!")
127 self.label_text.SetLabel("To help us improve this software, please provide a short summary of the problem or request. When you click the Send Report button, the short summary, full description and the version of the software will be sent to developers.")
128 self.label_log.SetLabel("")
129 self.text_ctrl_log.Hide()
130 self.errorReport = False
131 else:
132 self.SetTitle("Problem Report for PDFgui")
133 self.label_header.SetLabel("PDFgui has encountered a problem. We are sorry for the inconvenience.")
134 self.label_text.SetLabel("To help us improve this software, please provide a short summary of how the error occurred. When you click the Send Report button, the short summary, full description and the version of the software will be sent to developers.")
135 self.label_log.SetLabel("Error log:")
136 self.text_ctrl_log.Show()
137 self.errorReport = True
138
139 wx.Dialog.ShowModal(self)
140
141
143 from diffpy.pdfgui.bugreport import submitBugReport
144 if self.errorReport:
145 traceback = self.text_ctrl_log.GetValue()
146 else:
147 traceback = 'N/A'
148
149 bugdata = {
150 'summary' : self.text_ctrl_summary.GetValue(),
151 'description' : self.text_ctrl_description.GetValue(),
152 'reporter' : self.text_ctrl_reporter.GetValue(),
153 'traceback' : traceback,
154
155
156 }
157
158 try:
159 submitBugReport(bugdata)
160 except IOError, e:
161 errorinfo = str(e)
162 if hasattr(e, 'code'):
163 errorinfo += '< Error code = %s >' % e.code
164 emsg = "Report can not be sent: " + errorinfo
165 dlg = wx.MessageDialog(self,
166 emsg, "Error", wx.CANCEL|wx.ICON_ERROR)
167 dlg.ShowModal()
168 dlg.Destroy()
169 except:
170 raise
171
172 else:
173 dlg = wx.MessageDialog(self,
174 "Your report has been sent", "Message sent",
175 wx.OK|wx.ICON_INFORMATION)
176 dlg.ShowModal()
177 dlg.Destroy()
178 self.Close()
179 event.Skip()
180 return
181
182
183 - def onSummaryText(self, event):
184 """Enable sending only if short summary is filled out."""
185 self.button_send.Enable(True)
186 value = self.text_ctrl_summary.GetValue()
187 if not value.strip():
188 self.button_send.Enable(False)
189 event.Skip()
190
191
192
193
194
197 wx.InitAllImageHandlers()
198 self.dialog = ErrorReportDialog(None, -1, "")
199 self.SetTopWindow(self.dialog)
200 self.test()
201 self.dialog.ShowModal()
202 self.dialog.Destroy()
203 return 1
204
206 '''Testing code goes here.'''
207 errortext = """\
208 Exception in thread Thread-3:\n\
209 Traceback (most recent call last):\n\
210 File "/usr/lib/python2.4/threading.py", line 442, in __bootstrap\n\
211 self.run()\n\
212 File "/u23b/farrowch/Programming/Pyre/diffraction/PDFGui/gui/../control/fitting.py", line 54, in run\n\
213 self.fitting.run()\n\
214 File "/u23b/farrowch/Programming/Pyre/diffraction/PDFGui/gui/../control/fitting.py", line 299, in run\n\
215 if self.refine_step():\n\
216 File "/u23b/farrowch/Programming/Pyre/diffraction/PDFGui/gui/../control/fitting.py", line 504, in refine_step\n\
217 phase.obtainRefined(self.server, iphase)\n\
218 File "/u23b/farrowch/Programming/Pyre/diffraction/PDFGui/gui/../control/fitstructure.py", line 79, in obtainRefined\n\
219 self.refined.readStr(server.save_struct_string(iphase), 'pdffit')\n\
220 File "/u23b/farrowch/Programming/Pyre/diffraction/Structure/Structure/structure.py", line 141, in readStr\n\
221 new_structure = parse(s, format)\n\
222 File "/u23b/farrowch/Programming/Pyre/diffraction/Structure/Structure/Parsers/__init__.py", line 43, in parse\n\
223 stru = p.parseLines(lines)\n\
224 File "/u23b/farrowch/Programming/Pyre/diffraction/Structure/Structure/Parsers/P_pdffit.py", line 85, in parseLines\n\
225 xyz = [ float(w) for w in wl1[1:4] ]\n\
226 StructureFormatError: 10: file is not in PDFFit format"""
227
228
229 self.dialog.text_ctrl_log.SetValue(" ")
230
231
232 if __name__ == "__main__":
233 app = MyApp(0)
234 app.MainLoop()
235
236
237