From 1104e24408ef71b82d2d2fb9a5fe643d1005e3c0 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 26 Jan 2014 15:03:24 -0500 Subject: [PATCH] Error reports are now dropped by FTP on drop.hardcoded.net --- hscommon/error_report.py | 23 +++++++++++++++++++++++ qtlib/error_report_dialog.py | 10 ++++------ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 hscommon/error_report.py diff --git a/hscommon/error_report.py b/hscommon/error_report.py new file mode 100644 index 00000000..82ee3973 --- /dev/null +++ b/hscommon/error_report.py @@ -0,0 +1,23 @@ +# Created By: Virgil Dupras +# Created On: 2014-01-26 +# Copyright 2014 Hardcoded Software (http://www.hardcoded.net) +# +# This software is licensed under the "BSD" License as described in the "LICENSE" file, +# which should be included with this package. The terms are also available at +# http://www.hardcoded.net/licenses/bsd_license + +import ftplib +import io +import time +import threading + +def send_error_report(text): + def do(): + conn = ftplib.FTP('drop.hardcoded.net') + conn.login() + conn.cwd('/drop') + textfp = io.BytesIO(text.encode('utf-8')) + cmd = 'STOR report%d.txt' % time.time() + conn.storbinary(cmd, textfp) + + threading.Thread(target=do).start() diff --git a/qtlib/error_report_dialog.py b/qtlib/error_report_dialog.py index 6236a7e5..6e98dd1c 100644 --- a/qtlib/error_report_dialog.py +++ b/qtlib/error_report_dialog.py @@ -10,12 +10,12 @@ import traceback import sys import os -from PyQt5.QtCore import Qt, QUrl, QCoreApplication, QSize -from PyQt5.QtGui import QDesktopServices +from PyQt5.QtCore import Qt, QCoreApplication, QSize from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPlainTextEdit, QPushButton, QApplication) from hscommon.trans import trget +from hscommon.error_report import send_error_report from .util import horizontalSpacer tr = trget('qtlib') @@ -27,7 +27,7 @@ class ErrorReportDialog(QDialog): self._setupUi() name = QCoreApplication.applicationName() version = QCoreApplication.applicationVersion() - errorText = "Application Name: {0}\nVersion: {1}\n\n{2}".format(name, version, error) + errorText = "Application Name: {}\nVersion: {}\n\n{}".format(name, version, error) # Under windows, we end up with an error report without linesep if we don't mangle it errorText = errorText.replace('\n', os.linesep) self.errorTextEdit.setPlainText(errorText) @@ -65,9 +65,7 @@ class ErrorReportDialog(QDialog): self.verticalLayout.addLayout(self.horizontalLayout) def accept(self): - text = self.errorTextEdit.toPlainText() - url = QUrl("mailto:support@hardcoded.net?SUBJECT=Error Report&BODY=%s" % text) - QDesktopServices.openUrl(url) + send_error_report(self.errorTextEdit.toPlainText()) super().accept()