def __init__( self, flux_handle, type_mask, callback, topic_glob="*", match_tag=flux.constants.FLUX_MATCHTAG_NONE, args=None, ): self.flux_handle = flux_handle self.callback = callback self.args = args self.wargs = ffi.new_handle(self) c_topic_glob = ffi.new("char[]", topic_glob) match = ffi.new( "struct flux_match *", { "typemask": type_mask, "matchtag": match_tag, "topic_glob": c_topic_glob }, ) super(MessageWatcher, self).__init__( raw.flux_msg_handler_create(self.flux_handle.handle, match[0], message_handler_wrapper, self.wargs))
def __init__( self, flux_handle, type_mask, callback, topic_glob="*", match_tag=flux.constants.FLUX_MATCHTAG_NONE, args=None, ): self.callback = callback self.args = args self.wargs = ffi.new_handle(self) if topic_glob is None or topic_glob == ffi.NULL: topic_glob = ffi.NULL elif isinstance(topic_glob, str): topic_glob = topic_glob.encode("UTF-8") elif not isinstance(topic_glob, bytes): errmsg = "Topic must be a string, not {}".format(type(topic_glob)) raise TypeError(errno.EINVAL, errmsg) c_topic_glob = ffi.new("char[]", topic_glob) match = ffi.new( "struct flux_match *", {"typemask": type_mask, "matchtag": match_tag, "topic_glob": c_topic_glob}, ) super(MessageWatcher, self).__init__( flux_handle, raw.flux_msg_handler_create( flux_handle.handle, match[0], lib.message_handler_wrapper, self.wargs, ), )
def __init__( self, flux_handle, type_mask, callback, topic_glob="*", match_tag=flux.constants.FLUX_MATCHTAG_NONE, args=None, ): self.flux_handle = flux_handle self.callback = callback self.args = args self.wargs = ffi.new_handle(self) if topic_glob is None or topic_glob == ffi.NULL: topic_glob = ffi.NULL elif isinstance(topic_glob, six.text_type): topic_glob = topic_glob.encode("UTF-8") elif not isinstance(topic_glob, six.binary_type): errmsg = "Topic must be a string, not {}".format(type(topic_glob)) raise TypeError(errno.EINVAL, errmsg) c_topic_glob = ffi.new("char[]", topic_glob) match = ffi.new( "struct flux_match *", {"typemask": type_mask, "matchtag": match_tag, "topic_glob": c_topic_glob}, ) super(MessageWatcher, self).__init__( raw.flux_msg_handler_create( self.flux_handle.handle, match[0], message_handler_wrapper, self.wargs ) )
def get_str(self): # pylint: disable=duplicate-code resp_str = ffi.new("char *[1]") self.pimpl.get(resp_str) if resp_str[0] == ffi.NULL: return None return ffi.string(resp_str[0]).decode("utf-8")
def payload_str(self): s = ffi.new('char *[1]') if self.pimpl.has_payload(): self.pimpl.get_json(ffi.cast('char**', s)) return ffi.string(s[0]) else: return None
def payload_str(self): s = ffi.new('char *[1]') if self.pimpl.has_payload(): self.pimpl.get_payload_json(ffi.cast('char**', s)) return ffi.string(s[0]) else: return None
def __init__(self, flux_handle, type_mask, callback, topic_glob='*', match_tag=flux.FLUX_MATCHTAG_NONE, args=None): self.handle = None self.fh = flux_handle self.cb = callback self.args = args self.wargs = ffi.new_handle(self) c_topic_glob = ffi.new('char[]', topic_glob) match = ffi.new('struct flux_match *', { 'typemask': type_mask, 'matchtag': match_tag, 'topic_glob': c_topic_glob, }) self.handle = raw.flux_msg_handler_create(self.fh.handle, match[0], message_handler_wrapper, self.wargs)
def __init__(self, flux_handle, type_mask, callback, topic_glob='*', match_tag=flux.FLUX_MATCHTAG_NONE, bsize=0, args=None): self.handle = None self.fh = flux_handle self.cb = callback self.args = args wargs = ffi.new_handle(self) c_topic_glob = ffi.new('char[]', topic_glob) match = ffi.new('struct flux_match *', { 'typemask': type_mask, 'matchtag': match_tag, 'bsize': bsize, 'topic_glob': c_topic_glob, }) self.handle = raw.flux_msg_watcher_create(match[0], message_handler_wrapper, wargs)
def __init__(self, flux_handle, type_mask, callback, topic_glob='*', match_tag=flux.constants.FLUX_MATCHTAG_NONE, args=None): self.flux_handle = flux_handle self.callback = callback self.args = args self.wargs = ffi.new_handle(self) c_topic_glob = ffi.new('char[]', topic_glob) match = ffi.new('struct flux_match *', { 'typemask': type_mask, 'matchtag': match_tag, 'topic_glob': c_topic_glob, }) super(MessageWatcher, self).__init__( raw.flux_msg_handler_create( self.flux_handle.handle, match[0], message_handler_wrapper, self.wargs))
def strtostate(args): state = ffi.new("flux_job_state_t [1]") if not args.strings: args.strings = [line.strip() for line in sys.stdin] for s in args.strings: try: raw.flux_job_strtostate(s, state) except Exception: print(f"invalid string {s}") sys.exit(1) print(int(state[0]))
def strtoresult(args): result = ffi.new("flux_job_result_t [1]") if not args.strings: args.strings = [line.strip() for line in sys.stdin] for s in args.strings: try: raw.flux_job_strtoresult(s, result) except Exception: print(f"invalid string {s}") sys.exit(1) print(int(result[0]))
def topic(self): s = ffi.new('char *[1]') self.pimpl.get_topic(s) return ffi.string(s[0])
def get_str(self): payload_str = ffi.new("char *[1]") self.pimpl.flux_rpc_get(payload_str) if payload_str[0] == ffi.NULL: return None return ffi.string(payload_str[0]).decode("utf-8")
def payload_str(self): string = ffi.new("char *[1]") if self.pimpl.has_payload(): self.pimpl.get_string(ffi.cast("char**", string)) return ffi.string(string[0]).decode("utf-8") return None
def topic(self): topic_string = ffi.new("char *[1]") self.pimpl.get_topic(topic_string) return ffi.string(topic_string[0]).decode("utf-8")
def get_nodeid(self): nodeid = ffi.new("uint32_t [1]") self.pimpl.get_nodeid(nodeid) return int(nodeid[0])
def type(self): message_type = ffi.new("int [1]") self.pimpl.get_type(message_type) return message_type[0]
def get_str(self): j_str = ffi.new('char *[1]') self.pimpl.get(j_str) return ffi.string(j_str[0])
def topic(self): topic_string = ffi.new('char *[1]') self.pimpl.get_topic(topic_string) return ffi.string(topic_string[0])
def get_str(self): j_str = ffi.new("char *[1]") self.pimpl.get(j_str) if j_str[0] == ffi.NULL: return None return ffi.string(j_str[0]).decode("utf-8")
def type(self): s = ffi.new('int [1]') self.pimpl.get_type(s) return s[0]