summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/loggerwindow.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-05-16 16:18:59 -0300
committerTomás Touceda <chiiph@leap.se>2014-05-16 16:18:59 -0300
commit4c550c558dcb554b3ea1bc0246492e39e8532886 (patch)
tree3a18999e62eb18091d002e6c1c7222846a92947b /src/leap/bitmask/gui/loggerwindow.py
parent81715dc47d77934c4f67d2527a56c28f58f0345d (diff)
parentd52daa106a97562e1cc67c5a2f242f2ef9884508 (diff)
Merge branch 'release-0.5.1'0.5.1
Diffstat (limited to 'src/leap/bitmask/gui/loggerwindow.py')
-rw-r--r--src/leap/bitmask/gui/loggerwindow.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/leap/bitmask/gui/loggerwindow.py b/src/leap/bitmask/gui/loggerwindow.py
index 9f396574..f19b172f 100644
--- a/src/leap/bitmask/gui/loggerwindow.py
+++ b/src/leap/bitmask/gui/loggerwindow.py
@@ -21,14 +21,14 @@ History log window
import logging
import cgi
-from PySide import QtGui
+from PySide import QtCore, QtGui
from twisted.internet import threads
from ui_loggerwindow import Ui_LoggerWindow
from leap.bitmask.util.constants import PASTEBIN_API_DEV_KEY
from leap.bitmask.util.leap_log_handler import LeapLogHandler
-from leap.bitmask.util.pastebin import PastebinAPI, PastebinError
+from leap.bitmask.util import pastebin
from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
@@ -203,10 +203,10 @@ class LoggerWindow(QtGui.QDialog):
Send content to pastebin and return the link.
"""
content = self._current_history
- pb = PastebinAPI()
+ pb = pastebin.PastebinAPI()
link = pb.paste(PASTEBIN_API_DEV_KEY, content,
paste_name="Bitmask log",
- paste_expire_date='1W')
+ paste_expire_date='1M')
# convert to 'raw' link
link = "http://pastebin.com/raw.php?i=" + link.split('/')[-1]
@@ -220,12 +220,16 @@ class LoggerWindow(QtGui.QDialog):
:param link: the recently created pastebin link.
:type link: str
"""
+ self._set_pastebin_sending(False)
msg = self.tr("Your pastebin link <a href='{0}'>{0}</a>")
msg = msg.format(link)
- show_info = lambda: QtGui.QMessageBox.information(
- self, self.tr("Pastebin OK"), msg)
- self._set_pastebin_sending(False)
- self.reactor.callLater(0, show_info)
+
+ # We save the dialog in an instance member to avoid dialog being
+ # deleted right after we exit this method
+ self._msgBox = msgBox = QtGui.QMessageBox(
+ QtGui.QMessageBox.Information, self.tr("Pastebin OK"), msg)
+ msgBox.setWindowModality(QtCore.Qt.NonModal)
+ msgBox.show()
def pastebin_err(failure):
"""
@@ -234,13 +238,19 @@ class LoggerWindow(QtGui.QDialog):
:param failure: the failure that triggered the errback.
:type failure: twisted.python.failure.Failure
"""
+ self._set_pastebin_sending(False)
logger.error(repr(failure))
+
msg = self.tr("Sending logs to Pastebin failed!")
- show_err = lambda: QtGui.QMessageBox.critical(
- self, self.tr("Pastebin Error"), msg)
- self._set_pastebin_sending(False)
- self.reactor.callLater(0, show_err)
- failure.trap(PastebinError)
+ if failure.check(pastebin.PostLimitError):
+ msg = self.tr('Maximum posts per day reached')
+
+ # We save the dialog in an instance member to avoid dialog being
+ # deleted right after we exit this method
+ self._msgBox = msgBox = QtGui.QMessageBox(
+ QtGui.QMessageBox.Critical, self.tr("Pastebin Error"), msg)
+ msgBox.setWindowModality(QtCore.Qt.NonModal)
+ msgBox.show()
self._set_pastebin_sending(True)
d = threads.deferToThread(do_pastebin)