Beispiel #1
0
 def import_command_module(self, command_name):
     '''
     Utilize import_module to import command so
     that it gets interpreted by Python.
     Fail silently.
     '''
     try:
         import_module('frog.core.management.commands.%s' % command_name)
     except ImportError:
         pass
Beispiel #2
0
def import_user_settings():
    try:
        settings_mod_name = os.environ['FROG_SETTINGS_MODULE']
    except KeyError:
        raise ImproperlyConfigured('Variable name `FROG_SETTINGS_MODULE` not defined')
    try:
        settings_mod = import_module(settings_mod_name)
    except ImportError:
        raise ImproperlyConfigured('Settings `%s` not found.' % settings_mod_name)
    return settings_mod
Beispiel #3
0
 def resolve(cls, websocket):
     '''
     Resolve from the urls.py the configured handler class
     for this websocket.
     '''
     urls_module_path = settings.URL_CONF
     try:
         urls_module = import_module(urls_module_path)
     except ImportError:
         raise ImproperlyConfigured("URL_CONF `%s` not found." % urls_module_path)
     websocket_path = websocket.environ['PATH_INFO']
     # TODO (ctang) use more sophisticated lookup method
     app_cls = urls_module.mappings.get(websocket_path, None)
     if app_cls is None:
         raise ImproperlyConfigured("No application found listening for connection to this place `%s`" % websocket_path)
     return app_cls
Beispiel #4
0
def load_all_management_commands():
    management_dir = os.path.dirname(__file__)
    command_names = find_commands(management_dir)
    for name in command_names:
        full_name = '%s.%s' % ('frog.core.management.commands', name)
        import_module(full_name)
Beispiel #5
0
def load_handlers():
    # TODO (ctang) Possibily registering them into one place
    for handler in settings.INSTALLED_HANDLERS:
        import_module(handler)