示例#1
0
def get_key(path, validate=True):
    """
    Retrieves a key from S3 for the given file path or None if it
    does not exist.
    """
    key_path = filepath_to_key_path(path)
    bucket = s3.get_bucket(config.get("cloudformation", "bucket"))
    key = bucket.get_key(key_path, validate=validate)
    logger.debug("get_key(%r) -> %r", key_path, key)
    return key
示例#2
0
文件: minify.py 项目: opalmer/aws
def minify(path):
    """Minify a json document and remove any comments."""
    json_data = ""
    original_size = 0

    with open(path, "r") as source:
        for line in source:
            original_size += len(line)
            if not line.strip().startswith("//"):
                json_data += line

    # Dump the json data with no spaces between separators and sorted
    # keys.  Without the key sorting you can end up with different key order
    # between runs.
    try:
        json_data = dumps(
            loads(json_data),
            separators=(",", ":"), sort_keys=True
        )
    except Exception as error:
        logger.error("Failed to convert %s: %s", path, error)
        raise
    logger.debug("minify(%r): %s -> %s", path, original_size, len(json_data))
    return json_data.encode("utf-8")
示例#3
0
文件: config.py 项目: opalmer/aws
from os.path import expanduser
from configparser import ConfigParser
from pkg_resources import resource_filename
from awsutil.logger import logger

config = ConfigParser()
LOADED_CONFIGS = config.read([
    resource_filename("awsutil", "awsutil.ini"),
    expanduser("~/.awsutil.ini"),
    ".awsutil.ini"
])

logger.debug("Loaded config(s): %s", LOADED_CONFIGS)