当前位置: 首页>>代码示例>>Python>>正文


Python logger.error方法代码示例

本文整理汇总了Python中logzero.logger.error方法的典型用法代码示例。如果您正苦于以下问题:Python logger.error方法的具体用法?Python logger.error怎么用?Python logger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在logzero.logger的用法示例。


在下文中一共展示了logger.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def validate(ctx: click.Context, source: str,
             no_verify_tls: bool = False) -> Experiment:
    """Validate the experiment at SOURCE."""
    settings = load_settings(ctx.obj["settings_path"])

    try:
        experiment = load_experiment(
            source, settings, verify_tls=not no_verify_tls)
    except InvalidSource as x:
        logger.error(str(x))
        logger.debug(x)
        ctx.exit(1)

    try:
        notify(settings, ValidateFlowEvent.ValidateStarted, experiment)
        ensure_experiment_is_valid(experiment)
        notify(settings, ValidateFlowEvent.ValidateCompleted, experiment)
        logger.info("experiment syntax and semantic look valid")
    except ChaosException as x:
        notify(settings, ValidateFlowEvent.ValidateFailed, experiment, x)
        logger.error(str(x))
        logger.debug(x)
        ctx.exit(1)

    return experiment 
开发者ID:chaostoolkit,项目名称:chaostoolkit,代码行数:27,代码来源:cli.py

示例2: wda_status

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def wda_status(self):
        """
        Returns:
            dict or None
        """
        try:
            request = httpclient.HTTPRequest(self.wda_device_url + "/status",
                                             connect_timeout=3,
                                             request_timeout=15)
            client = httpclient.AsyncHTTPClient()
            resp = await client.fetch(request)
            info = json.loads(resp.body)
            self.__wda_info = info
            return info
        except httpclient.HTTPError as e:
            logger.debug("%s request wda/status error: %s", self, e)
            return None
        except (ConnectionResetError, ConnectionRefusedError):
            logger.debug("%s waiting for wda", self)
            return None
        except Exception as e:
            logger.warning("%s ping wda unknown error: %s %s", self, type(e),
                           e)
            return None 
开发者ID:openatx,项目名称:atxserver2-ios-provider,代码行数:26,代码来源:idb.py

示例3: wda_screenshot_ok

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def wda_screenshot_ok(self):
        """
        Check if screenshot is working
        Returns:
            bool
        """
        try:
            request = httpclient.HTTPRequest(self.wda_device_url +
                                             "/screenshot",
                                             connect_timeout=3,
                                             request_timeout=15)
            client = httpclient.AsyncHTTPClient()
            resp = await client.fetch(request)
            data = json.loads(resp.body)
            raw_png_data = base64.b64decode(data['value'])
            png_header = b"\x89PNG\r\n\x1a\n"
            if not raw_png_data.startswith(png_header):
                return False
            return True
        except Exception as e:
            logger.warning("%s wda screenshot error: %s", self, e)
            return False 
开发者ID:openatx,项目名称:atxserver2-ios-provider,代码行数:24,代码来源:idb.py

示例4: download_versions

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def download_versions(self, version=None):
        rr = requests.get(self.RELEASES_URL)
        soup = BeautifulSoup(rr.text, features='html.parser')
        hrefs = soup.findAll('a')
        hrefs = [x.attrs['href'] for x in hrefs]
        hrefs = [x for x in hrefs if x.endswith('.gz')]
        hrefs = [x for x in hrefs if 'latest' not in x]

        # filter by specific version if requested
        if version:
            hrefs = [x for x in hrefs if version in x]

        for href in hrefs:
            dst = os.path.join(self.cachedir, 'tars', href)
            src = os.path.join(self.RELEASES_URL, href)
            if not os.path.exists(dst):
                logger.debug('%s -> %s' % (dst,src))
                res = curl('-o', dst, src)
                if res.exit_code != 0:
                    logger.error('Failed to download %s to %s' % (src, dst))
                    logger.error(res.stdout)
                    logger.error(res.stderr)
                    sys.exit(1) 
开发者ID:jctanner,项目名称:ansible-tools,代码行数:25,代码来源:utils.py

