Skip to content

Commit

Permalink
Merge pull request #134 from ChristianTremblay/release_19.4.28
Browse files Browse the repository at this point in the history
Release 19.4.28
  • Loading branch information
ChristianTremblay authored Apr 29, 2019
2 parents 63f630a + a11947e commit 8d95b06
Show file tree
Hide file tree
Showing 48 changed files with 2,428 additions and 1,700 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ __pycache__
/tests/need_rebuild_Device.py
/tests/.coverage
/pylintrc
/.pytest_cache
/tests/archive
/BAC0/web/test
/venv/
32 changes: 20 additions & 12 deletions BAC0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import bacpypes
except ImportError:
# Using print here or setup.py will fail
print('='*80)
print('bacpypes module missing, please install latest version using \n $ "pip install bacpypes"')
print('\nDiscard this message if you are actually installing BAC0.')
print('='*80)
print("=" * 80)
print(
'bacpypes module missing, please install latest version using \n $ "pip install bacpypes"'
)
print("\nDiscard this message if you are actually installing BAC0.")
print("=" * 80)

try:
from . import core
Expand All @@ -21,28 +23,34 @@
from .tasks.Match import Match as match
from .core.utils.notes import update_log_level as log_level
from .infos import __version__ as version

# To be able to use the complete version pandas, flask and bokeh must be installed.
try:
import pandas
import bokeh
import flask
import flask_bootstrap

_COMPLETE = True
except ImportError:
_COMPLETE = False

if _COMPLETE:
from .scripts.Complete import Complete as connect
from .scripts.Lite import Lite as lite
else:
from .scripts.Lite import Lite as connect

lite = connect
#print('All features not available as some modules are missing (flask, flask-bootstrap, bokeh, pandas). See docs for details')
# print('All features not available as some modules are missing (flask, flask-bootstrap, bokeh, pandas). See docs for details')

except ImportError as err:
print('='*80)
print('Import Error, refer to documentation or reinstall using \n $ "pip install BAC0"')
print('\nDiscard this message if you are actually installing BAC0.')
print('='*80)
except ImportError as error:
print("=" * 80)
print(
'Import Error, refer to documentation or reinstall using \n $ "pip install BAC0"\n {}'.format(
error
)
)
print("\nDiscard this message if you are actually installing BAC0.")
print("=" * 80)
# Probably installing the app...
50 changes: 31 additions & 19 deletions BAC0/core/app/ScriptApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 2015 by Christian Tremblay, P.Eng <[email protected]>
# Licensed under LGPLv3, see file LICENSE in this source tree.
#
'''
"""
SimpleApplication
=================
Expand All @@ -15,19 +15,19 @@
Additional functionality is enabled by inheriting this application, and then
extending it with more functions. [See BAC0.scripts for more examples of this.]
'''
#--- standard Python modules ---
"""
# --- standard Python modules ---
from collections import defaultdict

#--- 3rd party modules ---
# --- 3rd party modules ---
from bacpypes.app import BIPSimpleApplication, BIPForeignApplication
from bacpypes.pdu import Address
from bacpypes.service.object import ReadWritePropertyMultipleServices

#--- this application's modules ---
# --- this application's modules ---
from ..utils.notes import note_and_log

#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------


@note_and_log
Expand All @@ -43,7 +43,10 @@ class SimpleApplication(BIPSimpleApplication, ReadWritePropertyMultipleServices)
def __init__(self, *args, bbmdAddress=None, bbmdTTL=0):
self.localAddress = None

super().__init__(*args)
try:
super().__init__(*args)
except OSError:
raise

self._request = None

Expand All @@ -54,17 +57,19 @@ def __init__(self, *args, bbmdAddress=None, bbmdTTL=0):
self.local_unicast_tuple = self.localAddress.addrTuple
self.local_broadcast_tuple = self.localAddress.addrBroadcastTuple
else:
self.local_unicast_tuple = ('', 47808)
self.local_broadcast_tuple = ('255.255.255.255', 47808)
self.local_unicast_tuple = ("", 47808)
self.local_broadcast_tuple = ("255.255.255.255", 47808)

def do_WhoIsRequest(self, apdu):
"""Respond to a Who-Is request."""
self.log(("do_WhoIsRequest {!r}".format(apdu)))

# build a key from the source and parameters
key = (str(apdu.pduSource),
apdu.deviceInstanceRangeLowLimit,
apdu.deviceInstanceRangeHighLimit)
key = (
str(apdu.pduSource),
apdu.deviceInstanceRangeLowLimit,
apdu.deviceInstanceRangeHighLimit,
)

# count the times this has been received
self.who_is_counter[key] += 1
Expand All @@ -85,7 +90,9 @@ def do_IAmRequest(self, apdu):


@note_and_log
class ForeignDeviceApplication(BIPForeignApplication, ReadWritePropertyMultipleServices):
class ForeignDeviceApplication(
BIPForeignApplication, ReadWritePropertyMultipleServices
):
"""
Defines a basic BACnet/IP application to process BACnet requests.
Expand All @@ -97,7 +104,10 @@ class ForeignDeviceApplication(BIPForeignApplication, ReadWritePropertyMultipleS
def __init__(self, *args, bbmdAddress=None, bbmdTTL=0):
self.localAddress = None

super().__init__(*args, bbmdAddress=bbmdAddress, bbmdTTL=bbmdTTL)
try:
super().__init__(*args, bbmdAddress=bbmdAddress, bbmdTTL=bbmdTTL)
except OSError:
raise

self._request = None

Expand All @@ -108,17 +118,19 @@ def __init__(self, *args, bbmdAddress=None, bbmdTTL=0):
self.local_unicast_tuple = self.localAddress.addrTuple
self.local_broadcast_tuple = self.localAddress.addrBroadcastTuple
else:
self.local_unicast_tuple = ('', 47808)
self.local_broadcast_tuple = ('255.255.255.255', 47808)
self.local_unicast_tuple = ("", 47808)
self.local_broadcast_tuple = ("255.255.255.255", 47808)

def do_WhoIsRequest(self, apdu):
"""Respond to a Who-Is request."""
self.log(("do_WhoIsRequest {!r}".format(apdu)))

# build a key from the source and parameters
key = (str(apdu.pduSource),
apdu.deviceInstanceRangeLowLimit,
apdu.deviceInstanceRangeHighLimit)
key = (
str(apdu.pduSource),
apdu.deviceInstanceRangeLowLimit,
apdu.deviceInstanceRangeHighLimit,
)

# count the times this has been received
self.who_is_counter[key] += 1
Expand Down
2 changes: 1 addition & 1 deletion BAC0/core/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from . import ScriptApplication
from . import ScriptApplication
Loading

0 comments on commit 8d95b06

Please sign in to comment.