38
38
from whyteboard.lib import BaseErrorDialog, icon, pub
39
39
import whyteboard.tools as tools
41
from whyteboard.core import LogRemembererHandler
41
42
from whyteboard.updater import Updater
42
43
from whyteboard.misc import meta
43
44
from whyteboard.misc import (get_home_dir, bitmap_button, fix_std_sizer_tab_order,
751
752
BaseErrorDialog.__init__(self, None, title=_("Error Report"), message=msg)
752
753
self.SetDescriptionLabel(_("An error has occured - please report it"))
753
754
self.gui = wx.GetTopLevelWindows()[0]
755
self.email_prompted = False
756
758
if isinstance(self.gui, ErrorDialog):
772
774
preference = preference.rstrip()
773
775
info.append(unicode(preference, "utf-8"))
776
778
return os.linesep.join(info)
778
780
def GetProgramName(self):
779
781
return u"Whyteboard %s" % meta.version
783
784
"""Send the error report. PHP script calls isset($_POST['submitted'])"""
785
if not self.email_prompted:
784
788
params = urlencode({'submitted': 'fgdg',
785
789
'message': self._panel.err_msg,
786
790
'desc': self._panel.action.GetValue(),
787
'email': self._panel.email.GetValue()})
791
'email': self._panel.email.GetValue(),
792
'log': self.get_logs()})
788
794
f = urlopen(u"http://www.whyteboard.org/bug_submit.php", params)
790
796
self.gui.prompt_for_save(self.Close)
799
logcontents = [x for x in LogRemembererHandler().get_logs()]
800
# last log is stacktrace...
801
return os.linesep.join(logcontents[:-1])
803
def check_email(self):
804
email = self._panel.email.GetValue()
807
dlg = self.prompt_for_email(email)
809
if dlg.ShowModal() == wx.ID_CANCEL:
811
self.email_prompted = True
814
valid = self.validate_email(email)
817
if dlg.ShowModal() == wx.ID_CANCEL:
819
self.email_prompted = True
821
new_email = dlg.GetValue()
823
if not self.validate_email(new_email):
824
wx.MessageBox("Please enter a valid email address")
825
dlg = self.prompt_for_email(new_email)
829
self._panel.email.SetValue(new_email)
832
if not self.validate_email(email):
833
wx.MessageBox("Please enter a valid email address")
836
def prompt_for_email(self, email):
837
dlg = wx.TextEntryDialog(self, _("You have not given your email address. Providing it can help fix bugs"),
838
_("No email address:"))
842
def validate_email(self, email):
844
http://www.daniweb.com/software-development/python/code/280071
846
sep = [x for x in email if not x.isalpha()]
847
sepjoined = ''.join(sep)
848
## sep joined must be ..@.... form
849
if sepjoined.strip('.') != '@':
853
part, i, end = end.partition(i)
793
857
#----------------------------------------------------------------------
795
859
def ExceptionHook(exctype, value, trace):