Added Exception Debugging for pyqt application
This commit is contained in:
parent
edf78275af
commit
1fcfe6009e
|
@ -0,0 +1,29 @@
|
|||
"""
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def read_hashset_file(filename):
|
||||
with open(filename, 'r') as hashfile:
|
||||
ltest = list(hashfile.readlines())
|
||||
return ltest
|
||||
|
||||
|
||||
def load_hashsets(path, status_callback=None):
|
||||
hashsets = {}
|
||||
for content in os.listdir(path):
|
||||
filename = os.path.join(path, content)
|
||||
if os.path.isfile(filename):
|
||||
hashset = os.path.basename(filename).split('.')[0]
|
||||
print('Reading Hashset "{}"...'.format(hashset))
|
||||
if status_callback:
|
||||
status_callback('Reading Hashset "{}"...'.format(hashset))
|
||||
hashes = read_hashset_file(filename)
|
||||
hashsets[hashset] = set(hashes)
|
||||
return hashsets
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
hashsets = load_hashsets('Hashsets')
|
|
@ -1,13 +1,30 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import locale
|
||||
from PyQt5.QtCore import Qt, QDateTime, QLocale
|
||||
from PyQt5.QtCore import Qt, QDateTime, QObject, pyqtSignal
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QAbstractItemView, QTableWidgetItem
|
||||
from PyQt5.QtGui import QStandardItemModel
|
||||
from MuleAnalyzerUI import Ui_MainWindow
|
||||
|
||||
from ED2K import load_knownfiles
|
||||
from HashDatabase import load_hashsets
|
||||
|
||||
|
||||
class ExceptionHandler(QObject):
|
||||
errorSignal = pyqtSignal()
|
||||
|
||||
def __init__(self):
|
||||
super(ExceptionHandler, self).__init__()
|
||||
|
||||
def handler(self, exctype, value, traceback):
|
||||
self.errorSignal.emit()
|
||||
sys._excepthook(exctype, value, traceback)
|
||||
|
||||
|
||||
exceptionHandler = ExceptionHandler()
|
||||
sys._excepthook = sys.excepthook
|
||||
sys.excepthook = exceptionHandler.handler
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
|
@ -132,6 +149,9 @@ def main(argv):
|
|||
app = QApplication(argv)
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
|
||||
exceptionHandler.errorSignal.connect(load_hashsets)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue