1.1 --- a/OpenSecurity/bin/opensecurity_client_restful_server.py Mon Sep 29 12:47:06 2014 +0200
1.2 +++ b/OpenSecurity/bin/opensecurity_client_restful_server.py Tue Sep 30 11:27:15 2014 +0200
1.3 @@ -99,12 +99,12 @@
1.4 log_file_bouncer = None
1.5
1.6 """The REST server object"""
1.7 -server = None
1.8 -
1.9 +#restful_client_server = None
1.10
1.11 """The System Tray Icon instance"""
1.12 tray_icon = None
1.13
1.14 +
1.15 # ------------------------------------------------------------
1.16 # code
1.17
1.18 @@ -537,11 +537,11 @@
1.19
1.20 def GET(self):
1.21
1.22 - stop()
1.23 + server = web.ctx.app_stack[0]
1.24 + raise KeyboardInterrupt()
1.25 return 'done'
1.26
1.27
1.28 -
1.29 class ProcessResultBouncer(threading.Thread):
1.30
1.31 """A class to post the result of a given process - assuming it to be in JSON - to a REST Api."""
1.32 @@ -716,8 +716,6 @@
1.33
1.34 """Start the REST server"""
1.35
1.36 - global server
1.37 -
1.38 # start the VM-log bouncer timer
1.39 global log_file_bouncer
1.40 log_file_bouncer = threading.Timer(5.0, _bounce_vm_logs)
1.41 @@ -728,6 +726,11 @@
1.42 server = web.application(opensecurity_urls, globals())
1.43 server.run()
1.44
1.45 + # from this point on we received the quit call
1.46 + # and are winding down
1.47 + log_file_bouncer.cancel()
1.48 + QtGui.QApplication.quit()
1.49 +
1.50
1.51 def serve(port = 8090, background = False):
1.52
1.53 @@ -736,27 +739,16 @@
1.54 background ... cease into background (spawn thread) and return immediately"""
1.55
1.56 # start threaded or direct version
1.57 + print('background=%s' % (str(background)))
1.58 if background == True:
1.59 t = RESTServerThread(port)
1.60 t.start()
1.61 else:
1.62 _serve(port)
1.63
1.64 -def stop():
1.65 -
1.66 - """Stop serving the REST Api"""
1.67 -
1.68 - global server
1.69 - if server is None:
1.70 - return
1.71 -
1.72 - global log_file_bouncer
1.73 - if log_file_bouncer is not None:
1.74 - log_file_bouncer.cancel()
1.75 -
1.76 - server.stop()
1.77
1.78 # start
1.79 if __name__ == "__main__":
1.80 serve()
1.81
1.82 +