Puts the environment in a globally accessible pickle file.
325781
def _serialiseEnv(self):
        
        # Dump out the environment of this process in the environment pickle file.
        with self._jobStore.writeSharedFileStream("environment.pickle") as fileHandle:
            pickle.dump(dict(os.environ), fileHandle, pickle.HIGHEST_PROTOCOL)
        logger.debug("Written the environment for the jobs to the environment file")
1065638
def load(self):
        
        try:
            with open(self.file_root + '.pkl', "rb") as f:
                return pickle.load(f)
        except IOError:
            raise CacheMissing(self.file_root)
805509
def load_pickle(file_path):
    
    pkl_file = open(file_path, 'rb')
    data = pickle.load(pkl_file)
    pkl_file.close()
    return data
1211789
def dump(cls, obj, file, protocol=0):
        
        cls.save_option_state = True
        pickle.dump(obj, file, protocol=protocol)
        cls.save_option_state = False
906444
def _save_env(env):
    
    env_path = os.path.join(env["resultdir"], "env")

    if os.path.isdir(env["resultdir"]):
        with open(env_path, "w") as f:
            yaml.dump(env, f)
1154607
def load_env():
    """"""
    # environment variables take precedence over conf file
    for key, envvar in [['cache_dir', 'INTAKE_CACHE_DIR'],
                        ['catalog_path', 'INTAKE_PATH'],
                        ['persist_path', 'INTAKE_PERSIST_PATH']]:
        if envvar in os.environ:
            conf[key] = make_path_posix(os.environ[envvar])
    conf['catalog_path'] = intake_path_dirs(conf['catalog_path'])
    for key, envvar in [['cache_disabled', 'INTAKE_DISABLE_CACHING'],
                        ['cache_download_progress', 'INTAKE_CACHE_PROGRESS']]:
        if envvar in os.environ:
            conf[key] = os.environ[envvar].lower() in ['true', 't', 'y', 'yes']
    if 'INTAKE_LOG_LEVEL' in os.environ:
        conf['logging'] = os.environ['INTAKE_LOG_LEVEL']
824551
def create_environment(self, environment):
        

        uri = 'api/v3/environment/'

        data = dict()
        data['environments'] = list()
        data['environments'].append(environment)

        return super(ApiEnvironment, self).post(uri, data)
881368
def _save(self):
        
        with open(self._pickle_file, 'wb') as source:
            pickler = pickle.Pickler(source, pickle.HIGHEST_PROTOCOL)

            for attribute in self._pickle_attributes:
                attr = getattr(self, attribute, None)
                pickler.dump(attr)
1277150
def unpickle(pickle_file):
    """"""
    pickle = None
    with open(pickle_file, "rb") as pickle_f:
        pickle = dill.load(pickle_f)
    if not pickle:
        LOG.error("Could not load python object from file")
    return pickle
934961
def save_new_environment(name, datadir, srcdir, ckan_version,
        deploy_target=None, always_prod=False):
    
    with open(datadir + '/.version', 'w') as f:
        f.write('2')

    cp = ConfigParser.SafeConfigParser()

    cp.read(srcdir + '/.datacats-environment')

    if not cp.has_section('datacats'):
        cp.add_section('datacats')
    cp.set('datacats', 'name', name)
    cp.set('datacats', 'ckan_version', ckan_version)

    if deploy_target:
        if not cp.has_section('deploy'):
            cp.add_section('deploy')
        cp.set('deploy', 'target', deploy_target)

    if always_prod:
        cp.set('datacats', 'always_prod', 'true')

    with open(srcdir + '/.datacats-environment', 'w') as config:
        cp.write(config)

    save_srcdir_location(datadir, srcdir)
353927
def save_cache(data, filename):
    """"""
    with open(filename, 'wb') as handle:
        pickle.dump(data, handle)
424797
def _env(self, line):
        '''
   
        '''
        line = self._setup('ENV', line)

        # Extract environment (list) from the line
        environ = parse_env(line)

        # Add to global environment, run during install
        self.install += environ

        # Also define for global environment
        self.environ += environ
561677
def dump_environment(self):
        
        # Dump the Alignak configuration to a temporary ini file
        path = os.path.join(tempfile.gettempdir(),
                            'dump-env-%s-%s-%d.ini' % (self.type, self.name, int(time.time())))

        try:
            with open(path, "w") as out_file:
                self.alignak_env.write(out_file)
        except Exception as exp:  # pylint: disable=broad-except
            logger.error("Dumping daemon environment raised an error: %s. ", exp)
751397
def save_pkl(self, filename):
        
        with open(filename, 'wb') as fout:
            pickle.dump(self, fout)
104990
def save(self, path):
        """"""
        with io.open(path, 'wb') as fout:
            return pickle.dump(dict(self.weights), fout)
1081539
def create_env(env_file):
    """"""

    environ = {}
    with open(env_file, 'r') as f:
        for line in f.readlines():
            line = line.rstrip(os.linesep)
            if '=' not in line:
                continue
            if line.startswith('#'):
                continue
            key, value = line.split('=', 1)
            environ[key] = parse_value(value)
    return environ
1350355
def create(cls, serializable_instance):
    """"""
    if not Serializable.is_serializable(serializable_instance):
      raise ValueError('Can only create pickles for Serializable objects, given {} of type {}'
                       .format(serializable_instance, type(serializable_instance).__name__))
    return cls(unpickle_func=_unpickle_serializable,
               args=(type(serializable_instance), serializable_instance._asdict()))