本文整理汇总了Python中pyon.util.log.log.exception函数的典型用法代码示例。如果您正苦于以下问题:Python exception函数的具体用法?Python exception怎么用?Python exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exception函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_version_info
def get_version_info():
import pkg_resources
pkg_list = ["coi-services",
"pyon",
"coverage-model",
"ion-functions",
"eeagent",
"epu",
"utilities",
"marine-integrations"]
version = {}
for package in pkg_list:
try:
version["%s-release" % package] = pkg_resources.require(package)[0].version
# @TODO git versions for each?
except pkg_resources.DistributionNotFound:
pass
try:
dir_client = DirectoryServiceProcessClient(process=service_gateway_instance)
sys_attrs = dir_client.lookup("/System")
if sys_attrs and isinstance(sys_attrs, dict):
version.update({k: v for (k, v) in sys_attrs.iteritems() if "version" in k.lower()})
except Exception as ex:
log.exception("Could not determine system directory attributes")
return gateway_json_response(version)
开发者ID:wbollenbacher,项目名称:coi-services,代码行数:31,代码来源:service_gateway_service.py
示例2: outgoing
def outgoing(self, invocation):
payload = invocation.message
# Compliance: Make sure sent message objects support DotDict as arguments.
# Although DotDict is subclass of dict, msgpack does not like it
if isinstance(payload, IonMessageObjectBase):
for k, v in payload.__dict__.iteritems():
if isinstance(v, DotDict):
setattr(payload, k, v.as_dict())
# Msgpack the content to binary str - does nested IonObject encoding
try:
invocation.message = msgpack.packb(payload, default=encode_ion)
except Exception:
log.exception("Illegal type in IonObject attributes: %s", payload)
raise BadRequest("Illegal type in IonObject attributes")
# Make sure no Nones exist in headers - this indicates a problem somewhere up the stack.
# pika will choke hard on them as well, masking the actual problem, so we catch here.
nonelist = [(k, v) for k, v in invocation.headers.iteritems() if v is None]
if nonelist:
raise BadRequest("Invalid headers containing None values: %s" % str(nonelist))
msg_size = len(invocation.message)
if msg_size > self.max_message_size:
raise BadRequest('The message size %s is larger than the max_message_size value of %s' % (
msg_size, self.max_message_size))
return invocation
开发者ID:scionrep,项目名称:scioncc,代码行数:29,代码来源:encode.py
示例3: start_app
def start_app(self, appdef=None, config=None):
"""
@brief Start an app from an app definition.
Note: apps can come in one of 2 variants:
1 processapp: In-line defined process to be started
2 regular app: Full app definition
"""
log.debug("AppManager.start_app(appdef=%s) ..." % appdef)
appdef = DotDict(appdef)
if 'config' in appdef:
app_cfg = appdef.config.copy()
if config:
dict_merge(app_cfg, config, inplace=True)
config = app_cfg
if 'processapp' in appdef:
# Case 1: Appdef contains definition of process to start
name, module, cls = appdef.processapp
try:
pid = self.container.spawn_process(name, module, cls, config)
appdef._pid = pid
self.apps.append(appdef)
except Exception, ex:
log.exception("Appl %s start from processapp failed" % appdef.name)
开发者ID:swarbhanu,项目名称:pyon,代码行数:26,代码来源:apps.py
示例4: build_service_map
def build_service_map(self):
"""
Adds all known service definitions to service registry.
@todo: May be a bit fragile due to using BaseService.__subclasses__
"""
for cls in BaseService.__subclasses__():
assert hasattr(cls, 'name'), 'Service class must define name value. Service class in error: %s' % cls
if cls.name:
self.services_by_name[cls.name] = cls
self.add_servicedef_entry(cls.name, "base", cls)
try:
self.add_servicedef_entry(cls.name, "schema", json.loads(cls.SCHEMA_JSON))
except Exception as ex:
log.exception("Cannot parse service schema " + cls.name)
interfaces = list(implementedBy(cls))
if interfaces:
self.add_servicedef_entry(cls.name, "interface", interfaces[0])
if cls.__name__.startswith("Base"):
try:
client = "%s.%sProcessClient" % (cls.__module__, cls.__name__[4:])
self.add_servicedef_entry(cls.name, "client", named_any(client))
sclient = "%s.%sClient" % (cls.__module__, cls.__name__[4:])
self.add_servicedef_entry(cls.name, "simple_client", named_any(sclient))
except Exception, ex:
log.warning("Cannot find client for service %s" % (cls.name))
开发者ID:edwardhunter,项目名称:scioncc,代码行数:25,代码来源:service.py
示例5: outgoing
def outgoing(self, invocation):
#log.trace("PolicyInterceptor.outgoing: %s", invocation.get_arg_value('process', invocation))
#Check for a field with the ResourceId decorator and if found, then set resource-id
# in the header with that field's value or if the decorator specifies a field within an object,
#then use the object's field value ( ie. _id)
try:
if isinstance(invocation.message, IonObjectBase):
decorator = 'ResourceId'
field = invocation.message.find_field_for_decorator(decorator)
if field is not None and hasattr(invocation.message,field):
deco_value = invocation.message.get_decorator_value(field, decorator)
if deco_value:
#Assume that if there is a value, then it is specifying a field in the object
fld_value = getattr(invocation.message,field)
if getattr(fld_value, deco_value) is not None:
invocation.headers['resource-id'] = getattr(fld_value, deco_value)
else:
if getattr(invocation.message,field) is not None:
invocation.headers['resource-id'] = getattr(invocation.message,field)
except Exception, ex:
log.exception(ex)
开发者ID:caseybryant,项目名称:pyon,代码行数:25,代码来源:policy_interceptor.py
示例6: stop
def stop(self):
log.debug("Container stopping...")
try:
self.app_manager.stop()
except Exception, ex:
log.exception("Container stop(): Error stop AppManager")
开发者ID:wfrench,项目名称:pyon,代码行数:7,代码来源:cc.py
示例7: execute_retrieve
def execute_retrieve(self):
"""
execute_retrieve Executes a retrieval and returns the result
as a value in lieu of publishing it on a stream
"""
try:
coverage = DatasetManagementService._get_coverage(self.dataset_id, mode="r")
if coverage.num_timesteps == 0:
log.info("Reading from an empty coverage")
rdt = RecordDictionaryTool(param_dictionary=coverage.parameter_dictionary)
else:
rdt = self._coverage_to_granule(
coverage=coverage,
start_time=self.start_time,
end_time=self.end_time,
stride_time=self.stride_time,
parameters=self.parameters,
tdoa=self.tdoa,
)
except:
log.exception("Problems reading from the coverage")
raise BadRequest("Problems reading from the coverage")
finally:
coverage.close(timeout=5)
return rdt.to_granule()
开发者ID:pkediyal,项目名称:coi-services,代码行数:25,代码来源:replay_process.py
示例8: get_valid_resource_commitments
def get_valid_resource_commitments(resource_id=None, actor_id=None):
"""
Returns the list of valid commitments for the specified resource.
If optional actor_id is supplied, then filtered by actor_id
"""
log.debug("Finding commitments for resource_id: %s and actor_id: %s", resource_id, actor_id)
if resource_id is None:
return None
try:
gov_controller = bootstrap.container_instance.governance_controller
commitments, _ = gov_controller.rr.find_subjects(RT.Commitment, PRED.hasTarget, resource_id, id_only=False)
if not commitments:
return None
cur_time = get_ion_ts_millis()
commitment_list = [com for com in commitments if (actor_id == None or com.consumer == actor_id) and \
(int(com.expiration) == 0 or (int(com.expiration) > 0 and cur_time < int(com.expiration)))]
if commitment_list:
return commitment_list
except Exception:
log.exception("Could not determine actor resource commitments")
return None
开发者ID:edwardhunter,项目名称:scioncc,代码行数:25,代码来源:__init__.py
示例9: handle_dds
def handle_dds(self, coverage, dataset, fields):
cov = coverage
try:
time_name = coverage.temporal_parameter_name
time_context = coverage.get_parameter_context(time_name)
time_attrs = self.get_attrs(cov, time_name)
time_base = BaseType(time_name, type=self.dap_type(time_context), attributes=time_attrs, dimensions=(time_name,), shape=(coverage.num_timesteps,))
dataset[time_name] = time_base
except:
log.exception('Problem reading cov %s', str(cov))
raise # Can't do much without time
for var in fields:
while var:
name, slice_ = var.pop(0)
name = urllib.unquote(name)
if name == time_name:
continue # Already added to the dataset
try:
grid = GridType(name=name)
context = coverage.get_parameter_context(name)
attrs = self.get_attrs(cov, name)
grid[name] = BaseType(name=name, type=self.dap_type(context), attributes=attrs, dimensions=(time_name,), shape=(coverage.num_timesteps,))
grid[cov.temporal_parameter_name] = time_base
dataset[name] = grid
except Exception:
log.exception('Problem reading cov %s', str(cov))
continue
return dataset
开发者ID:MauriceManning,项目名称:coi-services,代码行数:31,代码来源:coverage_handler.py
示例10: start_app
def start_app(self, appdef=None, config=None):
"""
@brief Start an app from an app definition.
Note: apps can come in one of 2 variants:
1 processapp: In-line defined process to be started
2 regular app: Full app definition
"""
log.debug("AppManager.start_app(appdef=%s) ..." % appdef)
appdef = DotDict(appdef)
app_config = DictModifier(CFG)
if 'config' in appdef:
# Apply config from app file
app_file_cfg = DotDict(appdef.config)
app_config.update(app_file_cfg)
if config:
# Nest dict modifier and apply config from rel file
app_config = DictModifier(app_config, config)
if 'processapp' in appdef:
# Case 1: Appdef contains definition of process to start
name, module, cls = appdef.processapp
try:
pid = self.container.spawn_process(name, module, cls, app_config)
appdef._pid = pid
self.apps.append(appdef)
except Exception, ex:
log.exception("Appl %s start from processapp failed" % appdef.name)
开发者ID:blazetopher,项目名称:pyon,代码行数:30,代码来源:apps.py
示例11: message_received
def message_received(self, msg, headers):
assert self._routing_obj, "How did I get created without a routing object?"
log.debug("RPCResponseEndpointUnit.message_received\n\tmsg: %s\n\theaders: %s", msg, headers)
cmd_arg_obj = msg
cmd_op = headers.get('op', None)
# transform cmd_arg_obj into a dict
if hasattr(cmd_arg_obj, '__dict__'):
cmd_arg_obj = cmd_arg_obj.__dict__
elif isinstance(cmd_arg_obj, dict):
pass
else:
raise BadRequest("Unknown message type, cannot convert into kwarg dict: %s" % str(type(cmd_arg_obj)))
# op name must exist!
if not hasattr(self._routing_obj, cmd_op):
raise BadRequest("Unknown op name: %s" % cmd_op)
ro_meth = getattr(self._routing_obj, cmd_op)
result = None
response_headers = {}
try:
result = ro_meth(**cmd_arg_obj)
response_headers = { 'status_code': 200, 'error_message': '' }
except TypeError as ex:
log.exception("TypeError while attempting to call routing object's method")
response_headers = self._create_error_response(ServerError(ex.message))
return result, response_headers
开发者ID:blazetopher,项目名称:pyon,代码行数:33,代码来源:endpoint.py
示例12: _read_interval_time
def _read_interval_time(self):
"""
Reads the hsflowd conf file to determine what time should be used.
"""
if not (self._hsflowd_addr == "localhost" or self._hsflowd_addr == "127.0.0.1"):
log.debug("Skipping reading hsflow auto file, hsflowd is not running locally")
else:
try:
mtime = os.stat(self._hsflowd_conf).st_mtime
except OSError:
# if you can't stat it, you can't read it most likely
log.info("Could not stat hsflowd.auto file")
return
if mtime != self._conf_last_mod:
self._conf_last_mod = mtime
# appears to be simple key=value, one per line
try:
with open(self._hsflowd_conf) as f:
while True:
c = f.readline()
if c == "":
break
elif c.startswith("polling="):
self._counter_interval = int(c.rstrip().split("=")[1])
log.debug("New polling interval time: %d", self._counter_interval)
break
except IOError:
log.exception("Could not open/read hsflowd.auto")
开发者ID:ooici,项目名称:pyon,代码行数:30,代码来源:sflow.py
示例13: serve_forever
def serve_forever(self):
""" Run the container until killed. """
log.debug("In Container.serve_forever")
if not self.proc_manager.proc_sup.running:
self.start()
# serve forever short-circuits if immediate is on and children len is ok
num_procs = len(self.proc_manager.proc_sup.children)
immediate = CFG.system.get('immediate', False)
if not (immediate and num_procs == 1): # only spawned greenlet is the CC-Agent
# print a warning just in case
if immediate and num_procs != 1:
log.warn("CFG.system.immediate=True but number of spawned processes is not 1 (%d)", num_procs)
try:
# This just waits in this Greenlet for all child processes to complete,
# which is triggered somewhere else.
self.proc_manager.proc_sup.join_children()
except (KeyboardInterrupt, SystemExit) as ex:
log.info('Received a kill signal, shutting down the container.')
if hasattr(self, 'gl_parent_watch') and self.gl_parent_watch is not None:
self.gl_parent_watch.kill()
except:
log.exception('Unhandled error! Forcing container shutdown')
else:
log.debug("Container.serve_forever short-circuiting due to CFG.system.immediate")
self.proc_manager.proc_sup.shutdown(CFG.cc.timeout.shutdown)
开发者ID:pkediyal,项目名称:pyon,代码行数:32,代码来源:cc.py
示例14: listen
def listen(self, binding=None):
log.debug("LEF.listen: binding %s", binding)
binding = binding or self._binding or self.name[1]
self._ensure_node()
self._chan = self.node.channel(self.channel_type)
self._setup_listener(self.name, binding=binding)
self._chan.start_consume()
# notify any listeners of our readiness
self._ready_event.set()
while True:
log.debug("LEF: %s blocking, waiting for a message" % str(self.name))
try:
newchan = self._chan.accept()
msg, headers, delivery_tag = newchan.recv()
log.debug("LEF %s received message %s, headers %s, delivery_tag %s", self.name, msg, headers, delivery_tag)
except ChannelClosedError as ex:
log.debug('Channel was closed during LEF.listen')
break
try:
e = self.create_endpoint(existing_channel=newchan)
e._message_received(msg, headers)
except Exception:
log.exception("Unhandled error while handling received message")
raise
finally:
# ALWAYS ACK
newchan.ack(delivery_tag)
开发者ID:blazetopher,项目名称:pyon,代码行数:34,代码来源:endpoint.py
示例15: stop
def stop(self):
log.info("=============== Container stopping... ===============")
if self.event_pub is not None:
try:
self.event_pub.publish_event(event_type="ContainerLifecycleEvent",
origin=self.id, origin_type="CapabilityContainer",
sub_type="TERMINATE",
state=ContainerStateEnum.TERMINATE)
except Exception as ex:
log.exception(ex)
while self._capabilities:
capability = self._capabilities.pop()
log.debug("stop(): Stopping '%s'" % capability)
try:
self._stop_capability(capability)
except Exception as ex:
log.exception("Container stop(): Error stop %s" % capability)
Container.instance = None
from pyon.core import bootstrap
bootstrap.container_instance = None
self._is_started = False
log.debug("Container stopped, OK.")
开发者ID:pkediyal,项目名称:pyon,代码行数:27,代码来源:cc.py
示例16: _unbind
def _unbind(self, exchange_point, exchange_name, binding_key):
xp = self.container.ex_manager.create_xp(exchange_point)
xn = self.container.ex_manager.create_xn_queue(exchange_name)
try:
xn.unbind(binding_key, xp)
except TransportError:
log.exception('Pubsub could not unbind %s from %s', binding_key, str(xp))
开发者ID:Bobfrat,项目名称:coi-services,代码行数:7,代码来源:pubsub_management_service.py
示例17: publish_heartbeat
def publish_heartbeat(self):
try:
hb_msg = self.get_heartbeat_message()
headers = dict(expiration=60000)
self.heartbeat_pub.publish(hb_msg, headers=headers)
except Exception:
log.exception("Error publishing heatbeat")
开发者ID:scion-network,项目名称:scioncc,代码行数:7,代码来源:cc.py
示例18: _publish_event
def _publish_event(self, event_msg, origin, event_type=None):
event_type = event_type or self.event_type or event_msg._get_type()
assert origin and event_type
topic = self._topic(event_type, origin, base_types=event_msg.base_types,
sub_type=event_msg.sub_type, origin_type=event_msg.origin_type)
to_name = (self._send_name.exchange, topic)
log.debug("Publishing event message to %s", to_name)
try:
ep = self.publish(event_msg, to_name=to_name)
ep.close()
except Exception as ex:
log.exception("Failed to publish event '%s'" % (event_msg))
return False
try:
# store published event but only if we specified an event_repo
if self.event_repo:
self.event_repo.put_event(event_msg)
except Exception as ex:
log.exception("Failed to store published event '%s'" % (event_msg))
return False
return True
开发者ID:oldpatricka,项目名称:pyon,代码行数:25,代码来源:event.py
示例19: serve_forever
def serve_forever(self):
""" Run the container until killed. """
log.debug("In Container.serve_forever")
if not self.proc_manager.proc_sup.running:
self.start()
# Exit if immediate==True and children len is ok
num_procs = len(self.proc_manager.proc_sup.children)
immediate = CFG.system.get('immediate', False)
if immediate and num_procs == 1: # only spawned greenlet is the CC-Agent
log.debug("Container.serve_forever exiting due to CFG.system.immediate")
else:
# print a warning just in case
if immediate and num_procs != 1:
log.warn("CFG.system.immediate=True but number of spawned processes is not 1 (%d)", num_procs)
try:
# This just waits in this Greenlet for all child processes to complete,
# which is triggered somewhere else.
self.proc_manager.proc_sup.join_children()
except (KeyboardInterrupt, SystemExit) as ex:
if hasattr(self, 'gl_parent_watch') and self.gl_parent_watch is not None:
# Remove the greenlet that watches the parent process
self.gl_parent_watch.kill()
# Let the caller handle this
raise
except:
log.exception('Unhandled error! Forcing container shutdown')
开发者ID:scion-network,项目名称:scioncc,代码行数:32,代码来源:cc.py
示例20: stop
def stop(self, do_exit=True):
log.info("=============== Container stopping... ===============")
self._status = TERMINATING
if self.has_capability(CCAP.EVENT_PUBLISHER) and self.event_pub is not None:
try:
self.event_pub.publish_event(event_type="ContainerLifecycleEvent",
origin=self.id, origin_type="CapabilityContainer",
sub_type="TERMINATE",
state=ContainerStateEnum.TERMINATE)
except Exception as ex:
log.exception("Error sending event")
while self._capabilities:
capability = self._capabilities.pop()
#log.debug("stop(): Stopping '%s'" % capability)
try:
cap_obj = self._cap_instances[capability]
cap_obj.stop()
del self._cap_instances[capability]
except Exception as ex:
log.exception("Container stop(): Error stop %s" % capability)
Container.instance = None
from pyon.core import bootstrap
bootstrap.container_instance = None
self._is_started = False
self._status = TERMINATED
log.info("Container stopped (%s).", self.id)
if do_exit:
os.kill(os.getpid(), signal.SIGTERM)
开发者ID:scion-network,项目名称:scioncc,代码行数:35,代码来源:cc.py
注:本文中的pyon.util.log.log.exception函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论