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


Python color.Log类代码示例

本文整理汇总了Python中heron.common.src.python.color.Log的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: submit_fatjar

def submit_fatjar(cl_args, unknown_args, tmp_dir):

  # execute main of the topology to create the topology definition
  topology_file = cl_args['topology-file-name']
  try:
    execute.heron_class(
      cl_args['topology-class-name'],
      utils.get_heron_libs(jars.topology_jars()),
      extra_jars = [topology_file],
      args = tuple(unknown_args),
      javaDefines = cl_args['javaDefines'])

  except Exception as ex:
    Log.error("Unable to execute topology main class")
    return False

  try:
    launch_topologies(cl_args, topology_file, tmp_dir)

  except Exception as ex:
    return False

  finally:
    shutil.rmtree(tmp_dir)

  return True
开发者ID:digitalis-io,项目名称:heron-elodina,代码行数:26,代码来源:submit.py

示例2: extract_common_args

def extract_common_args(command, parser, cl_args):
  try:
    cluster_role_env = cl_args.pop('cluster/[role]/[env]')
    config_path = cl_args['config_path']
    override_config_file = utils.parse_override_config(cl_args['config_property'])
  except KeyError:
    # if some of the arguments are not found, print error and exit
    subparser = utils.get_subparser(parser, command)
    print(subparser.format_help())
    return dict()

  cluster = utils.get_heron_cluster(cluster_role_env)
  config_path = utils.get_heron_cluster_conf_dir(cluster, config_path)
  if not os.path.isdir(config_path):
    Log.error("Config path cluster directory does not exist: %s" % config_path)
    return dict()

  new_cl_args = dict()
  try:
    cluster_tuple = utils.parse_cluster_role_env(cluster_role_env, config_path)
    new_cl_args['cluster'] = cluster_tuple[0]
    new_cl_args['role'] = cluster_tuple[1]
    new_cl_args['environ'] = cluster_tuple[2]
    new_cl_args['config_path'] = config_path
    new_cl_args['override_config_file'] = override_config_file
  except Exception as e:
    Log.error("Argument cluster/[role]/[env] is not correct: %s" % str(e))
    return dict()

  cl_args.update(new_cl_args)
  return cl_args
开发者ID:10fish,项目名称:heron,代码行数:31,代码来源:main.py

示例3: extract_common_args

def extract_common_args(command, parser, cl_args):
  try:
    # do not pop like cli because ``topologies`` subcommand still needs it
    cluster_role_env = cl_args['cluster/[role]/[env]']
    config_path = cl_args['config_path']
  except KeyError:
    # if some of the arguments are not found, print error and exit
    subparser = utils.get_subparser(parser, command)
    print(subparser.format_help())
    return dict()
  cluster = utils.get_heron_cluster(cluster_role_env)
  config_path = utils.get_heron_cluster_conf_dir(cluster, config_path)

  new_cl_args = dict()
  try:
    cluster_tuple = utils.parse_cluster_role_env(cluster_role_env, config_path)
    new_cl_args['cluster'] = cluster_tuple[0]
    new_cl_args['role'] = cluster_tuple[1]
    new_cl_args['environ'] = cluster_tuple[2]
    new_cl_args['config_path'] = config_path
  except Exception as e:
    Log.error("Unable to get valid topology location: %s" % str(e))
    return dict()

  cl_args.update(new_cl_args)
  return cl_args
开发者ID:TPNguyen,项目名称:heron,代码行数:26,代码来源:main.py

示例4: main

def main():
  '''
  Run the command
  :return:
  '''
  # verify if the environment variables are correctly set
  check_environment()

  # create the argument parser
  parser = create_parser()

  # if no argument is provided, print help and exit
  if len(sys.argv[1:]) == 0:
    parser.print_help()
    return 0

  # insert the boolean values for some of the options
  sys.argv = parse.insert_bool_values(sys.argv)

  # parse the args
  args, unknown_args = parser.parse_known_args()
  command_line_args = vars(args)

  try:
    if command_line_args['verbose']:
      opts.set_verbose()
    if command_line_args['trace_execution']:
      opts.set_trace_execution()
  except:
    pass

  # command to be execute
  command = command_line_args['subcommand']

  # file resources to be cleaned when exit
  files = []

  if command != 'help' and command != 'version':
    command_line_args = extract_common_args(command, parser, command_line_args)
    # bail out if args are empty
    if not command_line_args:
      return 1
    # register dirs cleanup function during exit
    files.append(command_line_args['override_config_file'])

  atexit.register(cleanup, files)

  # print the input parameters, if verbose is enabled
  if opts.verbose():
    print command_line_args

  start = time.time()
  retcode = run(command, parser, command_line_args, unknown_args)
  end = time.time()

  if command != 'help':
    sys.stdout.flush()
    Log.info('Elapsed time: %.3fs.' % (end - start))

  return 0 if retcode else 1
开发者ID:TPNguyen,项目名称:heron,代码行数:60,代码来源:main.py

示例5: run_metrics

def run_metrics(command, parser, cl_args, unknown_args):
  cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ']
  topology = cl_args['topology-name']
  try:
    result = utils.get_topology_info(cluster, env, topology, role)
    spouts = result['physical_plan']['spouts'].keys()
    bolts = result['physical_plan']['bolts'].keys()
    components = spouts + bolts
    cname = cl_args['component']
    if cname:
      if cname in components:
        components = [cname]
      else:
        Log.error('Unknown component: \'%s\'' % cname)
        raise
  except Exception:
    return False
  cresult = []
  for comp in components:
    try:
      metrics = utils.get_component_metrics(comp, cluster, env, topology, role)
      stat, header = to_table(metrics)
      cresult.append((comp, stat, header))
    except:
      return False
  for i, (comp, stat, header) in enumerate(cresult):
    if i != 0:
      print('')
    print('\'%s\' metrics:' % comp)
    print(tabulate(stat, headers=header))
  return True
