License / Documentation home / Help and feedback |
The following demos contain Python server examples. All examples can be found in the python/ subdirectory of these demos:
The Python versions in these examples are, to the greatest extent possible, exact parallels of the C versions, so you can study the two versions side by side.Among the major differences from the C bindings are:
import Galaxy# {c output :output_string "hello" }
f = Galaxy.Frame("output", Galaxy.GAL_CLAUSE)
f[":output_string"] = "hello"# or
f = Galaxy.Frame("output", Galaxy.GAL_CLAUSE, {":output_string": "hello"})
# {c listframe :list ( 5 6 7 ) }
f = Galaxy.Frame("listframe", Galaxy.GAL_CLAUSE)
f[":list"] = [5, 6, 7]# or
f = Galaxy.Frame("listframe", Galaxy.GAL_CLAUSE, {":list": [5, 6, 7]})
import sys, osAlternatively, instead of assuming the presence of GC_HOME in your environment, you could find another way to make the GalaxyCommunicator root directory available to your program.sys.path.insert(0, os.path.join(os.environ["GC_HOME"],
"contrib", "MITRE", "templates"))import GC_py_init
import Galaxy, GalaxyIO, SLSUtil
Each dispatch function takes an environment object and a frame and returns a dictionary or frame. In the case of Python, the call environment is the first argument, so that methods on classes inherited from GalaxyIO.CallEnvironment also have the same signature.
Here's a Python equivalent of the Parse dispatch function:
def Parse(env, frame):Note that we can return a dictionary, instead of a named frame, since the name of the reply is ignored anyway. The dictionary will be coerced into an appropriate reply frame.
input_string = frame[":input_string"]
p = ParseSentence(input_string)
return {":frame": ParseTreeToFrame(p)}
Python doesn't use macros to generate the declaration of dispatch functions or the name and default port information for the server. This is all handled via explicit function calls:
class ParseServer(GalaxyIO.Server):Note that because the dispatch functions are explicitly associated with their names, the name of the function and the name of the message that invokes it can differ.
...s = ParseServer(sys.argv, "Parser", default_port = 10000)
s.AddDispatchFunction("Parse", Parse)
Here's another way to set up your server, by using methods as dispatch functions:
class ParseEnvironment(GalaxyIO.CallEnvironment):You can use the specialized classes for the call environment or for the server to store arbitrary data as instance variables.
def Parse(self, frame):
input_string = frame[":input_string"]
p = ParseSentence(input_string)
return {":frame": ParseTreeToFrame(p)}...
s = ParseServer(sys.argv, "Parser", default_port = 10000,
env_class = ParseEnvironment)
s.AddDispatchFunction("Parse", ParseEnvironment.Parse)
By default, Python servers accept approximately the same set of default arguments as C servers. The differences are:
OAS = [("-increment i", "initial increment")]Note that we check command line arguments by creating a wrapper around the CheckUsage method of the server object. This method returns a dictionary whose keys are the argument names and whose values are a list of elements, as well as a sequence of unanalyzed arguments. If the argument list does not parse (if, for instance, some expected parameters of a given command line argument are missing), the server will exit. Here's a more complex example of an initialization string:# Write a wrapper for the usage check.
class DoubleServer(GalaxyIO.Server):
def CheckUsage(self, oas_list, args):
global InitialIncrement
data, out_args = GalaxyIO.Server.CheckUsage(self, OAS + oas_list, args)
if data.has_key("-increment"):
InitialIncrement = data["-increment"][0]
del data["-increment"]
return data, out_args
OAS = [("-utts utts_file num", "text utterance file for sequencing",The first element is the argument, with spaces delimiting the parameters. The second is a description. Both of these elements are as in the the oa library. The third element, if present, is a sequence of types, and the fourth element, if present, is a sequence of defaults. If there aren't enough types, types.StringType is used; if there is a defaults list but not enough defaults, the appropriate null value is used (0, 0.0, or ""). If the fourth element is present, the return dictionary will contain the defaults if the argument is not present in the arglist.
(types.StringType, types.IntType), (Utterance_File, 0)]
("-stdin", "Read sentences from stdin instead of a file")]
import typesParseError = "ParseError"
def Parse(env, frame):
try:
input_string = frame[":input_string"]
except KeyError:
input_string = None
if (type(input_string) is not type("")):
raise ParseError, "no input string"
p = ParseSentence(input_string)
if not p:
raise ParseError, "no parse"
p_frame = ParseTreeToFrame(p)
if not p_frame:
raise ParseError, "can't convert parse to frame"
return {":frame": p_frame}
def DoGreeting(env, frame):If you want to return no frame to the Hub, you must return None; an empty dictionary will return an empty frame.
s = "{c FromDialogue :output_frame {c greeting } :is_greeting 1 }"
greeting = Galaxy.Frame(str = s)
env.WriteFrame(greeting)
return None
Now, here's the DoDialogue example:
def DoDialogue(env, frame):If the Hub relays an error back to the server, the Python bindings will raise the error locally. The error raised will be GalaxyIO.DispatchError, as shown here.
msg_frame = Galaxy.Frame("DBQuery", Galaxy.GAL_CLAUSE)# ...
msg_frame[":sql_query"] = sql_query
try:
response_frame = env.DispatchFrame(msg_frame)
# Equivalent of GAL_REPLY_MSG_TYPE.
# Construct presentation of database response
# ...
except GalaxyIO.DispatchError:
# Equivalent of GAL_ERROR_MSG_TYPE
# Relay error back to Hub
# ...
Here's the equivalent of the Synthesize dispatch function, exemplifying the source server setup. If the broker setup fails, an error is raised:
def Synthesize(env, frame):Now, here's the setup for the client:
# ...
try:
p = GalaxyIO.BrokerProxyOut(env, 10, type = Galaxy.GAL_INT_16)
output_f = Galaxy.Frame("FromSynthesizer", Galaxy.GAL_FRAME,
{":sample_rate": s.sample_rate,
":encoding_format": s.encoding_format,
":proxy": p})
env.WriteFrame(output_f)
except GalaxyIO.BrokerInitError, m:
# ....
class AudioProxyInStream(GalaxyIO.BrokerProxyInStream):The data exchange works as follows. First, on the source server:
# ...def Play(env, frame):
bp = frame[":proxy"]
p = AudioPkg()# ...
try:
p.in_broker = bp
bp.Unproxify(env, AudioProxyInStream, immediate = 1)
# ...
except GalaxyIO.BrokerInitError, m:
# ...
data = PollSynthesis(s)On the client, it's handled as methods associated with the specialized broker class. The environment is an attribute of the proxy stream:while data:
p.Write(data)
data = PollSynthesis(s)
if SynthesisIsDone(s):
p.DataDone()
class AudioProxyInStream(GalaxyIO.BrokerProxyInStream):The original brokering API is also still available; see the audio example for details of its use.
def HandleObject(self, obj):
print "[Audio data to user (%d samples)]" % len(obj)
def DataDoneCallback(self):
print "[Audio data to user is finalized.]"
Frames, Property Lists, and Typed Objects | |
GalUtil_CPPFrame(sls_verbose_level, fore, back, fr) |
[not implemented] |
GalUtil_CPPObject(sls_verbose_level, fore, back, to) |
[not implemented] |
GalUtil_PPFrame(sls_verbose_level, fr) |
SLSUtil.OStream().write_level(fr.PPrint(), verbose_level) |
GalUtil_PPObject(sls_verbose_level, to) |
SLSUtil.OStream().write_level(Galaxy.OPr(o, PP_TYPE), verbose_level) |
GalUtil_PrObject(sls_verbose_level, to) |
SLSUtil.OStream().write_level(Galaxy.OPr(o), verbose_level) |
GalUtil_PrintObject(gal_verbose_level, to, how) |
SLSUtil.OStream().write_level(Galaxy.OPr(o, how), verbose_level) |
Gal_AddPred(fr, pred) |
fr.preds.append(pred) |
Gal_ArrayObjectAdd(obj, data, size) |
obj = obj + data |
[not implemented; always true] |
|
Gal_BinaryObject(data, size) |
Galaxy.BinaryObject(Galaxy.GAL_BINARY, data) |
Gal_BinarySize(to) |
len(obj) |
Gal_BinaryValue(obj, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_BINARY) |
Gal_Binaryp(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_BINARY |
Gal_ClauseFramep(fr) |
Galaxy.GetDetailedType(fr) == Galaxy.GAL_CLAUSE |
Gal_ClauseValue(to) |
[not implemented] |
Gal_Clausep(obj) |
Galaxy.GetDetailedType(obj) == Galaxy.GAL_CLAUSE |
Gal_ClearPreds(fr) |
fr.preds = [] |
Gal_CopyFrame(fr) |
fr.Copy() |
Gal_CopyObject(obj) |
[not implemented] |
Gal_CreateBinaryObject(data, size, manage_memory) |
Galaxy.BinaryObject(Galaxy.GAL_BINARY, data) |
Gal_CreateFloat32Object(data, num_float_32, manage_memory) |
Galaxy.BinaryObject(Galaxy.GAL_FLOAT_32, data) |
Gal_CreateFloat64Object(data, num_float_64, manage_memory) |
Galaxy.BinaryObject(Galaxy.GAL_FLOAT_64, data) |
Gal_CreateFloatObject(value, manage_memory) |
[not needed] |
Gal_CreateFrameObject(value, manage_memory) |
[not needed] |
Gal_CreateInt16Object(data, num_int_16, manage_memory) |
Galaxy.BinaryObject(Galaxy.GAL_INT_16, data) |
Gal_CreateInt32Object(data, num_int_32, manage_memory) |
Galaxy.BinaryObject(Galaxy.GAL_INT_32, data) |
Gal_CreateInt64Object(data, num_int_64, manage_memory) |
Galaxy.BinaryObject(Galaxy.GAL_INT_64, data) |
Gal_CreateListObject(values, n, free_fn , manage_memory) |
[not needed] |
Gal_CreateProxyObject(p, manage_memory) |
[not needed] |
Gal_CreateStringObject(cp, manage_memory) |
[not needed] |
Gal_CreateVarMapping(num_pairs, ...) |
[not implemented] |
Gal_DelPred(fr, i) |
del f.preds[i] |
Gal_DelPredByName(fr, name) |
p = f.GetPredByName(name); f.preds.remove(p) |
Gal_DelProp(fr, key) |
del f[key] |
Gal_DeletePreds(fr, pred_name) |
[not implemented] |
Gal_DoPreds(fr, pred_fn , caller_data) |
map(pred_fn, fr.preds) |
Gal_DoProperties(fr, prop_fn , caller_data) |
map(prop_fn, fr.items()) |
Gal_FindKey(fr, key_name) |
[not implemented] |
Gal_FindPred(fr, pred_name) |
[not implemented] |
Gal_FindPredParent(frame, name, parent, findpar, nth) |
[not implemented] |
Gal_FindTopic(fr, topic_name) |
[not implemented] |
Gal_Float32Size(to) |
len(o) |
Gal_Float32Value(obj, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_FLOAT_32) |
Gal_Float32p(to) |
Galaxy.GetObjectType(o) == Galaxy.GAL_FLOAT_32 |
Gal_Float64Size(to) |
len(o) |
Gal_Float64Value(obj, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_FLOAT_64) |
Gal_Float64p(to) |
Galaxy.GetObjectType(o) == Galaxy.GAL_FLOAT_64 |
Gal_FloatObject(val) |
[not needed] |
Gal_FloatValue(to) |
Galaxy.ValueWarn(o, Galaxy.GAL_FLOAT) |
Gal_Floatp(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_FLOAT OR type(obj) is types.FloatType |
Gal_FrameEqual(sf1, sf2) |
sf1.Equal(sf2) |
Gal_FrameIsType(fr, type) |
fr.type == type |
Gal_FrameName(fr) |
fr.name |
Gal_FrameNameEq(fr, name) |
fr.name == name |
Gal_FrameNamesEq(fr1, fr2) |
fr1.name == fr2.name |
Gal_FrameObject(val) |
[not needed] |
Gal_FrameValue(to) |
Galaxy.ValueWarn(o, Galaxy.GAL_FRAME) |
Gal_Framep(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_FRAME |
Gal_FreeFrame(fr) |
[not needed] |
Gal_FreeObject(obj) |
[not needed] |
Gal_FreeWrapper(to) |
[not needed] |
Gal_GetBinary(fr, key, size) |
fr.GetValue(key, Galaxy.GAL_BINARY) |
Galaxy.GetDetailedType(o) | |
Gal_GetFloat(fr, key) |
fr.GetValue(key, Galaxy.GAL_FLOAT) |
Gal_GetFloat32(fr, key, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_FLOAT_32) |
Gal_GetFloat64(fr, key, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_FLOAT_64) |
Gal_GetFrame(fr, key) |
fr.GetValue(key, Galaxy.GAL_FRAME) |
Gal_GetFrameType(fr) |
fr.type |
Gal_GetInt(fr, key) |
fr.GetValue(key, Galaxy.GAL_INT) |
Gal_GetInt16(fr, key, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT_16) |
Gal_GetInt32(fr, key, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT_32) |
Gal_GetInt64(fr, key, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT_64) |
Gal_GetList(fr, key, length) |
fr.GetValue(key, GAL_LIST) |
Gal_GetListObject(obj, n) |
obj[n] |
Gal_GetListValue(to, n, type) |
Galaxy.ValueWarn(o[n], type) |
Gal_GetObject(fr, key) |
fr[key] |
Galaxy.GetObjectType(o) | |
Galaxy.ObjectTypeString(Galaxy.GetObjectType(o)) | |
Gal_GetPred(fr, i) |
fr.preds[i] |
Gal_GetPredByName(fr, name) |
fr.GetPredByName(name) |
Gal_GetProperties(fr, nkeys) |
fr.keys() |
Gal_GetProxy(fr, key) |
fr.GetValue(key, Galaxy.GAL_PROXY) |
Gal_GetString(fr, key) |
fr.GetValue(key, Galaxy.GAL_STRING) |
Gal_GetTopicFrame(fr, key) |
[not implemented] |
Gal_Int16Size(to) |
len(o) |
Gal_Int16Value(obj, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT_16) |
Gal_Int16p(to) |
Galaxy.GetObjectType(o) == Galaxy.GAL_INT_16 |
Gal_Int32Size(to) |
len(o) |
Gal_Int32Value(obj, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT_32) |
Gal_Int32p(to) |
Galaxy.GetObjectType(o) == Galaxy.GAL_INT_32 |
Gal_Int64Size(to) |
len(o) |
Gal_Int64Value(obj, size) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT_64) |
Gal_Int64p(to) |
Galaxy.GetObjectType(o) == Galaxy.GAL_INT_64 |
Gal_IntObject(val) |
[not needed] |
Gal_IntValue(to) |
Galaxy.ValueWarn(obj, Galaxy.GAL_INT) |
Gal_Intp(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_INT OR type(obj) is types.IntType |
Gal_ListLength(obj) |
len(obj) |
Gal_ListObject(values, n) |
[not needed] |
Gal_ListObjectAdd(obj, elt) |
obj.append(elt) |
[not needed; always true] |
|
Gal_ListObjectFromElements(n, ...) |
[not needed] |
Gal_ListValue(obj, n) |
Galaxy.ValueWarn(obj, Galaxy.GAL_LIST) |
Gal_Listp(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_LIST OR type(obj) is types.ListType |
Gal_MakeClauseFrame(name) |
Galaxy.Frame(name = name, type = Galaxy.GAL_CLAUSE) |
Gal_MakeFrame(name, type) |
Galaxy.Frame(name = name, type = type) |
Gal_MakePredFrame(name) |
Galaxy.Frame(name = name, type = Galaxy.GAL_PRED) |
Gal_MakeTopicFrame(name) |
Galaxy.Frame(name = name, type = Galaxy.GAL_TOPIC) |
Gal_MatchFrame(sf1, sf2) |
[not implemented] |
Gal_MatchKeyValue(fr, key_name, match) |
[not implemented] |
len(fr) | |
Gal_NumPreds(fr) |
len(fr.preds) |
len(fr) | |
Gal_ObjectByteCount(obj) |
[not implemented] |
Gal_ObjectCaseEqual(obj1, obj2) |
Galaxy.ObjectEqual(obj1, obj2, ignore_case = 1) |
Gal_ObjectEqual(obj1, obj2) |
Galaxy.ObjectEqual(obj1, obj2) |
Galaxy.OPr(o) | |
Gal_ObjectTypeString(object_type) |
Galaxy.ObjectTypeString(object_type) |
Gal_OutlineFrame(fr, sls_verbose_level) |
[not implemented] |
Gal_OutlineObject(to, sls_verbose_level) |
[not implemented] |
Gal_PPFrame(fr) |
print fr.PPrint() OR fr.PP() |
Gal_PPFrameToFile(fr, fp) |
fp.write(fr.PPrint()) |
Gal_PPFrameToString(fr, buf, bufsizeptr) |
fr.PPrint() |
Gal_PPObject(to) |
print Galaxy.OPr(o, Galaxy.PP_TYPE) |
Gal_PPObjectToFile(to, fp) |
fp.write(Galaxy.OPr(o, Galaxy.PP_TYPE)) |
Gal_PrFrame(fr) |
print fr.Print() OR f.rPr() |
Gal_PrFrameToFile(fr, fp) |
fp.write(fr.Print()) |
Gal_PrFrameToString(fr, buf, bufsizeptr) |
fr.Print() |
Gal_PrObject(obj) |
print Galaxy.OPr(obj) OR Galaxy.PrObject(obj) |
Gal_PrObjectToFile(obj, fp) |
fp.write(Galaxy.OPr(obj)) |
Gal_PredFramep(fr) |
Galaxy.GetDetailedType(obj) == Galaxy.GAL_PRED |
Gal_PredValue(to) |
[not implemented] |
Gal_Predp(obj) |
Galaxy.GetDetailedType(obj) == Galaxy.GAL_PRED |
Gal_PrintFrameToFile(fr, fp, how) |
fp.write(fr._Print(how)) |
Gal_PrintFrameToString(fr, irpbuf, bufsizeptr, how) |
fr._Print(how) |
[not needed] |
|
[not implemented] |
|
obj.obj (only for outbound proxies) |
|
Gal_ProxyObjectType(obj) |
obj.type |
Galaxy.ValueWanr(o, Galaxy.GAL_PROXY) |
|
Gal_Proxyp(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_PROXY |
[not implemented] | |
Galaxy.Frame(str = buf) | |
[not implemented] | |
Galaxy._read_irp_value(buf) | |
Gal_ReadVarFrameFromString(buf, map) |
[not implemented] |
Gal_ReadVarObjectFromString(buf, map) |
[not implemented] |
Gal_RemPred(fr, i) |
p = fr.preds[i]; del fr.preds[i]; return p |
Gal_RemPredByName(fr, name) |
p = fr.GetPredByName(name); fr.preds.remove(p); return p |
Gal_RemProp(fr, key) |
p = fr[key]; del fr[key]; return p |
Gal_SetFrameName(fr, name) |
fr.name = name |
Gal_SetFrameType(fr, type) |
fr.type = type |
Gal_SetListObject(obj, n, elt) |
obj[n] = elt |
Gal_SetProp(fr, key, obj) |
fr[key] = obj |
Gal_StringObject(val) |
[not needed] |
Gal_StringValue(to) |
Galaxy.ValueWarn(obj, Galaxy.GAL_STRING) |
Gal_Stringp(obj) |
Galaxy.GetObjectType(obj) == Galaxy.GAL_STRING OR type(obj) is types.StringType |
Gal_TopicFramep(fr) |
Galaxy.GetDetailedType(obj) == Galaxy.GAL_TOPIC |
Gal_TopicValue(to) |
[not implemented] |
Gal_Topicp(obj) |
Galaxy.GetDetailedType(obj) == Galaxy.GAL_TOPIC |
Gal_VAReadVarFrameFromString(buf, num_pairs, ...) |
[not implemented] |
Gal_VAReadVarObjectFromString(buf, num_pairs, ...) |
[not implemented] |
_gal_free_object(obj) |
[not needed] |
Building a Communicator-Compliant Server | |
GalIO_GetError(f, err_desc) |
[not needed; just catch GalaxyIO.DispatchError] |
GalSS_AddDispatchFunction(i, name, fn, in_key_array, allow_other_in_keys, reply_provided, out_key_array, allow_other_out_keys) |
i.AddDispatchFunction(...) |
env.DestroyToken() | |
GalSS_EnvDispatchFrame(env, frame, t) |
env.DispatchFrame(frame) |
GalSS_EnvError(env, description) |
[not needed; just raise an error] |
GalSS_EnvGetClientData(env, name) |
[not needed; use instance attributes] |
GalSS_EnvGetCommData(env) |
[not needed; use instance attributes] |
GalSS_EnvReply(env, f) |
env.Reply(f) |
GalSS_EnvSetCommData(env, data, free_fn ) |
[not needed; use instance attributes] |
GalSS_EnvWriteFrame(env, frame, do_block) |
env.WriteFrame(frame) |
GalSS_InitializeServerDefaults(scomm, name, port) |
[not implemented] |
Gal_CreateDispatchFnKeyArray(ignore, ...) |
[not needed] |
Gal_FreeDispatchFnKeyArray(entry) |
[not needed] |
_GalSS_InitializeDefaults(scomm) |
[not needed; provided to scomm during initialization] |
_GalSS_init_server(server, argc, argv) |
[not needed; perform operations after initialization and before starting server] |
_GalSS_print_usage(argc, argv) |
[not implemented] |
Brokering and Audio Data | |
b.DataDone() | |
GalIO_BrokerDataInInit(host, port, frame, fnptr, caller_data, poll_ms) |
[not implemented] |
b.DataDone() | |
GalIO_BrokerDataOutInit(gcomm, poll_ms, timeout_seconds) |
b = GalaxyIO.BrokerDataOut(gcomm, timeout_seconds) |
[not implemented] | |
GalIO_BrokerPopulateFrame(b, f, host_key, port_key) |
b.PopulateFrame(f, host_key, port_key) |
GalIO_BrokerSetFinalizer(b, finalizer) |
[not implemented] |
GalIO_BrokerStructDequeue(b, bqueue) |
[not needed; no broker queues in Python] |
GalIO_BrokerStructQueueAppend(b, bqueue) |
[not needed; no broker queues in Python] |
GalIO_BrokerStructQueuePop(bqueue) |
[not needed; no broker queues in Python] |
GalIO_BrokerWriteBinary(b, data, n_bytes) |
b.Write(data) |
GalIO_BrokerWriteFloat(b, f) |
b.Write(f) |
GalIO_BrokerWriteFloat32(b, data, n_floats) |
b.Write(data) |
GalIO_BrokerWriteFloat64(b, data, n_floats) |
b.Write(data) |
GalIO_BrokerWriteFrame(b, frame) |
b.Write(f) |
GalIO_BrokerWriteInt(b, i) |
b.Write(i) |
GalIO_BrokerWriteInt16(b, data, n_ints) |
b.Write(data) |
GalIO_BrokerWriteInt32(b, data, n_ints) |
b.Write(data) |
GalIO_BrokerWriteInt64(b, data, n_ints) |
b.Write(data) |
GalIO_BrokerWriteList(b, elts, n_elts) |
b.Write(elts) |
GalIO_BrokerWriteObject(b, o) |
b.Write(o) |
GalIO_BrokerWriteString(b, str) |
b.Write(s) |
GalIO_CommBrokerDataInInit(host_gcomm, host, port, frame, fnptr, poll_ms, caller_data, caller_data_free_fn ) |
b = GalaxyIO.BrokerDataIn(host_gcomm, host, port, frame) |
GalIO_CommStartBroker(gcomm, b, poll_ms) |
[not needed[ |
[not implemented] | |
GalIO_FrameSetBrokerCallID(f, call_id) |
[not implemented] |
b.call_id | |
[not needed; use instance attributes] | |
[not needed; use instance attributes] | |
[not implemented] | |
b.port | |
GalaxyIO.IPAddress() | |
[not needed; no broker queues in Python] | |
GalIO_SetBrokerData(b, caller_data, free_fn ) |
[not needed; use instance attributes] |
b.env | |
[not implemented] |
|
bp.obj |
|
bp.type |
|
GalSS_BrokerSetEnvironment(b, env) |
[not needed; pass environment to BrokerDataIn] |
[not implemented] |
|
GalSS_CreateBrokerProxy(host, port, call_id, object_type, obj_data) |
[not implemented] |
GalSS_EnvBrokerDataInInit(env, host, port, frame, fnptr, poll_ms, refptr, free_fn ) |
b = GalaxyIO.BrokerDataIn(env, host, port, frame) |
GalSS_EnvBrokerProxyInInit(env, p, fnptr, poll_ms, refptr, free_fn ) |
b = GalaxyIO.BrokerDataIn(env, proxy = p) |
GalSS_EnvBrokerProxyObjInInit(env, proxy, fnptr, poll_ms, refptr, free_fn ) |
b = GalaxyIO.BrokerDataIn(env, proxy = p) |
GalSS_EnvStartBroker(env, b, poll_ms) |
[not needed] |
bp.Expire() |
|
[not needed] |
|
[not implemented] |
|
GalSS_ObjProxifyObject(env, obj, poll_ms, timeout_seconds) |
b = GalaxyIO.BrokerProxyOut(env, timeout_seconds, obj = obj) |
GalSS_ObjProxifyObjectType(env, t, poll_ms, timeout_seconds) |
b = GalaxyIO.BrokerProxyOut(env, timeout_seconds, type = t) |
GalSS_ObjProxyArrayAdd(obj, data, size) |
obj.Write(data) |
GalSS_ObjProxyDone(obj) |
obj.DataDone() |
GalSS_ObjProxyListAdd(obj, elt) |
obj.Write(elt) |
obj.SelfTerminates() |
|
GalSS_ObjProxyWrite(proxy_obj, obj, manage_memory) |
proxy_obj.Write(obj) |
GalSS_ObjUnproxify(env, obj, fn, done_fn, abort_fn, immediate, poll_ms, caller_data, caller_data_free_fn ) |
obj.Unproxify(env, immediate = immediate, proxy_stream_type =
<class w/callbacks>) |
GalSS_ObjUnproxifyObject(env, obj) |
obj.UnproxifyObject(env) |
GalSS_ProxifyObject(env, obj, poll_ms, timeout_seconds) |
b = GalaxyIO.BrokerProxyOut(env, timeout_seconds, obj = obj) |
GalSS_ProxifyObjectType(env, t, poll_ms, timeout_seconds) |
b = GalaxyIO.BrokerProxyOut(env, timeout_seconds, type = t) |
GalSS_ProxyArrayAdd(p, data, size) |
p.Write(data) |
p.DataDone() |
|
GalSS_ProxyListAdd(p, elt) |
p.Write(elt) |
p.SelfTerminates() |
|
GalSS_ProxyWrite(p, obj, manage_memory) |
pj.Write(obj) |
GalSS_Unproxify(env, p, fn, done_fn, abort_fn, immediate, poll_ms, caller_data, caller_data_free_fn ) |
p.Unproxify(env, immediate = immediate, proxy_stream_type = <class
w/callbacks>) |
GalSS_UnproxifyObject(env, p) |
p.UnproxifyObject(env) |
Server Architecture | |
GalIO_AddBrokerCallback(b, callback_event, fn, callback_data) |
b.AddCallback(callback_event, fn) |
GalIO_AddConnectionBrokerCallback(gcomm, callback_event, connect_callback, callback_data) |
[not needed; specialize __init__ method] |
GalIO_AddConnectionCallback(gcomm, callback_event, connect_callback, callback_data) |
[not implemented] |
GalIO_AddConnectionDispatchFnCallback(gcomm, dispatch_callback, callback_data) |
[not implemented] |
GalIO_AddServerCallback(scomm, callback_event, fn, callback_data) |
[not implemented] |
GalIO_AddServerConnectCallback(scomm, connect_callback, callback_data) |
[not implemented] |
GalIO_CommValidating(gcomm) |
gcomm.Validating() |
GalIO_CommWriteFrame(gcomm, frame, do_block) |
gcomm.WriteFrame(frame) |
GalIO_ContactHub(host, port, scomm, session_id, client_poll_flags) |
[not implemented] |
GalIO_DigestServerLocations(client_pair_string) |
[not implemented] |
GalIO_DispatchViaHub(gcomm, frame, msg_type_ptr) |
gcomm.DispatchFrame(frame) |
scomm.EnableValidation() | |
GalIO_GetCommClientData(gcomm, name) |
[not needed; use instance attributes] |
GalIO_GetCommData(gcomm) |
[not needed; use instance attributes] |
GalIO_GetCommServerData(gcomm) |
[not needed; use instance attributes] |
GalIO_GetCommServerName(gcomm) |
gcomm.server.ServerName() |
GalIO_GetServerClientData(server, name) |
[not needed; use instance attributes] |
GalIO_GetServerData(scomm) |
[not needed; use instance attributes] |
GalIO_GetServerDefaultPort(scomm) |
[not implemented] |
GalIO_GetServerListenPort(scomm) |
scomm.ListenPort() |
GalIO_GetServerLocations(scomm) |
[not implemented] |
scomm.MaxConnections() | |
GalIO_GetServerName(scomm) |
scomm.ServerName() |
len(scomm.conns) | |
GalIO_GetUniqueConnection(scomm) |
[not implemented] |
GalIO_NthHostAndPort(locs, i, port) |
[not implemented] |
GalIO_NumServerLocations(locs) |
[not implemented] |
GalIO_OperateOnConnections(scomm, arg, op ) |
map(op, scomm.conns.values()) |
GalIO_RemoveBrokerCallback(b, cb) |
[not implemented] |
GalIO_RemoveConnectionCallback(gcomm, cb) |
[not implemented] |
GalIO_RemoveServerCallback(scomm, cb) |
[not implemented] |
GalIO_ServerListenStatus(scomm) |
[not implemented] |
GalIO_ServerSessionID(scomm) |
[not implemented] |
GalIO_ServerUsesTimedTasks(server) |
[not implemented; polling by select] |
GalIO_SetCommClientData(gcomm, name, client_data) |
[not needed; use instance attributes] |
GalIO_SetCommData(gcomm, data, free_fn ) |
[not needed; use instance attributes] |
GalIO_SetServerClientData(server, name, client_data) |
[not needed; use instance attributes] |
GalIO_SetServerData(scomm, data, free_fn ) |
[not needed; use instance attributes] |
GalIO_SetServerDefaultPort(scomm, port) |
[not implemented] |
GalIO_SetServerMaxConnections(scomm, max) |
scomm.MaxConnections(max) |
GalIO_SetServerName(scomm, name) |
scomm.ServerName(name) |
GalSS_CmdlineInitializeServer(argc, argv) |
[not implemented] |
GalSS_CmdlineSetupServer(argc, argv) |
[not implemented] |
GalSS_CmdlineSetupServerForHubContact(argc, argv, client_string_ptr, session_id_ptr, allow_listener, client_poll_flags, loop_type) |
[not implemented] |
[not needed] | |
GalSS_EnvComm(env) |
env.conn |
GalSS_ExtractCmdlineServerArgs(arg_pkg, argc, argv, new_argc_ptr, new_argv_ptr) |
[not needed] |
GalSS_ExtractServerArgs(argc, argv, new_argc_ptr, new_argv_ptr) |
[not needed] |
GalSS_FreeArgPkg(arg_pkg) |
[not needed] |
GalSS_FreeArgv(argc, argv) |
[not needed] |
GalSS_InitializeServer(server_port, max_conns, use_color, do_assert, use_ttloop, validate, new_argc, new_argv) |
[not implemented] |
GalSS_InitializeServerFromServerArgs(arg_pkg, new_argc, new_argv) |
[not implemented] |
GalSS_InitializeServerToplevel(server_port, max_conns, use_color, do_assert, loop_type, validate, verbosity, server_listen_status, client_pair_string, session_id, new_argc, new_argv) |
[not implemented] |
GalSS_RunServer(server) |
[not implemented] |
GalSS_SAFixAssert(arg_pkg, assert) |
[not implemented] |
GalSS_SAFixColor(arg_pkg, color) |
[not implemented] |
GalSS_SAFixContactHubInfo(arg_pkg, client_pair_status, session_id, old_session_id_ptr) |
[not implemented] |
GalSS_SAFixLoopType(arg_pkg, loop_type) |
[not implemented] |
GalSS_SAFixMaxConns(arg_pkg, max_conns) |
[not implemented] |
GalSS_SAFixPort(arg_pkg, port) |
[not implemented] |
GalSS_SAFixServerListenStatus(arg_pkg, server_listen_status) |
[not implemented] |
GalSS_SAFixServerLocations(arg_pkg, server_locations_file) |
[not implemented] |
GalSS_SAFixValidate(arg_pkg, validate) |
[not implemented] |
GalSS_SAFixVerbosity(arg_pkg, verbosity) |
[not implemented] |
GalSS_SetupConnection(host, port, retrieved_contact_info, shutdown_after, scomm) |
[not implemented] |
GalSS_SetupEnvironment(host, port, session_id, retrieved_contact, retrieved_session, shutdown_after, scomm) |
[not implemented] |
GalSS_SetupServer(arg_pkg, new_argc, new_argv) |
GalaxyIO.Server(...) |
GalSS_StartAndRunServer(server) |
s.RunServer() |
Synchronous vs. asynchronous interaction and continuations | |
GalSS_EnvDispatchFrameToProviderWithContinuation(env, frame, provider, fn, continuation_state, continuation_state_free_fn ) |
env.DispatchFrameWithContinuation(frame, fn, provider = provider) |
GalSS_EnvDispatchFrameWithContinuation(env, frame, fn, continuation_state, continuation_state_free_fn ) |
env.DispatchFrameWithContinuation(frame, fn) |
[not implemented] |
|
Provider Names and Provider Selection | |
GalSS_EnvDispatchFrameToProvider(env, frame, provider_id, t) |
env.DispatchFrame(frame, provider = provider_id) |
env.GetOriginatingProvider() |
|
GalSS_EnvWriteFrameToProvider(env, frame, provider_id, do_block) |
env.WriteFrame(frame, provider = provider_id) |
Timestamps | |
env.GetTokenTimestamp() |
|
env.InheritTokenTimestamp() |
|
The Timed Task Loop | |
Gal_AddIdleFunction(func, client_data) |
[not implemented] |
Gal_AddTask( task , refcon, num_millisecs, read_blocking_available, cleanup_fn ) |
[not implemented] |
Gal_AddTaskExtended( task , caller_data, num_millisecs, read_blocking_available, read_socket, write_socket, err_socket, read_file, write_file, err_file, condition, cleanup_fn ) |
[not implemented] |
Gal_AddTaskWithFileIO( task , refcon, num_millisecs, read_blocking_available, read_file, write_file, cleanup_fn ) |
[not implemented] |
Gal_AddTaskWithSocketIO( task , refcon, num_millisecs, read_blocking_available, read_socket, write_socket, cleanup_fn ) |
[not implemented] |
Gal_AddTimedTask(task, refcon, num_millisecs) |
[not implemented] |
Gal_AddTimedTaskWithFileIO(task, refcon, num_millisecs, read_file, write_file) |
[not implemented] |
Gal_AddTimedTaskWithSocketIO(task, refcon, num_millisecs, read_socket, write_socket) |
[not implemented] |
[not implemented] | |
Gal_EndTasks(immediate) |
[not implemented] |
Gal_MaybeEndTask(immediate, deferred) |
[not implemented] |
Gal_ReAddTask(p, refcon, num_millisecs, read_blocking_available, cleanup_fn ) |
[not implemented] |
Gal_ReAddTaskExtended(p, caller_data, num_millisecs, read_blocking_available, read_socket, write_socket, err_socket, read_file, write_file, err_file, condition, cleanup_fn ) |
[not implemented] |
Gal_ReAddTaskWithFileIO(p, refcon, num_millisecs, read_blocking_available, read_file, write_file, cleanup_fn ) |
[not implemented] |
Gal_ReAddTaskWithSocketIO(p, refcon, num_millisecs, read_blocking_available, read_socket, write_socket, cleanup_fn ) |
[not implemented] |
Gal_RemoveIdleFunction(func) |
[not implemented] |
Gal_RemoveTask(task_id) |
[not implemented] |
Gal_RemoveTimedTask(task, refcon) |
[not implemented] |
[not implemented] | |
Gal_StartTask(pkg, num_millisecs) |
|
Gal_TaskPkgBlocking(pkg) |
[not implemented] |
Gal_TaskPkgData(pkg) |
[not implemented] |
[not implemented] | |
[not implemented] | |
[not implemented] | |
[not implemented] | |
[not implemented] | |
[not implemented] | |
Managing Session Information | |
env.GetSessionID() | |
GalSS_EnvUpdateSessionID(env, session_id) |
env.UpdateSessionID(session_id) |
Controlling Hub Server and Session Properties from the Server | |
GalIO_AddServiceType(server, stype) |
server.AddServiceType(stype) |
GalIO_ServerModifyProperties(server, new_properties, delete_properties) |
server.ModifyProperties(new_properties, delete_properties) |
GalIO_ServerProperties(server) |
[not implemented] |
GalSS_EnvDeleteServerProperties(env, keys) |
env.ModifyServerProperties(properties_to_delete = keys) |
GalSS_EnvDeleteSessionProperties(env, keys) |
env.ModifySessionProperties(properties_to_delete = keys) |
GalSS_EnvGetServerProperties(env, keys) |
env.GetServerProperties(keys) |
GalSS_EnvGetSessionProperties(env, keys) |
env.GetSessionProperties(keys) |
GalSS_EnvModifyServerProperties(env, properties_to_set, properties_to_delete) |
env.ModifyServerProperties(properties_to_set, properties_to_delete) |
GalSS_EnvModifySessionProperties(env, properties_to_set, properties_to_delete) |
env.ModifySessionProperties(properties_to_set, properties_to_delete) |
GalSS_EnvSetServerProperties(env, properties) |
env.ModifyServerProperties(properties_to_set = properties) |
GalSS_EnvSetSession(env, session_name, lock_info) |
env.SetSession(session_name, lock_info) |
GalSS_EnvSetSessionProperties(env, properties) |
env.ModifySessionProperties(properties_to_set = properties) |
Special Main Loops | |
GalIO_BrokerDataInCallbackHandler(b, read_blocking) |
[not implemented] |
[not implemented] | |
[implemented but not visible] | |
[implemented but not visible] | |
GalIO_CommReadReady(gcomm) |
[implemented but not visible] |
GalIO_CommWriteReady(gcomm) |
[implemented but not visible] |
GalIO_ConnectionCallbackHandler(gcomm, read_blocking) |
[not implemented] |
GalIO_ServerCallbackHandler(scomm, read_blocking, new_conn_ptr) |
[not implemented] |
GalIO_ServerCheckHubContacts(scomm) |
[not implemented] |
[not implemented] |
|
[not implemented] |
|
[not implemented] |
|
[not implemented] |
|
GalSS_ELRBroker(elr) |
[not implemented] |
GalSS_ELRCopy(source) |
[not implemented] |
GalSS_ELRCreate(scomm, timer_set_fn, timer_unset_fn, fd_set_fn, fd_unset_fn, behavior_fn, timer_is_persistent) |
[not implemented] |
GalSS_ELRDestroy(elr) |
[not implemented] |
GalSS_ELRDoCallback(elr, timer_or_fd) |
[not implemented] |
GalSS_ELRGComm(elr) |
[not implemented] |
GalSS_ELRGetLoopData(elr) |
[not implemented] |
GalSS_ELRSComm(elr) |
[not implemented] |
GalSS_ELRSetBrokerInCallback(elr, fn) |
[not implemented] |
GalSS_ELRSetBrokerOutCallback(elr, fn) |
[not implemented] |
GalSS_ELRSetConnectionCallback(elr, fn) |
[not implemented] |
GalSS_ELRSetLoopData(elr, loop_data, loop_data_free_fn ) |
[not implemented] |
GalSS_ELRSetServerClientCallback(elr, fn) |
[not implemented] |
GalSS_ELRSetServerListenerCallback(elr, fn) |
[not implemented] |
GalSS_ELRSetupServer(external_arg_pkg, argc, argv, timer_set_fn, timer_unset_fn, fd_set_fn, fd_unset_fn, behavior_fn, loop_data, loop_data_free_fn , timer_is_persistent) |
[not implemented] |
GalSS_ELRShutdown(elr) |
[not implemented] |
GalSS_ELRUpdatePollIntervals(elr, server_client_poll_ms, conn_ms, broker_ms) |
[not implemented] |
Signal Handling | |
Gal_AddSignalHandler(sig, handler ) |
[not implemented] |
[not implemented] | |
[not implemented] | |
Command Line Argument Parsing and Printing Utilities | |
GalUtil_Assert(truth, format, ...) |
env.ostream.p_assert(truth, msg) |
GalUtil_CPInfo1(fore, back, format, ...) |
[not implemented] |
GalUtil_CPInfo1WithLocation(fn, fore, back, fmt, ...) |
[not implemented] |
GalUtil_CPInfo2(fore, back, format, ...) |
[not implemented] |
GalUtil_CPrint(level, fore, back, format, ...) |
[not implemented] |
GalUtil_CreatePrintPkg(fatal_func, error_func, warn_func, level_func, clevel_func, pinfo1_func, pinfo2_func, cpinfo1_func, cpinfo2_func, debug1_func, debug2_func, client_data) |
[not implemented] |
GalUtil_Debug1(format, ...) |
env.ostream.debug1(msg) |
GalUtil_Debug2(format, ...) |
env.ostream.debug2(msg) |
GalUtil_Error(format, ...) |
env.ostream.error(msg) |
GalUtil_Fatal(format, ...) |
env.ostream.fatal(msg) |
GalUtil_OACheckUsage(argc, argv, oas, first_real_arg) |
GalaxyIO.Server.CheckUsage(scomm, oas, argv) |
GalUtil_OAExtract(argc, argv, oas, key, ...) |
SLSUtil.OAExtract(oas, argv, ostream) |
GalUtil_OAExtractAsserting(argc, argv, oas, key, ...) |
[not implemented] |
GalUtil_OAPrintUsage(argc, argv, oas) |
SLSUtil.OAPrintUsage(oas) |
GalUtil_PInfo1(format, ...) |
env.ostream.pinfo1(msg) |
GalUtil_PInfo1WithLocation(fn, fmt, ...) |
[not implemented] |
GalUtil_PInfo2(format, ...) |
env.ostream.pinfo2(msg) |
GalUtil_PkgAssert(pkg, truth, format, ...) |
[not implemented] |
GalUtil_PkgCPInfo1(pkg, fore, back, format, ...) |
[not implemented] |
GalUtil_PkgCPInfo2(pkg, fore, back, format, ...) |
[not implemented] |
GalUtil_PkgCPrint(pkg, level, fore, back, format, ...) |
[not implemented] |
GalUtil_PkgDebug1(pkg, format, ...) |
[not implemented] |
GalUtil_PkgDebug2(pkg, format, ...) |
[not implemented] |
GalUtil_PkgError(pkg, format, ...) |
[not implemented] |
GalUtil_PkgFatal(pkg, format, ...) |
[not implemented] |
GalUtil_PkgPInfo1(pkg, format, ...) |
[not implemented] |
GalUtil_PkgPInfo2(pkg, format, ...) |
[not implemented] |
GalUtil_PkgPrint(pkg, level, format, ...) |
[not implemented] |
GalUtil_PkgWarn(pkg, format, ...) |
[not implemented] |
GalUtil_Print(level, format, ...) |
env.ostream.write_level(level, msg) |
GalUtil_PrintWithLocation(level, fn, fmt, ...) |
[not implemented] |
GalUtil_SetVerbose(verbose_level) |
env.ostream.set_verbosity(verbose_level) |
[not implemented] | |
[not implemented] | |
GalUtil_Warn(format, ...) |
env.ostream.warn(msg) |
GalUtil_WarnLevelWithLocation(level, fn, fmt, ...) |
[not implemented] |
GalUtil_WarnWithLocation(fn, fmt, ...) |
[not implemented] |
GalUtil_fprintf(fp, fmt, ...) |
[not implemented] |
How to Use the Communicator Library in Arbitrary Executables | |
GalIO_ClientConnect(name, host, port, silent, welcome_frame, reply_frame) |
GalaxyIO.ClientConnection(host, port, welcome_frame) |
[not needed; called when the bindings are loaded] |
License / Documentation home / Help and feedback |