Commit b36b9961 authored by Antoine Millet's avatar Antoine Millet
Browse files

Display an error as value when a tag is expected but not fetched

parent b2119f6a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ class Client(object):
        """ Asynchronously update tags from the remote client using
            specified watcher.
        """
        watcher.register(self.conn, 'get_tags', tags, _data=robj)
        watcher.register(self.conn, 'get_tags', tags, _data=(tags, robj))

    def tags_register(self, name, ttl=None, value=None):
        """ Register a new remote tag for the client.
+1 −1
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ class HvClient(HostClient):
        """ Asynchronously update sub tags from the remote client using
            specified watcher.
        """
        watcher.register(self.conn, 'sub_tags', obj_id, tags, _data=robj)
        watcher.register(self.conn, 'sub_tags', obj_id, tags, _data=(tags, robj))


Client.register_client_class(HvClient)
+13 −6
Original line number Diff line number Diff line
@@ -159,10 +159,17 @@ class SRequestor(StaticRequestor):
                cb = tuple(to_update)[0].callback
                cb(watcher, obj, [t.name for t in to_update])
        # Get and process the results:
        for update in watcher.wait(timeout=10):  #TODO: adaptative timeout
            obj = update['data']
        for update in watcher.iter(timeout=10, raise_timeout=True):  #TODO: adaptative timeout
            requested_tags, obj = update['data']
            if 'return' not in update:
                continue  #TODO: display error in tag value
            for tag_name, tag_value in update['return'].iteritems():
                for tag_name in requested_tags:
                    obj.set(tag_name, '#ERR#')
            else:
                tags = update['return']
                for tag_name in requested_tags:
                    tag_value = tags.get(tag_name)
                    if tag_value is None:
                        obj.set(tag_name, '#ERR')
                    else:
                        obj.set(tag_name, tag_value)
                        obj[tag_name].cached = tag_value  # Set the tag cache value