update to match new (private) Automat tracing API

This commit is contained in:
Brian Warner 2017-04-13 16:34:22 -04:00
parent c2a71e7240
commit e6b9cf18be
13 changed files with 31 additions and 31 deletions

View File

@ -10,7 +10,7 @@ from . import _interfaces
class Allocator(object):
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def wire(self, rendezvous_connector, code):
self._RC = _interfaces.IRendezvousConnector(rendezvous_connector)

View File

@ -39,7 +39,7 @@ class Boss(object):
_tor_manager = attrib() # TODO: ITorManager or None
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._build_workers()
@ -92,25 +92,25 @@ class Boss(object):
"RC": self._RC, "L": self._L, "C": self._C,
"T": self._T}
for machine in which.split():
def tracer(old_state, input, new_state, output, machine=machine):
if output is None:
if new_state:
print("%s.%s[%s].%s -> [%s]" %
(client_name, machine, old_state, input,
new_state), file=file)
else:
# the RendezvousConnector emits message events as if
# they were state transitions, except that old_state
# and new_state are empty strings. "input" is one of
# R.connected, R.rx(type phase+side), R.tx(type
# phase), R.lost .
print("%s.%s.%s" % (client_name, machine, input),
file=file)
def tracer(old_state, input, new_state, machine=machine):
if new_state:
print("%s.%s[%s].%s -> [%s]" %
(client_name, machine, old_state, input,
new_state), file=file)
else:
if new_state:
print(" %s.%s.%s()" % (client_name, machine, output),
file=file)
# the RendezvousConnector emits message events as if
# they were state transitions, except that old_state
# and new_state are empty strings. "input" is one of
# R.connected, R.rx(type phase+side), R.tx(type
# phase), R.lost .
print("%s.%s.%s" % (client_name, machine, input),
file=file)
file.flush()
def output_tracer(output):
print(" %s.%s.%s()" % (client_name, machine, output),
file=file)
file.flush()
return output_tracer
names[machine].set_trace(tracer)
## def serialize(self):

View File

@ -13,7 +13,7 @@ def first(outputs):
class Code(object):
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def wire(self, boss, allocator, nameplate, key, input):
self._B = _interfaces.IBoss(boss)

View File

@ -14,7 +14,7 @@ def first(outputs):
class Input(object):
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._all_nameplates = set()

View File

@ -64,7 +64,7 @@ class Key(object):
_side = attrib(validator=instance_of(type(u"")))
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._SK = _SortedKey(self._appid, self._versions, self._side,
@ -115,7 +115,7 @@ class _SortedKey(object):
_side = attrib(validator=instance_of(type(u"")))
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def wire(self, boss, mailbox, receive):
self._B = _interfaces.IBoss(boss)

View File

@ -10,7 +10,7 @@ from . import _interfaces
class Lister(object):
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def wire(self, rendezvous_connector, input):
self._RC = _interfaces.IRendezvousConnector(rendezvous_connector)

View File

@ -10,7 +10,7 @@ from . import _interfaces
class Mailbox(object):
_side = attrib(validator=instance_of(type(u"")))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._mailbox = None

View File

@ -7,7 +7,7 @@ from ._wordlist import PGPWordList
@implementer(_interfaces.INameplate)
class Nameplate(object):
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __init__(self):
self._nameplate = None

View File

@ -11,7 +11,7 @@ class Order(object):
_side = attrib(validator=instance_of(type(u"")))
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._key = None

View File

@ -12,7 +12,7 @@ class Receive(object):
_side = attrib(validator=instance_of(type(u"")))
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._key = None

View File

@ -83,7 +83,7 @@ class RendezvousConnector(object):
self._trace = f
def _debug(self, what):
if self._trace:
self._trace(old_state="", input=what, new_state="", output=None)
self._trace(old_state="", input=what, new_state="")
def _make_endpoint(self, hostname, port):
if self._tor_manager:

View File

@ -12,7 +12,7 @@ class Send(object):
_side = attrib(validator=instance_of(type(u"")))
_timing = attrib(validator=provides(_interfaces.ITiming))
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __attrs_post_init__(self):
self._queue = []

View File

@ -6,7 +6,7 @@ from . import _interfaces
@implementer(_interfaces.ITerminator)
class Terminator(object):
m = MethodicalMachine()
set_trace = getattr(m, "setTrace", lambda self, f: None)
set_trace = getattr(m, "_setTrace", lambda self, f: None)
def __init__(self):
self._mood = None