Skip to content

Commit

Permalink
structure rebuild: bugfix. Works with PSI_test package
Browse files Browse the repository at this point in the history
  • Loading branch information
DanDayne committed Dec 6, 2019
1 parent 06861d0 commit 05ec414
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 221 deletions.
2 changes: 1 addition & 1 deletion DataManager/executioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, q, q_new_item, device_details, thread_name, experimental_deta
"""
:param q: queue.Queue() object, commands are put in it
:param q_new_item: queue.Event() object, is set when new commands are added to it, which triggers the checker
:param device_details: dict, check documentation.txt
:param device_details: dict, check wiki
:param thread_name: name of the thread, used to identify and keep in tact active threads
"""
thread_name = thread_name+'-checker'
Expand Down
3 changes: 2 additions & 1 deletion commandInterpreter/base_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def device_con(self, id, args):
return result
except TypeError:
raise Exception('Invalid input')
except Exception:
except Exception as e:
print(e)
count += 1
sleep(0.1)

Expand Down
24 changes: 18 additions & 6 deletions commandInterpreter/interpreterPBR.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initial_od(self):
while len(data) < 5:
try:
data.append(self.device_con(5, '[1]'))
except Exception:
except Exception as e:
# in case of connection error, log it
time_issued = datetime.datetime.utcnow()
time_issued = time_issued.strftime("%Y-%m-%d %H:%M:%S")
Expand Down Expand Up @@ -54,19 +54,23 @@ def __init__(self, device_details, q, q_new_item, log, device_class, experiment_
self.q = q
self.q_new_item = q_new_item
self.pump_state = [False]
self.log = log
self.device_details = device_details
self.device_class = device_class

self.OD_checker = OD_Checker.ODcheck(self.device_details,
self.OD_checker = OD_Checker.ODcheck(device_details,
self.q,
self.q_new_item,
self.initial_od(),
0,
self.pump_state)

super(DeviceManager, self).__init__(device_details,
device_class,
log,
super(DeviceManager, self).__init__(self.device_details,
self.device_class,
self.log,
self.pump_state,
self.OD_checker,
experiment_details)

self.commands = {
1: self.device.get_temp_settings,
2: self.device.get_temp,
Expand All @@ -92,6 +96,7 @@ def __init__(self, device_details, q, q_new_item, log, device_class, experiment_
22: self.device.get_hardware_address,
23: self.device.get_cluster_name
}

try:
self.device_con(8, str([device_details['setup']['pump_id'], False]))
except Exception:
Expand All @@ -107,3 +112,10 @@ def __init__(self, device_details, q, q_new_item, log, device_class, experiment_
}
)

initial_od = self.initial_od()
self.OD_checker.average = initial_od

if self.device_class == "Phenometrics":
self.device.pump_manager.last_OD = initial_od
self.device.pump_manager.stored_OD = initial_od

188 changes: 0 additions & 188 deletions documentation.txt

This file was deleted.

8 changes: 5 additions & 3 deletions server/DBapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ class ApiInit:

def __init__(self):
self.app = Flask(__name__)
script_location = Path(__file__).absolute().parent
with open(str(script_location / 'server_config.json'), 'r') as config_file:
self.script_location = Path(__file__).absolute().parent
with open(str(self.script_location / 'server_config.json'), 'r') as config_file:
config = load(config_file)
# if no auth is specified in config, no auth will be required
self.app.config['USERNAME'] = config.get('username', None)
Expand All @@ -320,7 +320,9 @@ def run_app(self):
:return: None, process is stuck on app.run()
"""
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('MyCertificate.crt', 'MyKey.key')
context.load_cert_chain(str(self.script_location / 'MyCertificate.crt'),
str(self.script_location / 'MyKey.key'))

self.app.run(host='0.0.0.0', ssl_context=context)

def run(self):
Expand Down
10 changes: 5 additions & 5 deletions server/protocolChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ def check_protocol(self, protocol):
for node in protocol:
for node_key in self.node_keys:
if node_key not in protocol[node]:
missing.append("Node %s is missing %s" % (node, node_key))
missing.append("Node %s is missing %s. " % (node, node_key))

for experiment_key in self.experiment_keys:
if experiment_key not in protocol[node].get('experiment_details', {}):
missing.append("Node %s is missing %s in experiment_details" % (node, experiment_key))
missing.append("Node %s is missing %s in experiment_details. " % (node, experiment_key))

device_counter = 0
for device in protocol[node].get('devices', {}):

for device_key in self.device_keys:
if device_key not in device:
missing.append(
"VirtualDevice %d on Node %s is missing %s" % (device_counter, node, device_key))
"VirtualDevice %d on Node %s is missing %s. " % (device_counter, node, device_key))

if 'device_type' in device and device['device_type'] == 'PBR':
for setup_key in self.PBR_setup:
if setup_key not in device.get('setup', {}):
missing.append(
"PBR on Node %s is missing %s in its setup" % (node, setup_key))
"PBR on Node %s is missing %s in its setup. " % (node, setup_key))
if 'device_class' in device:
for key in self.device_variants[device['device_class']]:
if key not in device:
missing.append("VirtualDevice of %s is missing %s" % (device['device_class'], key))
missing.append("VirtualDevice of %s is missing %s. " % (device['device_class'], key))
device_counter += 1

return missing
Loading

0 comments on commit 05ec414

Please sign in to comment.