UI/ErrorLogDialog.py

Mon, 25 Mar 2013 03:11:06 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 25 Mar 2013 03:11:06 +0100
branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2302
f29e9405c851
child 3057
10516539f238
permissions
-rw-r--r--

Script changes: Future import added, super calls modified and unicode behavior for str.

1726
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1745
diff changeset
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
1726
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to display an error log.
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
10 from __future__ import unicode_literals # __IGNORE_WARNING__
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
1726
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt4.QtCore import pyqtSlot
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt4.QtGui import QDialog, QStyle
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_ErrorLogDialog import Ui_ErrorLogDialog
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class ErrorLogDialog(QDialog, Ui_ErrorLogDialog):
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing a dialog to display an error log.
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, logFile, parent=None):
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param logFile name of the log file containing the error info (string)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param parent reference to the parent widget (QWidget)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
31 super(ErrorLogDialog, self).__init__(parent)
1726
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.setupUi(self)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 pixmap = self.style().standardIcon(QStyle.SP_MessageBoxQuestion).pixmap(32, 32)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.icon.setPixmap(pixmap)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.__ui = parent
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__logFile = logFile
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 try:
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 f = open(logFile, "r", encoding="utf-8")
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 txt = f.read()
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 f.close()
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.logEdit.setPlainText(txt)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 except IOError:
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 pass
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @pyqtSlot()
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 def on_emailButton_clicked(self):
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 Private slot to send an email.
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
1745
74c05a1ca2bc Fixed an issue with the new error log dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1740
diff changeset
53 self.accept()
1726
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__ui.showEmailDialog("bug",
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 attachFile=self.__logFile, deleteAttachFile=True)
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @pyqtSlot()
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 def on_deleteButton_clicked(self):
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Private slot to delete the log file.
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
1740
6a92ffd41de8 Fixed an issue in the error log dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1726
diff changeset
62 if os.path.exists(self.__logFile):
6a92ffd41de8 Fixed an issue in the error log dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1726
diff changeset
63 os.remove(self.__logFile)
1726
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.accept()
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @pyqtSlot()
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 def on_keepButton_clicked(self):
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 Private slot to just do nothing.
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
5d3132740ece Added a dialog to show a saved error log upon startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.accept()

eric ide

mercurial