Ejemplo n.º 1
0
def get_key_direct(flux_handle, key):
    valp = ffi.new('char *[1]')
    _raw.get(flux_handle, key, valp)
    if valp[0] == ffi.NULL:
      return None
    else:
      return json.loads(ffi.string(valp[0]))
Ejemplo n.º 2
0
def watch_once(flux_handle, key):
    """ Watches the selected key until the next change, then returns the updated value of the key """
    if isdir(flux_handle, key):
        d = get_dir(flux_handle)
        # The wrapper automatically unpacks d's handle
        _raw.watch_once_dir(flux_handle, d)
        return d
    else:
        out_json_str = ffi.new('char *[1]')
        _raw.watch_once(flux_handle, key, out_json_str)
        if out_json_str[0] == ffi.NULL:
          return None
        else:
          return json.loads(ffi.string(out_json_str[0]))
Ejemplo n.º 3
0
        def __init__(self, flux_handle=None, path='.', handle=None):
            self.handle = None
            if flux_handle is None and handle is None:  # pragma: no cover
                raise ValueError(
                    "flux_handle must be a valid Flux object or handle must be a valid kvsdir cdata pointer")
            if handle is None:
                d = ffi.new("kvsdir_t *[1]")
                _raw.kvs_get_dir(flux_handle, d, path)
                handle = d[0]

            super(self.__class__, self).__init__(ffi, lib,
                                                 handle=handle,
                                                 match=ffi.typeof('kvsdir_t *'),
                                                 prefixes=[
                                                     'kvsdir_',
                                                 ], )
Ejemplo n.º 4
0
        def __init__(self, flux_handle=None, path='.', handle=None):
            super(self.__class__, self).__init__(ffi, lib,
                                                 handle=handle,
                                                 match=ffi.typeof('kvsdir_t *'),
                                                 prefixes=[
                                                     'kvsdir_',
                                                 ],
                                                 destructor=_raw.kvsdir_destroy)

            if flux_handle is None and handle is None:  # pragma: no cover
                raise ValueError(
                    "flux_handle must be a valid Flux object or handle must be a valid kvsdir cdata pointer")
            if handle is None:
                d = ffi.new("kvsdir_t *[1]")
                _raw.kvs_get_dir(flux_handle, d, path)
                self.handle = d[0]
                if self.handle is None or self.handle == ffi.NULL:
                    raise EnvironmentError("No such file or directory")
Ejemplo n.º 5
0
        def __init__(self, flux_handle=None, path='.', handle=None):
            self.handle = None
            if flux_handle is None and handle is None:  # pragma: no cover
                raise ValueError(
                    "flux_handle must be a valid Flux object or handle must be a valid kvsdir cdata pointer"
                )
            if handle is None:
                d = ffi.new("kvsdir_t *[1]")
                _raw.kvs_get_dir(flux_handle, d, path)
                handle = d[0]

            super(self.__class__, self).__init__(
                ffi,
                lib,
                handle=handle,
                match=ffi.typeof('kvsdir_t *'),
                prefixes=[
                    'kvsdir_',
                ],
            )