added tray client termination support for uninstall
authorOliver Maurhart <oliver.maurhart@ait.ac.at>
Mon, 29 Sep 2014 12:46:51 +0200
changeset 226107dc235508f
parent 225 e68561e69f86
child 227 d93217c95131
added tray client termination support for uninstall
OpenSecurity.iss
OpenSecurity/bin/opensecurity_client_restful_server.py
OpenSecurity/bin/terminate_client_tray.pyw
     1.1 --- a/OpenSecurity.iss	Mon Sep 29 11:55:16 2014 +0200
     1.2 +++ b/OpenSecurity.iss	Mon Sep 29 12:46:51 2014 +0200
     1.3 @@ -65,6 +65,7 @@
     1.4  
     1.5  [UninstallRun]
     1.6  ; When uninstalling run this command prior
     1.7 +Filename: "{app}\python27\pythonw.exe"; Parameters: """{app}\bin\terminate_client_tray.pyw"" stop"; WorkingDir: "{app}"; StatusMsg: "Stopping the OpenSecurity Client Tray Service"; Flags: runascurrentuser
     1.8  Filename: "{app}\python27\pythonw.exe"; Parameters: """{app}\bin\opensecurity_service.pyw"" stop"; WorkingDir: "{app}"; StatusMsg: "Stopping the OpenSecurity Service"; Flags: runascurrentuser
     1.9  Filename: "{app}\python27\pythonw.exe"; Parameters: """{app}\bin\opensecurity_service.pyw"" remove"; WorkingDir: "{app}"; StatusMsg: "Removing the OpenSecurity Service"; Flags: runascurrentuser
    1.10  
     2.1 --- a/OpenSecurity/bin/opensecurity_client_restful_server.py	Mon Sep 29 11:55:16 2014 +0200
     2.2 +++ b/OpenSecurity/bin/opensecurity_client_restful_server.py	Mon Sep 29 12:46:51 2014 +0200
     2.3 @@ -83,6 +83,7 @@
     2.4      '/netmount',                'os_netmount',
     2.5      '/netumount',               'os_netumount',
     2.6      '/netcleanup',              'os_netcleanup',
     2.7 +    '/quit',                    'os_quit',
     2.8      '/',                        'os_root'
     2.9  )
    2.10  
    2.11 @@ -527,6 +528,20 @@
    2.12          return res
    2.13  
    2.14  
    2.15 +class os_quit:
    2.16 +
    2.17 +    """OpenSecurity '/quit' handler.
    2.18 +    
    2.19 +    Terminate the client REST server
    2.20 +    """
    2.21 +    
    2.22 +    def GET(self):
    2.23 +        
    2.24 +        stop()
    2.25 +        return 'done'
    2.26 +
    2.27 +
    2.28 +
    2.29  class ProcessResultBouncer(threading.Thread):
    2.30  
    2.31      """A class to post the result of a given process - assuming it to be in JSON - to a REST Api."""
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/OpenSecurity/bin/terminate_client_tray.pyw	Mon Sep 29 12:46:51 2014 +0200
     3.3 @@ -0,0 +1,51 @@
     3.4 +# -*- coding: utf-8 -*-
     3.5 +
     3.6 +# ------------------------------------------------------------
     3.7 +# terminate the client tray
     3.8 +# 
     3.9 +# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    3.10 +#
    3.11 +# Copyright (C) 2014 AIT Austrian Institute of Technology
    3.12 +# AIT Austrian Institute of Technology GmbH
    3.13 +# Donau-City-Strasse 1 | 1220 Vienna | Austria
    3.14 +# http://www.ait.ac.at
    3.15 +#
    3.16 +# This program is free software; you can redistribute it and/or
    3.17 +# modify it under the terms of the GNU General Public License
    3.18 +# as published by the Free Software Foundation version 2.
    3.19 +# 
    3.20 +# This program is distributed in the hope that it will be useful,
    3.21 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.22 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.23 +# GNU General Public License for more details.
    3.24 +# 
    3.25 +# You should have received a copy of the GNU General Public License
    3.26 +# along with this program; if not, write to the Free Software
    3.27 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    3.28 +# Boston, MA  02110-1301, USA.
    3.29 +# ------------------------------------------------------------
    3.30 +
    3.31 +
    3.32 +# ------------------------------------------------------------
    3.33 +# imports
    3.34 +
    3.35 +import urllib2
    3.36 +
    3.37 +
    3.38 +# ------------------------------------------------------------
    3.39 +# code
    3.40 +
    3.41 +
    3.42 +# start
    3.43 +if __name__ == "__main__":
    3.44 +
    3.45 +    try:
    3.46 +
    3.47 +        # TODO: HARDCODED ADDRESS OF OPENSECURITY CLIENT TRAY
    3.48 +        browsing_vm = urllib2.urlopen('http://127.0.0.1:8090/quit').readline()
    3.49 +        print('Called http://127.0.0.1:8090/quit')
    3.50 +        
    3.51 +    except Exception as e:
    3.52 +        print('Failed: %s' % (e.message))
    3.53 +        
    3.54 +