How to use the logzero.logger.warning function in logzero

To help you get started, we’ve selected a few logzero 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 openatx / atxserver2-android-provider / heartbeat.py View on Github external
async def _drain_ws_message(self):
        while True:
            message = await self._ws.read_message()
            logger.debug("WS read message: %s", message)
            if message is None:
                self._ws = None
                logger.warning("WS closed")
                self._ws = await self.connect()
                await self._queue.put(None)
            logger.info("WS receive message: %s", message)
github chaostoolkit-incubator / chaostoolkit-aws / chaosaws / ec2 / actions.py View on Github external
"""
    Restarts one or more EC2 instances.

    WARNING: If only an Availability Zone is provided, all instances in the
    provided AZ will be restarted.

    Additional filters may be used to narrow the scope:
    https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_instances
    """
    if not any([instance_ids, az, filters]):
        raise FailedActivity('To restart instances, you must specify the '
                             'instance-id, an Availability Zone, or provide a '
                             'set of filters')

    if az and not any([instance_ids, filters]):
        logger.warning('Based on configuration provided I am going to '
                       'restart all instances in AZ %s!' % az)

    client = aws_client('ec2', configuration, secrets)

    if not instance_ids:
        filters = deepcopy(filters) or []

        if az:
            filters.append({'Name': 'availability-zone', 'Values': [az]})
            logger.debug('Looking for instances in AZ: %s' % az)

        # Select instances based on filters
        instance_types = list_instances_by_type(filters, client)

        if not instance_types:
            raise FailedActivity(
github ritiek / spotify-downloader / spotdl / spotify_tools.py View on Github external
log.info(u"Writing {0} tracks to {1}".format(tracks["total"], text_file))
    track_urls = []
    with open(text_file, "a") as file_out:
        while True:
            for item in tracks["items"]:
                if "track" in item:
                    track = item["track"]
                else:
                    track = item
                try:
                    track_url = track["external_urls"]["spotify"]
                    log.debug(track_url)
                    file_out.write(track_url + "\n")
                    track_urls.append(track_url)
                except KeyError:
                    log.warning(
                        u"Skipping track {0} by {1} (local only?)".format(
                            track["name"], track["artists"][0]["name"]
                        )
                    )
            # 1 page = 50 results
            # check if there are more pages
            if tracks["next"]:
                tracks = spotify.next(tracks)
            else:
                break
    return track_urls
github chaostoolkit / chaostoolkit-lib / chaoslib / experiment.py View on Github external
journal_status = journal["status"]
        play_rollbacks = False
        if rollback_strategy == "always":
            logger.warning(
                "Rollbacks were explicitly requested to be played")
            play_rollbacks = True
        elif rollback_strategy == "never":
            logger.warning(
                "Rollbacks were explicitly requested to not be played")
            play_rollbacks = False
        elif rollback_strategy == "default" and \
                journal_status not in ["failed", "interrupted"]:
            play_rollbacks = True
        elif rollback_strategy == "deviated":
            if has_deviated:
                logger.warning(
                    "Rollbacks will be played only because the experiment "
                    "deviated")
                play_rollbacks = True
            else:
                logger.warning(
                    "Rollbacks werre explicitely requested to be played only "
                    "if the experiment deviated. Since this is not the case, "
                    "we will not play them.")

        if play_rollbacks:
            try:
                journal["rollbacks"] = apply_rollbacks(
                    experiment, config, secrets, rollback_pool, dry)
            except InterruptExecution as i:
                journal["status"] = "interrupted"
                logger.fatal(str(i))
github ritiek / spotify-downloader / spotdl / downloader.py View on Github external
def _cleanup(self, raw_song, exception):
        self.tracks.append(raw_song)
        # remove the downloaded song from file
        internals.trim_song(self.tracks_file)
        # and append it at the end of file
        with open(self.tracks_file, "a") as f:
            f.write("\n" + raw_song)
        log.exception(exception)
        log.warning("Failed to download song. Will retry after other songs\n")
github openatx / atxserver2-android-provider / device.py View on Github external
def _install_apk(self, path: str):
        assert path, "Invalid %s" % path
        try:
            m = apkutils.APK(path).manifest
            info = self._device.package_info(m.package_name)
            if info and m.version_code == info[
                    'version_code'] and m.version_name == info['version_name']:
                logger.debug("%s already installed %s", self, path)
            else:
                print(info, ":", m.version_code, m.version_name)
                logger.debug("%s install %s", self, path)
                self._device.install(path, force=True)
        except Exception as e:
            traceback.print_exc()
            logger.warning("%s Install apk %s error %s", self, path, e)
github chaostoolkit / chaostoolkit-lib / chaoslib / secret.py View on Github external
client = create_vault_client(configuration)

    for (target, keys) in secrets_info.items():
        secrets[target] = {}

        for (key, value) in keys.items():
            if isinstance(value, dict) and value.get("type") == "vault":
                if not HAS_HVAC:
                    logger.error(
                        "Install the `hvac` package to fetch secrets "
                        "from Vault: `pip install chaostoolkit-lib[vault]`.")
                    return {}

                path = value.get("path")
                if path is None:
                    logger.warning(
                        "Missing Vault secret path for '{}'".format(key))
                    continue

                # see https://github.com/chaostoolkit/chaostoolkit/issues/98
                kv = client.secrets.kv
                is_kv1 = kv.default_kv_version == "1"
                if is_kv1:
                    vault_payload = kv.v1.read_secret(
                        path=path,
                        mount_point=configuration.get(
                            "vault_secrets_mount_point", "secret"))
                else:
                    vault_payload = kv.v2.read_secret_version(
                        path=path,
                        mount_point=configuration.get(
                            "vault_secrets_mount_point", "secret"))
github openatx / atxserver2-android-provider / device.py View on Github external
def _push_stf(self,
                  path: str,
                  dest: str,
                  zipfile_path: str,
                  mode=0o755):
        """ push minicap and minitouch from zip """
        with zipfile.ZipFile(zipfile_path) as z:
            if path not in z.namelist():
                logger.warning("stf stuff %s not found", path)
                return
            src_info = z.getinfo(path)
            dest_info = self._device.sync.stat(dest)
            if dest_info.size == src_info.file_size and dest_info.mode & mode == mode:
                logger.debug("%s already pushed %s", self, path)
                return
            with z.open(path) as f:
                self._device.sync.push(f, dest, mode)
github chaostoolkit / chaostoolkit-lib / chaoslib / hypothesis.py View on Github external
with controls(level="hypothesis", experiment=experiment, context=hypo,
                  configuration=configuration, secrets=secrets) as control:
        probes = hypo.get("probes", [])
        control.with_state(state)

        for activity in probes:
            run = execute_activity(
                experiment=experiment, activity=activity,
                configuration=configuration, secrets=secrets, dry=dry)

            state["probes"].append(run)

            if run["status"] == "failed":
                run["tolerance_met"] = False
                state["steady_state_met"] = False
                logger.warning("Probe terminated unexpectedly, "
                               "so its tolerance could not be validated")
                return state

            run["tolerance_met"] = True

            if dry:
                # do not check for tolerance when dry mode is on
                continue

            tolerance = activity.get("tolerance")
            logger.debug("allowed tolerance is {t}".format(t=str(tolerance)))
            checked = within_tolerance(
                tolerance, run["output"], configuration=configuration,
                secrets=secrets)
            if not checked:
                run["tolerance_met"] = False
github LOLINTERNETZ / vscodeoffline / vscoffline / sync.py View on Github external
def version(self):
        if self.versions and len(self.versions) > 1:
            log.warning(f"version(). More than one version returned for {self.identity}. Unhandled.")
            return None
        return self.versions[0]['version']