def contribute_translations(item=None): do_it = gmGuiHelpers.gm_show_question ( aTitle = _('Contributing translations'), aMessage = _('Do you want to contribute your translations to the GNUmed project ?') ) if not do_it: return False fname = gmTools.get_unique_filename(prefix = 'gm-db-translations-', suffix = '.sql') gmPG2.export_translations_from_database(filename = fname) msg = ( 'These are database string translations contributed by a GNUmed user.\n' '\n' '\tThe GNUmed "%s" Client' ) % gmI18N.system_locale if not gmNetworkTools.compose_and_send_email ( auth = {'user': gmNetworkTools.default_mail_sender, 'password': '******'}, sender = 'GNUmed Client <*****@*****.**>', receiver = ['*****@*****.**'], subject = '<contribution>: database translation', message = msg, attachments = [[fname, 'text/plain', 'quoted-printable']] ): gmDispatcher.send(signal = 'statustext', msg = _('Unable to send mail. Cannot contribute translations to GNUmed community.') % report, beep = True) return False gmDispatcher.send(signal = 'statustext', msg = _('Thank you for your contribution to the GNUmed community!'), beep = True) return True
def _on_contribute_button_pressed(self, evt): report = self._PRW_report_name.GetValue().strip() if report == '': gmDispatcher.send(signal = 'statustext', msg = _('Report must have a name for contribution.'), beep = False) return query = self._TCTRL_query.GetValue().strip() if query == '': gmDispatcher.send(signal = 'statustext', msg = _('Report must have a query for contribution.'), beep = False) return do_it = gmGuiHelpers.gm_show_question ( _( 'Be careful that your contribution (the query itself) does\n' 'not contain any person-identifiable search parameters.\n' '\n' 'Note, however, that no query result data whatsoever\n' 'is included in the contribution that will be sent.\n' '\n' 'Are you sure you wish to send this query to\n' 'the gnumed community mailing list?\n' ), _('Contributing custom report') ) if not do_it: return msg = """--- This is a report definition contributed by a GNUmed user. --- Save it as a text file and drop it onto the Report Generator --- inside GNUmed in order to take advantage of the contribution. ---------------------------------------- --- %s %s ---------------------------------------- --- The GNUmed client. """ % (report, query) auth = {'user': gmNetworkTools.default_mail_sender, 'password': '******'} if not gmNetworkTools.compose_and_send_email ( sender = 'GNUmed Report Generator <*****@*****.**>', receiver = ['*****@*****.**'], subject = 'user contributed report', message = msg, server = gmNetworkTools.default_mail_server, auth = auth ): gmDispatcher.send(signal = 'statustext', msg = _('Unable to send mail. Cannot contribute report [%s] to GNUmed community.') % report, beep = True) return False gmDispatcher.send(signal = 'statustext', msg = _('Thank you for your contribution to the GNUmed community!'), beep = False) return True
def mail_log(parent=None, comment=None, helpdesk=None, sender=None): if (comment is None) or (comment.strip() == ''): comment = wx.GetTextFromUser ( message = _( 'Please enter a short note on what you\n' 'were about to do in GNUmed:' ), caption = _('Sending bug report'), parent = parent ) if comment.strip() == '': comment = '<user did not comment on bug report>' receivers = [] if helpdesk is not None: receivers = regex.findall ( '[\S]+@[\S]+', helpdesk.strip(), flags = regex.UNICODE ) if len(receivers) == 0: if _is_public_database: receivers = ['*****@*****.**'] receiver_string = wx.GetTextFromUser ( message = _( 'Edit the list of email addresses to send the\n' 'bug report to (separate addresses by spaces).\n' '\n' 'Note that <*****@*****.**> refers to\n' 'the public (!) GNUmed bugs mailing list.' ), caption = _('Sending bug report'), default_value = ','.join(receivers), parent = parent ) if receiver_string.strip() == '': return receivers = regex.findall ( '[\S]+@[\S]+', receiver_string, flags = regex.UNICODE ) dlg = gmGuiHelpers.c2ButtonQuestionDlg ( parent, -1, caption = _('Sending bug report'), question = _( 'Your bug report will be sent to:\n' '\n' '%s\n' '\n' 'Make sure you have reviewed the log file for potentially\n' 'sensitive information before sending out the bug report.\n' '\n' 'Note that emailing the report may take a while depending\n' 'on the speed of your internet connection.\n' ) % '\n'.join(receivers), button_defs = [ {'label': _('Send report'), 'tooltip': _('Yes, send the bug report.')}, {'label': _('Cancel'), 'tooltip': _('No, do not send the bug report.')} ], show_checkbox = True, checkbox_msg = _('include log file in bug report') ) dlg._CHBOX_dont_ask_again.SetValue(_is_public_database) go_ahead = dlg.ShowModal() if go_ahead == wx.ID_NO: dlg.DestroyLater() return include_log = dlg._CHBOX_dont_ask_again.GetValue() if not _is_public_database: if include_log: result = gmGuiHelpers.gm_show_question ( _( 'The database you are connected to is marked as\n' '"in-production with controlled access".\n' '\n' 'You indicated that you want to include the log\n' 'file in your bug report. While this is often\n' 'useful for debugging the log file might contain\n' 'bits of patient data which must not be sent out\n' 'without de-identification.\n' '\n' 'Please confirm that you want to include the log !' ), _('Sending bug report') ) include_log = (result is True) if sender is None: sender = _('<not supplied>') else: if sender.strip() == '': sender = _('<not supplied>') msg = """\ Report sent via GNUmed's handler for unexpected exceptions. user comment : %s client version: %s system account: %s staff member : %s sender email : %s # enable Launchpad bug tracking affects gnumed tag automatic-report importance medium """ % (comment, _client_version, _local_account, _staff_name, sender) if include_log: _log.error(comment) _log.warning('syncing log file for emailing') gmLog2.flush() attachments = [ [_logfile_name, 'text/plain', 'quoted-printable'] ] else: attachments = None dlg.DestroyLater() wx.BeginBusyCursor() _cfg = gmCfg2.gmCfgData() try: gmNetworkTools.compose_and_send_email ( sender = '%s <%s>' % (_staff_name, gmNetworkTools.default_mail_sender), receiver = receivers, subject = '<bug>: %s' % comment, message = msg, server = gmNetworkTools.default_mail_server, auth = {'user': gmNetworkTools.default_mail_sender, 'password': '******'}, debug = _cfg.get(option = 'debug'), attachments = attachments ) gmDispatcher.send(signal='statustext', msg = _('Bug report has been emailed.')) except: _log.exception('cannot send bug report') gmDispatcher.send(signal='statustext', msg = _('Bug report COULD NOT be emailed.')) wx.EndBusyCursor()
def _on_contribute_button_pressed(self, evt): report = self._PRW_report_name.GetValue().strip() if report == '': gmDispatcher.send( signal='statustext', msg=_('Report must have a name for contribution.'), beep=False) return query = self._TCTRL_query.GetValue().strip() if query == '': gmDispatcher.send( signal='statustext', msg=_('Report must have a query for contribution.'), beep=False) return do_it = gmGuiHelpers.gm_show_question( _('Be careful that your contribution (the query itself) does\n' 'not contain any person-identifiable search parameters.\n' '\n' 'Note, however, that no query result data whatsoever\n' 'is included in the contribution that will be sent.\n' '\n' 'Are you sure you wish to send this query to\n' 'the gnumed community mailing list?\n'), _('Contributing custom report')) if not do_it: return msg = """--- This is a report definition contributed by a GNUmed user. --- Save it as a text file and drop it onto the Report Generator --- inside GNUmed in order to take advantage of the contribution. ---------------------------------------- --- %s %s ---------------------------------------- --- The GNUmed client. """ % (report, query) auth = { 'user': gmNetworkTools.default_mail_sender, 'password': '******' } if not gmNetworkTools.compose_and_send_email( sender='GNUmed Report Generator <*****@*****.**>', receiver=['*****@*****.**'], subject='user contributed report', message=msg, server=gmNetworkTools.default_mail_server, auth=auth): gmDispatcher.send( signal='statustext', msg= _('Unable to send mail. Cannot contribute report [%s] to GNUmed community.' ) % report, beep=True) return False gmDispatcher.send( signal='statustext', msg=_('Thank you for your contribution to the GNUmed community!'), beep=False) return True
def mail_log(parent=None, comment=None, helpdesk=None, sender=None): if (comment is None) or (comment.strip() == ''): comment = wx.GetTextFromUser(message=_( 'Please enter a short note on what you\n' 'were about to do in GNUmed:'), caption=_('Sending bug report'), parent=parent) if comment.strip() == '': comment = '<user did not comment on bug report>' receivers = [] if helpdesk is not None: receivers = regex.findall('[\S]+@[\S]+', helpdesk.strip(), flags=regex.UNICODE) if len(receivers) == 0: if _is_public_database: receivers = ['*****@*****.**'] receiver_string = wx.GetTextFromUser(message=_( 'Edit the list of email addresses to send the\n' 'bug report to (separate addresses by spaces).\n' '\n' 'Note that <*****@*****.**> refers to\n' 'the public (!) GNUmed bugs mailing list.'), caption=_('Sending bug report'), default_value=','.join(receivers), parent=parent) if receiver_string.strip() == '': return receivers = regex.findall('[\S]+@[\S]+', receiver_string, flags=regex.UNICODE) dlg = gmGuiHelpers.c2ButtonQuestionDlg( parent, -1, caption=_('Sending bug report'), question=_('Your bug report will be sent to:\n' '\n' '%s\n' '\n' 'Make sure you have reviewed the log file for potentially\n' 'sensitive information before sending out the bug report.\n' '\n' 'Note that emailing the report may take a while depending\n' 'on the speed of your internet connection.\n') % '\n'.join(receivers), button_defs=[{ 'label': _('Send report'), 'tooltip': _('Yes, send the bug report.') }, { 'label': _('Cancel'), 'tooltip': _('No, do not send the bug report.') }], show_checkbox=True, checkbox_msg=_('include log file in bug report')) dlg._CHBOX_dont_ask_again.SetValue(_is_public_database) go_ahead = dlg.ShowModal() if go_ahead == wx.ID_NO: dlg.DestroyLater() return include_log = dlg._CHBOX_dont_ask_again.GetValue() if not _is_public_database: if include_log: result = gmGuiHelpers.gm_show_question( _('The database you are connected to is marked as\n' '"in-production with controlled access".\n' '\n' 'You indicated that you want to include the log\n' 'file in your bug report. While this is often\n' 'useful for debugging the log file might contain\n' 'bits of patient data which must not be sent out\n' 'without de-identification.\n' '\n' 'Please confirm that you want to include the log !'), _('Sending bug report')) include_log = (result is True) if sender is None: sender = _('<not supplied>') else: if sender.strip() == '': sender = _('<not supplied>') msg = """\ Report sent via GNUmed's handler for unexpected exceptions. user comment : %s client version: %s system account: %s staff member : %s sender email : %s # enable Launchpad bug tracking affects gnumed tag automatic-report importance medium """ % (comment, _client_version, _local_account, _staff_name, sender) if include_log: _log.error(comment) _log.warning('syncing log file for emailing') gmLog2.flush() attachments = [[_logfile_name, 'text/plain', 'quoted-printable']] else: attachments = None dlg.DestroyLater() wx.BeginBusyCursor() _cfg = gmCfg2.gmCfgData() try: gmNetworkTools.compose_and_send_email( sender='%s <%s>' % (_staff_name, gmNetworkTools.default_mail_sender), receiver=receivers, subject='<bug>: %s' % comment, message=msg, server=gmNetworkTools.default_mail_server, auth={ 'user': gmNetworkTools.default_mail_sender, 'password': '******' }, debug=_cfg.get(option='debug'), attachments=attachments) gmDispatcher.send(signal='statustext', msg=_('Bug report has been emailed.')) except: _log.exception('cannot send bug report') gmDispatcher.send(signal='statustext', msg=_('Bug report COULD NOT be emailed.')) wx.EndBusyCursor()