From fd22da96474268ce9e534702c8c995eca5eacfa8 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sun, 28 Sep 2014 10:02:43 +0300
Subject: [PATCH] Now logs exception as well.

---
 source/manager.py | 62 +++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/source/manager.py b/source/manager.py
index f748bb4..b90da07 100755
--- a/source/manager.py
+++ b/source/manager.py
@@ -14,27 +14,27 @@ from os.path import basename
 import syslog
 import time
 
-class verifyThread(QtCore.QThread):
+class verifyThread (QtCore.QThread):
     '''A seperate thread to verify the DCP (IO intensive).
 
     Verify the assets of DCP (reads all of the files to
     calculate the hash) in a seperate thread from the GUI to keep the GUI
     responsive. At the end update the verifyLine test to reflect the result.'''
-    def run(self):
+    def run (self):
         '''The action the thread takes.'''
-        result = dcp.verify()
+        result = dcp.verify ()
         try:
-            result = dcp.verify()
+            result = dcp.verify ()
             if result:
-                window.verifyLine.setText('OK')
+                window.verifyLine.setText ('OK')
                 syslog.syslog (syslog.LOG_INFO, time.ctime () +\
                         directoryname + ' verification succeeded.')
             else:
-                window.verifyLine.setText('Corrupted!')
+                window.verifyLine.setText ('Corrupted!')
                 syslog.syslog (syslog.LOG_INFO, time.ctime () +\
                         directoryname + ' verification failed.')
         except BaseException as exception:
-            window.verifyLine.setText(str(exception))
+            window.verifyLine.setText (str (exception))
 
 
 def verify_in_thread():
@@ -43,33 +43,33 @@ def verify_in_thread():
     Firstly disable the button and change the verifyLine to reflect that the
     verification is running (in the same thread to update the window immediately
     then calls the seperate thread to verify the assets of DCP.'''
-    window.verifyLine.setText('Verifying, please wait...')
-    window.verifyButton.setEnabled(False)
-    thread.start()
+    window.verifyLine.setText ('Verifying, please wait...')
+    window.verifyButton.setEnabled (False)
+    thread.start ()
 
 
 if __name__ == '__main__':
     syslog.openlog (ident = 'dcpman', facility = syslog.LOG_USER)
-    app = QtGui.QApplication(sys.argv)
-    icon = QtGui.QIcon('/usr/share/icons/oxygen/16x16/apps/kmplayer.png')
-    app.setWindowIcon(icon)
-    directory = QtGui.QFileDialog.getExistingDirectory( \
+    app = QtGui.QApplication (sys.argv)
+    icon = QtGui.QIcon ('/usr/share/icons/oxygen/16x16/apps/kmplayer.png')
+    app.setWindowIcon (icon)
+    directory = QtGui.QFileDialog.getExistingDirectory ( \
             caption='Please select the location of the DCP')
     directoryname = basename (directory)
-    mainwindow = QtGui.QMainWindow()
-    window = ui.Ui_MainWindow()
-    window.setupUi(mainwindow)
-    thread = verifyThread()
+    mainwindow = QtGui.QMainWindow ()
+    window = ui.Ui_MainWindow ()
+    window.setupUi (mainwindow)
+    thread = verifyThread ()
     try:
-        dcp = DCP(directory)
+        dcp = DCP (directory)
         try:
-            window.nameLine.setText(dcp.name)
+            window.nameLine.setText (dcp.name)
             syslog.syslog (syslog.LOG_INFO, time.ctime () + directoryname +\
                     ' parsed.')
-        except AttributeError:
+        except AttributeError as exception:
             window.nameLine.setText (basename (directory))
             syslog.syslog (syslog.LOG_INFO, time.ctime () + directoryname +\
-                    ' parsed.')
+                    exception)
         if dcp.signed:
              syslog.syslog (syslog.LOG_INFO, time.ctime () + directoryname +\
                      ' is signed.')
@@ -79,16 +79,16 @@ if __name__ == '__main__':
         syslog.syslog (syslog.LOG_INFO, time.ctime () + directoryname +\
                 ' duration is ' + str (dcp.duration))
         if dcp.signed and dcp.duration == 0:
-            window.encryptedLine.setText('Most likely')
+            window.encryptedLine.setText ('Most likely')
         elif dcp.signed or dcp.duration == 0:
             window.encryptedLine.setText ('Probably')
         else:
-            window.encryptedLine.setText('Probably not')
-        window.verifyLine.setText('Click button to start verification')
-        window.verifyButton.clicked.connect(verify_in_thread)
+            window.encryptedLine.setText ('Probably not')
+        window.verifyLine.setText ('Click button to start verification')
+        window.verifyButton.clicked.connect (verify_in_thread)
     except BaseException as exception:
-        window.nameLine.setText(str(exception))
-        window.verifyButton.setEnabled(False)
-    mainwindow.show()
-    mainwindow.activateWindow()
-    exit(app.exec_())
+        window.nameLine.setText (str (exception))
+        window.verifyButton.setEnabled (False)
+    mainwindow.show ()
+    mainwindow.activateWindow ()
+    exit(app.exec_ ())
-- 
GitLab