Error reports are now dropped by FTP on drop.hardcoded.net

This commit is contained in:
Virgil Dupras 2014-01-26 15:03:24 -05:00
parent f66db94ffd
commit 1104e24408
2 changed files with 27 additions and 6 deletions

23
hscommon/error_report.py Normal file
View File

@ -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()

View File

@ -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()