def main(): setup_logging(debug=False, no_colour=False) try: cli() except RemoteDockerException as e: logger.error(e) sys.exit(-1)
def test_setup_logging_without_debug(self): logger = setup_logging(False, False) assert logger.getEffectiveLevel() == logging.INFO assert logging.getLogger("botocore").getEffectiveLevel() == \ logging.CRITICAL # Silence logging for the rest of the tests logger.setLevel(logging.CRITICAL)
def cli( ctx, debug, directory, output, no_colour, var, var_file, ignore_dependencies ): """ Sceptre is a tool to manage your cloud native infrastructure deployments. """ logger = setup_logging(debug, no_colour) colorama.init() # Enable deprecation warnings warnings.simplefilter("always", DeprecationWarning) ctx.obj = { "user_variables": {}, "output_format": output, "no_colour": no_colour, "ignore_dependencies": ignore_dependencies, "project_path": directory if directory else os.getcwd() } if var_file: for fh in var_file: parsed = yaml.safe_load(fh.read()) ctx.obj.get("user_variables").update(parsed) # the rest of this block is for debug purposes only existing_keys = set(ctx.obj.get("user_variables").keys()) new_keys = set(parsed.keys()) overloaded_keys = existing_keys & new_keys # intersection if overloaded_keys: logger.debug( "Duplicate variables encountered: {0}. " "Using values from: {1}." .format(", ".join(overloaded_keys), fh.name) ) if var: def update_dict(variable): variable_key, variable_value = variable.split("=") keys = variable_key.split(".") def nested_set(dic, keys, value): for key in keys[:-1]: dic = dic.setdefault(key, {}) dic[keys[-1]] = value nested_set(ctx.obj.get("user_variables"), keys, variable_value) # --var options overwrite --var-file options for variable in var: update_dict(variable)
def cli( ctx, debug, directory, no_colour, output, var, var_file ): """ Sceptre is a tool to manage your cloud native infrastructure deployments. """ logger = setup_logging(debug, no_colour) colorama.init() # Enable deprecation warnings warnings.simplefilter("always", DeprecationWarning) ctx.obj = { "user_variables": {}, "output_format": output, "no_colour": no_colour, "sceptre_dir": directory if directory else os.getcwd() } if var_file: for fh in var_file: parsed = yaml.safe_load(fh.read()) ctx.obj["user_variables"].update(parsed) # the rest of this block is for debug purposes only existing_keys = set(ctx.obj["user_variables"].keys()) new_keys = set(parsed.keys()) overloaded_keys = existing_keys & new_keys # intersection if overloaded_keys: logger.debug( "Duplicate variables encountered: {0}. " "Using values from: {1}." .format(", ".join(overloaded_keys), fh.name) ) if var: # --var options overwrite --var-file options for variable in var: variable_key, variable_value = variable.split("=") if variable_key in ctx.obj["user_variables"]: logger.debug( "Duplicate variable encountered: {0}. " "Using value from --var option." .format(variable_key) ) ctx.obj["user_variables"].update({variable_key: variable_value})
from sceptre.cli.helpers import setup_logging from sceptre.context import SceptreContext from sceptre.plan.plan import SceptrePlan from unison_gitignore.parser import GitIgnoreToUnisonIgnore from .config import RemoteDockerConfigProfile from .constants import ( AWS_REGION_TO_UBUNTU_AMI_MAPPING, DOCKER_PORT_FORWARD, INSTANCE_USERNAME, PORT_MAP_TYPE, SCEPTRE_PATH, ) from .util import get_replica_and_sync_paths_for_unison, logger, wait_until_port_is_open setup_logging(debug=False, no_colour=False) @lru_cache(maxsize=128) def get_ec2_client(region_name): return boto3.client("ec2", region_name=region_name) class RemoteDockerClient: def __init__( self, project_code: str, aws_region: str, instance_service_name: str, instance_type: str, local_forwards: PORT_MAP_TYPE,