Esempio n. 1
0
def _calculate_delta(settings):
    delta = {'notchanged': [], 'changed': []}
    current_envs = set(os.listdir(settings.CACHEDIR + "/environments"))
    updated_envs = set(get_names_of_declared_environments(settings))

    delta['new'] = updated_envs.difference(current_envs)
    delta['deleted'] = current_envs.difference(updated_envs)

    existing = updated_envs.intersection(current_envs)

    for environment in existing:
        # TODO: Cache file should always be there, but check just in case
        # and count it as changed if missing so the cache is generated again.
        hash_cache_file = open(settings.CACHEDIR + "/environments/%s" %
            environment)
        old_hash = hash_cache_file.read()
        hash_cache_file.close()
        new_hash = hash_object(settings.ENV_METADATADIR + "/%s.yaml" %
            environment)
        if old_hash == new_hash:
            delta['notchanged'].append(environment)
        else:
            delta['changed'].append(environment)

    return delta
Esempio n. 2
0
def _calculate_delta(settings):
    delta = {'notchanged': [], 'changed': []}
    current_envs = set(os.listdir(settings.CACHEDIR + "/environments"))
    updated_envs = set(get_names_of_declared_environments(settings))

    delta['new'] = updated_envs.difference(current_envs)
    delta['deleted'] = current_envs.difference(updated_envs)

    existing = updated_envs.intersection(current_envs)

    for environment in existing:
        # TODO: Cache file should always be there, but check just in case
        # and count it as changed if missing so the cache is generated again.
        hash_cache_file = open(settings.CACHEDIR +
                               "/environments/%s" % environment)
        old_hash = hash_cache_file.read()
        hash_cache_file.close()
        new_hash = hash_object(settings.ENV_METADATADIR +
                               "/%s.yaml" % environment)
        if old_hash == new_hash:
            delta['notchanged'].append(environment)
        else:
            delta['changed'].append(environment)

    return delta
Esempio n. 3
0
def _annotate_environment(settings, environment):
    hash_cache_file = open(settings.CACHEDIR + "/environments/%s" % \
            environment, "w+")
    environment_definition = settings.ENV_METADATADIR + "/%s.yaml" % \
            environment
    hash_value = hash_object(environment_definition)
    logging.debug("New cached hash for environment '%s' is '%s'" % \
        (environment, hash_value))
    # TODO: Add error handling here, if the cache can't be saved
    # basically the environment will be regenerated in the next
    # run (which is fine, but must be logged at INFO level)
    hash_cache_file.write(hash_value)
    hash_cache_file.close()
Esempio n. 4
0
def _annotate_environment(settings, environment):
    hash_cache_file = open(settings.CACHEDIR + "/environments/%s" % \
            environment, "w+")
    environment_definition = settings.ENV_METADATADIR + "/%s.yaml" % \
            environment
    hash_value = hash_object(environment_definition)
    logging.debug("New cached hash for environment '%s' is '%s'" % \
        (environment, hash_value))
    # TODO: Add error handling here, if the cache can't be saved
    # basically the environment will be regenerated in the next
    # run (which is fine, but must be logged at INFO level)
    hash_cache_file.write(hash_value)
    hash_cache_file.close()