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


Python AppScaleLogger.warn方法代码示例

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


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

示例1: _get_stats

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import warn [as 别名]
def _get_stats(keyname, stats_kind, include_lists):
  """
  Returns statistics from Hermes.

  Args:
    keyname: A string representing an identifier from AppScaleFile.
    stats_kind: A string representing a kind of statistics.
    include_lists: A dict representing desired fields.

  Returns:
    A dict of statistics.
    A dict of failures.
  """
  load_balancer_ip = LocalState.get_host_with_role(keyname, 'load_balancer')
  secret = LocalState.get_secret_key(keyname=keyname)
  administration_port = "17441"
  stats_path = "/stats/cluster/{stats_kind}".format(stats_kind=stats_kind)

  headers = {'Appscale-Secret': secret}
  data = {'include_lists': include_lists}
  url = "https://{ip}:{port}{path}".format(
    ip=load_balancer_ip,
    port=administration_port,
    path=stats_path
  )

  try:
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
    resp = requests.get(
      url=url,
      headers=headers,
      json=data,
      verify=False
    )
    resp.raise_for_status()
  except requests.HTTPError as err:
    AppScaleLogger.warn(
      "Failed to get {stats_kind} stats ({err})"
      .format(stats_kind=stats_kind, err=err)
    )
    return {}, {}

  json_body = resp.json()
  return json_body["stats"], json_body["failures"]
开发者ID:AppScale,项目名称:appscale-tools,代码行数:46,代码来源:appscale_stats.py

示例2: print_failures

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import warn [as 别名]
def print_failures(failures):
  """
  Prints a failure list.

  Args:
    failures: A dict in which each key is a kind of statistics and
      value if a failure list.
  """
  stats_kinds = {
    "nodes": "Node",
    "processes": "Process",
    "proxies": "Proxy"
  }

  AppScaleLogger.warn("There are some failures while getting stats:")
  for kind, fails in failures.iteritems():
    for ip, failure in fails.iteritems():
      AppScaleLogger.warn(
        "  {stats_kind} stats from {ip}: {failure}".format(
          stats_kind=stats_kinds[kind], ip=ip, failure=failure
        )
      )
开发者ID:AppScale,项目名称:appscale-tools,代码行数:24,代码来源:appscale_stats.py


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