Skip to content

Commit

Permalink
Preparing next release
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Tremblay <christian.tremblay@servisys.com>
  • Loading branch information
ChristianTremblay committed May 2, 2017
1 parent b4bf4bc commit 67401bc
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@
/doc
/.coverage
/doc/build
/__pycache__
/.cache
/.coveragerc
/.pylintrc
__pycache__
/BAC0/core/devices/mixins/__pycache__
/BAC0/sql/__pycache__
/BAC0/.coverage
/Jupyter/BACPypes.ipynb
/tests/__pycache__
/tests/need_rebuild_Device.py
/tests/.coverage
/pylintrc
62 changes: 62 additions & 0 deletions BAC0/core/functions/GetIPAddr - ProposedBug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 by Christian Tremblay, P.Eng <christian.tremblay@servisys.com>
# Licensed under LGPLv3, see file LICENSE in this source tree.
#
'''
GetIPAddr.py - Utility functions to retrieve local host's IP information.
'''

#--- standard Python modules ---
import subprocess
import ipaddress
import sys

#--- 3rd party modules ---
from bacpypes.pdu import Address

#--- this application's modules ---

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

class HostIP():
"""
Identify host's IP information
"""
def __init__(self, ip=None, mask = None):
if 'win' in sys.platform:
proc = subprocess.Popen('ipconfig', stdout=subprocess.PIPE)
for l in proc.stdout:
line= str(l)
if 'Address' in line:
ip= line.split(':')[-1]
if 'Mask' in line:
mask= line.split(':')[-1]

self.interface = ipaddress.IPv4Interface('%r/%s' % (ip, mask))
else:
proc = subprocess.Popen('ifconfig', stdout=subprocess.PIPE)
for l in proc.stdout:
line= l.decode('utf-8')
if 'Bcast' in line:
_,ipaddr,bcast,mask= line.split()
_,ip= ipaddr.split(':')
_,mask= mask.split(':')

self.interface = ipaddress.IPv4Interface('{}/{}'.format(ip, mask))
break
self.interface = ipaddress.IPv4Interface('{}/{}'.format(ip, mask))

@property
def ip_address(self):
return str(self.interface) # IP Address/subnet

@property
def address(self):
return (Address(str(self.interface))) # bacpypes format: ip


if __name__ == '__main__':
h = HostIP()
print('Localhost IP address= ',h.ip_address)
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ BAC0 |build-status| |coverage| |docs|
.. image:: https://badges.gitter.im/ChristianTremblay/BAC0.svg
:alt: Join the chat at https://gitter.im/ChristianTremblay/BAC0
:target: https://gitter.im/ChristianTremblay/BAC0?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

BAC0 is a Python 3 (3.4 and over) scripting application that uses BACpypes_ to process BACnet messages on a IP network.
This library brings out simple commands to browse a BACnet network, read properties from BACnet devices or write to them.

Expand Down

0 comments on commit 67401bc

Please sign in to comment.