def load_environment(srcdir, datadir=None, allow_old=False):
cp = ConfigParser.SafeConfigParser()<EOL>try:<EOL><INDENT>cp.read([srcdir + '<STR_LIT>'])<EOL><DEDENT>except ConfigParser.Error:<EOL><INDENT>raise DatacatsError('<STR_LIT>')<EOL><DEDENT>name = cp.get('<STR_LIT>', '<STR_LIT:name>')<EOL>if datadir:<EOL><INDENT>save_srcdir_location(datadir, srcdir)<EOL><DEDENT>else:<EOL><INDENT>datadir = path.expanduser('<STR_LIT>' + name)<EOL><DEDENT>if migrate.needs_format_conversion(datadir) and not allow_old:<EOL><INDENT>raise DatacatsError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if migrate.is_locked(datadir):<EOL><INDENT>raise DatacatsError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>ckan_version = cp.get('<STR_LIT>', '<STR_LIT>')<EOL>try:<EOL><INDENT>always_prod = cp.getboolean('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except ConfigParser.NoOptionError:<EOL><INDENT>always_prod = False<EOL><DEDENT>try:<EOL><INDENT>extra_containers = cp.get('<STR_LIT>', '<STR_LIT>').split('<STR_LIT:U+0020>')<EOL><DEDENT>except ConfigParser.NoOptionError:<EOL><INDENT>extra_containers = ()<EOL><DEDENT>try:<EOL><INDENT>deploy_target = cp.get('<STR_LIT>', '<STR_LIT>')+ "<STR_LIT:@>" + cp.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):<EOL><INDENT>deploy_target = DEFAULT_REMOTE_SERVER_TARGET<EOL><DEDENT>try:<EOL><INDENT>remote_server_key = cp.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):<EOL><INDENT>remote_server_key = None<EOL><DEDENT>return (datadir, name, ckan_version, always_prod, deploy_target,<EOL>remote_server_key, extra_containers)<EOL>
Load configuration values for an environment

:param srcdir: environment source directory
:param datadir: environment data direcory, if None will be discovered
                from srcdir
:param allow_old: Don't throw an exception if this is an old site
                  This is only valid for sites that you are purging.
if datadir is None it will be discovered from srcdir

Returns (datadir, name, ckan_version, always_prod, deploy_target,
         remote_server_key)