def __init__(self, action='start', options={}, reactor=reactor): self.action = action self.options = hx_options() self.options.update(options) self.services = [] self.resources = [] self.reactor = reactor self.use_settings = True # because running the management command overrides self.options['wsgi'] if self.options['wsgi']: wsgi_dot_path = self.options['wsgi'] self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.use_settings = False else: os.environ['DJANGO_SETTINGS_MODULE'] = self.options['settings'] django_conf = importlib.import_module('django.conf') settings = getattr(django_conf, 'settings') self.services = get_additional_services(settings) self.resources = get_additional_resources(settings) self.options = HendrixDeploy.getConf(settings, self.options) if self.use_settings: wsgi_dot_path = getattr(settings, 'WSGI_APPLICATION', None) self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.is_secure = self.options['key'] and self.options['cert'] self.servers = []
def setUp(self): super(TestMain, self).setUp() self.DEFAULTS = hx_options() os.environ['DJANGO_SETTINGS_MODULE'] = '' self.devnull = open(os.devnull, 'w') self.args_list = ['hx', 'start'] self.patcher = patch('hendrix.ux.findSettingsModule') self.patcher.start()
def __init__(self, action='start', options={}, reactor=reactor, threadpool=None): self.action = action self.options = hx_options() self.options.update(options) self.services = [] self.resources = [] self.reactor = reactor self.threadpool = threadpool or ThreadPool(name="Hendrix Web Service") self.use_settings = True # because running the management command overrides self.options['wsgi'] if self.options['wsgi']: if hasattr(self.options['wsgi'], '__call__'): # If it has a __call__, we assume that it is the application # object itself. self.application = self.options['wsgi'] try: self.options['wsgi'] = "%s.%s" % ( self.application.__module__, self.application.__name__) except AttributeError: self.options['wsgi'] = self.application.__class__.__name__ else: # Otherwise, we'll try to discern an application in the belief # that this is a dot path. wsgi_dot_path = self.options['wsgi'] # will raise AttributeError if we can't import it. self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.use_settings = False else: os.environ['DJANGO_SETTINGS_MODULE'] = self.options['settings'] settings = import_string('django.conf.settings') self.services = get_additional_services(settings) self.resources = get_additional_resources(settings) self.options = HendrixDeploy.getConf(settings, self.options) if self.use_settings: django = importlib.import_module('django') if django.VERSION[:2] >= (1, 7): django.setup() wsgi_dot_path = getattr(settings, 'WSGI_APPLICATION', None) self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.is_secure = self.options['key'] and self.options['cert'] self.servers = [] self._lock = DeferredLock()
def __init__(self, action='start', options={}, reactor=reactor, threadpool=None): self.action = action self.options = hx_options() self.options.update(options) self.services = [] self.resources = [] self.reactor = reactor self.threadpool = threadpool or ThreadPool(name="Hendrix Web Service") self.use_settings = True # because running the management command overrides self.options['wsgi'] if self.options['wsgi']: if hasattr(self.options['wsgi'], '__call__'): # If it has a __call__, we assume that it is the application # object itself. self.application = self.options['wsgi'] try: self.options['wsgi'] = "%s.%s" % ( self.application.__module__, self.application.__name__ ) except AttributeError: self.options['wsgi'] = self.application.__class__.__name__ else: # Otherwise, we'll try to discern an application in the belief # that this is a dot path. wsgi_dot_path = self.options['wsgi'] # will raise AttributeError if we can't import it. self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.use_settings = False else: os.environ['DJANGO_SETTINGS_MODULE'] = self.options['settings'] settings = import_string('django.conf.settings') self.services = get_additional_services(settings) self.resources = get_additional_resources(settings) self.options = HendrixDeploy.getConf(settings, self.options) if self.use_settings: django = importlib.import_module('django') if django.VERSION[:2] >= (1, 7): django.setup() wsgi_dot_path = getattr(settings, 'WSGI_APPLICATION', None) self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.is_secure = self.options['key'] and self.options['cert'] self.servers = [] self._lock = DeferredLock()
def __init__(self, action='start', options={}, reactor=reactor): self.action = action self.options = hx_options() self.options.update(options) self.services = [] self.resources = [] self.reactor = reactor self.use_settings = True # because running the management command overrides self.options['wsgi'] if self.options['wsgi']: if hasattr(self.options['wsgi'], '__call__'): # If it has a __call__, we assume that it is the application object itself. self.application = self.options['wsgi'] try: self.options['wsgi_app_name'] = "%s.%s" % (self.application.__module__, self.application.__name__) except AttributeError: self.options['wsgi_app_name'] = self.application.__class__.__name__ else: # Otherwise, we'll try to discern an application in the belief that this is a dot path. wsgi_dot_path = self.options['wsgi'] self.application = HendrixDeploy.importWSGI(wsgi_dot_path) # will raise AttributeError if we can't import it. self.options['wsgi_app_name'] = wsgi_dot_path self.use_settings = False else: os.environ['DJANGO_SETTINGS_MODULE'] = self.options['settings'] django_conf = importlib.import_module('django.conf') settings = getattr(django_conf, 'settings') self.services = get_additional_services(settings) self.resources = get_additional_resources(settings) self.options = HendrixDeploy.getConf(settings, self.options) if self.use_settings: django = importlib.import_module('django') if django.VERSION[:2] >= (1, 7): installed_apps = getattr(settings, "INSTALLED_APPS") django.apps.apps.populate(installed_apps) wsgi_dot_path = getattr(settings, 'WSGI_APPLICATION', None) self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.is_secure = self.options['key'] and self.options['cert'] self.servers = []
def setUp(self): super(TestMain, self).setUp() self.DEFAULTS = hx_options() os.environ['DJANGO_SETTINGS_MODULE'] = '' self.devnull = open(os.devnull, 'w') self.args_list = ['hx', 'start']