diff --git a/hue_plus/hue_ui.py b/hue_plus/hue_ui.py index 4e24a06..e7e1893 100755 --- a/hue_plus/hue_ui.py +++ b/hue_plus/hue_ui.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -VERSION="1.4.2" +VERSION="1.4.3" import sys +import io +import traceback from time import sleep import os import types @@ -55,6 +57,7 @@ def main(): # sys.exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'.") #if not is_admin(): # runAsAdmin() + sys.excepthook = excepthook app = QApplication(sys.argv) form = MainWindow() form.show() @@ -735,5 +738,36 @@ def animatedApply(self): self.animatedThread = multiprocessing.Process(target=hue.animated, args=(self.portTxt.text(), self.getChannel(), self.animatedColors, self.animatedSpeed.value())) self.animatedThread.start() + +def excepthook(excType, excValue, tracebackobj): + """Rewritten "excepthook" function, to display a message box with details about the exception. + @param excType exception type + @param excValue exception value + @param tracebackobj traceback object + """ + separator = '-' * 40 + notice = "An unhandled exception has occurred\n" + + tbinfofile = io.StringIO() + traceback.print_tb(tracebackobj, None, tbinfofile) + tbinfofile.seek(0) + tbinfo = tbinfofile.read() + errmsg = '%s: \n%s' % (str(excType), str(excValue)) + sections = [separator, errmsg, separator, tbinfo] + msg = '\n'.join(sections) + + # Create a QMessagebox + error_box = QMessageBox() + + error_box.setText(str(notice)+str(msg)) + error_box.setWindowTitle("Hue-plus - unhandled exception") + error_box.setIcon(QMessageBox.Critical) + error_box.setStandardButtons(QMessageBox.Ok) + error_box.setTextInteractionFlags(Qt.TextSelectableByMouse) + + # Show the window + error_box.exec_() + sys.exit(1) + if __name__ == '__main__': main() diff --git a/installer.cfg b/installer.cfg index 79a921b..c8c9e7a 100644 --- a/installer.cfg +++ b/installer.cfg @@ -1,6 +1,6 @@ [Application] name=hue_plus -version=1.4.2 +version=1.4.3 publisher=Gustav Hansen # How to launch the app - this calls the 'main' function from the 'myapp' package: entry_point=hue_plus.hue_ui:main diff --git a/setup.py b/setup.py index bb7d758..52072be 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import os setup(name='hue_plus', - version='1.4.2', + version='1.4.3', description='A utility to control the NZXT Hue+ in Linux', classifiers=[ 'Development Status :: 5 - Production/Stable', diff --git a/version b/version index 9df886c..428b770 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.4.2 +1.4.3