本文整理匯總了Python中core.logger.Logger.warn方法的典型用法代碼示例。如果您正苦於以下問題:Python Logger.warn方法的具體用法?Python Logger.warn怎麽用?Python Logger.warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core.logger.Logger
的用法示例。
在下文中一共展示了Logger.warn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: bool
# 需要導入模塊: from core.logger import Logger [as 別名]
# 或者: from core.logger.Logger import warn [as 別名]
# TODO actually test trakt.tv authentication
success = bool(Dict['trakt.token'])
if not success:
# status - False = invalid credentials, None = request failed
if retry:
# Increase retry interval each time to a maximum of 30 minutes
if retry_interval < 60 * 30:
retry_interval = int(retry_interval * 1.3)
# Ensure we never go over 30 minutes
if retry_interval > 60 * 30:
retry_interval = 60 * 30
log.warn('Unable to authentication with trakt.tv, will try again in %s seconds', retry_interval)
schedule(cls.authenticate, retry_interval, retry_interval)
else:
log.warn('Authentication failed, username or password is incorrect')
Main.update_config(False)
return False
log.info('Authentication successful')
Main.update_config(True)
return True
def start(self):
# Check for authentication token
log.info('X-Plex-Token: %s', 'available' if os.environ.get('PLEXTOKEN') else 'unavailable')
示例2: should_retry
# 需要導入模塊: from core.logger import Logger [as 別名]
# 或者: from core.logger.Logger import warn [as 別名]
data = urllib2.urlopen(req, **kwargs).read()
if cache_id is not None:
cache.update((req.get_full_url(), cache_id), data)
return Response.from_data(response_type, data)
except RequestError, e:
ex = e
except Exception, e:
ex = NetworkError.from_exception(e, response_type=response_type)
if raise_exceptions:
raise ex
else:
log.warn('Network request raised exception: %s' % ex)
return default
def should_retry(error_code):
# If there is no error code, assume we should retry
if error_code is None:
return True
for retry_code in HTTP_RETRY_CODES:
if type(retry_code) is tuple and len(retry_code) == 2:
if retry_code[0] <= error_code <= retry_code[1]:
return True
elif type(retry_code) is int:
if retry_code == error_code: