Exemplo n.º 1
0
 def handle_req(self, msg):
     parts = self._decoder(msg[0])
     if debug:
         DEBUG('received %s' % parts)
     try:
         funct = deep_getattr(self._comp, parts[0])
         ret = funct(*parts[1], **parts[2])
     except Exception:
         ret = traceback.format_exc()
         logging.exception('handle_req %s %s %s',
                           parts[0], parts[1], parts[2])
     if debug:
         DEBUG('returning %s' % ret)
     try:
         self._repstream.send_multipart([self._encoder(ret)])
     except Exception:
         print "Error handling request: %s: %s" % (msg, traceback.format_exc())
Exemplo n.º 2
0
 def handle_req(self, msg):
     parts = self._decoder(msg[0])
     if debug:
         DEBUG('received %s' % parts)
     try:
         funct = deep_getattr(self._comp, parts[0])
         ret = funct(*parts[1], **parts[2])
     except Exception:
         ret = traceback.format_exc()
         logging.exception('handle_req %s %s %s',
                           parts[0], parts[1], parts[2])
     if debug:
         DEBUG('returning %s' % ret)
     try:
         self._repstream.send_multipart([self._encoder(ret)])
     except Exception:
         print "Error handling request: %s: %s" % (msg, traceback.format_exc())
Exemplo n.º 3
0
    def set_flattened_value(self, path, value):
        val,rop = deep_getattr(self, path.split('[',1)[0])
        idx = get_index(path)
        if isinstance(val, int_types):
            pass  # fall through to exception
        if isinstance(val, complex_or_real_types):
            if idx is None:
                setattr(self, path, value[0])
                return
            # else, fall through to error
        elif isinstance(val, ndarray):
            if idx is None:
                setattr(self, path, value)
            else:
                val[idx] = value
            return
        elif IVariableTree.providedBy(val):
            raise NotImplementedError("no support for setting flattened values into vartrees")

        raise TypeError("%s: Failed to set flattened value to variable %s" % (self.name, path))
Exemplo n.º 4
0
    def set_flattened_value(self, path, value):
        val, rop = deep_getattr(self, path.split('[', 1)[0])
        idx = get_index(path)
        if isinstance(val, int_types):
            pass  # fall through to exception
        if isinstance(val, complex_or_real_types):
            if idx is None:
                setattr(self, path, value[0])
                return
            # else, fall through to error
        elif isinstance(val, ndarray):
            if idx is None:
                setattr(self, path, value)
            else:
                val[idx] = value
            return
        elif IVariableTree.providedBy(val):
            raise NotImplementedError(
                "no support for setting flattened values into vartrees")

        raise TypeError("%s: Failed to set flattened value to variable %s" %
                        (self.name, path))