# HG changeset patch # User Oliver Maurhart # Date 1412069235 -7200 # Node ID 0672e435d564824974cf46ebb5e972571228454d # Parent d93217c951319e18525e641f241535d0cdb50680 termintate tray icon via REST call "/quit" diff -r d93217c95131 -r 0672e435d564 OpenSecurity/bin/opensecurity_client_restful_server.py --- a/OpenSecurity/bin/opensecurity_client_restful_server.py Mon Sep 29 12:47:06 2014 +0200 +++ b/OpenSecurity/bin/opensecurity_client_restful_server.py Tue Sep 30 11:27:15 2014 +0200 @@ -99,12 +99,12 @@ log_file_bouncer = None """The REST server object""" -server = None - +#restful_client_server = None """The System Tray Icon instance""" tray_icon = None + # ------------------------------------------------------------ # code @@ -537,11 +537,11 @@ def GET(self): - stop() + server = web.ctx.app_stack[0] + raise KeyboardInterrupt() return 'done' - class ProcessResultBouncer(threading.Thread): """A class to post the result of a given process - assuming it to be in JSON - to a REST Api.""" @@ -716,8 +716,6 @@ """Start the REST server""" - global server - # start the VM-log bouncer timer global log_file_bouncer log_file_bouncer = threading.Timer(5.0, _bounce_vm_logs) @@ -728,6 +726,11 @@ server = web.application(opensecurity_urls, globals()) server.run() + # from this point on we received the quit call + # and are winding down + log_file_bouncer.cancel() + QtGui.QApplication.quit() + def serve(port = 8090, background = False): @@ -736,27 +739,16 @@ background ... cease into background (spawn thread) and return immediately""" # start threaded or direct version + print('background=%s' % (str(background))) if background == True: t = RESTServerThread(port) t.start() else: _serve(port) -def stop(): - - """Stop serving the REST Api""" - - global server - if server is None: - return - - global log_file_bouncer - if log_file_bouncer is not None: - log_file_bouncer.cancel() - - server.stop() # start if __name__ == "__main__": serve() +