Skip to content

Commit 579f4af

Browse files
author
btgoodwin
committed
Property configure/allocate/deallocate robustness
Switched to returning a CF.DataType list for configure/allocate/deallocate. This made processing parsed properties more robust overall. Also added debugging log statements for investigating server response in the future since we revisit this seemingly every 6-12 months.
1 parent d227d9d commit 579f4af

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

model/redhawk.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727

2828
from domain import Domain, scan_domains, ResourceNotFound
2929

30+
from ossie.cf import CF
3031
from ossie.properties import __TYPE_MAP as TYPE_MAP
3132
from ossie.properties import props_from_dict, props_to_dict
3233

3334
from tornado.websocket import WebSocketClosedError
34-
from tornado import ioloop
35+
from tornado import ioloop, log
3536

3637
import collections
3738

@@ -192,30 +193,15 @@ def release_application(self, domain_name, app_id):
192193
@background_task
193194
def application_configure(self, domain_name, app_id, new_properties):
194195
app = self._get_application(domain_name, app_id)
195-
props = Redhawk._application_externalProps(app)
196-
196+
props = app._getPropertySet()
197197
changes = Redhawk._get_prop_changes(props, new_properties)
198198
return app.configure(changes)
199199

200-
'''
201-
Helper function to streamline getting a property list similar to what one
202-
gets from components, devices, etc.
203-
'''
204-
@staticmethod
205-
def _application_externalProps(app):
206-
props = []
207-
for epid, t in app._externalProps.iteritems():
208-
pid = t[0] # First item is the property id relative to the component
209-
cid = t[1] # Second item in tuple is prefix of component identifier
210-
for comp in app.comps:
211-
if comp.identifier.startswith(cid):
212-
for prop in comp._properties:
213-
if prop.id == pid:
214-
props.append(prop)
215-
return props
216-
217200
##############################
218201
# COMMON PROPERTIES
202+
'''
203+
Cleans out IDs being unicode, etc. since CF can't handle unicode strings.
204+
'''
219205
@staticmethod
220206
def _clean_property(property):
221207
if isinstance(property, basestring):
@@ -231,16 +217,22 @@ def _clean_property(property):
231217
# CF.Properties and dict() of { 'id': value, ... }
232218
# Use force to treat all ID matches as required changes
233219
def _get_prop_changes(current_props, new_properties, force=False):
234-
changes = {}
220+
changes = []
235221
for prop in current_props:
236222
if prop.id in new_properties:
237223
if new_properties[prop.id] != prop.queryValue() or force:
238-
changes[str(prop.id)] = prop.fromAny(
239-
prop.toAny(
240-
Redhawk._clean_property(new_properties[prop.id])
224+
changes.append(
225+
CF.DataType(
226+
prop.id,
227+
prop.toAny(
228+
Redhawk._clean_property(new_properties[prop.id])
229+
)
241230
)
242231
)
243-
return props_from_dict(changes)
232+
log.app_log.debug('Current properties: {}'.format(current_props))
233+
log.app_log.debug('New properties: {}'.format(new_properties))
234+
log.app_log.debug('Changes: {}'.format(changes))
235+
return changes
244236

245237
##############################
246238
# COMPONENT

rest/application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get(self, domain_name, app_id=None):
3838
if app_id:
3939
app = yield self.redhawk.get_application(domain_name, app_id)
4040
comps = yield self.redhawk.get_component_list(domain_name, app_id)
41-
props = self.redhawk._application_externalProps(app)
41+
props = app._getPropertySet()
4242

4343
info = {
4444
'id': app._get_identifier(),
@@ -120,7 +120,7 @@ class ApplicationProperties(JsonHandler, PropertyHelper):
120120
def get(self, domain, app_id):
121121
try:
122122
app = yield self.redhawk.get_application(domain, app_id)
123-
props = self.redhawk._application_externalProps(app)
123+
props = app._getPropertySet()
124124

125125
self._render_json({
126126
'properties': self.format_properties(props, app.query([]))

0 commit comments

Comments
 (0)