當前位置: 首頁>>代碼示例>>Python>>正文


Python logger.warning方法代碼示例

本文整理匯總了Python中logzero.logger.warning方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.warning方法的具體用法?Python logger.warning怎麽用?Python logger.warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logzero.logger的用法示例。


在下文中一共展示了logger.warning方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def post(self, udid=None):
        """ 設備清理 """
        udid = udid or self.get_argument("udid")
        logger.info("Receive colding request for %s", udid)
        request_secret = self.get_argument("secret")
        if secret != request_secret:
            logger.warning("secret not match, expect %s, got %s", secret,
                           request_secret)
            return

        if udid not in udid2device:
            return

        device = udid2device[udid]
        await device.reset()
        await hbconn.device_update({
            "udid": udid,
            "colding": False,
            "provider": device.addrs(),
        })
        self.write({"success": True, "description": "Device colded"}) 
開發者ID:openatx,項目名稱:atxserver2-android-provider,代碼行數:23,代碼來源:main.py

示例2: connect

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def connect(self):
        """
        Returns:
            tornado.WebSocketConnection
        """
        cnt = 0
        while True:
            try:
                ws = await self._connect()
                cnt = 0
                return ws
            except Exception as e:
                cnt = min(30, cnt + 1)
                logger.warning("WS connect error: %s, reconnect after %ds", e,
                               cnt + 1)
                await gen.sleep(cnt + 1) 
開發者ID:openatx,項目名稱:atxserver2-android-provider,代碼行數:18,代碼來源:heartbeat.py

示例3: check_newer_version

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def check_newer_version(command: str):
    """
    Query for the latest release of the chaostoolkit to compare it
    with the current's version. If the former is higher then issue a warning
    inviting the user to upgrade its environment.
    """
    try:
        command = command.strip()
        r = requests.get(LATEST_RELEASE_URL, timeout=(2, 30),
                         params={"current": __version__, "command": command})
        if r.status_code == 200:
            payload = r.json()
            latest_version = payload["version"]
            if payload.get("up_to_date") is False:
                options = '--pre -U' if 'rc' in latest_version else '-U'
                logger.warning(
                    "\nThere is a new version ({v}) of the chaostoolkit "
                    "available.\n"
                    "You may upgrade by typing:\n\n"
                    "$ pip install {opt} chaostoolkit\n\n"
                    "Please review changes at {u}\n".format(
                        u=CHANGELOG_URL, v=latest_version, opt=options))
                return latest_version
    except Exception:
        pass 
開發者ID:chaostoolkit,項目名稱:chaostoolkit,代碼行數:27,代碼來源:check.py

示例4: vcount

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def vcount(shpfile):
    df = gp.read_file(shpfile)
    if not df.size==0:
        for i, row in df.iterrows():
            # It's better to check if multigeometry
            multi = row.geometry.type.startswith("Multi")
            if multi:
                n = 0
                # iterate over all parts of multigeometry
                for part in row.geometry:
                    n += len(part.exterior.coords)
            else: # if single geometry like point, linestring or polygon
                n = len(row.geometry.exterior.coords)

            #print('Total vertices: {:,}'.format(n))
            overall.append(n)
        if all(i < 1000000 for i in overall)==True:
            return sum(overall)
        else:
            logger.warning(shpfile+' has overall max vertex of '+str(max(overall))+' with max allowed 1000000 ingest might fail')
            return sum(overall)
            #print('Total vertices per feature exceeded max. Overall vertices: {}'.format(sum(overall)))
            #return sum(overall)
    else:
        return df.size 
開發者ID:samapriya,項目名稱:geeup,代碼行數:27,代碼來源:zipfiles.py

示例5: wait_until_ready

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def wait_until_ready(self, timeout: float = 60.0) -> bool:
        """
        Returns:
            bool
        """
        deadline = time.time() + timeout
        while time.time() < deadline and not self._stop.is_set():
            quited = any([p.poll() is not None for p in self._procs])
            if quited:
                logger.warning("%s process quit %s", self,
                               [(p.pid, p.poll()) for p in self._procs])
                return False
            if await self.wda_status():
                return True
            await self._sleep(1)
        return False 