示例5: load_settings

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def load_settings(settings_path: str = CHAOSTOOLKIT_CONFIG_PATH) -> Settings:
    """
    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))) 
开发者ID:chaostoolkit,项目名称:chaostoolkit-lib,代码行数:19,代码来源:settings.py

示例6: ReadByte

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def ReadByte(self, do_ord=True):
        """
        Read a single byte.

        Args:
            do_ord (bool): (default True) convert the byte to an ordinal first.

        Returns:
            bytes: a single byte if successful. 0 (int) if an exception occurred.
        """
        try:
            if do_ord:
                return ord(self.stream.read(1))
            return self.stream.read(1)
        except Exception as e:
            logger.error("ord expected character but got none")
        return 0 
开发者ID:CityOfZion,项目名称:neo-python-core,代码行数:19,代码来源:BinaryReader.py

示例7: tearDownClass

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def tearDownClass(cls):
        super(BoaFixtureTest, cls).tearDownClass()
        try:
            if os.path.exists(settings.debug_storage_leveldb_path):

                shutil.rmtree(settings.debug_storage_leveldb_path)
            else:
                logger.error("debug storage path doesn't exist")
        except Exception as e:
            logger.error("couldn't remove debug storage %s " % e) 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:12,代码来源:test_contract.py

示例8: get_commands

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def get_commands():
    commands = ""
    try:
        with open("files/commands.txt", "rb") as file:
            for command in file.readlines():
                commands += "/" + command.decode("utf-8")
        return commands
    except FileNotFoundError:
        log.error("File could not be opened.") 
开发者ID:JosXa,项目名称:BotListBot,代码行数:11,代码来源:helpers.py

示例9: schedule_conversation_deletion

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def schedule_conversation_deletion(self, peer, delay=5):
        await asyncio.sleep(delay)
        self.send(DeleteHistory(await self.resolve_peer(peer), max_id=999999999, just_clear=True))
        log.debug("Deleted conversation with {}".format(peer))

    # def delete_all_conversations(self):
    #     all_peers = [utils.resolve_id(x[0]) for x in self.session.entities.get_input_list()]
    #     for peer in all_peers:
    #         log.debug("Deleting conversation with {}...".format(peer))
    #         try:
    #             input_entity = self.client.session.entities.get_input_entity(peer[0])
    #             self.client(DeleteHistoryRequest(input_entity, max_id=9999999999999999))
    #         except:
    #             log.error("Couldn't find {}".format(peer[0])) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:16,代码来源:botchecker.py

示例10: resolve_bot

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def resolve_bot(self, bot: BotModel):
        if bot.chat_id:
            try:
                return self.resolve_peer(bot.chat_id)
            except:
                pass

        try:
            results = self.send(Search(bot.username, limit=3))
            if results.users:
                try:
                    return next(
                        s for s in results.users if s.username.lower() == bot.username[1:].lower())
                except StopIteration:
                    pass
        except QueryTooShort:
            pass

        if self.username_flood_until:
            if self.username_flood_until < datetime.now():
                self.username_flood_until = None
        else:
            try:
                return self.resolve_peer(bot.username)
            except FloodWait as e:
                self.username_flood_until = datetime.now() + timedelta(
                    seconds=e.x)
                log.warning("Flood wait for ResolveUsername: {}s (until {})".format(
                    e.x, self.username_flood_until))
            except UsernameInvalid as e:
                log.error(e)  # TODO

        return None 
开发者ID:JosXa,项目名称:BotListBot,代码行数:35,代码来源:botchecker.py

示例11: download_profile_photo

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def download_profile_photo(self, bot: BotModel, photo_path):
        tmp_file = os.path.join(TMP_DIR, bot.username.replace('@', '') + '.jpg')
        photos = self.get_user_profile_photos(bot.chat_id).photos
        if photos:
            photo_size_object = photos[0][-1]

            await self.__photos_lock.acquire()
            try:
                try:
                    self.download_media(
                        photo_size_object,
                        file_name=tmp_file,
                        block=True
                    )
                except FloodWait as e:
                    # TODO: as the error happens inside of the update worker, this won't work (yet)
                    # Leaving it in as the default behavior should be to raise the FloodWait
                    # when block=True
                    log.debug(f"FloodWait for downloading media ({e.x})")

                if os.path.exists(tmp_file):
                    try:
                        similar = filecmp.cmp(tmp_file, photo_path, shallow=False)
                    except FileNotFoundError:
                        similar = False

                    if not similar:
                        shutil.copy(tmp_file, photo_path)
            finally:
                self.__photos_lock.release() 
开发者ID:JosXa,项目名称:BotListBot,代码行数:32,代码来源:botchecker.py

示例12: send_or_edit

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def send_or_edit(self, text, message_id, reply_markup=None):
        sleep(3)
        try:
            if self.resend:
                return util.send_md_message(self.bot, self.channel.chat_id, text, timeout=120,
                                            disable_notification=True, reply_markup=reply_markup)
            else:
                if reply_markup:
                    return self.bot.formatter.send_or_edit(self.channel.chat_id, text,
                                                           to_edit=message_id,
                                                           timeout=120,
                                                           disable_web_page_preview=True,
                                                           disable_notification=True,
                                                           reply_markup=reply_markup)
                else:
                    return self.bot.formatter.send_or_edit(self.channel.chat_id, text,
                                                           to_edit=message_id,
                                                           timeout=120,
                                                           disable_web_page_preview=True,
                                                           disable_notification=True)
        except BadRequest as e:
            if 'chat not found' in e.message.lower():
                self.notify_admin_err(
                    "I can't reach BotList Bot with chat-id `{}` (CHAT NOT FOUND error). "
                    "There's probably something wrong with the database.".format(
                        self.channel.chat_id))
                raise e
            if 'message not modified' in e.message.lower():
                return None
            else:
                log.error(e)
                raise e 
开发者ID:JosXa,项目名称:BotListBot,代码行数:34,代码来源:botlist.py

示例13: get_thermal_image_from_file

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def get_thermal_image_from_file(thermal_input, thermal_class=CFlir, colormap=None):
    '''
    Function to get the image associated with each RJPG file using the FLIR Thermal base class CFlir
    Saves the thermal images in the same place as the original RJPG
    '''
    CThermal = thermal_class

    inputpath = Path(thermal_input)
    if Path.is_dir(inputpath):
        rjpg_img_paths = list(Path(input_folder).glob('*R.JPG'))
        fff_file_paths = list(Path(input_folder).glob('*.fff'))
        if len(rjpg_img_paths)>0:
            for rjpg_img in tqdm(rjpg_img_paths, total=len(rjpg_img_paths)):
                thermal_obj = CThermal(rjpg_img, color_map=colormap)
                path_wo_ext = str(rjpg_img).replace('_R'+rjpg_img.suffix,'') 
                thermal_obj.save_thermal_image(path_wo_ext+'.jpg')

        elif len(fff_file_paths)>0:
            for fff in tqdm(fff_file_paths, total=len(fff_file_paths)):
                save_image_path = str(fff).replace('.fff','.jpg')
                thermal_obj = CThermal(fff, color_map=colormap)
                thermal_obj.save_thermal_image(save_image_path)
        else:
            logger.error('Input folder contains neither fff or RJPG files')

    elif Path.is_file(inputpath):
        thermal_obj = CThermal(thermal_input, color_map=colormap)
        path_wo_ext = Path.as_posix(inputpath).replace(inputpath.suffix,'')
        thermal_obj.save_thermal_image(path_wo_ext+'.jpg')

    else:
        logger.error('Path given is neither file nor folder. Please check') 
开发者ID:detecttechnologies,项目名称:Thermal_Image_Analysis,代码行数:34,代码来源:CThermal.py

示例14: post

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def post(self, udid=None):
        udid = udid or self.get_argument('udid', None)
        assert udid
        d = idevices.get(udid)
        try:
            if not d:
                raise Exception("Device not found")

            d.restart_wda_proxy() # change wda public port
            wda_url = "http://{}:{}".format(current_ip(), d.public_port)
            await d.wda_healthcheck()
            await hbc.device_update({
                "udid": udid,
                "colding": False,
                "provider": {
                    "wdaUrl": wda_url,
                }
            })
            self.write({
                "success": True,
                "description": "Device successfully colded"
            })
        except Exception as e:
            logger.warning("colding procedure got error: %s", e)
            self.set_status(400)  # bad request
            self.write({
                "success": False,
                "description": "udid: %s not found" % udid
            }) 
开发者ID:openatx,项目名称:atxserver2-ios-provider,代码行数:31,代码来源:main.py

示例15: runcommand

# 需要导入模块: from logzero import logger [as 别名]
# 或者: from logzero.logger import error [as 别名]
def runcommand(*args) -> str:
    try:
        output = subprocess.check_output(args)
        return output.strip().decode('utf-8')
    except (subprocess.CalledProcessError, FileNotFoundError):
        return ""
    except Exception as e:
        logger.warning("unknown error: %s", e)
        return "" 
开发者ID:openatx,项目名称:atxserver2-ios-provider,代码行数:11,代码来源:idb.py


注:本文中的logzero.logger.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。