# Path: awscfncli2/runner/commands/command.py
# class Command(object):
#     SKIP_UPDATE_REFERENCES = False
# 
#     def __init__(self, pretty_printer, options):
#         assert isinstance(pretty_printer, StackPrettyPrinter)
#         self.ppt = pretty_printer
#         self.options = options
# 
#     def run(self, stack_context):
#         raise NotImplementedError
# 
# Path: awscfncli2/runner/commands/utils.py
# def is_stack_does_not_exist_exception(ex):
#     """Check whether given exception is "stack does not exist",
#     botocore doesn't throw a distinct exception class in this case.
#     """
#     if isinstance(ex, botocore.exceptions.ClientError):
#         error = ex.response.get('Error', {})
#         error_message = error.get('Message', 'Unknown')
#         return error_message.endswith('does not exist')
#     else:
#         return False


from collections import namedtuple
from .command import Command
from .utils import is_stack_does_not_exist_exception
import botocore.exceptions


dummy_stack = namedtuple('dummy_stack', ['stack_name', 'stack_status'])


class StackStatusCommand(Command):
    SKIP_UPDATE_REFERENCES = True

    def run(self, stack_context):
        # stack contexts
        session = stack_context.session
        parameters = stack_context.parameters
        metadata = stack_context.metadata

        self.ppt.pprint_stack_name(stack_context.stack_key,
                                   parameters['StackName'])
        # shortcut since dry run is already handled in cli package
        if self.options.dry_run:
            return

        # metadata and parameters only get printed when verbosity>0
        self.ppt.pprint_metadata(metadata)
        self.ppt.pprint_parameters(parameters)

        cfn = session.resource('cloudformation')
        stack = cfn.Stack(parameters['StackName'])

        try:
            stack.stack_status
        except botocore.exceptions.ClientError as ex:

# Path: awscfncli2/runner/commands/command.py
# class Command(object):
#     SKIP_UPDATE_REFERENCES = False
# 
#     def __init__(self, pretty_printer, options):
#         assert isinstance(pretty_printer, StackPrettyPrinter)
#         self.ppt = pretty_printer
#         self.options = options
# 
#     def run(self, stack_context):
#         raise NotImplementedError
# 
# Path: awscfncli2/runner/commands/utils.py
# def is_stack_does_not_exist_exception(ex):
#     """Check whether given exception is "stack does not exist",
#     botocore doesn't throw a distinct exception class in this case.
#     """
#     if isinstance(ex, botocore.exceptions.ClientError):
#         error = ex.response.get('Error', {})
#         error_message = error.get('Message', 'Unknown')
#         return error_message.endswith('does not exist')
#     else:
#         return False


# Path: awscfncli2/runner/commands/stack_status_command.py
from collections import namedtuple
from .command import Command
from .utils import is_stack_does_not_exist_exception
import botocore.exceptions



dummy_stack = namedtuple('dummy_stack', ['stack_name', 'stack_status'])


class StackStatusCommand(Command):
    SKIP_UPDATE_REFERENCES = True

    def run(self, stack_context):
        # stack contexts
        session = stack_context.session
        parameters = stack_context.parameters
        metadata = stack_context.metadata

        self.ppt.pprint_stack_name(stack_context.stack_key,
                                   parameters['StackName'])
        # shortcut since dry run is already handled in cli package
        if self.options.dry_run:
            return

        # metadata and parameters only get printed when verbosity>0
        self.ppt.pprint_metadata(metadata)
        self.ppt.pprint_parameters(parameters)

        cfn = session.resource('cloudformation')
        stack = cfn.Stack(parameters['StackName'])

        try:
            stack.stack_status
        except botocore.exceptions.ClientError as ex:

            if is_stack_does_not_exist_exception(ex):