Dockerize everything

This commit is contained in:
Patrick McDonagh
2017-05-23 12:38:03 -05:00
parent 0644242498
commit fa6d451f71
8 changed files with 91 additions and 22 deletions

View File

@@ -0,0 +1,13 @@
FROM python:2.7
# Install some python packages
RUN pip install requests pymongo pymodbus cryptography pyasn1
RUN pip install git+https://github.com/Henry-Pump/Pycomm-Helper.git
RUN pip install git+https://github.com/ruscito/pycomm.git
# Copy source files
RUN mkdir /root/poc_to_modbus
COPY poc_modbus_server/poc_to_modbus.py /root/poc_to_modbus/poc_to_modbus.py
COPY poc_modbus_server/run_server.py /root/poc_to_modbus/run_server.py
CMD ["python", "-u", "/root/poc_to_modbus/run_server.py"]

View File

@@ -103,8 +103,9 @@ class DigitalTagDataBlock(ModbusSparseDataBlock):
super(DigitalTagDataBlock, self).__init__(values)
def getValues(self, address, count=1):
client = MongoClient()
client = MongoClient(host="mongodb", port=27017)
db = client.tag_data
db.authenticate(name="poc", password="poc")
tags = db.tag_vals
for i in range(address, address + count):
@@ -120,8 +121,9 @@ class DigitalTagDataBlock(ModbusSparseDataBlock):
:param address: The starting address
:param values: The new values to be set
'''
client = MongoClient()
client = MongoClient(host="mongodb", port=27017)
db = client.tag_data
db.authenticate(name="poc", password="poc")
tags = db.tag_vals
tag_found = tags.find_one({'register_number': address, 'register_type': self.register_type})
tag_name = tag_found['tag_name']
@@ -172,8 +174,9 @@ class AnalogTagDataBlock(ModbusSparseDataBlock):
super(AnalogTagDataBlock, self).__init__(values)
def getValues(self, address, count=1):
client = MongoClient()
client = MongoClient(host="mongodb", port=27017)
db = client.tag_data
db.authenticate(name="poc", password="poc")
tags = db.tag_vals
try:
for i in range(address, address + count):
@@ -205,8 +208,9 @@ class AnalogTagDataBlock(ModbusSparseDataBlock):
'''
print("provided values: {}".format(value))
try:
client = MongoClient()
client = MongoClient(host="mongodb", port=27017)
db = client.tag_data
db.authenticate(name="poc", password="poc")
tags = db.tag_vals
tag_found = tags.find_one({'register_number': address, 'register_type': self.register_type})
tag_name = tag_found['tag_name']
@@ -226,8 +230,9 @@ class AnalogTagDataBlock(ModbusSparseDataBlock):
def getTagsFromDB():
client = MongoClient()
client = MongoClient(host="mongodb", port=27017)
db = client.tag_data
db.authenticate(name="poc", password="poc")
tags = db.tag_vals
print("Found {} tags in the database".format(tags.count()))
di_tags_cur = tags.find({'register_type': 'di'})

View File

@@ -82,7 +82,6 @@ setup(
'pymodbus',
'cryptography',
'pyasn1',
'pycomm_helper',
],
dependency_links=[
'https://github.com/Henry-Pump/Pycomm-Helper/tarball/master#egg=pycomm_helper-0.1',