Example #1
0
    def _get_repository_path(self):
        from aiida.backends import settings
        from aiida.common.setup import (get_config, get_profile_config,
                                        parse_repository_uri)
        from aiida.common.exceptions import ConfigurationError

        try:
            confs = get_config()
        except ConfigurationError:
            raise ConfigurationError(
                "Please run the AiiDA Installation, no config found")

        if settings.AIIDADB_PROFILE is None:
            raise ConfigurationError(
                "settings.AIIDADB_PROFILE not defined, did you load django"
                "through the AiiDA load_dbenv()?")

        profile_conf = get_profile_config(settings.AIIDADB_PROFILE,
                                          conf_dict=confs)

        REPOSITORY_URI = profile_conf.get('AIIDADB_REPOSITORY_URI', '')
        REPOSITORY_PROTOCOL, REPOSITORY_PATH = parse_repository_uri(
            REPOSITORY_URI)

        return REPOSITORY_PATH
Example #2
0
        'PASSWORD': DBPASS,
        'HOST': DBHOST,
        'PORT': DBPORT,
    }
}

# Checks on the REPOSITORY_* variables
try:
    REPOSITORY_URI
except NameError:
    raise ConfigurationError(
        "Please setup correctly the REPOSITORY_URI variable to "
        "a suitable directory on which you have write permissions.")

# Note: this variable might disappear in the future
REPOSITORY_PROTOCOL, REPOSITORY_PATH = parse_repository_uri(REPOSITORY_URI)

if settings.IN_RT_DOC_MODE:
    pass
elif REPOSITORY_PROTOCOL == 'file':
    if not os.path.isdir(REPOSITORY_PATH):
        try:
            # Try to create the local repository folders with needed parent
            # folders
            os.makedirs(REPOSITORY_PATH)
        except OSError:
            # Possibly here due to permission problems
            raise ConfigurationError(
                "Please setup correctly the REPOSITORY_PATH variable to "
                "a suitable directory on which you have write permissions. "
                "(I was not able to create the directory.)")