Ejemplo n.º 1
0
def cli(ctx):
    """
    AWS Serverless Application Model (SAM) CLI

    The AWS Serverless Application Model extends AWS CloudFormation to provide a simplified way of defining the
    Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.
    You can find more in-depth guide about the SAM specification here:
    https://github.com/awslabs/serverless-application-model.
    """
    if global_cfg.telemetry_enabled is None:
        enabled = True

        try:
            global_cfg.telemetry_enabled = enabled

            if enabled:
                click.secho(TELEMETRY_PROMPT, fg="yellow", err=True)

                # When the Telemetry prompt is printed, we can safely assume that this is the first time someone
                # is installing SAM CLI on this computer. So go ahead and send the `installed` metric
                send_installed_metric()

        except (IOError, ValueError) as ex:
            LOG.debug("Unable to write telemetry flag", exc_info=ex)

    sam_cli_logger = logging.getLogger('samcli')
    sam_cli_formatter = logging.Formatter('%(message)s')
    lambda_builders_logger = logging.getLogger('aws_lambda_builders')

    SamCliLogger.configure_logger(sam_cli_logger, sam_cli_formatter,
                                  logging.INFO)
    SamCliLogger.configure_logger(lambda_builders_logger, sam_cli_formatter,
                                  logging.INFO)
Ejemplo n.º 2
0
    def test_must_send_installed_metric_with_attributes(self, TelemetryClassMock):
        telemetry_mock = TelemetryClassMock.return_value = Mock()

        self.gc_mock.return_value.telemetry_enabled = False
        send_installed_metric()

        telemetry_mock.emit.assert_called_with("installed", {
            "osPlatform": platform.system(),
            "telemetryEnabled": False
        })