def invoke_command()

in ec2instanceconnectcli/EC2InstanceConnectCLI.py [0:0]


    def invoke_command(self):
        """
        Generates the appropriate shell command and invokes it
        :return: Return code for remote command
        :rtype: int
        """
        try:
            for bundle in self.instance_bundles:
                session = self._get_botocore_session(profile_name=bundle['profile'], region=bundle['region'])
                # enable debug logging on botocore session if command line debug option is set
                if self.logger.getEffectiveLevel() == logging.DEBUG:
                    session.set_debug_logger()
                bundle['session'] = session

            self.call_ec2()
            self.handle_keys()

            #important to generate the command after calling call_ec2 and handle_keys
            return self.run_command(self.cli_command.get_command())

        except Exception as e:
            self.logger.error("Failed with: " + str(e))
            sys.exit(1)