How to use the iotedgedev.telemetry function in iotedgedev

To help you get started, we’ve selected a few iotedgedev examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / iotedgedev / iotedgedev / decorators.py View on Github external
def _wrapped_func(*args, **kwargs):
        from . import telemetry
        from .telemetryconfig import TelemetryConfig

        config = TelemetryConfig()
        config.check_firsttime()
        params = parse_params(*args, **kwargs)
        telemetry.start(func.__name__, params)
        try:
            value = func(*args, **kwargs)
            telemetry.success()
            telemetry.flush()
            return value
        except Exception as e:
            from .output import Output
            Output().error(str(e))
            telemetry.fail(str(e), 'Command failed')
            telemetry.flush()
            sys.exit(1)
github Azure / iotedgedev / iotedgedev / decorators.py View on Github external
from . import telemetry
        from .telemetryconfig import TelemetryConfig

        config = TelemetryConfig()
        config.check_firsttime()
        params = parse_params(*args, **kwargs)
        telemetry.start(func.__name__, params)
        try:
            value = func(*args, **kwargs)
            telemetry.success()
            telemetry.flush()
            return value
        except Exception as e:
            from .output import Output
            Output().error(str(e))
            telemetry.fail(str(e), 'Command failed')
            telemetry.flush()
            sys.exit(1)
github Azure / iotedgedev / iotedgedev / decorators.py View on Github external
from .telemetryconfig import TelemetryConfig

        config = TelemetryConfig()
        config.check_firsttime()
        params = parse_params(*args, **kwargs)
        telemetry.start(func.__name__, params)
        try:
            value = func(*args, **kwargs)
            telemetry.success()
            telemetry.flush()
            return value
        except Exception as e:
            from .output import Output
            Output().error(str(e))
            telemetry.fail(str(e), 'Command failed')
            telemetry.flush()
            sys.exit(1)
github Azure / iotedgedev / iotedgedev / decorators.py View on Github external
def _wrapped_func(*args, **kwargs):
        from . import telemetry
        from .telemetryconfig import TelemetryConfig

        config = TelemetryConfig()
        config.check_firsttime()
        params = parse_params(*args, **kwargs)
        telemetry.start(func.__name__, params)
        try:
            value = func(*args, **kwargs)
            telemetry.success()
            telemetry.flush()
            return value
        except Exception as e:
            from .output import Output
            Output().error(str(e))
            telemetry.fail(str(e), 'Command failed')
            telemetry.flush()
            sys.exit(1)
github Azure / iotedgedev / iotedgedev / modules.py View on Github external
def add(self, name, template, group_id):
        self.output.header("ADDING MODULE {0}".format(name))

        deployment_manifest = DeploymentManifest(self.envvars, self.output, self.utility, self.envvars.DEPLOYMENT_CONFIG_TEMPLATE_FILE, True)

        cwd = self.envvars.MODULES_PATH
        self.utility.ensure_dir(cwd)

        if name.startswith("_") or name.endswith("_"):
            raise ValueError("Module name cannot start or end with the symbol _")
        elif not re.match("^[a-zA-Z0-9_]+$", name):
            raise ValueError("Module name can only contain alphanumeric characters and the symbol _")
        elif os.path.exists(os.path.join(cwd, name)):
            raise ValueError("Module \"{0}\" already exists under {1}".format(name, os.path.abspath(self.envvars.MODULES_PATH)))

        telemetry.add_extra_props({"template": template})

        repo = "{0}/{1}".format("${CONTAINER_REGISTRY_SERVER}", name.lower())
        if template == "c":
            github_prefix = "https://github.com/Azure"
            git_repo = "azure-iot-edge-c-module"
            branch = "master"
            url = "{0}/{1}/archive/{2}.zip".format(github_prefix, git_repo, branch)
            response = urlopen(url)

            temp_dir = os.path.join(os.path.expanduser("~"), '.iotedgedev')
            self.utility.ensure_dir(temp_dir)
            zip_file_prefix = "{0}-{1}".format(git_repo, branch)
            temp_template_dir = os.path.join(temp_dir, zip_file_prefix)
            if os.path.exists(temp_template_dir):
                shutil.rmtree(temp_template_dir)
github Azure / iotedgedev / iotedgedev / azurecli.py View on Github external
def set_modules(self, device_id, connection_string, config):
        self.output.status(f("Deploying '{config}' to '{device_id}'..."))

        config = os.path.join(os.getcwd(), config)

        if not os.path.exists(config):
            raise FileNotFoundError('Deployment manifest file "{0}" not found. Please run `iotedgedev build` first'.format(config))

        telemetry.add_extra_props({'iothubhostname': connection_string.iothub_host.name_hash, 'iothubhostnamesuffix': connection_string.iothub_host.name_suffix})

        return self.invoke_az_cli_outproc(["iot", "edge", "set-modules", "-d", device_id, "-n", connection_string.iothub_host.hub_name, "-k", config, "-l", connection_string.connection_string],
                                          error_message=f("Failed to deploy '{config}' to '{device_id}'..."), suppress_output=True)