開發者ID:openatx,項目名稱:atxserver2-ios-provider,代碼行數:18,代碼來源:idb.py

示例6: wda_screenshot_ok

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [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

示例7: validate_python_control

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def validate_python_control(control: Control):
    """
    Verify that a control block matches the specification
    """
    name = control["name"]
    provider = control["provider"]
    mod_name = provider.get("module")
    if not mod_name:
        raise InvalidActivity(
            "Control '{}' must have a module path".format(name))

    try:
        importlib.import_module(mod_name)
    except ImportError:
        logger.warning("Could not find Python module '{mod}' "
                       "in control '{name}'. Did you install the Python "
                       "module? The experiment will carry on running "
                       "nonetheless.".format(mod=mod_name, name=name)) 
開發者ID:chaostoolkit,項目名稱:chaostoolkit-lib,代碼行數:20,代碼來源:python.py

示例8: _log_deprecated

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def _log_deprecated(name: str, alt_name: str):
    logger.warning("{} function is DEPRECATED and will be removed in the next \
        releases, please use {} instead".format(
        name, alt_name)) 
開發者ID:chaostoolkit,項目名稱:chaostoolkit-kubernetes,代碼行數:6,代碼來源:__init__.py

示例9: resolve_bot

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [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

示例10: _drain_ws_message

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
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) 
開發者ID:openatx,項目名稱:atxserver2-android-provider,代碼行數:12,代碼來源:heartbeat.py

示例11: run_forever

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def run_forever(self):
        try:
            await self.init()
        except Exception as e:
            logger.warning("Init failed: %s", e) 
開發者ID:openatx,項目名稱:atxserver2-android-provider,代碼行數:7,代碼來源:device.py

示例12: _install_apk

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
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) 
開發者ID:openatx,項目名稱:atxserver2-android-provider,代碼行數:17,代碼來源:device.py

示例13: apply_watch_from_yaml

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def apply_watch_from_yaml(self, data):
        """
        Examples of argument data

            ---
            - when: "@com.example.app/popup"
            then: >
                def callback(d):
                    d.click(0.5, 0.5)
            - when: 繼續
            then: click
        """
        try:
            import yaml
        except ImportError:
            self.logger.warning("missing lib pyyaml")

        data = yaml.load(data, Loader=yaml.SafeLoader)
        for item in data:
            when, then = item['when'], item['then']

            trigger = lambda: None
            self.logger.info("%s, %s", when, then)
            if then == 'click':
                trigger = lambda selector: selector.get_last_match().click()
                trigger.__doc__ = "click"
            elif then.lstrip().startswith("def callback"):
                mod = ModuleType("_inner_module")
                exec(then, mod.__dict__)
                trigger = mod.callback
                trigger.__doc__ = then
            else:
                self.logger.warning("Unknown then: %r", then)

            self.logger.debug("When: %r, Trigger: %r", when, trigger.__doc__)
            self.when(when).call(trigger) 
開發者ID:openatx,項目名稱:uiautomator2,代碼行數:38,代碼來源:xpath.py

示例14: cli

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def cli(ctx: click.Context, verbose: bool = False,
        no_version_check: bool = False, change_dir: str = None,
        no_log_file: bool = False, log_file: str = "chaostoolkit.log",
        log_format: str = "string", settings: str = CHAOSTOOLKIT_CONFIG_PATH):

    if no_log_file:
        configure_logger(
            verbose=verbose, log_format=log_format,
            context_id=str(uuid.uuid4()))
    else:
        configure_logger(
            verbose=verbose, log_file=log_file, log_format=log_format,
            context_id=str(uuid.uuid4()))

    subcommand = ctx.invoked_subcommand

    # make it nicer for going through the log file
    logger.debug("#" * 79)
    logger.debug("Running command '{}'".format(subcommand))

    ctx.obj = {}
    ctx.obj["settings_path"] = click.format_filename(settings)
    logger.debug("Using settings file '{}'".format(ctx.obj["settings_path"]))

    if not no_version_check:
        check_newer_version(command=subcommand)

    if change_dir:
        logger.warning("Moving to {d}".format(d=change_dir))
        os.chdir(change_dir) 
