working on GUI
authorOliver Maurhart <oliver.maurhart@ait.ac.at>
Wed, 02 Apr 2014 10:27:38 +0200
changeset 11556a79fe30085
parent 114 a8d6c2165655
child 116 eb2c1260134e
working on GUI
OpenSecurity/bin/opensecurityd.pyw
OpenSecurity/bin/ui/configure_dialog.py
     1.1 --- a/OpenSecurity/bin/opensecurityd.pyw	Wed Apr 02 09:54:38 2014 +0200
     1.2 +++ b/OpenSecurity/bin/opensecurityd.pyw	Wed Apr 02 10:27:38 2014 +0200
     1.3 @@ -124,17 +124,8 @@
     1.4          download_initial_image_script = '/OpenSecurity/bin/download_initial_image.sh \'' + machine_folder + '\''
     1.5          Cygwin.bashExecute(download_initial_image_script, wait_return = False, stdout = trace_file, stderr = trace_file) 
     1.6  
     1.7 -        page = """
     1.8 -        <html>
     1.9 -        <head></head>
    1.10 -        <body>
    1.11 -        Fetch OpenSecurity image log ({0}):<br/>
    1.12 -        <iframe src="file://{0}" width="100%" height="100%"></iframe>
    1.13 -        </body>
    1.14 -        </head>
    1.15 -        """
    1.16 -        return page.format(trace_file_name)
    1.17 -
    1.18 +        res = '{ "fetch.log": " ' + trace_file_name.replace('\\', '\\\\') + '" }'
    1.19 +        return res
    1.20  
    1.21  class os_init:
    1.22      """OpenSecurity '/init' handler
    1.23 @@ -153,16 +144,8 @@
    1.24          initial_import_script = '/OpenSecurity/bin/initial_vm.sh \'' + vm_image + '\''
    1.25          Cygwin.bashExecute(initial_import_script, wait_return = False, stdout = trace_file, stderr = trace_file) 
    1.26  
    1.27 -        page = """
    1.28 -        <html>
    1.29 -        <head></head>
    1.30 -        <body>
    1.31 -        Import initial OpenSecurity image log ({0}):<br/>
    1.32 -        <iframe src="file://{0}" width="100%" height="100%"></iframe>
    1.33 -        </body>
    1.34 -        </head>
    1.35 -        """
    1.36 -        return page.format(trace_file_name)
    1.37 +        res = '{ "init.log": " ' + trace_file_name.replace('\\', '\\\\') + '" }'
    1.38 +        return res
    1.39  
    1.40  
    1.41  class os_initial_image:
     2.1 --- a/OpenSecurity/bin/ui/configure_dialog.py	Wed Apr 02 09:54:38 2014 +0200
     2.2 +++ b/OpenSecurity/bin/ui/configure_dialog.py	Wed Apr 02 10:27:38 2014 +0200
     2.3 @@ -66,6 +66,7 @@
     2.4  
     2.5          # local members
     2.6          self._about_dialog = AboutDialog()
     2.7 +        self._file_watcher = QtCore.QFileSystemWatcher(self)
     2.8  
     2.9          # connectors
    2.10          self.ui.btnAbout.clicked.connect(self.clicked_about)
    2.11 @@ -87,6 +88,25 @@
    2.12      def clicked_download(self):
    2.13  
    2.14          """Download button has been clicked."""
    2.15 +
    2.16 +        self.ui.edtProgress.clear()
    2.17 +        while  self._file_watcher.files().count() > 0:
    2.18 +            self._file_watcher.removePath(self._file_watcher.files().first())
    2.19 +
    2.20 +        try:
    2.21 +            pass
    2.22 +
    2.23 +        except:
    2.24 +            pass
    2.25 +
    2.26 +        # get general server info
    2.27 +        #j = json.load(urllib2.urlopen('http://127.0.0.1:8080/fetch_initial_image'))
    2.28 +        #file_name = j['fetch_log']
    2.29 +        file_name = 'C:\\Windows\\Temp\\OpenSecurity_fetch_image.log'
    2.30 +        f = open(file_name, 'r')
    2.31 +        self.ui.edtProgress.appendPlainText(f.read())
    2.32 +
    2.33 + 
    2.34          print('clicked_download()')
    2.35  
    2.36