mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
merging fix for #124
This commit is contained in:
commit
78757d3c8d
|
@ -391,23 +391,20 @@ bacpypes_debugging(decode_file)
|
||||||
|
|
||||||
class Tracer(DebugContents):
|
class Tracer(DebugContents):
|
||||||
|
|
||||||
def __init__(self, initialState=None):
|
def __init__(self, initial_state=None):
|
||||||
if _debug: Tracer._debug("__init__ initialState=%r", initialState)
|
if _debug: Tracer._debug("__init__ initial_state=%r", initial_state)
|
||||||
|
|
||||||
# set the current state to the initial state
|
# set the current state to the initial state
|
||||||
self.Next(initialState or self.Start)
|
self.next(initial_state or self.start)
|
||||||
|
|
||||||
def Next(self, fn):
|
def next(self, fn):
|
||||||
if _debug: Tracer._debug("Next %r", fn)
|
if _debug: Tracer._debug("next %r", fn)
|
||||||
|
|
||||||
# a little error checking
|
|
||||||
if fn: assert fn.im_self is self
|
|
||||||
|
|
||||||
# set the state
|
# set the state
|
||||||
self.currentState = fn
|
self.current_state = fn
|
||||||
|
|
||||||
def Start(self, pkt):
|
def start(self, pkt):
|
||||||
if _debug: Tracer._debug("Start %r", pkt)
|
if _debug: Tracer._debug("start %r", pkt)
|
||||||
|
|
||||||
bacpypes_debugging(Tracer)
|
bacpypes_debugging(Tracer)
|
||||||
|
|
||||||
|
@ -419,17 +416,17 @@ def trace(fname, tracers):
|
||||||
if _debug: trace._debug("trace %r %r", fname, tracers)
|
if _debug: trace._debug("trace %r %r", fname, tracers)
|
||||||
|
|
||||||
# make a list of tracers
|
# make a list of tracers
|
||||||
currentTracers = [traceClass() for traceClass in tracers]
|
current_tracers = [traceClass() for traceClass in tracers]
|
||||||
|
|
||||||
# decode the file
|
# decode the file
|
||||||
for pkt in decode_file(fname):
|
for pkt in decode_file(fname):
|
||||||
for i, tracer in enumerate(currentTracers):
|
for i, tracer in enumerate(current_tracers):
|
||||||
# give the packet to the tracer
|
# give the packet to the tracer
|
||||||
tracer.currentState(pkt)
|
tracer.current_state(pkt)
|
||||||
|
|
||||||
# if there is no current state, make a new one
|
# if there is no current state, make a new one
|
||||||
if not tracer.currentState:
|
if not tracer.current_state:
|
||||||
currentTracers[i] = tracers[i]()
|
current_tracers[i] = tracers[i]()
|
||||||
|
|
||||||
bacpypes_debugging(trace)
|
bacpypes_debugging(trace)
|
||||||
|
|
||||||
|
@ -439,7 +436,7 @@ bacpypes_debugging(trace)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
from consolelogging import ConsoleLogHandler
|
from bacpypes.consolelogging import ConsoleLogHandler
|
||||||
|
|
||||||
if ('--debug' in sys.argv):
|
if ('--debug' in sys.argv):
|
||||||
indx = sys.argv.index('--debug')
|
indx = sys.argv.index('--debug')
|
||||||
|
@ -460,4 +457,3 @@ if __name__ == "__main__":
|
||||||
_log.exception("an error has occurred: %s", err)
|
_log.exception("an error has occurred: %s", err)
|
||||||
finally:
|
finally:
|
||||||
_log.debug("finally")
|
_log.debug("finally")
|
||||||
|
|
||||||
|
|
|
@ -386,23 +386,20 @@ def decode_file(fname):
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
class Tracer(DebugContents):
|
class Tracer(DebugContents):
|
||||||
|
|
||||||
def __init__(self, initialState=None):
|
def __init__(self, initial_state=None):
|
||||||
if _debug: Tracer._debug("__init__ initialState=%r", initialState)
|
if _debug: Tracer._debug("__init__ initial_state=%r", initial_state)
|
||||||
|
|
||||||
# set the current state to the initial state
|
# set the current state to the initial state
|
||||||
self.Next(initialState or self.Start)
|
self.next(initial_state or self.start)
|
||||||
|
|
||||||
def Next(self, fn):
|
def next(self, fn):
|
||||||
if _debug: Tracer._debug("Next %r", fn)
|
if _debug: Tracer._debug("next %r", fn)
|
||||||
|
|
||||||
# a little error checking
|
|
||||||
if fn: assert fn.im_self is self
|
|
||||||
|
|
||||||
# set the state
|
# set the state
|
||||||
self.currentState = fn
|
self.current_state = fn
|
||||||
|
|
||||||
def Start(self, pkt):
|
def start(self, pkt):
|
||||||
if _debug: Tracer._debug("Start %r", pkt)
|
if _debug: Tracer._debug("start %r", pkt)
|
||||||
|
|
||||||
#
|
#
|
||||||
# trace
|
# trace
|
||||||
|
@ -413,17 +410,17 @@ def trace(fname, tracers):
|
||||||
if _debug: trace._debug("trace %r %r", fname, tracers)
|
if _debug: trace._debug("trace %r %r", fname, tracers)
|
||||||
|
|
||||||
# make a list of tracers
|
# make a list of tracers
|
||||||
currentTracers = [traceClass() for traceClass in tracers]
|
current_tracers = [traceClass() for traceClass in tracers]
|
||||||
|
|
||||||
# decode the file
|
# decode the file
|
||||||
for pkt in decode_file(fname):
|
for pkt in decode_file(fname):
|
||||||
for i, tracer in enumerate(currentTracers):
|
for i, tracer in enumerate(current_tracers):
|
||||||
# give the packet to the tracer
|
# give the packet to the tracer
|
||||||
tracer.currentState(pkt)
|
tracer.current_state(pkt)
|
||||||
|
|
||||||
# if there is no current state, make a new one
|
# if there is no current state, make a new one
|
||||||
if not tracer.currentState:
|
if not tracer.current_state:
|
||||||
currentTracers[i] = tracers[i]()
|
current_tracers[i] = tracers[i]()
|
||||||
|
|
||||||
#
|
#
|
||||||
# __main__
|
# __main__
|
||||||
|
@ -431,7 +428,7 @@ def trace(fname, tracers):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
from consolelogging import ConsoleLogHandler
|
from bacpypes.consolelogging import ConsoleLogHandler
|
||||||
|
|
||||||
if ('--debug' in sys.argv):
|
if ('--debug' in sys.argv):
|
||||||
indx = sys.argv.index('--debug')
|
indx = sys.argv.index('--debug')
|
||||||
|
@ -452,4 +449,3 @@ if __name__ == "__main__":
|
||||||
_log.exception("an error has occurred: %s", err)
|
_log.exception("an error has occurred: %s", err)
|
||||||
finally:
|
finally:
|
||||||
_log.debug("finally")
|
_log.debug("finally")
|
||||||
|
|
||||||
|
|
|
@ -386,23 +386,20 @@ def decode_file(fname):
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
class Tracer(DebugContents):
|
class Tracer(DebugContents):
|
||||||
|
|
||||||
def __init__(self, initialState=None):
|
def __init__(self, initial_state=None):
|
||||||
if _debug: Tracer._debug("__init__ initialState=%r", initialState)
|
if _debug: Tracer._debug("__init__ initial_state=%r", initial_state)
|
||||||
|
|
||||||
# set the current state to the initial state
|
# set the current state to the initial state
|
||||||
self.Next(initialState or self.Start)
|
self.next(initial_state or self.start)
|
||||||
|
|
||||||
def Next(self, fn):
|
def next(self, fn):
|
||||||
if _debug: Tracer._debug("Next %r", fn)
|
if _debug: Tracer._debug("next %r", fn)
|
||||||
|
|
||||||
# a little error checking
|
|
||||||
if fn: assert fn.im_self is self
|
|
||||||
|
|
||||||
# set the state
|
# set the state
|
||||||
self.currentState = fn
|
self.current_state = fn
|
||||||
|
|
||||||
def Start(self, pkt):
|
def start(self, pkt):
|
||||||
if _debug: Tracer._debug("Start %r", pkt)
|
if _debug: Tracer._debug("start %r", pkt)
|
||||||
|
|
||||||
#
|
#
|
||||||
# trace
|
# trace
|
||||||
|
@ -413,17 +410,17 @@ def trace(fname, tracers):
|
||||||
if _debug: trace._debug("trace %r %r", fname, tracers)
|
if _debug: trace._debug("trace %r %r", fname, tracers)
|
||||||
|
|
||||||
# make a list of tracers
|
# make a list of tracers
|
||||||
currentTracers = [traceClass() for traceClass in tracers]
|
current_tracers = [traceClass() for traceClass in tracers]
|
||||||
|
|
||||||
# decode the file
|
# decode the file
|
||||||
for pkt in decode_file(fname):
|
for pkt in decode_file(fname):
|
||||||
for i, tracer in enumerate(currentTracers):
|
for i, tracer in enumerate(current_tracers):
|
||||||
# give the packet to the tracer
|
# give the packet to the tracer
|
||||||
tracer.currentState(pkt)
|
tracer.current_state(pkt)
|
||||||
|
|
||||||
# if there is no current state, make a new one
|
# if there is no current state, make a new one
|
||||||
if not tracer.currentState:
|
if not tracer.current_state:
|
||||||
currentTracers[i] = tracers[i]()
|
current_tracers[i] = tracers[i]()
|
||||||
|
|
||||||
#
|
#
|
||||||
# __main__
|
# __main__
|
||||||
|
@ -431,7 +428,7 @@ def trace(fname, tracers):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
from consolelogging import ConsoleLogHandler
|
from bacpypes.consolelogging import ConsoleLogHandler
|
||||||
|
|
||||||
if ('--debug' in sys.argv):
|
if ('--debug' in sys.argv):
|
||||||
indx = sys.argv.index('--debug')
|
indx = sys.argv.index('--debug')
|
||||||
|
@ -452,4 +449,3 @@ if __name__ == "__main__":
|
||||||
_log.exception("an error has occurred: %s", err)
|
_log.exception("an error has occurred: %s", err)
|
||||||
finally:
|
finally:
|
||||||
_log.debug("finally")
|
_log.debug("finally")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user