Ejemplo n.º 1
0
def create_project(name):
    try:
        import_module(name)
    except ImportError:
        pass
    else:
        raise InvalidCommand("%r conflicts with the name of an existing "
                               "Python module and cannot be used as a "
                               "project name. Please try another name." %
                               name)
    cur_path = '%s/%s' % (os.getcwd(), name)
    encoding = sys.getfilesystemencoding()
    project_template = '%s/../../conf/project_template/' % os.path.dirname(unicode(__file__, encoding))
    if not os.path.exists(cur_path):
        copy_tree(project_template, cur_path)
Ejemplo n.º 2
0
def create_project(name):
    try:
        import_module(name)
    except ImportError:
        pass
    else:
        raise InvalidCommand("%r conflicts with the name of an existing "
                             "Python module and cannot be used as a "
                             "project name. Please try another name." % name)
    cur_path = '%s/%s' % (os.getcwd(), name)
    encoding = sys.getfilesystemencoding()
    project_template = '%s/../../conf/project_template/' % os.path.dirname(
        unicode(__file__, encoding))
    if not os.path.exists(cur_path):
        copy_tree(project_template, cur_path)
Ejemplo n.º 3
0
    def load_plugins(self):
        """
        Populate plugin lists from settings.PLUGINS.

        """

        for plugin_path in settings.PLUGINS:
            try:
                try:
                    pg_module, pg_classname = plugin_path.rsplit('.', 1)
                except ValueError, e:
                    raise exceptions.ImproperlyConfigured(
                        '%s isn\'t a plugin module' % plugin_path)

                try:
                    mod = importlib.import_module(pg_module)
                except ImportError, e:
                    raise exceptions.ImproperlyConfigured(
                        'Error importing plugin %s: "%s"' % (pg_module, e))

                try:
                    pg_class = getattr(mod, pg_classname)
                except AttributeError, e:
                    raise exceptions.ImproperlyConfigured(
                        'Plugins module "%s" does not define a "%s" class' %
                        (pg_module, pg_classname))
Ejemplo n.º 4
0
def get_cache(backend):
    if backend == 'Default':
        backend = settings.CACHE_BACKEND

    if not backend:
        return None

    mod_path, cls_name = backend.rsplit('.', 1)
    mod = importlib.import_module(mod_path)
    backend_cls = getattr(mod, cls_name)

    cache = backend_cls(settings.CACHE_LOCATION, {'params': {'timeout': settings.CACHE_DEFAULT_TIMEOUT}})

    return cache
Ejemplo n.º 5
0
    def load_plugins(self):
        """
        Populate plugin lists from settings.PLUGINS.

        """

        for plugin_path in settings.PLUGINS:
            try:
                pg_module, pg_classname = plugin_path.rsplit('.', 1)
            except ValueError, e:
                raise exceptions.ImproperlyConfigured('%s isn\'t a plugin module' % plugin_path)

            try:
                mod = importlib.import_module(pg_module)
            except ImportError, e:
                raise exceptions.ImproperlyConfigured('Error importing plugin %s: "%s"' % (pg_module, e))
Ejemplo n.º 6
0
    def __init__(self):
        # update this dict from global settings (but only for ALL_CAPS settings)
        for setting in dir(base_settings):
            if setting == setting.upper():
                setattr(self, setting, getattr(base_settings, setting))

        try:
            settings_module = os.environ[ENVIRONMENT_VARIABLE]
        except KeyError:
            raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
        # store the settings module in case someone later cares
        self.SETTINGS_MODULE = settings_module

        try:
            mod = importlib.import_module(self.SETTINGS_MODULE)
        except ImportError, e:
            raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))