Example #1
0
    def print_trace_details(self, trace, args, **kwargs):
        options = {
            'attributes':
            TRACE_ATTRIBUTE_DISPLAY_ORDER
            if args.json else TRACE_HEADER_DISPLAY_ORDER
        }
        options['json'] = args.json
        options['yaml'] = args.yaml
        options[
            'attribute_transform_functions'] = self.attribute_transform_functions

        formatter = execution_formatter.ExecutionResult

        self.print_output(trace, formatter, **options)

        # Everything should be printed if we are printing json.
        if args.json or args.yaml:
            return

        components = []
        if any(attr in args.attr for attr in TRIGGER_INSTANCE_DISPLAY_OPTIONS):
            components.extend([
                Resource(
                    **{
                        'id': trigger_instance['object_id'],
                        'type': TriggerInstance._alias.lower(),
                        'ref': trigger_instance['ref'],
                        'updated_at': trigger_instance['updated_at']
                    }) for trigger_instance in trace.trigger_instances
            ])
        if any(attr in args.attr for attr in ['all', 'rules']):
            components.extend([
                Resource(
                    **{
                        'id': rule['object_id'],
                        'type': Rule._alias.lower(),
                        'ref': rule['ref'],
                        'updated_at': rule['updated_at']
                    }) for rule in trace.rules
            ])
        if any(attr in args.attr for attr in ACTION_EXECUTION_DISPLAY_OPTIONS):
            components.extend([
                Resource(
                    **{
                        'id': execution['object_id'],
                        'type': LiveAction._alias.lower(),
                        'ref': execution['ref'],
                        'updated_at': execution['updated_at']
                    }) for execution in trace.action_executions
            ])
        if components:
            components.sort(key=lambda resource: resource.updated_at)
            self.print_output(components,
                              table.MultiColumnTable,
                              attributes=TRACE_COMPONENT_DISPLAY_LABELS,
                              json=args.json,
                              yaml=args.yaml)
Example #2
0
    def print_trace_details(self, trace, args, **kwargs):
        options = {
            "attributes": TRACE_ATTRIBUTE_DISPLAY_ORDER
            if args.json
            else TRACE_HEADER_DISPLAY_ORDER
        }
        options["json"] = args.json
        options["yaml"] = args.yaml
        options["attribute_transform_functions"] = self.attribute_transform_functions

        formatter = execution_formatter.ExecutionResult

        self.print_output(trace, formatter, **options)

        # Everything should be printed if we are printing json.
        if args.json or args.yaml:
            return

        components = []
        if any(attr in args.attr for attr in TRIGGER_INSTANCE_DISPLAY_OPTIONS):
            components.extend(
                [
                    Resource(
                        **{
                            "id": trigger_instance["object_id"],
                            "type": TriggerInstance._alias.lower(),
                            "ref": trigger_instance["ref"],
                            "updated_at": trigger_instance["updated_at"],
                        }
                    )
                    for trigger_instance in trace.trigger_instances
                ]
            )
        if any(attr in args.attr for attr in ["all", "rules"]):
            components.extend(
                [
                    Resource(
                        **{
                            "id": rule["object_id"],
                            "type": Rule._alias.lower(),
                            "ref": rule["ref"],
                            "updated_at": rule["updated_at"],
                        }
                    )
                    for rule in trace.rules
                ]
            )
        if any(attr in args.attr for attr in ACTION_EXECUTION_DISPLAY_OPTIONS):
            components.extend(
                [
                    Resource(
                        **{
                            "id": execution["object_id"],
                            "type": Execution._alias.lower(),
                            "ref": execution["ref"],
                            "updated_at": execution["updated_at"],
                        }
                    )
                    for execution in trace.action_executions
                ]
            )
        if components:
            components.sort(key=lambda resource: resource.updated_at)
            self.print_output(
                components,
                table.MultiColumnTable,
                attributes=TRACE_COMPONENT_DISPLAY_LABELS,
                json=args.json,
                yaml=args.yaml,
            )