本文整理汇总了Python中heron.common.src.python.color.Log.error方法的典型用法代码示例。如果您正苦于以下问题:Python Log.error方法的具体用法?Python Log.error怎么用?Python Log.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类heron.common.src.python.color.Log
的用法示例。
在下文中一共展示了Log.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submit_fatjar
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例2: extract_common_args
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例3: get_topology_info
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例4: run_metrics
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例5: extract_common_args
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例6: run_bolts
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例7: launch_topologies
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def launch_topologies(cl_args, topology_file, tmp_dir):
# the submitter would have written the .defn file to the tmp_dir
defn_files = glob.glob(tmp_dir + '/*.defn')
if len(defn_files) == 0:
raise Exception("No topologies found")
try:
for defn_file in defn_files:
# load the topology definition from the file
topology_defn = topology_pb2.Topology()
try:
f = open(defn_file, "rb")
topology_defn.ParseFromString(f.read())
f.close()
except:
raise Exception("Could not open and parse topology defn file %s" % defn_file)
# launch the topology
try:
Log.info("Launching topology \'%s\'" % topology_defn.name)
launch_a_topology(cl_args, tmp_dir, topology_file, defn_file)
Log.info("Topology \'%s\' launched successfully" % topology_defn.name)
except Exception as ex:
Log.error('Failed to launch topology \'%s\' because %s' % (topology_defn.name, str(ex)))
raise
except:
raise
示例8: register_watch
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def register_watch(self, callback):
"""
Returns the UUID with which the watch is
registered. This UUID can be used to unregister
the watch.
Returns None if watch could not be registered.
The argument 'callback' must be a function that takes
exactly one argument, the topology on which
the watch was triggered.
Note that the watch will be unregistered in case
it raises any Exception the first time.
This callback is also called at the time
of registration.
"""
RETRY_COUNT = 5
# Retry in case UID is previously
# generated, just in case...
for _ in range(RETRY_COUNT):
# Generate a random UUID.
uid = uuid.uuid4()
if uid not in self.watches:
Log.info("Registering a watch with uid: " + str(uid))
try:
callback(self)
except Exception as e:
Log.error("Caught exception while triggering callback: " + str(e))
Log.debug(traceback.format_exc())
return None
self.watches[uid] = callback
return uid
return None
示例9: get_clusters
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def get_clusters():
instance = tornado.ioloop.IOLoop.instance()
try:
return instance.run_sync(lambda: API.get_clusters())
except Exception as ex:
Log.error('Error: %s' % str(ex))
Log.error('Failed to retrive clusters')
raise
示例10: get_topology_metrics
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例11: get_cluster_topologies
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
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
示例12: get_cluster_role_env_topologies
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def get_cluster_role_env_topologies(cluster, role, env):
instance = tornado.ioloop.IOLoop.instance()
try:
return instance.run_sync(lambda: API.get_cluster_role_env_topologies(cluster, role, env))
except Exception as ex:
Log.error(str(ex))
Log.error('Failed to retrive topologies running in cluster'
'\'%s\' submitted by %s under environment %s' % (cluster, role, env))
raise
示例13: get_logical_plan
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def get_logical_plan(cluster, env, topology, role):
instance = tornado.ioloop.IOLoop.instance()
try:
return instance.run_sync(lambda: API.get_logical_plan(cluster, env, topology, role))
except Exception as ex:
Log.error('Error: %s' % str(ex))
Log.error('Failed to retrive logical plan info of topology \'%s\''
% ('/'.join([cluster, role, env, topology])))
raise
示例14: check_release_file_exists
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def check_release_file_exists():
release_file = get_heron_release_file()
# if the file does not exist and is not a file
if not os.path.isfile(release_file):
Log.error("Required file not found: %s" % release_file)
return False
return True
示例15: get_clusters
# 需要导入模块: from heron.common.src.python.color import Log [as 别名]
# 或者: from heron.common.src.python.color.Log import error [as 别名]
def get_clusters():
"""Synced API call to get all cluster names"""
instance = tornado.ioloop.IOLoop.instance()
# pylint: disable=unnecessary-lambda
try:
return instance.run_sync(lambda: API.get_clusters())
except Exception as ex:
Log.error('Error: %s' % str(ex))
Log.error('Failed to retrive clusters')
raise