How to use the logzero.logger.error 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 knjcode / pytorch-finetuner / train.py View on Github external
# resume from a checkpoint
        if os.path.isfile(args.resume):
            logger.info("=> loading saved checkpoint '{}'".format(args.resume))
            checkpoint = torch.load(args.resume, map_location=device)
            args.model = checkpoint['arch']
            base_model = make_model(args.model,
                                    num_classes=train_num_classes,
                                    pretrained=False,
                                    input_size=(args.input_size, args.input_size))
            base_model.load_state_dict(checkpoint['model'])
            args.start_epoch = checkpoint['epoch']
            best_acc1 = float(checkpoint['acc1'])
            logger.info("=> loaded checkpoint '{}' (epoch {})"
                        .format(args.resume, checkpoint['epoch']))
        else:
            logger.error("=> no checkpoint found at '{}'".format(args.resume))
            sys.exit(1)
    else:
        if args.scratch:
            # train from scratch
            logger.info("=> creating model '{}' (train from scratch)".format(args.model))
            base_model = make_model(args.model,
                                    num_classes=train_num_classes,
                                    pretrained=False,
                                    input_size=(args.input_size, args.input_size))
        else:
            # fine-tuning
            logger.info("=> using pre-trained model '{}'".format(args.model))
            base_model = make_model(args.model,
                                    num_classes=train_num_classes,
                                    pretrained=True,
                                    input_size=(args.input_size, args.input_size))
github checktheroads / hyperglass / hyperglass / hyperglass.py View on Github external
def handle_500(e):
    """General Error Page"""
    client_addr = get_ipaddr()
    count_errors.labels(500, e, client_addr, None, None, None).inc()
    logger.error(f"Error: {e}, Source: {client_addr}")
    html = render.html("500")
    return html, 500
github ddi-lab / generion-middleware / neo / Prompt / Utils.py View on Github external
if '--tx-attr=' in item:
            to_remove.append(item)
            try:
                attr_str = item.replace('--tx-attr=', '')
                tx_attr_obj = eval(attr_str)
                if type(tx_attr_obj) is dict:
                    if attr_obj_to_tx_attr(tx_attr_obj) is not None:
                        tx_attr_dict.append(attr_obj_to_tx_attr(tx_attr_obj))
                elif type(tx_attr_obj) is list:
                    for obj in tx_attr_obj:
                        if attr_obj_to_tx_attr(obj) is not None:
                            tx_attr_dict.append(attr_obj_to_tx_attr(obj))
                else:
                    logger.error("Invalid transaction attribute specification: %s " % type(tx_attr_obj))
            except Exception as e:
                logger.error("Could not parse json from tx attrs: %s " % e)
    for item in to_remove:
        params.remove(item)

    return params, tx_attr_dict
github tmobile / monarch / monarch / pcf / app.py View on Github external
:param appname: String; the name of the application deployment within cloud foundry.
        :return: App; Instance of App which holds all the discovered information.
        """
        if monarch.pcf.util.cf_target(org, space):
            logger.error("Failed to target org %s and space %s!", org, space)
            return None
        app = App(org, space, appname)
        app.add_services_from_cfg()
        if not app.find_guid():
            logger.error("App discovery failed because GUID could not be found!")
            return None
        if not app.find_instances():
            logger.error("App discovery failed because no application instances could be found!")
            return None
        if app.find_services() is None:
            logger.error("App discovery failed because there was an error when finding services!")
            return None

        logger.info("Successfully discovered %s in %s %s.", appname, org, space)
        logger.debug(json.dumps(app.serialize(), indent=2))
        return app
github ddi-lab / generion-middleware / neo / SmartContract / ApplicationEngine.py View on Github external
item = self.EvaluationStack.Peek()

                if not item.IsArray:
                    logger.error("ITEM NOT ARRAY:")
                    return False

                size = len(item.GetArray())

        if size == 0:
            return True

        size += self.EvaluationStack.Count + self.AltStack.Count

        if size > maxStackSize:
            logger.error("SIZE IS OVER MAX STACK SIZE!!!!")
            return False

        return True
github chaostoolkit / chaostoolkit-lib / chaoslib / settings.py View on Github external
"""
    Load chaostoolkit settings as a mapping of key/values or return `None`
    when the file could not be found.
    """
    if not os.path.exists(settings_path):
        logger.debug("The Chaos Toolkit settings file could not be found at "
                     "'{c}'.".format(c=settings_path))
        return

    with open(settings_path) as f:
        try:
            settings = yaml.safe_load(f.read())
            loaded_settings.set(settings)
            return settings
        except yaml.YAMLError as ye:
            logger.error("Failed parsing YAML settings: {}".format(str(ye)))
github openatx / atxserver2-ios-provider / main.py View on Github external
"provider": {
                "wdaUrl": "http://{}:{}".format(current_ip(), d.public_port)
            },
            "properties": {
                "ip": info['value']['ios']['ip'],
                "version": info['value']['os']['version'],
                "sdkVersion": info['value']['os']['sdkVersion'],
            }
        })  # yapf: disable
    elif status == wd.status_fatal:
        await hbc.device_update({
            "udid": d.udid,
            "provider": None,
        })
    else:
        logger.error("Unknown status: %s", status)
github trinity-project / trinity / src / crypto / Cryptography / Crypto.py View on Github external
def VerifySignature(message, signature, public_key):

        Crypto.SetupSignatureCurve()

        if type(public_key) is EllipticCurve.ECPoint:

            pubkey_x = public_key.x.value.to_bytes(32, 'big')
            pubkey_y = public_key.y.value.to_bytes(32, 'big')

            public_key = pubkey_x + pubkey_y

        m = message
        try:
            m = binascii.unhexlify(message)
        except Exception as e:
            logger.error("could not get m: %s" % e)

        if len(public_key) == 33:

            public_key = bitcoin.decompress(public_key)
            public_key = public_key[1:]

        try:
            vk = VerifyingKey.from_string(public_key, curve=NIST256p, hashfunc=hashlib.sha256)
            res = vk.verify(signature, m, hashfunc=hashlib.sha256)
            return res
        except Exception as e:
            pass

        return False