From cd2246c228a5b5b26c89db7138c9260a339a5e50 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Sat, 30 Apr 2016 17:07:58 -0400 Subject: [PATCH] finish the conversion from py25 to py27 in #75 by using decorators --- samples/COVMixin.py | 5 ++--- samples/ConsoleCmd.py | 3 +-- samples/ReadProperty.py | 4 ++-- samples/ReadPropertyAny.py | 4 ++-- samples/SampleApplication.py | 2 +- samples/SampleConsoleCmd.py | 4 ++-- samples/SubscribeCOV.py | 4 ++-- samples/TCPClient.py | 5 ++--- samples/TCPServer.py | 4 ++-- samples/WhoIsIAm.py | 4 ++-- samples/WhoIsIAmForeign.py | 4 ++-- 11 files changed, 20 insertions(+), 23 deletions(-) diff --git a/samples/COVMixin.py b/samples/COVMixin.py index 99e043c4..d786c12b 100755 --- a/samples/COVMixin.py +++ b/samples/COVMixin.py @@ -51,6 +51,7 @@ # SubscriptionList # +@bacpypes_debugging class SubscriptionList: def __init__(self): @@ -93,7 +94,6 @@ def __iter__(self): for cov in self.cov_subscriptions: yield cov -bacpypes_debugging(SubscriptionList) # # Subscription @@ -881,6 +881,7 @@ class SubscribeCOVApplication(COVApplicationMixin, BIPSimpleApplication): # COVConsoleCmd # +@bacpypes_debugging class COVConsoleCmd(ConsoleCmd): def do_subscribe(self, args): @@ -1091,8 +1092,6 @@ def do_write(self, args): except Exception as err: print("exception: %s" % (err,)) -bacpypes_debugging(COVConsoleCmd) - def main(): global test_application diff --git a/samples/ConsoleCmd.py b/samples/ConsoleCmd.py index 1e04812c..9aed3871 100755 --- a/samples/ConsoleCmd.py +++ b/samples/ConsoleCmd.py @@ -23,6 +23,7 @@ # ConsoleCmdTemplate # +@bacpypes_debugging class ConsoleCmdTemplate(ConsoleCmd): def do_echo(self, args): @@ -32,8 +33,6 @@ def do_echo(self, args): sys.stdout.write(' '.join(args) + '\n') -bacpypes_debugging(ConsoleCmdTemplate) - def main(): global this_console diff --git a/samples/ReadProperty.py b/samples/ReadProperty.py index 6b96404c..a1f3714e 100755 --- a/samples/ReadProperty.py +++ b/samples/ReadProperty.py @@ -36,6 +36,7 @@ # ReadPropertyApplication # +@bacpypes_debugging class ReadPropertyApplication(BIPSimpleApplication): def __init__(self, *args): @@ -86,12 +87,12 @@ def confirmation(self, apdu): value.debug_contents(file=sys.stdout) sys.stdout.flush() -bacpypes_debugging(ReadPropertyApplication) # # ReadPropertyConsoleCmd # +@bacpypes_debugging class ReadPropertyConsoleCmd(ConsoleCmd): def do_read(self, args): @@ -130,7 +131,6 @@ def do_read(self, args): except Exception as error: ReadPropertyConsoleCmd._exception("exception: %r", error) -bacpypes_debugging(ReadPropertyConsoleCmd) # # __main__ diff --git a/samples/ReadPropertyAny.py b/samples/ReadPropertyAny.py index 43776cfb..32e59619 100755 --- a/samples/ReadPropertyAny.py +++ b/samples/ReadPropertyAny.py @@ -36,6 +36,7 @@ # ReadPropertyAnyApplication # +@bacpypes_debugging class ReadPropertyAnyApplication(BIPSimpleApplication): def __init__(self, *args): @@ -88,12 +89,12 @@ def confirmation(self, apdu): sys.stdout.flush() -bacpypes_debugging(ReadPropertyAnyApplication) # # ReadPropertyAnyConsoleCmd # +@bacpypes_debugging class ReadPropertyAnyConsoleCmd(ConsoleCmd): def do_read(self, args): @@ -131,7 +132,6 @@ def do_read(self, args): except Exception as error: ReadPropertyAnyConsoleCmd._exception("exception: %r", error) -bacpypes_debugging(ReadPropertyAnyConsoleCmd) # # __main__ diff --git a/samples/SampleApplication.py b/samples/SampleApplication.py index 574beb9d..50047c82 100755 --- a/samples/SampleApplication.py +++ b/samples/SampleApplication.py @@ -33,6 +33,7 @@ # SampleApplication # +@bacpypes_debugging class SampleApplication(BIPSimpleApplication): def __init__(self, device, address): @@ -55,7 +56,6 @@ def confirmation(self, apdu): if _debug: SampleApplication._debug("confirmation %r", apdu) BIPSimpleApplication.confirmation(self, apdu) -bacpypes_debugging(SampleApplication) # # __main__ diff --git a/samples/SampleConsoleCmd.py b/samples/SampleConsoleCmd.py index 13fa1ec5..dc6ceed5 100755 --- a/samples/SampleConsoleCmd.py +++ b/samples/SampleConsoleCmd.py @@ -29,6 +29,7 @@ # SampleApplication # +@bacpypes_debugging class SampleApplication(BIPSimpleApplication): def __init__(self, device, address): @@ -51,12 +52,12 @@ def confirmation(self, apdu): if _debug: SampleApplication._debug("confirmation %r", apdu) BIPSimpleApplication.confirmation(self, apdu) -bacpypes_debugging(SampleApplication) # # SampleConsoleCmd # +@bacpypes_debugging class SampleConsoleCmd(ConsoleCmd): def do_nothing(self, args): @@ -64,7 +65,6 @@ def do_nothing(self, args): args = args.split() if _debug: SampleConsoleCmd._debug("do_nothing %r", args) -bacpypes_debugging(SampleConsoleCmd) # # __main__ diff --git a/samples/SubscribeCOV.py b/samples/SubscribeCOV.py index fbee8bc4..fde42211 100755 --- a/samples/SubscribeCOV.py +++ b/samples/SubscribeCOV.py @@ -40,6 +40,7 @@ # SubscribeCOVApplication # +@bacpypes_debugging class SubscribeCOVApplication(BIPSimpleApplication): def __init__(self, *args): @@ -95,12 +96,12 @@ def do_ConfirmedCOVNotificationRequest(self, apdu): def do_UnconfirmedCOVNotificationRequest(self, apdu): if _debug: SubscribeCOVApplication._debug("do_UnconfirmedCOVNotificationRequest %r", apdu) -bacpypes_debugging(SubscribeCOVApplication) # # SubscribeCOVConsoleCmd # +@bacpypes_debugging class SubscribeCOVConsoleCmd(ConsoleCmd): def do_subscribe(self, args): @@ -188,7 +189,6 @@ def do_abort(self, args): rsvp = (False, None, args[0]) -bacpypes_debugging(SubscribeCOVConsoleCmd) # # __main__ diff --git a/samples/TCPClient.py b/samples/TCPClient.py index 4a40d75d..f487fbe9 100644 --- a/samples/TCPClient.py +++ b/samples/TCPClient.py @@ -31,6 +31,7 @@ # MiddleMan # +@bacpypes_debugging class MiddleMan(Client, Server): """ An instance of this class sits between the TCPClientDirector and the @@ -57,12 +58,12 @@ def confirmation(self, pdu): # pass it along self.response(pdu) -bacpypes_debugging(MiddleMan) # # MiddleManASE # +@bacpypes_debugging class MiddleManASE(ApplicationServiceElement): def indication(self, addPeer=None, delPeer=None): @@ -84,8 +85,6 @@ def indication(self, addPeer=None, delPeer=None): if _debug: MiddleManASE._debug(" - quitting") stop() -bacpypes_debugging(MiddleManASE) - def main(): """ diff --git a/samples/TCPServer.py b/samples/TCPServer.py index feb49043..2b825be0 100755 --- a/samples/TCPServer.py +++ b/samples/TCPServer.py @@ -32,6 +32,7 @@ # EchoMaster # +@bacpypes_debugging class EchoMaster(Client): def confirmation(self, pdu): @@ -39,12 +40,12 @@ def confirmation(self, pdu): self.request(PDU(pdu.pduData, destination=pdu.pduSource)) -bacpypes_debugging(EchoMaster) # # MiddleManASE # +@bacpypes_debugging class MiddleManASE(ApplicationServiceElement): def indication(self, addPeer=None, delPeer=None): @@ -61,7 +62,6 @@ def indication(self, addPeer=None, delPeer=None): if delPeer: if _debug: MiddleManASE._debug(" - delete peer %s", delPeer) -bacpypes_debugging(MiddleManASE) # # __main__ diff --git a/samples/WhoIsIAm.py b/samples/WhoIsIAm.py index 196a73cf..60a710e3 100755 --- a/samples/WhoIsIAm.py +++ b/samples/WhoIsIAm.py @@ -34,6 +34,7 @@ # WhoIsIAmApplication # +@bacpypes_debugging class WhoIsIAmApplication(BIPSimpleApplication): def __init__(self, *args): @@ -84,12 +85,12 @@ def indication(self, apdu): # forward it along BIPSimpleApplication.indication(self, apdu) -bacpypes_debugging(WhoIsIAmApplication) # # WhoIsIAmConsoleCmd # +@bacpypes_debugging class WhoIsIAmConsoleCmd(ConsoleCmd): def do_whois(self, args): @@ -156,7 +157,6 @@ def do_rtn(self, args): # pass along to the service access point this_application.nsap.add_router_references(adapter, router_address, network_list) -bacpypes_debugging(WhoIsIAmConsoleCmd) # # __main__ diff --git a/samples/WhoIsIAmForeign.py b/samples/WhoIsIAmForeign.py index a2e9f889..d8738af3 100755 --- a/samples/WhoIsIAmForeign.py +++ b/samples/WhoIsIAmForeign.py @@ -34,6 +34,7 @@ # WhoIsIAmApplication # +@bacpypes_debugging class WhoIsIAmApplication(BIPForeignApplication): def __init__(self, *args): @@ -84,12 +85,12 @@ def indication(self, apdu): # forward it along BIPForeignApplication.indication(self, apdu) -bacpypes_debugging(WhoIsIAmApplication) # # WhoIsIAmConsoleCmd # +@bacpypes_debugging class WhoIsIAmConsoleCmd(ConsoleCmd): def do_whois(self, args): @@ -156,7 +157,6 @@ def do_rtn(self, args): # pass along to the service access point this_application.nsap.add_router_references(adapter, router_address, network_list) -bacpypes_debugging(WhoIsIAmConsoleCmd) # # main