service log integration in config dialog
authorOliver Maurhart <oliver.maurhart@ait.ac.at>
Thu, 12 Jun 2014 12:27:28 +0200
changeset 188090d85701ed3
parent 187 63ca020b148d
child 189 59b383ff9780
service log integration in config dialog
OpenSecurity/bin/ui/configure_dialog.py
     1.1 --- a/OpenSecurity/bin/ui/configure_dialog.py	Thu Jun 12 12:14:38 2014 +0200
     1.2 +++ b/OpenSecurity/bin/ui/configure_dialog.py	Thu Jun 12 12:27:28 2014 +0200
     1.3 @@ -102,6 +102,8 @@
     1.4          self._file_watched_name = ''
     1.5          self._file_watched_size = 0
     1.6          self._file_watcher = QtCore.QTimer(self)
     1.7 +        self._service_log_path = ''
     1.8 +        self._service_log_size = 0
     1.9  
    1.10          # connectors
    1.11          self.ui.btnAbout.clicked.connect(self.clicked_about)
    1.12 @@ -178,6 +180,9 @@
    1.13              self.ui.edtStatus.setEnabled(True)
    1.14              self.ui.edtVersion.setText(j['os_server']['version'])
    1.15              self.ui.edtVersion.setEnabled(True)
    1.16 +            self._service_log_path = os.path.join(j['os_server']['current log folder'], 'OpenSecurity.log')
    1.17 +            self._service_log_size = 0
    1.18 +            print(self._service_log_path)
    1.19  
    1.20              # get initial template info
    1.21              j = json.load(urllib2.urlopen('http://127.0.0.1:8080/initial_image'))
    1.22 @@ -200,9 +205,6 @@
    1.23      def update_progress(self):
    1.24          
    1.25          """Our log file has changed, update ui"""
    1.26 -        
    1.27 -        if self._file_watched_name == '':
    1.28 -            return
    1.29  
    1.30          # we could use os.stat(PATH).st_mtime ...
    1.31          # 
    1.32 @@ -213,6 +215,18 @@
    1.33          #
    1.34          # This is terrible. 
    1.35  
    1.36 +        # first the service log
    1.37 +        if self._service_log_path != '':
    1.38 +            file_size = os.stat(self._service_log_path).st_size
    1.39 +            if file_size > self._service_log_size:
    1.40 +                f = open(self._service_log_path, 'r')
    1.41 +                self.ui.edtLog.setPlainText(f.read())
    1.42 +                self._service_log_size = file_size
    1.43 +        
    1.44 +        # now any processing log (download or import)
    1.45 +        if self._file_watched_name == '':
    1.46 +            return
    1.47 +
    1.48          file_size = os.stat(self._file_watched_name).st_size
    1.49          if self._file_watched_size >= file_size:
    1.50              return