Skip to content

Commit

Permalink
finish the conversion from py25 to py27 in #75 by using decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBender committed Apr 30, 2016
1 parent fc6e1e7 commit cd2246c
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 23 deletions.
5 changes: 2 additions & 3 deletions samples/COVMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
# SubscriptionList
#

@bacpypes_debugging
class SubscriptionList:

def __init__(self):
Expand Down Expand Up @@ -93,7 +94,6 @@ def __iter__(self):
for cov in self.cov_subscriptions:
yield cov

bacpypes_debugging(SubscriptionList)

#
# Subscription
Expand Down Expand Up @@ -881,6 +881,7 @@ class SubscribeCOVApplication(COVApplicationMixin, BIPSimpleApplication):
# COVConsoleCmd
#

@bacpypes_debugging
class COVConsoleCmd(ConsoleCmd):

def do_subscribe(self, args):
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions samples/ConsoleCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# ConsoleCmdTemplate
#

@bacpypes_debugging
class ConsoleCmdTemplate(ConsoleCmd):

def do_echo(self, args):
Expand All @@ -32,8 +33,6 @@ def do_echo(self, args):

sys.stdout.write(' '.join(args) + '\n')

bacpypes_debugging(ConsoleCmdTemplate)


def main():
global this_console
Expand Down
4 changes: 2 additions & 2 deletions samples/ReadProperty.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
# ReadPropertyApplication
#

@bacpypes_debugging
class ReadPropertyApplication(BIPSimpleApplication):

def __init__(self, *args):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -130,7 +131,6 @@ def do_read(self, args):
except Exception as error:
ReadPropertyConsoleCmd._exception("exception: %r", error)

bacpypes_debugging(ReadPropertyConsoleCmd)

#
# __main__
Expand Down
4 changes: 2 additions & 2 deletions samples/ReadPropertyAny.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
# ReadPropertyAnyApplication
#

@bacpypes_debugging
class ReadPropertyAnyApplication(BIPSimpleApplication):

def __init__(self, *args):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -131,7 +132,6 @@ def do_read(self, args):
except Exception as error:
ReadPropertyAnyConsoleCmd._exception("exception: %r", error)

bacpypes_debugging(ReadPropertyAnyConsoleCmd)

#
# __main__
Expand Down
2 changes: 1 addition & 1 deletion samples/SampleApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# SampleApplication
#

@bacpypes_debugging
class SampleApplication(BIPSimpleApplication):

def __init__(self, device, address):
Expand All @@ -55,7 +56,6 @@ def confirmation(self, apdu):
if _debug: SampleApplication._debug("confirmation %r", apdu)
BIPSimpleApplication.confirmation(self, apdu)

bacpypes_debugging(SampleApplication)

#
# __main__
Expand Down
4 changes: 2 additions & 2 deletions samples/SampleConsoleCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# SampleApplication
#

@bacpypes_debugging
class SampleApplication(BIPSimpleApplication):

def __init__(self, device, address):
Expand All @@ -51,20 +52,19 @@ 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):
"""nothing can be done"""
args = args.split()
if _debug: SampleConsoleCmd._debug("do_nothing %r", args)

bacpypes_debugging(SampleConsoleCmd)

#
# __main__
Expand Down
4 changes: 2 additions & 2 deletions samples/SubscribeCOV.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
# SubscribeCOVApplication
#

@bacpypes_debugging
class SubscribeCOVApplication(BIPSimpleApplication):

def __init__(self, *args):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -188,7 +189,6 @@ def do_abort(self, args):

rsvp = (False, None, args[0])

bacpypes_debugging(SubscribeCOVConsoleCmd)

#
# __main__
Expand Down
5 changes: 2 additions & 3 deletions samples/TCPClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# MiddleMan
#

@bacpypes_debugging
class MiddleMan(Client, Server):
"""
An instance of this class sits between the TCPClientDirector and the
Expand All @@ -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):
Expand All @@ -84,8 +85,6 @@ def indication(self, addPeer=None, delPeer=None):
if _debug: MiddleManASE._debug(" - quitting")
stop()

bacpypes_debugging(MiddleManASE)


def main():
"""
Expand Down
4 changes: 2 additions & 2 deletions samples/TCPServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@
# EchoMaster
#

@bacpypes_debugging
class EchoMaster(Client):

def confirmation(self, pdu):
if _debug: EchoMaster._debug('confirmation %r', 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):
Expand All @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions samples/WhoIsIAm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# WhoIsIAmApplication
#

@bacpypes_debugging
class WhoIsIAmApplication(BIPSimpleApplication):

def __init__(self, *args):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions samples/WhoIsIAmForeign.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# WhoIsIAmApplication
#

@bacpypes_debugging
class WhoIsIAmApplication(BIPForeignApplication):

def __init__(self, *args):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cd2246c

Please sign in to comment.