def onLogNotification(probeUri, logClass, logInfo): probeUri = str(probeUri) try: # if we receive the notification, that's we subscribe for the probe - normally if not WatchedProbes.has_key(probeUri): return if logClass == "system-sent": label = logInfo["label"] payload = logInfo["payload"] sutAddress = logInfo.get('sut-address', None) # TODO/FIXME: retrieve the tsiPort from the probeUri TestermanTCI.logSystemSent(tsiPort=probeUri, label=label, payload=payload, sutAddress=sutAddress) elif logClass == "system-received": label = logInfo["label"] payload = logInfo["payload"] sutAddress = logInfo.get('sut-address', None) # TODO/FIXME: retrieve the tsiPort from the probeUri TestermanTCI.logSystemReceived(tsiPort=probeUri, label=label, payload=payload, sutAddress=sutAddress) except Exception, e: log("Exception in onLogNotification: %s" % str(e))
def info(self, txt): TestermanTCI.logInternal("SA: %s" % txt) ################################################################################ # The TRI interface - TE Provided ################################################################################ TE_triEnqueueMsg = None
def triSUTactionInformal(message, timeout, tc): _ActionLock.acquire() _ActionEvent.clear() # Send a "signal" to the job subscribers to display a prompt TestermanTCI.logActionRequested(message, timeout, tc) # Wait _ActionEvent.wait(timeout) # Send a "signal clear" to the job subscribers to hide the prompt, if needed TestermanTCI.logActionCleared(reason="n/a", tc=tc) _ActionLock.release()
def triSUTactionInformal(message, timeout, tc): _ActionLock.acquire() _ActionEvent.clear() # Send a "signal" to the job subscribers to display a prompt TestermanTCI.logActionRequested(message, timeout, tc) # Wait _ActionEvent.wait(timeout) # Send a "signal clear" to the job subscribers to hide the prompt, if needed TestermanTCI.logActionCleared(reason = "n/a", tc = tc) _ActionLock.release()
def triSend(componentId, tsiPortId, sutAddress, message): """ @type componentId: string @param componentId: the name of the TC that sends the message (not used yet) @type tsiPortId: string @param tsiPortId: the name of the system port from which we send the message. Must be bound to a test adapter. @type sutAddress: test adapter/probe dependent @param sutAddress: test adapter/probe-dependent (IP address, URL, ...) @type message: test adapter/probe-dependent, but valid "Testerman" message structure @param message: test adapter/probe-dependent message (already encoded through possible codecs) @rtype: integer @returns: TR_Error (1) if the probe resource was unavailable or cannot be found. TR_OK (0) if the resource was correctly acquired. @throws: TestermanException, Exception """ # Look for a test adapter bound to this system port if not ProbeBindings.has_key(tsiPortId): raise TestermanSAException( "Internal error: trying to send a message through unbound test system port %s" % tsiPortId) # Test adapter found. Send the message through it. probe = ProbeBindings[tsiPortId] try: probe.onTriSend(message, sutAddress) except Exception: raise TestermanSAException( "Unable to send message through TSI port '%s': %s " % (tsiPortId, TestermanTCI.getBacktrace())) return TR_OK
def onLogNotification(probeUri, logClass, logInfo): probeUri = str(probeUri) try: # if we receive the notification, that's we subscribe for the probe - normally if not WatchedProbes.has_key(probeUri): return if logClass == "system-sent": label = logInfo["label"] payload = logInfo["payload"] sutAddress = logInfo.get('sut-address', None) # TODO/FIXME: retrieve the tsiPort from the probeUri TestermanTCI.logSystemSent(tsiPort = probeUri, label = label, payload = payload, sutAddress = sutAddress) elif logClass == "system-received": label = logInfo["label"] payload = logInfo["payload"] sutAddress = logInfo.get('sut-address', None) # TODO/FIXME: retrieve the tsiPort from the probeUri TestermanTCI.logSystemReceived(tsiPort = probeUri, label = label, payload = payload, sutAddress = sutAddress) except Exception, e: log("Exception in onLogNotification: %s" % str(e))
def debug(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def error(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def warning(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def logReceivedPayload(self, label, payload, sutAddress=None): TestermanTCI.logSystemReceived(tsiPort=self.getUri(), label=label, payload=payload, sutAddress=sutAddress)
def logSentPayload(self, label, payload, sutAddress=None): TestermanTCI.logSystemSent(tsiPort=self.getUri(), label=label, payload=payload, sutAddress=sutAddress)
def log(msg): TestermanTCI.logInternal("SA: %s" % msg)
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. ## ## # Codec manager - view from the TE ## import CodecManager import TestermanTCI from CodecManager import CodecNotFoundException CodecManager.instance().setLogCallback( lambda x: TestermanTCI.logInternal("CD: %s" % x)) def instance(): return CodecManager.instance() def alias(name, codec, **kwargs): return instance().alias(name, codec, **kwargs) def registerCodecClass(name, class_): return instance().registerCodecClass(name, class_) def encode(name, template):
def logSentPayload(self, label, payload, sutAddress = None): TestermanTCI.logSystemSent(tsiPort = self.getUri(), label = label, payload = payload, sutAddress = sutAddress)
def critical(self, txt): TestermanTCI.logInternal("SA: %s" % txt) def info(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def error(self, txt): TestermanTCI.logInternal("SA: %s" % txt) def debug(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def warning(self, txt): TestermanTCI.logInternal("SA: %s" % txt) def error(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def critical(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def triSend(componentId, tsiPortId, sutAddress, message): """ @type componentId: string @param componentId: the name of the TC that sends the message (not used yet) @type tsiPortId: string @param tsiPortId: the name of the system port from which we send the message. Must be bound to a test adapter. @type sutAddress: test adapter/probe dependent @param sutAddress: test adapter/probe-dependent (IP address, URL, ...) @type message: test adapter/probe-dependent, but valid "Testerman" message structure @param message: test adapter/probe-dependent message (already encoded through possible codecs) @rtype: integer @returns: TR_Error (1) if the probe resource was unavailable or cannot be found. TR_OK (0) if the resource was correctly acquired. @throws: TestermanException, Exception """ # Look for a test adapter bound to this system port if not ProbeBindings.has_key(tsiPortId): raise TestermanSAException("Internal error: trying to send a message through unbound test system port %s" % tsiPortId) # Test adapter found. Send the message through it. probe = ProbeBindings[tsiPortId] try: probe.onTriSend(message, sutAddress) except Exception: raise TestermanSAException("Unable to send message through TSI port '%s': %s " % (tsiPortId, TestermanTCI.getBacktrace())) return TR_OK
def info(self, txt): TestermanTCI.logInternal("SA: %s" % txt)
def logReceivedPayload(self, label, payload, sutAddress = None): TestermanTCI.logSystemReceived(tsiPort = self.getUri(), label = label, payload = payload, sutAddress = sutAddress)
def log(message): TestermanTCI.logInternal("PA: %s" % str(message))
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. ## ## # Codec manager - view from the TE ## import CodecManager import TestermanTCI from CodecManager import CodecNotFoundException CodecManager.instance().setLogCallback(lambda x: TestermanTCI.logInternal("CD: %s" % x)) def instance(): return CodecManager.instance() def alias(name, codec, **kwargs): return instance().alias(name, codec, **kwargs) def registerCodecClass(name, class_): return instance().registerCodecClass(name, class_) def encode(name, template): return instance().encode(name, template) def decode(name, data): return instance().decode(name, data)