本文整理汇总了Python中pyon.public.IonObject类的典型用法代码示例。如果您正苦于以下问题:Python IonObject类的具体用法?Python IonObject怎么用?Python IonObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IonObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_type_interface
def _get_type_interface(self, res_type):
"""
Creates a merge of params and commands up the type inheritance chain.
Note: Entire param and command entries if subtypes replace their super types definition.
"""
res_interface = dict(params={}, commands={})
base_types = IonObject(res_type)._get_extends()
base_types.insert(0, res_type)
for rt in reversed(base_types):
type_interface = self.resource_interface.get(rt, None)
if not type_interface:
continue
for tpar, tval in type_interface.iteritems():
if tpar in res_interface:
rval = res_interface[tpar]
if isinstance(rval, dict):
rval.update(tval)
else:
res_interface[tpar] = tval
else:
res_interface[tpar] = dict(tval) if isinstance(tval, dict) else tval
return res_interface
开发者ID:blazetopher,项目名称:coi-services,代码行数:25,代码来源:resource_management_service.py
示例2: get_user_notifications
def get_user_notifications(self, user_id=''):
'''
Get the notification request objects that are subscribed to by the user
@param user_id str
@retval notifications list of NotificationRequest objects
'''
user = self.clients.resource_registry.read(user_id)
if not user:
return None
if not user.name:
raise BadRequest("Please assign a name to the resource. Example: resource.name = \'Irene\' for UNS to "
"be able to fetch the related notifications")
if self.event_processor.user_info.has_key(user.name):
notifications = self.event_processor.user_info[user.name]['notifications']
ret = IonObject(OT.ComputedListValue)
if notifications:
ret.value = notifications
ret.status = ComputedValueAvailability.PROVIDED
else:
ret.status = ComputedValueAvailability.NOTAVAILABLE
return ret
else:
return None
开发者ID:tomoreilly,项目名称:coi-services,代码行数:30,代码来源:user_notification_service.py
示例3: _convert_negotiations_to_requests
def _convert_negotiations_to_requests(self, negotiations=None, user_info_id='', org_id=''):
assert isinstance(negotiations, list)
orgs,_ = self.clients.resource_registry.find_resources(restype=RT.Org)
ret_list = []
for neg in negotiations:
request = IonObject(OT.OrgUserNegotiationRequest, ts_updated=neg.ts_updated, negotiation_id=neg._id,
negotiation_type=NegotiationTypeEnum._str_map[neg.negotiation_type],
negotiation_status=NegotiationStatusEnum._str_map[neg.negotiation_status],
originator=ProposalOriginatorEnum._str_map[neg.proposals[-1].originator],
request_type=neg.proposals[-1].type_,
description=neg.description, reason=neg.reason,
user_id=user_info_id)
# since this is a proxy for the Negotiation object, simulate its id to help the UI deal with it
request._id = neg._id
org_request = [ o for o in orgs if o._id == neg.proposals[-1].provider ]
if org_request:
request.org_id = org_request[0]._id
request.name = org_request[0].name
ret_list.append(request)
return ret_list
开发者ID:ednad,项目名称:coi-services,代码行数:27,代码来源:identity_management_service.py
示例4: get_is_persisted
def get_is_persisted(self, data_product_id=''):
# Returns True if data product is currently being persisted
ret = IonObject(OT.ComputedIntValue)
ret.value = self.is_persisted(data_product_id)
ret.status = ComputedValueAvailability.PROVIDED
return ret
开发者ID:blazetopher,项目名称:coi-services,代码行数:7,代码来源:data_product_management_service.py
示例5: _get_computed_events
def _get_computed_events(self, events, add_usernames=True, include_events=False):
"""
Get events for use in extended resource computed attribute
@retval ComputedListValue with value list of 4-tuple with Event objects
"""
events = events or []
ret = IonObject(OT.ComputedEventListValue)
ret.value = events
ret.computed_list = [get_event_computed_attributes(event, include_event=include_events) for event in events]
ret.status = ComputedValueAvailability.PROVIDED
if add_usernames:
try:
actor_ids = {evt.actor_id for evt in events if evt.actor_id}
log.debug("Looking up UserInfo for actors: %s" % actor_ids)
if actor_ids:
userinfo_list, assoc_list = self.clients.resource_registry.find_objects_mult(actor_ids,
predicate=PRED.hasInfo,
id_only=False)
actor_map = {assoc.s: uinfo for uinfo, assoc in zip(userinfo_list, assoc_list)}
for evt, evt_cmp in zip(events, ret.computed_list):
ui = actor_map.get(evt.actor_id, None)
if ui:
evt_cmp["event_summary"] += " [%s %s]" % (ui.contact.individual_names_given, ui.contact.individual_name_family)
except Exception as ex:
log.exception("Cannot find user names for event actor_ids")
return ret
开发者ID:MatthewArrott,项目名称:coi-services,代码行数:31,代码来源:user_notification_service.py
示例6: run_reverse_transform
def run_reverse_transform(self):
''' Runs a reverse transform example and displays the results of performing the transform
'''
tms_cli = TransformManagementServiceClient(node=self.container.node)
procd_cli = ProcessDispatcherServiceClient(node=self.container.node)
#-------------------------------
# Process Definition
#-------------------------------
process_definition = IonObject(RT.ProcessDefinition, name='transform_process_definition')
process_definition.executable = {
'module': 'ion.processes.data.transforms.transform_example',
'class':'ReverseTransform'
}
process_definition_id = procd_cli.create_process_definition(process_definition)
#-------------------------------
# Execute Transform
#-------------------------------
input = [1,2,3,4]
retval = tms_cli.execute_transform(process_definition_id=process_definition_id,
data=[1,2,3,4],
configuration={})
log.debug('Transform Input: %s', input)
log.debug('Transform Output: %s', retval)
开发者ID:daf,项目名称:coi-services,代码行数:26,代码来源:transform_example.py
示例7: test_createDataProduct_and_DataProducer_with_id_BadRequest
def test_createDataProduct_and_DataProducer_with_id_BadRequest(self):
# setup
self.resource_registry.find_resources.return_value = ([], 'do not care')
self.resource_registry.create.return_value = ('SOME_RR_ID1', 'Version_1')
self.data_acquisition_management.create_data_producer.side_effect = BadRequest("Create cannot create document with ID: ")
# Data Product
dpt_obj = IonObject(RT.DataProduct,
name='DPT_X',
description='some new data product')
# Data Producer
dpr_obj = IonObject(RT.DataProducer,
name='DP_X',
description='some new data producer')
dpr_obj._id = "SOME_OTHER_RR_ID"
# test call
with self.assertRaises(BadRequest) as cm:
dp_id = self.data_product_management_service.create_data_product(dpt_obj, dpr_obj)
# check results
self.resource_registry.find_resources.assert_called_once_with(RT.DataProduct, None, dpt_obj.name, True)
self.resource_registry.create.assert_called_once_with(dpt_obj)
self.data_acquisition_management.create_data_producer.assert_called_once_with(dpr_obj)
ex = cm.exception
self.assertEqual(ex.message, "Create cannot create document with ID: ")
开发者ID:tgiguere,项目名称:coi-services,代码行数:25,代码来源:test_data_product_management_service.py
示例8: create_resource_commitment
def create_resource_commitment(self, org_id="", actor_id="", resource_id="", exclusive=False, expiration=0):
"""Creates a Commitment for the specified resource for a specified actor within
the specified Org. Once shared, the resource is committed to the actor.
"""
org_obj = self._validate_resource_id("org_id", org_id, RT.Org, optional=True)
actor_obj = self._validate_resource_id("actor_id", actor_id, RT.ActorIdentity)
resource_obj = self._validate_resource_id("resource_id", resource_id)
if org_id:
# Check that resource is shared in Org?
pass
res_commitment = IonObject(OT.ResourceCommitment, resource_id=resource_id, exclusive=exclusive)
commitment = IonObject(RT.Commitment, name="", provider=org_id, consumer=actor_id, commitment=res_commitment,
description="Resource Commitment", expiration=str(expiration))
commitment._id, commitment._rev = self.rr.create(commitment)
# Creating associations to all related objects
self.rr.create_association(actor_id, PRED.hasCommitment, commitment._id)
self.rr.create_association(commitment._id, PRED.hasTarget, resource_id)
if org_id:
self.rr.create_association(org_id, PRED.hasCommitment, commitment._id)
self.event_pub.publish_event(event_type=OT.ResourceCommitmentCreatedEvent,
origin=org_id, origin_type="Org", sub_type=resource_obj.type_,
description="The resource has been committed by the Org",
resource_id=resource_id, org_name=org_obj.name,
commitment_id=commitment._id, commitment_type=commitment.commitment.type_)
return commitment._id
开发者ID:edwardhunter,项目名称:scioncc,代码行数:33,代码来源:org_management_service.py
示例9: _create_association
def _create_association(self, subject=None, predicate=None, obj=None, support_bulk=False):
"""
Create an association between two IonObjects with a given predicate.
Supports bulk mode
"""
if self.bulk and support_bulk:
if not subject or not predicate or not obj:
raise BadRequest("Association must have all elements set: %s/%s/%s" % (subject, predicate, obj))
if isinstance(subject, basestring):
subject = self._get_resource_obj(subject)
if "_id" not in subject:
raise BadRequest("Subject id not available")
subject_id = subject._id
st = subject.type_
if isinstance(obj, basestring):
obj = self._get_resource_obj(obj)
if "_id" not in obj:
raise BadRequest("Object id not available")
object_id = obj._id
ot = obj.type_
assoc_id = create_unique_association_id()
assoc_obj = IonObject("Association",
s=subject_id, st=st,
p=predicate,
o=object_id, ot=ot,
ts=get_ion_ts())
assoc_obj._id = assoc_id
self.bulk_associations[assoc_id] = assoc_obj
return assoc_id, '1-norev'
else:
return self.rr.create_association(subject, predicate, obj)
开发者ID:crchemist,项目名称:scioncc,代码行数:33,代码来源:preload.py
示例10: acquire_resource
def acquire_resource(self, sap=None):
"""Creates a Commitment Resource for the specified resource for a specified user withing the specified Org as defined in the
proposal. Once shared, the resource is committed to the user. Throws a NotFound exception if none of the ids are found.
@param proposal AcquireResourceProposal
@retval commitment_id str
@throws NotFound object with specified id does not exist
"""
param_objects = self._validate_parameters(org_id=sap.provider, user_id=sap.consumer, resource_id=sap.resource)
if sap.type_ == OT.AcquireResourceExclusiveProposal:
exclusive = True
else:
exclusive = False
res_commitment = IonObject(OT.ResourceCommitment, resource_id=sap.resource, exclusive=exclusive)
commitment = IonObject(RT.Commitment, name='', provider=sap.provider, consumer=sap.consumer, commitment=res_commitment,
description='Resource Commitment', expiration=sap.expiration)
commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
commitment._id = commitment_id
commitment._rev = commitment_rev
#Creating associations to all objects
self.clients.resource_registry.create_association(sap.provider, PRED.hasCommitment, commitment_id)
self.clients.resource_registry.create_association(sap.consumer, PRED.hasCommitment, commitment_id)
self.clients.resource_registry.create_association(sap.resource, PRED.hasCommitment, commitment_id)
self.clients.resource_registry.create_association(sap.negotiation_id, PRED.hasContract, commitment_id)
#TODO - publish some kind of event for creating a commitment
return commitment_id
开发者ID:tomoreilly,项目名称:coi-services,代码行数:33,代码来源:org_management_service.py
示例11: get_data_ingestion_datetime
def get_data_ingestion_datetime(self, data_product_id=''):
# Returns a temporal bounds object of the earliest/most recent values ingested into in the data product
ret = IonObject(OT.ComputedStringValue)
ret.value = ""
ret.status = ComputedValueAvailability.NOTAVAILABLE
ret.reason = "FIXME. also, should datetime be stored as a string?"
return ret
开发者ID:tomoreilly,项目名称:coi-services,代码行数:8,代码来源:data_product_management_service.py
示例12: get_data_datetime
def get_data_datetime(self, data_product_id=''):
# Returns a temporal bounds object of the span of data product life span (may exist without getting a granule)
ret = IonObject(OT.ComputedStringValue)
ret.value = ""
ret.status = ComputedValueAvailability.NOTAVAILABLE
ret.reason = "FIXME. also, should datetime be stored as a string?"
return ret
开发者ID:tomoreilly,项目名称:coi-services,代码行数:8,代码来源:data_product_management_service.py
示例13: get_data_url
def get_data_url(self, data_product_id=''):
# The unique pointer to this set of data
ret = IonObject(OT.ComputedStringValue)
ret.value = ""
ret.status = ComputedValueAvailability.NOTAVAILABLE
ret.reason = "FIXME."
return ret
开发者ID:tomoreilly,项目名称:coi-services,代码行数:9,代码来源:data_product_management_service.py
示例14: fun
def fun():
#ret = Mock()
log.debug("Creating sample %s", iontype)
ret = IonObject(iontype)
ret.name = "sample %s" % iontype
ret.description = "description of sample %s" % iontype
for k, v in resource_params.iteritems():
setattr(ret, k, v)
return ret
开发者ID:MatthewArrott,项目名称:coi-services,代码行数:9,代码来源:helpers.py
示例15: get_data_contents_updated
def get_data_contents_updated(self, data_product_id=''):
# the datetime when the contents of the data were last modified in any way.
# This is distinct from modifications to the data product attributes
ret = IonObject(OT.ComputedStringValue)
ret.value = ""
ret.status = ComputedValueAvailability.NOTAVAILABLE
ret.reason = "FIXME. also, should datetime be stored as a string?"
return ret
开发者ID:blazetopher,项目名称:coi-services,代码行数:9,代码来源:data_product_management_service.py
示例16: create_ion_object
def create_ion_object(object_params):
new_obj = IonObject(object_params["type_"])
#Iterate over the parameters to add to object; have to do this instead
#of passing a dict to get around restrictions in object creation on setting _id, _rev params
for param in object_params:
set_object_field(new_obj, param, object_params.get(param))
new_obj._validate() # verify that all of the object fields were set with proper types
return new_obj
开发者ID:swarbhanu,项目名称:coi-services,代码行数:10,代码来源:service_gateway_service.py
示例17: parse_constraints
def parse_constraints(self, environ):
# print ">> Start parse_constraints"
# import pprint
# pprint.pprint("")
# pprint.pprint(environ)
ds_name, ds_id, ds_url, buf_size = get_dataset_info(self)
# print "DS Info: name=%s ds_id=%s ds_url=%s buf_size=%s" % (ds_name, ds_id, ds_url, buf_size)
# TODO: Call the "damsP" module to retrieve a BaseDatasetHandler based on the ds_id
dsh = self.damsP.get_data_handlers(ds_id=ds_id)
#DSH WAY
dataset_type = DatasetType(name=ds_name, attributes={'NC_GLOBAL': dsh.get_attributes()})
fields, queries = environ['pydap.ce']
fields = fields or [[(name, ())] for name in dsh.ds.variables]
# print "CE Fields: %s" % fields
# print "CE Queries: %s" % queries
pdr_obj = IonObject("PydapVarDataRequest", name="p_req")
for fvar in fields:
target = dataset_type
while fvar:
name, slice_ = fvar.pop(0)
pdr_obj.name = name
pdr_obj.slice = slice_
if (name in dsh.ds.dimensions or not dsh.ds.variables[name].dimensions or target is not dataset_type):
# print "==> if"
nm, dat, tc, di, at = dsh.acquire_data(request=pdr_obj)
target[name] = BaseType(name=nm, data=dat, shape=dat.shape, type=tc, dimensions=di, attributes=at)
elif fvar:
# print "==> elif"
attrs = dsh.get_attributes(name)
target.setdefault(name, StructureType(name=name, attributes=attrs))
target = target[name]
else:
# print "==> else"
attrs = dsh.get_attributes(name)
grid = target[name] = GridType(name=name, attributes=attrs)
nm, dat, tc, di, at = dsh.acquire_data(request=pdr_obj)
grid[name] = BaseType(name=nm, data=dat, shape=dat.shape, type=tc, dimensions=di, attributes=at)
slice_ = list(slice_) + [slice(None)] * (len(grid.array.shape) - len(slice_))
for dim, dimslice in zip(dsh.ds.variables[name].dimensions, slice_):
pdr_obj.name=dim
pdr_obj.slice=dimslice
nm, dat, tc, di, at = dsh.acquire_data(request=pdr_obj)
grid[dim] = BaseType(name=nm, data=dat, shape=dat.shape, type=tc, dimensions=di, attributes=at)
dataset_type._set_id()
dataset_type.close = dsh.ds.close
# print ">> End parse_constraints"
return dataset_type
开发者ID:ooici-eoi,项目名称:pydap-handlers-ion,代码行数:55,代码来源:__init__.py
示例18: test_tuple_in_dict
def test_tuple_in_dict(self):
# create a resource with a tuple saved in a dict
transform_obj = IonObject(RT.Transform)
transform_obj.configuration = {}
transform_obj.configuration["tuple"] = ('STRING',)
transform_id, _ = self.resource_registry_service.create(transform_obj)
# read the resource back
returned_transform_obj = self.resource_registry_service.read(transform_id)
self.assertEqual(transform_obj.configuration["tuple"], returned_transform_obj.configuration["tuple"])
开发者ID:jamie-cyber1,项目名称:coi-services,代码行数:11,代码来源:test_resource_registry_service.py
示例19: create_ion_object
def create_ion_object(self, object_params):
"""Create and initialize an ION object from a dictionary of parameters coming via HTTP,
ready to be passed on to services/messaging. The object is validated after creation.
Note: This is not called for service operation argument signatures
"""
new_obj = IonObject(object_params["type_"])
# Iterate over the parameters to add to object; have to do this instead
# of passing a dict to get around restrictions in object creation on setting _id, _rev params
for param in object_params:
self.set_object_field(new_obj, param, object_params.get(param))
new_obj._validate() # verify that all of the object fields were set with proper types
return new_obj
开发者ID:IvanHreskiv,项目名称:scioncc,代码行数:14,代码来源:service_gateway.py
示例20: get_active_user_subscriptions
def get_active_user_subscriptions(self, data_product_id=''):
# The UserSubscription objects for this data product
ret = IonObject(OT.ComputedListValue)
ret.value = []
try:
ret.status = ComputedValueAvailability.PROVIDED
raise NotFound #todo: ret.value = ???
except NotFound:
ret.status = ComputedValueAvailability.NOTAVAILABLE
ret.reason = "FIXME: this message should say why the calculation couldn't be done"
except Exception as e:
raise e
return ret
开发者ID:tomoreilly,项目名称:coi-services,代码行数:14,代码来源:data_product_management_service.py
注:本文中的pyon.public.IonObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论