def _load(self):
     super(DeliverySink, self)._load()
     self._dict_fields['channel'] = r.hgetall('channels:{}'.format(self._dict_fields['channel']))
     self._dict_fields['broker'] = r.hgetall('brokers:{}'.format(self._dict_fields['broker']))
     self._dict_fields['broker']['port'] = int(self._dict_fields['broker']['port'])
     recipient = self._dict_fields['channel'].copy()
     recipient.update(self._dict_fields['broker'])
     self._dict_fields['recipient'] = recipient
     try:
         del self._dict_fields['delivery']
     except KeyError:
         pass
Beispiel #2
0
def get_request(rid):
    if not r.keys('requests:{}'.format(rid)):
        raise NotFound('The request {} does not exist'.format(rid))
    r_dict = filter_hash_attrs('requests:{}'.format(rid), lambda x: not x.startswith('__'))
    channel = r_dict['channel']
    ch_dict = r.hgetall('channels:{}'.format(channel))
    broker = r_dict['broker']
    br_dict = r.hgetall('brokers:{}'.format(broker))
    r_dict['channel'] = ch_dict
    r_dict['broker'] = br_dict
    r_dict['pattern'] = "{ %s }" % r_dict['pattern']
    if 'mapping' in r_dict:
        r_dict['mapping'] = eval(r_dict['mapping'])

    return jsonify(r_dict)
 def load(self):
     dict_fields = r.hgetall(self._enrichment_key)
     self.target = URIRef(dict_fields.get('target', None))
     self.fragment_id = dict_fields.get('fragment_id', None)
     self.links = map(lambda (link, v): (URIRef(link), v), [eval(pair_str) for pair_str in
                                                            r.smembers('{}:links'.format(
                                                                self._enrichment_key))])
Beispiel #4
0
def filter_hash_attrs(key, predicate):
    hash_map = r.hgetall(key)
    visible_attrs = filter(predicate, hash_map)
    return {attr: hash_map[attr] for attr in filter(lambda x: x in visible_attrs, hash_map)}
Beispiel #5
0
 def _load(self):
     self._dict_fields = r.hgetall('requests:{}'.format(self._request_id))
 def completed(self):
     return all([eval(value) for value in r.hgetall('{}:links:status'.format(self._enrichment_key)).values()])