1 """MyProxy Server Utilities module
2 """
3 __author__ = "P J Kershaw"
4 __date__ = "28/05/12"
5 __copyright__ = "(C) 2012 Science and Technology Facilities Council"
6 __license__ = "BSD - see LICENSE file in top-level directory"
7 __contact__ = "Philip.Kershaw@stfc.ac.uk"
8 __revision__ = '$Id$'
9 import logging
10 logging.basicConfig(level=logging.DEBUG)
11
12 import paste.httpserver
13 from threading import Thread
14 from paste.deploy import loadapp
15 from paste.script.util.logging_config import fileConfig
19 """Wrapper to paste.httpserver to enable background threading"""
20
21 - def __init__(self, app=None, cfgFilePath=None, port=7443, host='0.0.0.0',
22 ssl_context=None, withLoggingConfig=True):
23 """Load an application configuration from cfgFilePath ini file and
24 instantiate Paste server object
25 """
26 self.__thread = None
27
28 if cfgFilePath:
29 if withLoggingConfig:
30 fileConfig(cfgFilePath)
31 app = loadapp('config:%s' % cfgFilePath)
32
33 elif app is None:
34 raise KeyError('Either the "cfgFilePath" or "app" keyword must be '
35 'set')
36
37 self.__pasteServer = paste.httpserver.serve(app, host=host, port=port,
38 start_loop=False,
39 ssl_context=ssl_context)
40
41 @property
43 return self.__pasteServer
44
45 @property
48
50 """Start server"""
51 self.pasteServer.serve_forever()
52
57
60