开发者ID:TPNguyen,项目名称:heron,代码行数:31,代码来源:physicalplan.py

示例6: run_bolts

def run_bolts(command, parser, cl_args, unknown_args):
  cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ']
  topology = cl_args['topology-name']
  try:
    result = utils.get_topology_info(cluster, env, topology, role)
    bolts = result['physical_plan']['bolts'].keys()
    bolt_name = cl_args['bolt']
    if bolt_name:
      if bolt_name in bolts:
        bolts = [bolt_name]
      else:
        Log.error('Unknown bolt: \'%s\'' % bolt_name)
        raise
  except Exception:
    return False
  bolts_result = []
  for bolt in bolts:
    try:
      metrics = utils.get_component_metrics(bolt, cluster, env, topology, role)
      stat, header = to_table(metrics)
      bolts_result.append((bolt, stat, header))
    except Exception:
      return False
  for i, (bolt, stat, header) in enumerate(bolts_result):
    if i != 0:
      print('')
    print('\'%s\' metrics:' % bolt)
    print(tabulate(stat, headers=header))
  return True
开发者ID:TPNguyen,项目名称:heron,代码行数:29,代码来源:physicalplan.py

示例7: get_topology_info

def get_topology_info(*args):
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_topology_info(*args))
  except Exception as ex:
    Log.error(str(ex))
    raise
开发者ID:avalond,项目名称:heron,代码行数:7,代码来源:utils.py

示例8: get

  def get(self):
    """ get method """
    try:
      cluster = self.get_argument_cluster()
      role = self.get_argument_role()
      environ = self.get_argument_environ()
      topology_name = self.get_argument_topology()
      container = self.get_argument(constants.PARAM_CONTAINER)
      path = self.get_argument(constants.PARAM_PATH)
      offset = self.get_argument_offset()
      length = self.get_argument_length()
      topology_info = self.tracker.getTopologyInfo(topology_name, cluster, role, environ)

      stmgr_id = "stmgr-" + container
      stmgr = topology_info["physical_plan"]["stmgrs"][stmgr_id]
      host = stmgr["host"]
      shell_port = stmgr["shell_port"]
      file_data_url = "http://%s:%d/filedata/%s?offset=%s&length=%s" % \
        (host, shell_port, path, offset, length)

      http_client = tornado.httpclient.AsyncHTTPClient()
      response = yield http_client.fetch(file_data_url)
      self.write_success_response(json.loads(response.body))
      self.finish()
    except Exception as e:
      Log.debug(traceback.format_exc())
      self.write_error_response(e)
开发者ID:asawq2006,项目名称:heron,代码行数:27,代码来源:containerfilehandler.py

示例9: get_logical_plan

def get_logical_plan(cluster, env, topology, role):
  """Synced API call to get logical plans"""
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_logical_plan(cluster, env, topology, role))
  except Exception:
    Log.info(traceback.format_exc())
    raise
开发者ID:asawq2006,项目名称:heron,代码行数:8,代码来源:tracker_access.py

示例10: get_cluster_topologies

def get_cluster_topologies(cluster):
  """Synced API call to get topologies under a cluster"""
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_cluster_topologies(cluster))
  except Exception:
    Log.info(traceback.format_exc())
    raise
开发者ID:asawq2006,项目名称:heron,代码行数:8,代码来源:tracker_access.py

示例11: get_topology_metrics

def get_topology_metrics(*args):
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_comp_metrics(*args))
  except Exception as ex:
    Log.error(str(ex))
    Log.error("Failed to retrive metrics of component \'%s\'" % args[3])
    raise
开发者ID:avalond,项目名称:heron,代码行数:8,代码来源:utils.py

示例12: get_cluster_topologies

def get_cluster_topologies(cluster):
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_cluster_topologies(cluster))
  except Exception as ex:
    Log.error(str(ex))
    Log.error('Failed to retrive topologies running in cluster \'%s\'' % cluster)
    raise
开发者ID:avalond,项目名称:heron,代码行数:8,代码来源:utils.py

示例13: get_topology_metrics

def get_topology_metrics(*args):
  """Synced API call to get topology metrics"""
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_comp_metrics(*args))
  except Exception:
    Log.info(traceback.format_exc())
    raise
开发者ID:asawq2006,项目名称:heron,代码行数:8,代码来源:tracker_access.py

示例14: unregister_watch

 def unregister_watch(self, uid):
   """
   Unregister the watch with the given UUID.
   """
   # Do not raise an error if UUID is
   # not present in the watches.
   Log.info("Unregister a watch with uid: " + str(uid))
   self.watches.pop(uid, None)
开发者ID:asawq2006,项目名称:heron,代码行数:8,代码来源:topology.py

示例15: get_cluster_role_env_topologies

def get_cluster_role_env_topologies(cluster, role, env):
  """Synced API call to get topologies under a cluster submitted by a role under env"""
  instance = tornado.ioloop.IOLoop.instance()
  try:
    return instance.run_sync(lambda: API.get_cluster_role_env_topologies(cluster, role, env))
  except Exception:
    Log.info(traceback.format_exc())
    raise
开发者ID:asawq2006,项目名称:heron,代码行数:8,代码来源:tracker_access.py


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