本文整理匯總了Python中log.logger.warning方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.warning方法的具體用法?Python logger.warning怎麽用?Python logger.warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類log.logger
的用法示例。
在下文中一共展示了logger.warning方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: with_retry
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def with_retry(retries_limit=RETRIES_LIMIT, allowed_exceptions=None):
allowed_exceptions = allowed_exceptions or (ControlledException,)
def retry(operation):
@wraps(operation)
def wrapped(*args, **kwargs):
last_raised = None
for _ in range(retries_limit):
try:
return operation(*args, **kwargs)
except allowed_exceptions as e:
logger.warning(
"retrying %s due to %s", operation.__qualname__, e
)
last_raised = e
raise last_raised
return wrapped
return retry
示例2: podgroup_status_history
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def podgroup_status_history(self, procname, instance):
for pg in self.app_spec.PodGroups:
if pg.Name.split('.')[2] == procname:
r = self.default_deploy.get_podhistory(pg.Name, int(instance))
if r.status_code < 400:
status_histories = r.json()
for history in status_histories:
image, node = history['from'].split(' ')
history['image'] = image.split('/')[1]
history['node'] = node[5:] # len('node:')
del history['from']
status_histories.reverse()
return {
'Name': pg.Name,
'Instance': instance,
'StatusHistory': status_histories
}
else:
logger.warning(
"fail getting PodGroup status history: %s" % r.content)
return None
return None
示例3: is_valid_user
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def is_valid_user(username, password):
try:
auth_url = _get_sso_server() + '/oauth2/auth' + '?' + urlencode({
'client_id': client_id,
'response_type': 'code',
'scope': 'write:group',
'redirect_uri': redirect_uri,
'state': 'foobar',
})
usr_msg = {'login': username, 'password': password}
result = requests.post(
auth_url,
data=usr_msg,
allow_redirects=False)
code_callback_url = result.headers['Location']
authentication = parse_qs(urlparse(code_callback_url).query)
return authentication['code'][0] != ''
except Exception, e:
logger.warning(
"failed checking user's username and password: %s" % str(e))
return False
示例4: authorize_registry
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def authorize_registry(cls, request):
info = authorize.registry.parse_request(request)
if info.actions is not None and \
len(info.actions) == 1 and \
str(info.actions[0]) == 'pull':
return True, authorize.registry.get_jwt_with_request_info(info)
if not authorize.registry.ip_in_whitelist(info.client_ip):
if not authorize.utils.is_valid_user(info.username, info.password):
logger.warning("requests from %s, %s not valid" % (
info.username, info.password))
return False, 'the username or password may not be correct.'
if LAIN_ADMIN_NAME in authorize.utils.get_user_group(info.username).json()["groups"]:
return True, authorize.registry.get_jwt_with_request_info(info)
if info.appname:
succ, role = Group.get_user_role(info.username, info.appname)
if not succ:
logger.warning("requests from %s for %s not valid" % (
info.username, info.appname))
return False, 'the user has no access to %s' % info.appname
return True, authorize.registry.get_jwt_with_request_info(info)
示例5: create_group_for_app
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def create_group_for_app(cls, access_token, appname):
if not Authorize.need_auth(AUTH_TYPES['SSO']):
return True, "don't need sso auth, no need for create group"
try:
response = authorize.utils.create_group_for_app(
access_token, appname)
if response.status_code != 201:
logger.warning("fail create group for app %s : %s" %
(appname, response.text))
return False, "fail create group for app %s : %s" % (appname, response.text)
else:
success, msg = Group.add_group_member(access_token, appname,
LAIN_ADMIN_NAME, LAIN_ADMIN_ROLE, is_lain_admin=True)
if not success:
return False, msg
return True, "create group for app %s successfully" % appname
except Exception, e:
logger.error("Exception create group for app %s : %s" %
(appname, str(e)))
return False, "sso system wrong when creating group for app %s" % appname
示例6: add_group_member
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def add_group_member(cls, access_token, appname, username, role, is_lain_admin=False):
try:
add_group_func = authorize.utils.add_group_member_for_admin if is_lain_admin else \
authorize.utils.add_group_member
response = add_group_func(access_token, appname, username, role)
if response.status_code != 200:
logger.warning("fail add group member %s to app %s : %s" % (
username, appname, response.text))
return False, "fail add group member %s to app %s : %s" % (
username, appname, response.text)
else:
return True, 'add group member successfully'
except Exception, e:
logger.error('Exception add group member %s to app %s : %s' % (
username, appname, str(e)))
return False, "sso system wrong when adding group member %s to app %s" % (
username, appname)
示例7: delete_group_member
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def delete_group_member(cls, access_token, appname, username):
try:
response = authorize.utils.delete_group_member(
access_token, appname, username)
if response.status_code != 204:
logger.warning("fail delete group member %s from app %s : %s" % (
username, appname, response.text))
return False, "fail delete group member %s from app %s : %s" % (
username, appname, response.text)
else:
return True, "delete group member successfully"
except Exception, e:
logger.error('Exception delete group member %s from app %s: %s' % (
username, appname, str(e)))
return False, "sso system wrong when deleting group member %s from app %s" % (
username, appname)
示例8: get_group_members
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def get_group_members(cls, appname):
try:
response = authorize.utils.get_group_info(appname)
maintainers = []
if response.status_code != 200:
logger.warning("fail get group members for app %s : %s" % (
appname, response.text))
return False, "fail get group members for app %s : %s" % (appname, response.text)
else:
members = response.json()['members']
for member in members:
maintainers.append(member)
return True, maintainers
except Exception, e:
logger.error('Exception get group members for app %s: %s' %
(appname, str(e)))
return False, "sso system wrong when getting group member for app %s" % appname
示例9: check_sheet
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def check_sheet(wb, tab_name, col, check_col):
"""
Checks a sheet.
Arguments:
----------
col: integer
Either 0 or 7, 0 for column a, 7 for column h
check_col: list
The list for the column to compare against
tab_name: string
The tab name to extract the column from
wb: workbook object
The workbook to use
"""
matches = True
tmp_sheet = wb.sheet_by_name(tab_name)
tmp = [x.value for x in tmp_sheet.col(col)]
error_rows = []
if tmp != check_col:
matches = False
logger.warning(u"File tab {} column A differs:".format(tab_name))
max_row = max(len(tmp), len(check_col))
for i in range(max_row):
if i < len(tmp) and i < len(check_col):
if tmp[i] != check_col[i]:
error_rows.append(i)
logger.warning(u"Row {}, base is {}, file is {}".format(i + 1, check_col[i], tmp[i]))
elif i >= len(tmp) and i < len(check_col):
logger.warning(u"Row {}, base is {}, but doesn't exist in file".format(i + 1, check_col[i]))
elif i< len(tmp) and i >= len(check_col):
logger.warning(u"Row {}, doesn't exist in base, but in file is {}".format(i + 1, tmp[i]))
if matches:
return True
else:
return error_rows
示例10: board_size
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def board_size(self):
node_boardsize = self.cursor.node.get('SZ')
if node_boardsize:
board_size = int(node_boardsize.data[0])
if board_size != 19:
logger.warning("Board size is not 19 so analysis could be very inaccurate.")
else:
board_size = 19
return board_size
示例11: send_command
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def send_command(self, cmd, timeout=100, drain=True):
"""Send command to GTP console and drains stdout/stderr"""
if isinstance(cmd, list):
commands_count = len(cmd)
command = '\n'.join(cmd)
else:
commands_count = 1
command = cmd
self.process.stdin.write(command + "\n")
self.process.stdin.flush()
tries = 0
success_count = 0
while tries <= timeout:
# Loop until reach given number of success
while True:
s = self.stdout_thread.readline()
# Break loop, sleep and wait for more
if s == "":
break
# GTP prints a line starting with "=" upon success.
if '=' in s:
success_count += 1
if success_count >= commands_count:
if drain:
self.drain()
return
tries += 1
sleep(0.1)
logger.warning(f"Failed to send command: {command}")
示例12: parse_analysis
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def parse_analysis(self, stdout, stderr):
"""Parse stdout & stderr."""
logger.debug(f"GTP stdout:\n%s", ''.join(stdout))
logger.debug(f"GTP stderr:\n%s", ''.join(stderr))
stats = {}
move_list = []
for line in stderr:
line = line.strip()
stats = self.parse_bookmove(stats, line)
stats.update(self.parse_move_status(line))
move_list = self.parse_move(move_list, line)
stats = self.parse_status(stats, None, line)
stats['best'] = move_list[0]['pos']
stats['winrate'] = move_list[0]['winrate']
stats = self.parse_finished(stats, stdout)
required_keys = ['best', 'winrate', 'visits']
# Check for missed data
for k in required_keys:
if k not in stats:
logger.warning("Analysis stats missing %s data", k)
# In the case where Leela resigns, just replace with the move Leela did think was best
if stats['chosen'] == "resign":
stats['chosen'] = stats['best']
return stats, move_list
示例13: podgroup_status
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def podgroup_status(self, name):
for pg in self.app_spec.PodGroups:
if pg.Name == name:
r = self.default_deploy.get_podgroup(pg.Name)
if r.status_code < 400:
return {
'Name': pg.Name,
'Status': r.json()
}
else:
logger.warning("fail getting PodGroup: %s" % r.content)
return None
return None
示例14: dependency_status
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def dependency_status(self, name):
r = self.default_deploy.get_dependency(name)
if r.status_code < 400:
return {
'Name': name,
'Status': r.json()
}
else:
logger.warning("fail getting Dependency: %s" % r.content)
return None
示例15: useless_procs_remove
# 需要導入模塊: from log import logger [as 別名]
# 或者: from log.logger import warning [as 別名]
def useless_procs_remove(self, origin_procs):
remove_results = {}
remove_success_results = {}
remove_failed_results = {}
remove_missed_results = {}
current_pgs = ["%s.%s.%s" % (self.appname, p.type.name, p.name)
for p in self.lain_config.procs.values()]
try:
for proc in origin_procs:
pg_name = "%s.%s.%s" % (
self.appname, proc.type.name, proc.name)
if pg_name in current_pgs:
continue
logger.info("remove useless proc %s of app : %s " %
(pg_name, self.appname))
remove_r = self.podgroup_remove(pg_name) if proc.type != ProcType.portal else \
self.dependency_remove(pg_name)
if remove_r.status_code < 400:
remove_success_results[pg_name] = remove_r
elif remove_r.status_code == 404:
remove_missed_results[pg_name] = remove_r
else:
remove_failed_results[pg_name] = remove_r
except Exception, e:
logger.warning("failed when trying to remove useless proc of app %s: %s" %
(self.appname, str(e)))