本文整理汇总了Python中tcf.protocol.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: doneGetContext
def doneGetContext(self, token, error, ctx):
pending.remove(token)
if error:
protocol.log("Error from Registers.getContext", error)
else:
print ctx
if ctx.isReadable() and not ctx.isReadOnce() and ctx.getSize() >= 2:
locs = []
locs.append(registers.Location(ctx.getID(), 0, 1))
locs.append(registers.Location(ctx.getID(), 1, 1))
class DoneGetM(registers.DoneGet):
def doneGet(self, token, error, value):
pending.remove(token)
if error:
protocol.log("Error from Registers.getm", error)
else:
print "getm", ctx.getID(), map(ord, value)
if not pending:
onDone()
pending.append(regs.getm(locs, DoneGetM()))
if ctx.isWriteable() and not ctx.isWriteOnce() and ctx.getSize() >= 2:
locs = []
locs.append(registers.Location(ctx.getID(), 0, 1))
locs.append(registers.Location(ctx.getID(), 1, 1))
class DoneSetM(registers.DoneSet):
def doneGet(self, token, error):
pending.remove(token)
if error:
protocol.log("Error from Registers.setm", error)
if not pending:
onDone()
pending.append(regs.setm(locs, (255, 255), DoneSetM()))
if not pending:
onDone()
开发者ID:eswartz,项目名称:emul,代码行数:34,代码来源:BasicTests.py
示例2: doneGet
def doneGet(self, token, error, mmap):
if error:
protocol.log("Error from PathMap.get", error)
else:
print mmap
with lock:
lock.notify()
开发者ID:deviprasad742,项目名称:tcf,代码行数:7,代码来源:BasicTests.py
示例3: __init__
def __init__(self, service, name, data):
self.service = service
self.name = name
try:
self.args = channel.fromJSONSequence(data)
except Exception as x:
protocol.log("Error decoding event data", x)
开发者ID:eswartz,项目名称:emul,代码行数:7,代码来源:event.py
示例4: doneGetContext
def doneGetContext(self, token, error, context):
pending.remove(token)
if error:
protocol.log("Error from RunControl.getContext", error)
else:
print context
class DoneGetState(runcontrol.DoneGetState):
def doneGetState(self, token, error, suspended, pc, reason,
params):
pending.remove(token)
if error:
protocol.log(
"Error from RunControl.getState", error)
else:
print "suspended: ", suspended
print "pc: ", pc
print "reason: ", reason
print "params: ", params
if suspended:
_suspended.append(context.getID())
if len(pending) == 0:
with lock:
lock.notify()
if context and context.hasState():
pending.append(context.getState(DoneGetState()))
if len(pending) == 0:
with lock:
lock.notify()
开发者ID:deviprasad742,项目名称:tcf,代码行数:30,代码来源:BasicTests.py
示例5: doneGetChildren
def doneGetChildren(self, token, error, context_ids):
if error:
protocol.log("Error from Processes.GetChildren", error)
else:
print "Processes:", context_ids
with lock:
lock.notify()
开发者ID:deviprasad742,项目名称:tcf,代码行数:7,代码来源:BasicTests.py
示例6: _log
def _log(self, msg, x):
if not self._alive: return
# Don't report same error multiple times to avoid filling up the log file.
with self._error_log_lock:
if msg in self.error_log: return
self.error_log.add(msg)
protocol.log(msg, x)
开发者ID:eswartz,项目名称:emul,代码行数:7,代码来源:LocatorService.py
示例7: doneCommand
def doneCommand(self, token, error):
if error:
protocol.log("Error from RunControl.resume", error)
else:
context.suspend(runcontrol.DoneCommand())
with lock:
lock.notify()
开发者ID:deviprasad742,项目名称:tcf,代码行数:7,代码来源:BasicTests.py
示例8: doneGet
def doneGet(self, token, error, value):
pending.remove(token)
if error:
protocol.log("Error from Registers.getm", error)
else:
print "getm", ctx.getID(), map(ord, value)
if not pending:
onDone()
开发者ID:eswartz,项目名称:emul,代码行数:8,代码来源:BasicTests.py
示例9: __traceMessageReceived
def __traceMessageReceived(self, m):
for l in self.trace_listeners:
try:
id = None
if m.token is not None:
id = m.token.getID()
l.onMessageReceived(m.type, id, m.service, m.name, m.data)
except Exception as x:
protocol.log("Exception in channel listener", x)
开发者ID:eswartz,项目名称:emul,代码行数:9,代码来源:AbstractChannel.py
示例10: doneCommand
def doneCommand(self, token, error):
"""Called when run control command execution is complete.
:param token: pending command handle.
:param error: command execution error or **None**.
"""
if error:
protocol.log("Error from RunContext.resume", error)
with condition:
condition.notify()
开发者ID:ppalaga,项目名称:tcf,代码行数:10,代码来源:ProcessStart.py
示例11: doneGetChildren
def doneGetChildren(self, token, error, context_ids):
pending.remove(token)
if error:
protocol.log("Error from RunControl.GetChildren", error)
else:
for c in context_ids:
contexts.append(c)
pending.append(rc.getChildren(c, self))
if len(pending) == 0:
cache.set(None, None, contexts)
开发者ID:eswartz,项目名称:emul,代码行数:10,代码来源:BasicTests.py
示例12: trace
def trace(msg):
"""
Trace hooks should use this method to log a message. It prepends the
message with a timestamp and sends it to the TCF logger facility. The
logger implementation may or may not inject its own timestamp. For
tracing, we definitely need one, so we introduce a minimal, relative-time
stamp.
@param msg the trace message
"""
protocol.log('%s %s' % (getDebugTime(), msg))
开发者ID:wind-river-cdt,项目名称:tcf,代码行数:11,代码来源:logging.py
示例13: doneSubscribe
def doneSubscribe(self, token, error):
"""Called when stream subscription is done.
:param token: pending command handle
:param error: error description if operation failed, **None**
if succeeded.
"""
if error:
protocol.log("Error from streams.subscribe()", error)
with condition:
condition.notify()
开发者ID:ppalaga,项目名称:tcf,代码行数:11,代码来源:ProcessStart.py
示例14: sendPeerRemovedEvent
def sendPeerRemovedEvent(self):
for l in protocol.getLocator().getListeners():
try:
l.peerRemoved(self.rw_attrs.get(ATTR_ID))
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs.get(ATTR_ID)]
protocol.sendEvent(locator.NAME, "peerRemoved", json.dumps(args))
except IOError as x:
protocol.log("Locator: failed to send 'peerRemoved' event", x)
开发者ID:eswartz,项目名称:emul,代码行数:11,代码来源:peer.py
示例15: doneGet
def doneGet(self, token, error, value):
pending.remove(token)
if error:
protocol.log(
"Error from Registers.getm",
error)
else:
print("getm " + str(ctx.getID()) +
" " +
str(list(map(int, value))))
if not pending:
onDone()
开发者ID:eclipse,项目名称:tcf,代码行数:12,代码来源:BasicTests.py
示例16: sendPeerAddedEvent
def sendPeerAddedEvent(self):
for l in protocol.getLocator().getListeners():
try:
l.peerAdded(self)
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs]
protocol.sendEvent(locator.NAME, "peerAdded", json.dumps(args))
except IOError as x:
protocol.log("Locator: failed to send 'peerAdded' event", x)
self.last_heart_beat_time = int(time.time() * 1000)
开发者ID:eswartz,项目名称:emul,代码行数:12,代码来源:peer.py
示例17: event
def event(self, name, data):
try:
args = channel.fromJSONSequence(data)
if name == "peerAdded":
assert len(args) == 1
_peer = Peer(self.channel.getRemotePeer(), args[0])
if self.proxy.peers.get(_peer.getID()):
protocol.log("Invalid peerAdded event", Exception())
return
self.proxy.peers[_peer.getID()] = _peer
for l in self.proxy.listeners:
try:
l.peerAdded(_peer)
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
elif name == "peerChanged":
assert len(args) == 1
m = args[0]
if not m: raise Exception("Locator service: invalid peerChanged event - no peer ID")
_peer = self.proxy.peers.get(m.get(peer.ATTR_ID))
if not _peer: return
self.proxy.peers[_peer.getID()] = _peer
for l in self.proxy.listeners:
try:
l.peerChanged(_peer)
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
elif name == "peerRemoved":
assert len(args) == 1
id = args[0]
_peer = self.proxy.peers.get(id)
if not _peer: return
del self.proxy.peers[id]
for l in self.proxy.listeners:
try:
l.peerRemoved(id)
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
elif name == "peerHeartBeat":
assert len(args) == 1
id = args[0]
_peer = self.proxy.peers.get(id)
if not _peer: return
for l in self.proxy.listeners:
try:
l.peerHeartBeat(id)
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
else:
raise IOError("Locator service: unknown event: " + name)
except Exception as x:
self.channel.terminate(x)
开发者ID:wind-river-cdt,项目名称:tcf,代码行数:52,代码来源:LocatorProxy.py
示例18: _close
def _close(self, error):
assert self.state != STATE_CLOSED
self.state = STATE_CLOSED
# Closing channel underlying streams can block for a long time,
# so it needs to be done by a background thread.
thread = threading.Thread(target=self.stop, name="TCF Channel Cleanup")
thread.daemon = True
thread.start()
if error and isinstance(self.remote_peer, peer.AbstractPeer):
self.remote_peer.onChannelTerminated()
if self.registered_with_trasport:
self.registered_with_trasport = False
transport.channelClosed(self, error)
if self.proxy:
try:
self.proxy.onChannelClosed(error)
except Exception as x:
protocol.log("Exception in channel listener", x)
channel = self
class Runnable(object):
def __call__(self):
if channel.out_tokens:
x = None
if isinstance(error, Exception): x = error
elif error: x = Exception(error)
else: x = IOError("Channel is closed")
for msg in channel.out_tokens.values():
try:
s = str(msg)
if len(s) > 72: s = s[:72] + "...]"
y = IOError("Command " + s + " aborted")
# y.initCause(x)
msg.token.getListener().terminated(msg.token, y)
except Exception as e:
protocol.log("Exception in command listener", e)
channel.out_tokens.clear()
if channel.channel_listeners:
for l in channel.channel_listeners:
if not l: break
try:
l.onChannelClosed(error)
except Exception as x:
protocol.log("Exception in channel listener", x)
elif error:
protocol.log("TCF channel terminated", error)
if channel.trace_listeners:
for l in channel.trace_listeners:
try:
l.onChannelClosed(error)
except Exception as x:
protocol.log("Exception in channel listener", x)
protocol.invokeLater(Runnable())
开发者ID:eswartz,项目名称:emul,代码行数:52,代码来源:AbstractChannel.py
示例19: onChannelOpened
def onChannelOpened(channel, service_names, services_by_name):
with _lock:
for name in service_names:
for provider in _providers:
try:
service = provider.getServiceProxy(channel, name)
if not service: continue
services_by_name[name] = service
break
except Exception as x:
protocol.log("Error calling TCF service provider", x)
if name in services_by_name: continue
services_by_name[name] = GenericProxy(channel, name)
开发者ID:wind-river-cdt,项目名称:tcf,代码行数:13,代码来源:__init__.py
示例20: doneList
def doneList(self, token, error, ctx_ids):
if error:
protocol.log("Error from Symbols.list", error)
return
class DoneGetContext(symbols.DoneGetContext):
def doneGetContext(self, token, error, ctx):
if error:
protocol.log("Error from Symbols.getContext", error)
return
print ctx
if ctx_ids:
for ctx_id in ctx_ids:
syms.getContext(ctx_id, DoneGetContext())
开发者ID:eswartz,项目名称:emul,代码行数:13,代码来源:BasicTests.py
注:本文中的tcf.protocol.log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论