開發者ID:chaostoolkit,項目名稱:chaostoolkit,代碼行數:32,代碼來源:cli.py

示例15: raw2temp

# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import warning [as 別名]
def raw2temp(raw, E=0.9,OD=1,RTemp=20,ATemp=20,IRWTemp=20,IRT=1,RH=50,PR1=21106.77,PB=1501,PF=1,PO=-7340,PR2=0.012545258):
        """ convert raw values from the flir sensor to temperatures in °C """
        # this calculation has been ported to python from https://github.com/gtatters/Thermimage/blob/master/R/raw2temp.R
        # a detailed explanation of what is going on here can be found there

        # constants
        ATA1=0.006569; ATA2=0.01262; ATB1=-0.002276; ATB2=-0.00667; ATX=1.9; #RH=0
        # transmission through window (calibrated)
        emiss_wind = 1 - IRT
        refl_wind = 0
        # transmission through the air
        h2o = (RH/100)*exp(1.5587+0.06939*(ATemp)-0.00027816*(ATemp)**2+0.00000068455*(ATemp)**3)
        tau1 = ATX*exp(-sqrt(OD/2)*(ATA1+ATB1*sqrt(h2o)))+(1-ATX)*exp(-sqrt(OD/2)*(ATA2+ATB2*sqrt(h2o)))
        tau2 = ATX*exp(-sqrt(OD/2)*(ATA1+ATB1*sqrt(h2o)))+(1-ATX)*exp(-sqrt(OD/2)*(ATA2+ATB2*sqrt(h2o)))        
        # radiance from the environment
        raw_refl1 = PR1/(PR2*(exp(PB/(RTemp+273.15))-PF))-PO
        raw_refl1_attn = (1-E)/E*raw_refl1 # Reflected component

        raw_atm1 = PR1/(PR2*(exp(PB/(ATemp+273.15))-PF))-PO # Emission from atmosphere 1
        raw_atm1_attn = (1-tau1)/E/tau1*raw_atm1 # attenuation for atmospheric 1 emission

        raw_wind = PR1/(PR2*(exp(PB/(IRWTemp+273.15))-PF))-PO # Emission from window due to its own temp
        raw_wind_attn = emiss_wind/E/tau1/IRT*raw_wind # Componen due to window emissivity

        raw_refl2 = PR1/(PR2*(exp(PB/(RTemp+273.15))-PF))-PO # Reflection from window due to external objects
        raw_refl2_attn = refl_wind/E/tau1/IRT*raw_refl2 # component due to window reflectivity

        raw_atm2 = PR1/(PR2*(exp(PB/(ATemp+273.15))-PF))-PO # Emission from atmosphere 2
        raw_atm2_attn = (1-tau2)/E/tau1/IRT/tau2*raw_atm2 # attenuation for atmospheric 2 emission

        raw_obj = (raw/E/tau1/IRT/tau2-raw_atm1_attn-raw_atm2_attn-raw_wind_attn-raw_refl1_attn-raw_refl2_attn)
        val_to_log = PR1/(PR2*(raw_obj+PO))+PF
        if any(val_to_log.ravel()<0):
            logger.warning('Image seems to be corrupted')
            val_to_log = np.where(val_to_log<0, sys.float_info.min, val_to_log)
        # temperature from radiance
        temp_C = PB/np.log(val_to_log)-273.15

        return temp_C 
開發者ID:detecttechnologies,項目名稱:Thermal_Image_Analysis,代碼行數:41,代碼來源:CThermal.py


注:本文中的logzero.logger.warning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。