in tools/scraper/parser.py [0:0]
def extract_facts(self):
perf = self.data.described_type.dtype_number
res = self.data
resdict = self.data.described_type.dict
res.sdorg_str = "HELP I'M A ROCK - Unknown performative: %s" % perf
# the performatives
# Note: res.channel is already populated
if perf == 0x10:
# Performative: open [0] always channel 0
res.name = "open"
res.channel = "0"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
res.sdorg_str = "OPEN"
if res.direction == text.direction_in():
res.conn_peer = self.resdict_value(resdict, "container-id", "unknown")
res.web_show_str += (" (peer: %s)" % res.conn_peer)
res.sdorg_str += (" (peer: %s)" % res.conn_peer)
elif perf == 0x11:
# Performative: begin [channel,remoteChannel]
# TODO: This has a bug where the local and remote channel numbers are confused.
# Usually they are the same. See if anyone notices!
# res.channel
res.name = "begin"
res.remote = self.resdict_value(resdict, "remote-channel", "None)")
res.channel_remote = "[%s,%s]" % (res.channel, res.remote)
res.web_show_str = "<strong>%s</strong> %s" % (res.name, res.channel_remote)
res.sdorg_str = "BEGIN %s" % (res.channel_remote)
elif perf == 0x12:
# Performative: attach [channel,handle] role name (source: src, target: tgt)
res.name = "attach"
res.handle = resdict["handle"]
res.role = "receiver" if resdict["role"] == "true" else "sender"
res.is_receiver = res.role == "receiver"
# translated names handled later
name = self.resdict_value(resdict, "name", "None")
self.shorteners.short_link_names.register(name, self)
tmpsrc = self.resdict_value(resdict, "source", None)
tmptgt = self.resdict_value(resdict, "target", None)
res.snd_settle_mode = self.sender_settle_mode_of(
resdict["snd-settle-mode"]) if "snd-settle-mode" in resdict else "mixed"
res.rcv_settle_mode = self.receiver_settle_mode_of(
resdict["rcv-settle-mode"]) if "rcv-settle-mode" in resdict else "first"
caps = ""
if tmpsrc is not None:
res.source = self.resdict_value(tmpsrc.dict, "address", "none")
caps = self.resdict_value(tmpsrc.dict, "capabilities", "")
else:
res.source = "none"
if tmptgt is not None:
res.target = self.resdict_value(tmptgt.dict, "address", "none")
if caps == "":
caps = self.resdict_value(tmptgt.dict, "capabilities", "")
else:
res.target = "none"
res.channel_handle = "[%s,%s]" % (res.channel, res.handle)
if 'qd.router-data' in caps:
res.link_class = 'router-data'
elif 'qd.router' in caps:
res.link_class = 'router'
"""
TODO:
res.source = short_endp_names.translate(res.source)
res.target = short_endp_names.translate(res.target)
res.snd_settle_mode = extract_name(tmpssm)
res.rcv_settle_mode = extract_name(tmprsm)
"""
# show_str handled in post_extract
elif perf == 0x13:
# Performative: flow [channel,handle]
res.name = "flow"
res.handle = resdict["handle"]
res.flow_deliverycnt = self.resdict_value(resdict, "delivery-count", "0")
res.flow_linkcredit = self.resdict_value(resdict, "link-credit", "0")
res.flow_drain = resdict.get("drain", "") == "true"
res.channel_handle = "[%s,%s]" % (res.channel, res.handle)
res.flow_cnt_credit = "(%s,%s)" % (res.flow_deliverycnt, res.flow_linkcredit)
res.web_show_str = "<strong>%s</strong> %s (%s,%s) %s" % (
res.name, colorize_bg(res.channel_handle), res.flow_deliverycnt, res.flow_linkcredit,
self.highlighted("drain", res.flow_drain, common.color_of("drain")))
res.sdorg_str = "FLOW %s (%s,%s)" % (res.channel_handle, res.flow_deliverycnt, res.flow_linkcredit) # TODO: Add drain
elif perf == 0x14:
# Performative: transfer [channel,handle] (id)
res.name = "transfer"
res.transfer = True
res.handle = resdict["handle"]
res.channel_handle = "[%s,%s]" % (res.channel, res.handle)
res.delivery_id = self.resdict_value(resdict, "delivery-id", "none")
res.delivery_tag = self.resdict_value(resdict, "delivery-tag", "none")
res.settled = self.resdict_value(resdict, "settled", "false")
res.transfer_settled = resdict.get("settled", "") == "true"
res.transfer_more = resdict.get("more", "") == "true"
res.transfer_resume = resdict.get("resume", "") == "true"
res.transfer_aborted = resdict.get("aborted", "") == "true"
# translated names handled in post_extract
self.shorteners.short_data_names.register(res.transfer_bare, self)
elif perf == 0x15:
# Performative: disposition [channel] (role first-last)
res.name = "disposition"
res.role = "receiver" if resdict["role"] == "true" else "sender"
res.is_receiver = res.role == "receiver"
res.first = self.resdict_value(resdict, "first", "0")
res.last = self.resdict_value(resdict, "last", res.first)
res.settled = self.resdict_value(resdict, "settled", "false")
state = resdict.get("state")
if state is not None:
res.disposition_state = state.dtype_name
### colorize_dispositions_not_accepted(proto, res, global_vars, count_anomalies)
res.web_show_str = ("<strong>%s</strong> [%s] (%s %s-%s settled=%s state=%s)" %
(res.name, res.channel, res.role, res.first, res.last, res.settled, res.disposition_state))
res.sdorg_str = ("%s [%s] (%s %s-%s settled=%s state=%s)" %
(res.name, res.channel, res.role, res.first, res.last, res.settled, res.disposition_state))
elif perf == 0x16:
# Performative: detach [channel, handle]
res.name = "detach"
res.handle = resdict["handle"]
### TODO: colorize_performative_error(proto, res, global_vars, count_anomalies)
res.channel_handle = "[%s,%s]" % (res.channel, res.handle)
res.web_show_str = "<strong>%s</strong> %s" % (res.name, colorize_bg(res.channel_handle))
res.sdorg_str = "DETACH %s" % (res.channel_handle)
elif perf == 0x17:
# Performative: end [channel]
res.name = "end"
### TODO: colorize_performative_error(proto, res, global_vars, count_anomalies)
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
res.sdorg_str = "END [%s]" % (res.channel)
elif perf == 0x18:
# Performative: close [0] always channel 0
res.channel = "0"
res.name = "close"
### colorize_performative_error(proto, res, global_vars, count_anomalies)
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
res.sdorg_str = "CLOSE [%s]" % (res.channel)
elif perf == 0x1d:
# transport:definitions error
res.name = "error"
descr = self.resdict_value(resdict, "description", "none")
res.web_show_str = "<strong>%s</strong> [%s] %s" % (res.name, res.channel, descr)
elif perf == 0x23:
# messaging:delivery-state received
res.name = "received"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x24:
# messaging:delivery-state accepted
res.name = "accepted"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x25:
# messaging:delivery-state rejected
res.name = "rejected"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x26:
# messaging:delivery-state released
res.name = "released"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x27:
# messaging:delivery-state modified
res.name = "modified"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x28:
# messaging:addressing source
res.name = "source"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x29:
# messaging:addressing target
res.name = "target"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x2b:
# messaging:addressing delete-on-close
res.name = "delete-on-close"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x2c:
# messaging:addressing delete-on-no-links
res.name = "delete-on-no-links"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x2d:
# messaging:addressing delete-on-no-messages
res.name = "delete-on-no-messages"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x2e:
# messaging:addressing delete-on-no-links-or-messages
res.name = "delete-on-no-links-or-messages"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x30:
# transactions:coordination coordinator
res.name = "coordinator"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x31:
# transactions:coordination declare
res.name = "declare"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x32:
# transactions:coordination discharge
res.name = "discharge"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x33:
# transactions:coordination declared
res.name = "declared"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x34:
# transactions:coordination transactional-state
res.name = "transactional-state"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x40:
# security:sasl sasl-mechanisms
res.name = "sasl-mechanisms"
mechs = self.resdict_value(resdict, "sasl-server-mechanisms", "none")
res.web_show_str = "<strong>%s</strong> [%s] %s" % (res.name, res.channel, mechs)
elif perf == 0x41:
# security:sasl sasl-init
res.name = "sasl-init"
mech = self.resdict_value(resdict, "mechanism", "none")
res.web_show_str = "<strong>%s</strong> [%s] %s" % (res.name, res.channel, mech)
elif perf == 0x42:
# security:sasl sasl-challenge
res.name = "sasl-challenge"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x43:
# security:sasl sasl-response
res.name = "sasl-response"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x44:
# security:sasl sasl-outcome
res.name = "sasl-outcome"
code = self.resdict_value(resdict, "code", "none")
res.web_show_str = "<strong>%s</strong> [%s] code=%s" % (res.name, res.channel, code)
elif perf == 0x70:
# messaging:message-format header
res.name = "header"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x71:
# messaging:message-format delivery-annotations
res.name = "delivery-annotations"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x72:
# messaging:message-format message-annotations
res.name = "message-annotations"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x73:
# messaging:message-format properties
res.name = "properties"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x74:
# messaging:message-format application-properties
res.name = "application-properties"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x75:
# messaging:message-format data
res.name = "data"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x76:
# messaging:message-format amqp-sequence
res.name = "amqp-sequence"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x77:
# messaging:message-format amqp-value
res.name = "amqp-value"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
elif perf == 0x78:
# messaging:message-format footer
res.name = "footer"
res.web_show_str = "<strong>%s</strong> [%s]" % (res.name, res.channel)
else:
res.web_show_str = "HELP I'M A ROCK - Unknown performative: %s" % perf
if "error" in resdict:
res.amqp_error = True
dct = resdict["error"].dict
condi = dct["condition"]
descr = dct["description"] if "description" in dct else ""
res.web_show_str += (" <span style=\"background-color:%s\">error</span> "
"%s %s" % (common.color_of("errors"), condi, descr))