Python UserDevice

Index Home MAE Python Interface > Python Index > Python UserDevice

Module UserDevice
Public Properties
Public Methods
setfield(device, table, field, value)
settext(device, text, style)
write(device, text, style)
writeln(device, text, style)
writewiki(device, text)
addhotspot(device, text, action, cbdata, style)
addhinttext(device, text)
button(device, text, action, cbdata)
format(device, control, on)
newregion(device, newtag, styleName, size)
style(device, styleName)
attention(device, text)
selection(device, value)
chat(device, from, text)
clear(device)
show(device)
hide(device)
newtable(device, tableName, tableType, rows, columns)
newlist(device, name, items)
record(device, recordName, idmap, values, overwrite)
report(device, reportName, table, table_id)
prompt(device, query, value, promptType, xid, style)
select(device, option0, options, xid, selected)
checkbox(device, query, value, xid, style)
textarea(device, text, xid, style, saveLabel)
form(device, formName, vars, xid)
screen(device, name, rows, columns)
scrattr(device, attributes)
scrchar(device, row, column, letter, amount)
setmenu(device, menu, option, command)
unsetmenu(device, menu, option)
setwindow(device, windowName)
unsetwindow(device, windowName)
setindex(device, indexName)
unsetindex(device, indexName)
newsection(device, title, sectionType, newtag)
collapseSection(device)
expandSection(device)
displayImage(device, imageName, image_type, action, cbdata, append)
displayImage(device, image_id, action, cbdata, append)
playAudio(device, audioName)
download(device, query, fileclass, xid)
upload(device, imageName, image_type)
imagelibpre(device, id)
bufimage(device, imageName, image_type, width, height, size, binary, chunk, totalChunks, chunksize, data)
setvar(device, variable, value)
getvar(device, variable, value)
run(device, appname, startParams)
stop(device)
userAccountChange(userId, action, value)
registerApp(appmode, apptype, action, contentInputType, contentOutputType, operations, msgchannel, privatePages)
startraw(device, statusCode, contentType)
writeraw(device, text, isBinary)
closeraw(device)
send(request, params)
simpleEncrypt(text, offset)
simpleEncryptLike(text, likeOtherText)
isSimpleEncrypted(text)
simpleDecrypt(text)
prompt(device, question, prefillAnswer, queryType, cbapp, cbtag, cbdata, style)
select(device, question, choices, cbtag, cbdata, defaultValue)
textarea(device, question, origText, cbtag, cbdata, style, saveButtonLabel)
checkbox(device, question, cbtag, cbdata, defaultValue, style)
form(device, formName, formDefaults, cbtag, cbdata)
run(device, appname, appparams)
download(device, query, cbtag, cbdata, fileclass)
registerMenu(device, menuname, menuoption, action)
registerKey(device, keystroke, action)
registerHotspot(device, region, action)
redirectHotspot(device, region, otherapp)
registerMouse(device, region, action)
registerCommand(device, cmd, cmdparams)
send(request, params)
htmlize(url)
urlize(url)
sendImage(device, iid, errmsg, action, cbdata)
saveToImageLib(device, filename, filetype, filecontent, xid, category)
saveToImageLib(image_id, filename, filetype, filecontent, category)
updateImageLib(image_id)
saveToImageLib(image_id, filecontent)
setImageCategory(image_id, category)
setImageName(image_id, name)
setImageType(image_id, type)
newImage(table, id)
send(request, params)
response(device, xid, text)
chat(device, text)
cmd(device, cmd)
key(device, key)
click(device)
mouse(device, direction, x, y, action, cbdata)
hotspot(device, action, cbdata)
upload(device, fileclass, filetype, imagelibid, xid)
refresh(device)
select(device, value)
online(device, appparams)
withdraw(device)
timeout(device)
send(request, params)
open(name, mode, cbtag, cbdata)
putchar(ioId, c, ioChannel)
write(ioId, text, ioChannel)
write(ioId, data, ioChannel)
seek(ioId, offset, ioChannel)
lock(ioId, exclusive, wait, ioChannel)
unlock(ioId, exclusive, wait, ioChannel)
close(ioId, ioChannel)
fsverify(node, ioChannel)
fsreview(dirResourceId, ioChannel)
fsconfirm(node, size)
fsupdate(node, change, size)
ls(maepath)
stat(maepathandfilename, statbuf)
send(request, params, channel)
send(request, params)
key(device, key, keycode)
redraw(device)
send(request, params)
postNotice(notice)
postComment(comment)
send(request, params)
supervisorConsole(device)
supervisorCommand(cmd, device)
mgmtMetaGet(channel, group)
mgmtMetaGetValue(group, list, status)
mgmtMetaSet(channel, group)
mgmtMetaSetValue(group, list, status)
mgmtGet(channel, group, variable)
mgmtGetValue(group, variable, value, status)
mgmtGetValue(group, variables, status)
mgmtSet(channel, group, variable, value)
supervisorUsersSort(device, header)
supervisorSelectUser(device, row)
mgmtSysAdminUI(device, channel, topic, param)
mgmtOperator(device, channel, topic, param)
mgmtInputResponse(device, channel, cbtag, param, response)
send(request, params)
create(device, name, rows, width, termtype)
redraw(device)
putchar(device, c)
puts(device, text)
setpos(device, y, x)
termchar(device, c, module)
termchar(device, text, module)
newtermtype(device, termtype, module)
setTerminalType(device, termType)
bold(device, mode)
underline(device, mode)
reverse(device, mode)
blinking(device, mode)
color(device, newcolor)
clear(device, area)
delline(device, y, amount)
insline(device, y, amount)
delchar(device, y, x, amount)
inschar(device, y, x, c, amount)
fill(device, y1, x1, y2, x2, c)
move(device, y1, x1, y2, x2, yt, xt, c)
cursor(device, direction, amount)
send(request, params, channel)
send(request, params)
init(argv)
main()
quit(rc, msg)
Class Cache
Public Methods
__init__(self, objType, size)
__del__(self)
add(self, newKey, newOne)
removeKey(self, key)
remove(self, pos)
findPos(self, searchKey, fetchIfMissing)
exists(self, searchKey)
get(self, key)
__getitem__(self, pos)
__len__(self)
Class Datastore
Summary
Public Properties
Public Methods
__init__(self, tableName)
valid(self)
status(self)
statusOK(self)
isOpen(self)
statusMsg(self)
fieldNameToType(self, name)
fieldTypeToName(self, fieldtype)
errorMsg(self, rcToGetMsgFor)
open(self, tableName)
select(self, tableName)
connected(self)
pack(self)
close(self, specifiedTable)
getTableList(self)
addField(self, fieldName, type, size, table, isIndex)
getFieldId(self, fieldName, table)
addFieldEnum(self, fieldName, enumName, enumId, table)
getFieldType(self, fieldName, table)
addRecord(self, data, recno, table)
deleteRecord(self, recno, table)
lockRecord(self, recno, table)
unlockRecord(self, recno, table)
clearField(self, recno, fieldName, table)
setValue(self, recno, fieldName, value, table)
setRecord(self, recno, newValues, table)
getFieldInt(self, recno, fieldName, table)
getFieldString(self, recno, fieldName, table)
getFieldFloat(self, recno, fieldName, table)
getFieldEnumValue(self, recno, fieldName, table)
getRecord(self, recno, fields, table)
getFieldEnumValueAsInt(self, recno, fieldName, table)
queryRecordsEnum(self, fieldName, value, sortby, table)
queryRecords(self, fieldName, value, sortby, table)
queryRecords2(self, criteria, ANDed, sortby, table)
queryExpr(self, expression, fields, sortby, table)
queryAllRecords(self, sortby, table)
queryFieldNames(self, table)
queryFieldIds(self, table)
connect(self)
doCommand(self, cmd, params)
send(self, params)
receive(self)
encodeNewline(self, text)
unencodeNewline(self, text)
Class HashArray
Summary
Using HashArray
Caveats
Public Methods
__init__(self, value, separator)
setProps(self, other)
size(self)
empty(self)
set(self, key, value)
setBool(self, key, value)
unset(self, key)
get(self, key)
getInt(self, key)
getFloat(self, key)
getDouble(self, key)
getBool(self, key)
toString(self, separator)
isHashArray(text)
fromString(self, text, separatorCharacter)
Class ImageLib
Using ImageLib
Public Methods
__init__(self, id)
__init__(self, name, category)
clear(self)
__init__(self, data)
set(self, data)
append(self)
save(self)
toHashArray(self, forDB)
load(self, id)
toString(self)
fromString(self, data)
calcChecksum(self)
getName(self, id)
getHeightWidth(self, id, height, width)
getType(self, id)
find(self, name, category)
Class Image
Summary
Using Image
Graphics Commnds
setSize()
setOrigin()
setWindow()
drawBox()
drawLine()
drawCircle()
drawText()
drawArc()
drawPolygon()
drawPolyline()
Public Methods
__init__(self, group_id, imageName, module)
valid()
Class MAEApp
Summary
Public Methods
__init__(self, programName, appchannels)
Class MAEConn
Summary
Public Properties
Public Methods
__init__(self, host, port)
writeLine(self, text)
read(self)
readCommHub(self, wait, rcLineOnly)
readDB(self, wait, lockoutCallbacks)
readMsg(self, wait, queueOk)
readRpc(self, wait, lockoutCallbacks, queueOk)
readyCommHub(self)
readyDB(self)
readyMsg(self)
readyRpc(self)
msgSize(self)
dbSize(self)
rpcSize(self)
setCommHubCB(self, cb, data)
setDBCB(self, cb, data)
setMsgCB(self, cb, data)
setRpcCB(self, cb, data)
setRpcRespCB(self, cb, data)
getMsgCB(self)
readLine(self, wait, lockoutCallbacks)
processLine(self, line, lockoutCallbacks)
getCmdCount(self)
servicePendingCallbacks(self, includingCommHub)
setDbPrefix(self, prefix)
setMsgPrefix(self, prefix)
setRpcPrefix(self, prefix)
recordLine(self, send, text)
setTap(self, tap)
getTap(self)
tapActive(self)
Class MAEDaemon
Summary
Public Methods
__init__(self, programName, appchannels)
Class MAE
Summary
Public Properties
Public Methods
__init__(self, module, name, channels)
setName(name)
getName()
getInstance()
setDaemon()
setApp()
setUtility()
isDaemon()
isApp()
isUtility()
init()
main()
quit(rc, msg)
dbglog(message)
dbgflush()
toggleDebug()
getBroadcast()
Class MAETask
Summary
Public Properties
Public Methods
__init__()
init()
log(text)
dbglog(message)
dbgflush()
fd()
isCommHub()
suspendable(ok)
isSuspended()
pidUpdate(forcePid)
ok(msg)
degraded(msg)
failed(msg)
done(msg)
setQuit(cbfn)
setSuspend(cbfn)
setResume(cbfn)
setDebug(cbfn)
fork()
process(forever, justone)
openControl(commhubHost)
controlConnect(startIfNoAnswer, hostname)
controlStart(name)
controlStartInstance(name, instanceId)
controlStop(name)
controlSuspend(name)
controlResume(name)
controlStatus(name)
controlInstances(name)
commhubStat(status)
commhubSpokes(node, status)
controlStatusName(status)
controlStatusPid(status)
controlStatusCluster(status)
controlStatusState(status)
controlStatusMsg(status)
controlDebug(name, msg, level)
controlTap(name, msg)
controlNewTask(name, msg)
controlDeleteTask(name, msg)
controlQuit()
controlCommand(cmd)
sayHello(daemon, quitIfNoAnswer)
getCommand(wait)
getTaskControlArgs()
setName(newname)
setInstance(newInstance)
getName()
getInstance()
isInstance()
taskBaseName(taskname)
setAppId(appid)
getAppId()
setType(newtype)
setStatus(msg, state, extra)
setManaged(isManaged)
setDaemon(isDaemon)
isDaemon()
setClusterName(name)
getSystemParameter(parameterName, taskname)
setSystemParameter(parameterName, parameterValue, taskname)
quit(rc, msg)
suspend()
resume()
toggleTap(_unused)
getConfDir()
getLogDir()
setupAt(triggerTime, cbfn, data, triggerLabel)
doAfter(delay, cbfn, data, triggerLabel)
setupPeriodic(seconds, cbfn, data, triggerLabel)
signalRaised()
serviceTimer()
getTimerState()
Class MAEUtility
Summary
Public Methods
__init__(self, programName)
Class Messenger
Summary
Public Properties
Public Methods
__init__(self)
__del__(self)
closeAll()
get(channel)
getChannels()
open(self, channel, persist, cbfn)
send(self, dest, request, data)
sendError(self, dest, errorMessage)
close(self)
cease(self)
mastercb(sock, intext)
Class
Class MgmtClient
Public Methods
__init__(self)
__init__(self, channel)
setChannel(self, newChannel)
getChannel(self)
addFixedGetParameter(self, category, newParam, fixedValue)
addGetParameter(self, category, newParam, getFunction)
addSetParameter(self, category, newParam, setFunction)
getParameter(self, category, qparam)
parameterExists(self, category, qparam, get)
setParameter(self, category, setparam, value)
ensureInit(self)
initIntrinsics(self)
getCategories(self, get)
getNames(self, get, category)
handleMesssage(self, cmdparam)
uptime(self)
incrementInboundRequestCount(self)
incrementInboundBroadcastCount(self)
incrementInputCount(self)
incrementInboundErrorCount(self)
incrementInputErrorCount(self)
Class
Class MsgImage
Summary
Public Methods
__init__(self)
getId(self)
reset(self)
imageCommand(self, msgr, src, iid, image_id, param)
__init__(self)
size(self)
setSize(max_size)
isImageCmd(self, request, param, msgr, src)
addImageLib(self, lib_id)
getImage(self, image_id, deleteAfterGet)
getImageRW(self, image_id)
dumpImageCache(self)
sendImage(self, destination, request, params, image, errmsg, group)
Class
Class PointList
Summary
Public Properties
Public Methods
__init__(self, pt)
getX(self)
getY(self)
getZ(self)
setX(self, value)
setY(self, value)
setZ(self, value)
set(self, newX, newY, newZ)
setPoint(self)
Shift(self)
ShiftXY(self, dx, dy)
ShiftXYZ(self, dx, dy, dz)
ShiftPolar(self, radius, theta)
translate(self)
offsetFrom(self)
distance(self)
distanceXZ(self)
distanceXY(self)
deltax(self)
deltay(self)
deltaz(self)
distancex(self)
distancey(self)
distancez(self)
snapToPrecision(self, precision)
origin(self)
valid(self)
isOrigin(self)
invalidPoint(self)
isInvalid(self)
inclination(self)
azimuth(self)
angleXY(self)
angleXZ(self)
angleZY(self)
angle(self)
same(self, tolerance)
samexy(self, tolerance)
equal(self)
flat(self, tolerance)
rotateRight(self, theta, focus)
rotateCW(self, theta, focus)
rotateLeft(self, theta, focus)
rotateCCW(self, theta, focus)
round(self, accuracy)
midpoint(self, fraction)
__add__(self)
__sub__(self)
__rsub__(self)
__mul__(self)
morphPoints(self, pts, focus, angle, scale)
morphPoint(self, pt, focus, angle, scale)
fromString(self, text)
toString(self)
__init__(self, pts)
fromString(self, text)
toString(self)
Class RemoteService
Summary
Public Properties
Public Methods
__init__(self, service, cbfn, cbdata, timeout)
__del__(self)
lineEncode(text)
lineDecode(text)
call(service, params)
mastercb(sock, text, data)
setError(result, error)
getServiceName(self)
getError(result)
Class Socket
Summary
Public Properties
Public Methods
__init__(self, host, port)
open(self, host, port)
__del__(self)
close(self)
isClosed(self)
eof(self)
fd(self)
getErrno(self)
sleep(self, seconds, useconds, exitOnInterrupt)
isReadReady(self, wait)
isWriteReady(self, wait)
signalRaised(self)
clearSignal(self)
signalLock(self, locked)
writeBytes(self, text)
write(self)
readLine(self, wait, ignoreSignal)
setTcpNoDelay(self, nodelay)
clearErrno(self)
Class Stopwatch
Summary
Public Methods
__init__(self, startImmediately)
start(self)
restart(self)
stop(self)
elapsed(self)
startTime(self)
calcValue(self)
Class StrExt
Summary
Public Properties
Public Methods
split(input, delimiter)
concat(textlist, delimiter)
tokenCount(input, separator)
getTokenAt(input, delimiter, pos, honorEscape)
stripLeading(strToStrip, charsToStrip)
stripLeadingWhitespace(strToStrip)
stripTrailing(strToStrip, charsToStrip)
stripTrailingWhitespace(strToStrip)
stripLeadingTrailing(strToStrip, charsToStrip)
stripLeadingTrailingWhitespace(strToStrip)
startsWith(input, start)
endsWith(input, ending)
trimLeft(text, length)
trimRight(text, length)
trimToken(text, token, trimWhite)
trimQuotedToken(input, token, trimWhite)
trimIfLeading(input, textToTrim)
trimIfTrailing(input, textToTrim)
nextToken(text)
extractToken(text, trimWhite)
nextIdentifier(input, allowClass)
extractIdentifier(input, trimWhite, allowClass)
nextQuotedToken(input, removeQuotes)
extractQuotedToken(input, removeQuotes)
toInt(input)
toFloat(input)
toBool(value)
findAndReplace(input, findThis, replaceWith, startNdx, maxReplacements)
escapeNewline(stringToEscape)
unescapeNewline(stringToUnescape)
Class StringList
Summary
Public Methods
__init__(self, text, separator)
toString(self, separator)
fromString(self, text, separator)
add(self, element)
hasElement(self, element)
contains(self, element)
find(self, element)
remove(self, element)
replace(self, oldtext, newtext, all)
sort(self)
Class Timer
Summary
Public Properties
Class
Class
Class UserDevice
Using UserDevice
Format
Examples
Notes
Public Properties
Public Methods
valid(self)
__init__(self, user_id, pc_id, setting_id, appmode, region, group)
fromString(self, text)
toString(self)
copy(self)
getUserId(self)
getConnectionId(self)
getPlayerId(self)
getSettingId(self)
getAppMode(self)
getServerGroup(self)
getRegion(self)
isDM(self)
isPlayer(self)
isConnection(self)
isUser(self)
setUserId(self, newId)
setConnectionId(self, newId)
setPlayerId(self, newId)
setSettingId(self, newId)
setAppMode(self, newMode)
setServerGroup(self, newGroup)
setRegion(self, newRegion)
clearRegion(self)
setDM(self, yes)
setPC(self, yes)
setUserVariable(self, variable, value)
getUserVariable(self, variable)
getUserVariableInt(self, variable)
pushSettingId(self, newSettingId)
pushPlayerId(self, newPlayerId)
setfield(self, table, field, value)
settext(self, value, tag, style)
write(self, text, tag, style)
writeln(self, text, tag, style)
writewiki(self, text, tag)
addhotspot(self, text, action, cbdata, tag, style)
button(self, text, action, cbdata, tag)
style(self, styleName, tag)
attention(self, text)
record(self, recordName, values, tag, overwrite)
recordTemplate(self, recordName, idmap, values, tag, overwrite)
selection(self, value, tag)
chat(self, fromuser, text)
report(self, reportName, table, table_id, tag)
addRegion(self, tag, styleName, size)
clear(self, tag)
show(self, tag)
hide(self, tag)
setMenu(self, menu, option, action)
unsetMenu(self, menu, option)
setWindow(self, windowName)
unsetWindow(self, windowName)
setIndex(self, indexName)
unsetIndex(self, indexName)
newTable(self, name, tableType, rows, columns)
setTable(self, name)
tableRowColumn(self, row, column)
newSection(self, title, sectionType, tag)
getSection(self, title, tag)
collapseSection(self)
expandSection(self)
rmSection(self, title, tag)
newList(self, name, items)
listItem(self, item_no)
newImage(self, imageName, module)
drawImage(self, image, tag)
addimagehotspot(self, image, action, cbdata, tag)
addhinttext(self, text, tag)
bufferImage(self, imageName, image_type, width, height, size, data, binary)
displayImage(self, image_id, action, cbdata, tag)
playAudio(self, audioName)
upload(self, imageName, image_type)
download(self, query, cbtag, cbdata, fileclass, tag)
downloadImageLib(query, action, cbdata, tag)
registerMenu(menuname, submenuname, action, appmode)
registerKey(keystroke, action, appmode)
registerHotspot(region, action, appmode)
redirectHotspot(region, otherapp, appmode)
registerMouse(region, action, appmode)
registerCommand(cmd, cbdata, appmode)
run(self, appname, params)
webpage(self, url)
quit(self)
logout(self)
query(self, question, prefillAnswer, queryType, cbtag, cbdata, displayTag, style)
queryText(self, question, cbtag, cbdata, displayTag)
queryRoll(self, question, dieRoll, cbtag, cbdata, displayTag)
queryYN(self, question, cbtag, cbdata, displayTag)
queryInt(self, question, cbtag, cbdata, displayTag, prefillAnswer)
querySelection(self, question, choices, cbtag, cbdata, displayTag, defaultValue)
queryCheckbox(self, question, cbtag, cbdata, displayTag, defaultValue, style)
queryTextarea(self, question, origText, cbtag, cbdata, displayTag, style, saveButtonLabel)
queryPassword(self, question, cbtag, cbdata, displayTag, style, prefillAnswer)
form(self, formName, formDefaults, cbtag, cbdata, displayTag)
setQueryCB(newcbfn)
setFormCB(newcbfn)
isQueryCB(messenger, src, dest, request, param)
invalidate()
cleanTag(self, tag)

Module UserDevice

Public Properties

debug_on

Flag: True if debug output should generated, False if not

Default value: 0

programName

The program's name, as known to MAE

Default value: 'programName not set'

dbgf

The file pointer to the debug file

Default value: None

MAX_OFFSET

Default value: 26

cypher

Default value: "OriginalSoftwareWrittenInBasicOnCommodore64,PortedToTurboPascal,ThenPortedToC/C++,AndNowOntoLinuxAndMySQL."

db

Default value: None

TEXT_FONT_SIZE

Default value: 12

svgStartTag

Default value: None

svgEndTag

Default value: None

clientInit

Default value: None

clientSupervisorGUI

Default value: None

clientOperatorGUI

Default value: None

IMAGE_CMDS_PER_BATCH

About 100 Image commands generates about 13K long message

Default value: 100

POINT_PRECISION

Default value: .01

PI

Default value: 3.14159265358979323

INVALID_MAGIC_NUMBER

Default value: -123456

CHUNK_SIZE

When sending raw data, it will be broken down into chunks of this size per message

Default value: 4096


Public Methods

setfield(device, table, field, value)

device

the end-user's device

table

the area with a collection of fields in it

field

the specific field within that area

value

the string to display


Update/Replace the table and field entry with the value provided

Return value: true if sent successfully

settext(device, text, style)

device

the end-user's device

text

the text to put there

style

display style for the text


Replace the display region with the text provided.

Return value: true if sent successfully

write(device, text, style)

device

the end-user's device

text

the text to append

style

display style for the text


Append to the display reagion with the provided text for the user specified

Return value: true if sent successfully

writeln(device, text, style)

device

the end-user's device

text

the text to append

style

display style for the text


Append to the display reagion with the provided text for the user specified, followed by a line break.

Return value: true if sent successfully

writewiki(device, text)

device

the end-user's device

text

the text to append


Convert the text from wiki text (see wiki2doc) and display to the display region.

Return value: true if sent successfully

addhotspot(device, text, action, cbdata, style)

device

the end-user's device

text

the text to append

action

the message keyword to send when user clicks on text (aka request)

cbdata

data to send along with action message

style

the preset way to display the text (color, font, etc)


Append the tagged area with the provided text for the user specified and make it a hot spot that triggers an action.

Return value: true if sent successfully

addhinttext(device, text)

device

the end-user's device

text

the hint text to show the user


Provide hint text to the end-user for the display region. Exact implementation up to the end interface, but it may be to display text when the user hovers over the display region.

Return value: true if sent successfully

button(device, text, action, cbdata)

device

the end-user's device

text

the text on the button

action

the message keyword to send when user clicks on text (aka request)

cbdata

data to send along with action message


Append the tagged area with the provided text on a button for the user on the device specified. When clicked, it triggers a a message with the action and callback data.

format(device, control, on)

device

the end-user's device

control

the UI state keyword to update, e.g. strong, emphasis, bold, italic, underline, color:color

on

flag to say turn the control on or off


DEPRECATED - use style() instead.  Update the current display style state.

Return value: true if sent successfully

newregion(device, newtag, styleName, size)

device

the end-user's device

newtag

the new region's name

styleName

the preset way to display the text (color, font, etc)

size

the number of characters wide for the new region (suggestion)


Create a new display region inside device's current display region.

Return value: true if sent successfully

style(device, styleName)

device

the end-user's device

styleName

the new region's name


Set the named display style for device's current display region.  See the configured properties of the style in the appropriate end-user display type (e.g. usergw uses HTML CSS).

Return value: true if sent successfully

attention(device, text)

device

the end-user's device

text

the text for the user to see


Display a message to get the user's attention.

Return value: true if sent successfully

selection(device, value)

device

the end-user's device

value

the value to show on the selector


When a display region contains a selector, set the active selection to the value provided. If the value is not a valid selection, behavior is undefined.

Return value: true if sent successfully

chat(device, from, text)

device

the end-user's device

from

name of user whom the message is from

text

the message to display


Send a chat message to the end-user's device.

Return value: true if sent successfully

clear(device)

device

the end-user's device


Clear all displayed objects and text from the current display region of the device.

Return value: true if sent successfully

show(device)

device

the end-user's device


Display the objects and text inside the current display region of the device.

Return value: true if sent successfully

hide(device)

device

the end-user's device


Hide the objects and text inside the current display region of the device. Make them non-visible.

Return value: true if sent successfully

newtable(device, tableName, tableType, rows, columns)

device

the end-user's device

tableName

the name of the table

tableType

the type of table, e.g. left, center, right

rows

the number of rows in the table

columns

the number of columns in the table


Create a table display region on the user'd device. It will be setup with the rows and columns specified.  Note that referencing one column more to the right will create that column; and referencing one more row below will create that row.

Return value: true if sent successfully

newlist(device, name, items)

device

the end-user's device

name

the name of the list

items

a count of the expected number of list items (suggestion)


Create a bulleted list that can contains items. Note that adding a list item immediately beyond the end will expand the list.

Return value: true if sent successfully

record(device, recordName, idmap, values, overwrite)

device

the end-user's device

recordName

the record template's name (this corresponds to a file under .../html/record)

idmap

(optional) mapping of template field names to actual ids to use

values

key/value paris of id/values to fill in values in the record

overwrite

flag: true to replace existing display region, false to append


Output a record of information using a templte to map old UI ids to new ones.  For idmap, the key is the old id and the value is the new id

Return value: true if sent successfully

report(device, reportName, table, table_id)

device

the end-user's device

reportName

the name of the report to output

table

the name of the table to ...?

table_id

the id for the table ...?


FUTURE USE.  Output a report of information

Return value: true if sent successfully

prompt(device, query, value, promptType, xid, style)

device

the end-user's device

query

(optional) the question text for the user

value

the default value

promptType

the type of prompt, e.g. text, yn, int, etc.

xid

a transaction id maintained by the calling app (guibroker)

style

the style to use for the query


Present the user with a question and response (text entry) box. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

select(device, option0, options, xid, selected)

device

the end-user's device

option0

The visible question that is the first option on the list - and the default if no value is given.  If the user actually selects this option, the app will be given the value $NA

options

the list of options to show the user.  They key is show; the value is returned as the reply.

xid

a transaction id maintained by the calling app (guibroker)

selected

the selected option


Present the user with a selection of choices.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

checkbox(device, query, value, xid, style)

device

the end-user's device

query

(optional) the question text for the user

value

the default value

xid

a transaction id maintained by the calling app (guibroker)

style

the style to use for the query


Present the user with a selection of choices as checkboxes.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

textarea(device, text, xid, style, saveLabel)

device

the end-user's device

text

the initial text in the box

xid

a transaction id maintained by the calling app (guibroker)

style

the style to use for the query

saveLabel

the label on the button for the user to click on to send the revised text


Present the user with an area to type a lot of text.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

form(device, formName, vars, xid)

device

the end-user's device

formName

the name of the form (relates to .../html/form files)

vars

key/value paris of id/values to fill in default values

xid

a transaction id maintained by the calling app (guibroker)


Present the user with input form template.  The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI).

Return value: true if sent successfully

screen(device, name, rows, columns)

device

the end-user's device

name

the name of the screen for reference

rows

number of rows in the screen

columns

the number of columns in the screen


Create a terminal screen of the specified size on the user's device.

Return value: true if sent successfully

scrattr(device, attributes)

device

the end-user's device

attributes

a comma separated list of styles, e.g. cursor, bold, underline, reverse, red, blue, etc


Set the current terminal screen attributes for the next character(s) to be written.

Return value: true if sent successfully

scrchar(device, row, column, letter, amount)

device

the end-user's device

row

the terminal row

column

the terminal column

letter

a numerical value for the letter to write, e.g. ASCII. Note that letters 0-31 are non-printable.

amount

the number of letters to write out (repeating letters)


Write a character to the terminal screen previously defined at device's display region.

Return value: true if sent successfully

setmenu(device, menu, option, command)

device

the end-user's device

menu

the menu heading that contains menu options

option

the menu option text

command

the request keyword to send to the app


Configure the end-user's device with the menu option under the specified menu.  When the end-user selects it, the specified command will be sent as a message request of the app.

Return value: true if sent successfully

unsetmenu(device, menu, option)

device

the end-user's device

menu

the menu heading that contains menu options

option

the menu option text


Remove the menu option under the specified menu on the end-user's device.

Return value: true if sent successfully

setwindow(device, windowName)

device

the end-user's device

windowName

the name of the window; it appears as the window's title


Configure the end-user's device with a window, titled with the name provided.

Return value: true if sent successfully

unsetwindow(device, windowName)

device

the end-user's device

windowName

the name of the window; it appears as the window's title


Remove/Close the named window from the end-user's device.

Return value: true if sent successfully

setindex(device, indexName)

device

the end-user's device

indexName

the name of the index; it appears as the index's title


Configure the end-user's device with the index (tab).  

Return value: true if sent successfully

unsetindex(device, indexName)

device

the end-user's device

indexName

the name of the index; it appears as the index's title


Remove the named index from the end-user's device.

Return value: true if sent successfully

newsection(device, title, sectionType, newtag)

device

the end-user's device

title

the section title

sectionType

a comma separated list of section qualities, e.g. collabsable, h2, h3

newtag

the tag for the section (must begin with Section_)


Add a section the the UI.  Sections can be manipulated, for example expanded/collapsed.

Return value: true if sent successfully

collapseSection(device)

device

the end-user's device


Collapse the section identified as the current display region.

Return value: true if sent successfully

expandSection(device)

device

the end-user's device


Expand the section identified as the current display region.

Return value: true if sent successfully

displayImage(device, imageName, image_type, action, cbdata, append)

device

the end-user's device

imageName

the Image's name (see Image class)

image_type

the image type, e.g. svg, gif

action

(optional) if specified, then image is a hot spot; when the user clicks on it, a message will be send with this action/request keyword

cbdata

(optional) if an action was specified, then image is a hot spot; when the user clicks on it, a message will be send with this callback data

append

Add the image or replace the contents of the device's current region. Default: false/replace.


Display the referenced buffered image that has already been transferred to display channel. If an action is provided, the image can be clicked on to trigger the action with its callback data.

Return value: true if sent successfully

displayImage(device, image_id, action, cbdata, append)

device

the end-user's device

image_id

the image id from the ImageLib library

action

(optional) if specified, then image is a hot spot; when the user clicks on it, a message will be send with this action/request keyword

cbdata

(optional) if an action was specified, then image is a hot spot; when the user clicks on it, a message will be send with this callback data

append

Add the image or replace the contents of the device's current region. Default: false/replace.


Display the referenced buffered image that has already been transferred to display channel. If an action is provided, the image can be clicked on to trigger the action with its callback data.

Return value: true if sent successfully

playAudio(device, audioName)

device

the end-user's device

audioName

the audio sound's name (or HTML tag, e.g. audio_audioName)


Play the referenced audio sound.  

Return value: true if sent successfully

download(device, query, fileclass, xid)

device

the end-user's device

query

the question/prompt to the user

fileclass

a comma separated list of file types, e.g. html, pdf, svg, etc.

xid

a transaction id maintained by the calling app (guibroker)


Request that the user send the app a file.

Return value: true if sent successfully

upload(device, imageName, image_type)

device

the end-user's device

imageName

the Image's name (see Image class)

image_type

the image type, e.g. svg, gif


Send a file to the end-user's device that has already been transferred to display channel.  

Return value: true if sent successfully

imagelibpre(device, id)

device

the end-user's device

id

the image's id in ImageLib


Pre-fetch and image from ImageLib.  

Return value: true if sent successfully

bufimage(device, imageName, image_type, width, height, size, binary, chunk, totalChunks, chunksize, data)

device

the end-user's device

imageName

the Image's name (see Image class)

image_type

the image type, e.g. svg, gif

width

image width, in pixels

height

image height, in pixels

size

size of image, in bytes

binary

flag set to true if data is binary (hex encoded)

chunk

chunk #, starting at 0, increasing with subsequent chunks

totalChunks

total number of chunks being sent

chunksize

size of this chunk of data, in bytes

data

the data of this chunk


Send a chunk of data to the display chennel (to fit within a message max size).

Return value: true if sent successfully

setvar(device, variable, value)

device

the end-user's device

variable

the end-user device variable to set, e.g. wid (tenant id), pc

value

the new value of the variable


Alter a end-user device built-in variable value.

Return value: true if sent successfully

getvar(device, variable, value)

device

the end-user's device

variable

the end-user device variable to set, e.g. wid (tenant id), pc

value

(output) the current value of the variable


Alter a end-user device built-in variable value.

Return value: true if sent successfully

run(device, appname, startParams)

device

the end-user's device

appname

the app to run

startParams

the initial parameters for running that app (app-specific); note that any XML sub-objects will not pass through to new process - only key/value property pairs


Switch the user from running one app to a different app using the provided parameters.

Return value: true if sent successfully

stop(device)

device

the end-user's device


Stop running the current application.

Return value: true if sent successfully

userAccountChange(userId, action, value)

userId

User datastore's id for user

action

Action to take on user's account, e.g disable

value

Parameter for action, e.g. T, F


Take an action on a user's account.

Return value: true if sent successfully

registerApp(appmode, apptype, action, contentInputType, contentOutputType, operations, msgchannel, privatePages)

appmode

Name of appmode, likely the app's name. All URL's for //site/appmode/ will trigger a message using action below

apptype

type of behavior to remote client: Ux (asynchronous user experience in browser), Direct (synchronous query gets synchronous response), Pipe (streamed data from remote connection is fed to app by line or binary block)

action

name of action to send to app when URL connection established

contentInputType

the expected input content payload. A HTTP simple form POSTing sends form-data; a REST call may send json or xml.

contentOutputType

the default response content payload, e.g. json, xml

operations

a list of HTTP operations allowed. "GET,POST" is typical, but a REST interface may also include PUT, DELETE, or PATCH. The value is a comma separted list.

msgchannel

specify if other than the default channel for the calling app.

privatePages

true if only authenticated users may access, false if public


Register an app mode with UserGW. This captures all URL activity for URLs that begin with that appmode.

Return value: true if sent successfully

startraw(device, statusCode, contentType)

device

the end-user's device

statusCode

disposition status of the connection: 0- Success, 1- Input error, 2- Invalid, 3- Not authorized, 4- Failure (no output

contentType

the output content type, likely json or xml. However a major/minor value is allowed (and passes straight through)


Declare to UserGW that response output is ready to send.

Return value: true if sent successfully

writeraw(device, text, isBinary)

device

the end-user's device

text

the text to send

isBinary

true if text is hexadecimal codes for binary data


Output text to the connection without modifying the text at all.  If the text is binary, it is converted from hex codes to binary before transmission.

Return value: true if sent successfully

closeraw(device)

device

the end-user's device)


Append to the display reagion with the provided text for the user specified

Return value: true if sent successfully

send(request, params)

request

params


simpleEncrypt(text, offset)

text: str

offset: int

Default value: -1


Return str value:

simpleEncryptLike(text, likeOtherText)

text: str

likeOtherText: str


Return str value:

isSimpleEncrypted(text)

text: str


Return bool value:

simpleDecrypt(text)

text: str


Return str value:

prompt(device, question, prefillAnswer, queryType, cbapp, cbtag, cbdata, style)

device

question

prefillAnswer

queryType

cbapp

cbtag

cbdata

style


select(device, question, choices, cbtag, cbdata, defaultValue)

device

question

choices

cbtag

cbdata

defaultValue


textarea(device, question, origText, cbtag, cbdata, style, saveButtonLabel)

device

question

origText

cbtag

cbdata

style

saveButtonLabel


checkbox(device, question, cbtag, cbdata, defaultValue, style)

device

question

cbtag

cbdata

defaultValue

style


form(device, formName, formDefaults, cbtag, cbdata)

device

formName

formDefaults

cbtag

cbdata


run(device, appname, appparams)

device

appname

appparams


download(device, query, cbtag, cbdata, fileclass)

device

query

cbtag

cbdata

fileclass


registerMenu(device, menuname, menuoption, action)

device

menuname

menuoption

action


registerKey(device, keystroke, action)

device

keystroke

action


registerHotspot(device, region, action)

device

region

action


redirectHotspot(device, region, otherapp)

device

region

otherapp


error check

registerMouse(device, region, action)

device

region

action


registerCommand(device, cmd, cmdparams)

device

cmd

cmdparams


send(request, params)

request

params


htmlize(url)

url: str


Converts a string to a string usable inside HTML code.

The returned pointer should be free()ed by the calling routine.

Return str value:

urlize(url)

url: str


Operations performed:

change % to %25

change = to nothing

change + to %3b

change space to %20

change # to %23

Return str value:

sendImage(device, iid, errmsg, action, cbdata)

device

iid

errmsg

action

cbdata


saveToImageLib(device, filename, filetype, filecontent, xid, category)

device

filename

filetype

filecontent

xid

category


saveToImageLib(image_id, filename, filetype, filecontent, category)

image_id

filename

filetype

filecontent

category


updateImageLib(image_id)

image_id


saveToImageLib(image_id, filecontent)

image_id

filecontent


setImageCategory(image_id, category)

image_id

category


setImageName(image_id, name)

image_id

name


setImageType(image_id, type)

image_id

type


newImage(table, id)

table

id


send(request, params)

request

params


response(device, xid, text)

device

xid

text


chat(device, text)

device

text


cmd(device, cmd)

device

cmd


key(device, key)

device

key


click(device)

device


mouse(device, direction, x, y, action, cbdata)

device

direction

x

y

action

cbdata


hotspot(device, action, cbdata)

device

action

cbdata


upload(device, fileclass, filetype, imagelibid, xid)

device

fileclass

filetype

imagelibid

xid


refresh(device)

device


select(device, value)

device

value


online(device, appparams)

device

appparams


withdraw(device)

device


timeout(device)

device


send(request, params)

request

params


open(name, mode, cbtag, cbdata)

name

mode

cbtag

cbdata


putchar(ioId, c, ioChannel)

ioId

c

ioChannel


write(ioId, text, ioChannel)

ioId

text

ioChannel


write(ioId, data, ioChannel)

ioId

data

ioChannel


seek(ioId, offset, ioChannel)

ioId

offset

ioChannel


lock(ioId, exclusive, wait, ioChannel)

ioId

exclusive

wait

ioChannel


unlock(ioId, exclusive, wait, ioChannel)

ioId

exclusive

wait

ioChannel


close(ioId, ioChannel)

ioId

ioChannel


fsverify(node, ioChannel)

node

ioChannel


fsreview(dirResourceId, ioChannel)

dirResourceId

ioChannel


fsconfirm(node, size)

node

size


fsupdate(node, change, size)

node

change

size


ls(maepath)

maepath


stat(maepathandfilename, statbuf)

maepathandfilename

statbuf


send(request, params, channel)

request

params

channel


send(request, params)

request

params


key(device, key, keycode)

device

key

keycode


redraw(device)

device


send(request, params)

request

params


postNotice(notice)

notice


postComment(comment)

comment


send(request, params)

request

params


supervisorConsole(device)

device


supervisorCommand(cmd, device)

cmd

device


mgmtMetaGet(channel, group)

channel

group


mgmtMetaGetValue(group, list, status)

group

list

status


mgmtMetaSet(channel, group)

channel

group


mgmtMetaSetValue(group, list, status)

group

list

status


mgmtGet(channel, group, variable)

channel

group

variable


mgmtGetValue(group, variable, value, status)

group

variable

value

status


mgmtGetValue(group, variables, status)

group

variables

status


mgmtSet(channel, group, variable, value)

channel

group

variable

value


supervisorUsersSort(device, header)

device

header


supervisorSelectUser(device, row)

device

row


mgmtSysAdminUI(device, channel, topic, param)

device

channel

topic

param


mgmtOperator(device, channel, topic, param)

device

channel

topic

param


mgmtInputResponse(device, channel, cbtag, param, response)

device

channel

cbtag

param

response


send(request, params)

request

params


create(device, name, rows, width, termtype)

device

name

rows

width

termtype


redraw(device)

device


putchar(device, c)

device

c


puts(device, text)

device

text


setpos(device, y, x)

device

y

x


termchar(device, c, module)

device

c

module


termchar(device, text, module)

device

text

module


newtermtype(device, termtype, module)

device

termtype

module


setTerminalType(device, termType)

device

termType


bold(device, mode)

device

mode


underline(device, mode)

device

mode


reverse(device, mode)

device

mode


blinking(device, mode)

device

mode


color(device, newcolor)

device

newcolor


clear(device, area)

device

area


delline(device, y, amount)

device

y

amount


insline(device, y, amount)

device

y

amount


delchar(device, y, x, amount)

device

y

x

amount


inschar(device, y, x, c, amount)

device

y

x

c

amount


fill(device, y1, x1, y2, x2, c)

device

y1

x1

y2

x2

c


move(device, y1, x1, y2, x2, yt, xt, c)

device

y1

x1

y2

x2

yt

xt

c


cursor(device, direction, amount)

device

direction

amount


send(request, params, channel)

request

params

channel


send(request, params)

request

params


init(argv)

argv


main()

quit(rc, msg)

rc

Default value: 0

msg

Default value:


Class Cache

Public Methods

__init__(self, objType, size)

objType

the class of the object to cache

size: int

the maximum size allowable for the cache

Default value: 0


Constructor.

__del__(self)

Destructor

add(self, newKey, newOne)

newKey: int

newOne


Add a record to the cache. It must be valid().

Return int value:

removeKey(self, key)

key


Remove a record from the cache

Return bool value:

remove(self, pos)

pos: int


Remove a record from the cache

Return bool value:

findPos(self, searchKey, fetchIfMissing)

searchKey

fetchIfMissing: bool

Default value: True


Locate the cache position (-1 if not found)

Note: Pull into cache if fetchIfNotFound is True

Note: key must be a positive (non-zero) number

Return int value:

exists(self, searchKey)

searchKey: int


Check if key exists in list

Return bool value:

get(self, key)

key


Get pointer to data for the key. Check if result is valid().

Note: key must be a positive (non-zero) number

__getitem__(self, pos)

pos: int

position in cache, from 0+


This method allows the class instance to be indexed, e.g. HelloCache[2] to get the second element (not key==2)

Return value: the instance at position

__len__(self)

Return the size of the cache when using the len() function

Class Datastore

Summary

This class abstracts database protocols and allows an app to use this interface to perform database table queries and changes.

This class connects to dbbroker, which actually performs the database manipulation.  Note that dbbroker can be configured to connect to a variety of databases; this gets rid of app responsibility for database connection and syntax; an app can simply use the database.

It is safe (and convenient) to create an instance of this class for each table your program uses.

If you have an existing database table and you want to create a class interface to it, consider using genmae like this:

genmae db2h tablename > classname.h

genmae py classname.h > classname.py

Likewise, if you create .h file with the core class variables, you can use genmae to create the SQL code to setup the table, like this:

genmae h2sql classname.h > tablename.sql

Note that database manipulation commands will block program execution until a response from dbbroker is received.

Public Properties

FieldType

Default value: Enum('FieldType', 'FieldInt', 'FieldTime', 'FieldEnum', 'FieldLogical', 'FieldString', 'FieldFloat', 'FieldDate', 'FieldBinary')

OK

DB operation was successful (no error)

Default value: 0

INVALID_NAME

DB operation failed - invalid name given

Default value: -1

OPEN

DB operation failed - cannot open table

Default value: -2

INVALID_TYPE

DB operation failed - invalid field type

Default value: -3

INVALID_FIELD

DB operation failed - invalid field name

Default value: -4

INVALID_REC

DB operation failed - invalid record id

Default value: -5

INVALID_ENUM

DB operation failed - invalid enum

Default value: -6

INVALID_PARAM

DB operation failed - invalid parameter

Default value: -7

LOCKED

DB operation failed - record locked

Default value: -8

NOT_SUPPORTED

DB operation failed - operation not supported

Default value: -9

FAILED

DB operation failed - (non-specific)

Default value: -10

REC_NOT_FOUND

DB operation failed - record not found

Default value: -11

ALREADY_EXISTS

DB operation failed - record already exists

Default value: -12

INVALID_SCHEMA

DB operation failed - invalid schema

Default value: -13

COMM_ERROR

DB operation failed - communications error

Default value: -14

CORRUPT_REPLY

DB operation failed - reply was corrupt (cannot parse)

Default value: -15

INVALID_CONN

DB operation failed - invalid connection

Default value: -16

INVALID_EXPR

DB operation failed - invalid expression

Default value: -17

LINEPAYLOADMAX

Maximum line length to send to dbbroker

Default value: 10000 - 100

PAYLOADMAX

Default value: 10000


Public Methods

__init__(self, tableName)

tableName: str

Default value:


Constructor to initialize our data structure.  This does not yet setup the connection to dbbroker.

valid(self)

Determine status of our connection to database - is it valid?

Return int value: True if connected to db

status(self)

Get the status of the last request

Return int value: the status of the last request (see codes at top of Datastore.py)

statusOK(self)

Determine if the status of the last operator was successful.

Return bool value: True if last operation successful, False otherwise.

isOpen(self)

Determine if the database connection is established and ready.

Return bool value: True if db connection ready

statusMsg(self)

Return human readable status of last request.

Return str value: msg corresponding to last DB request

fieldNameToType(self, name)

name: str


fieldTypeToName(self, fieldtype)

fieldtype


Return str value:

errorMsg(self, rcToGetMsgFor)

rcToGetMsgFor: int

the return code number to look up

Default value: 1


Get the status message of the specified return code.

Return str value: the text of the error message

open(self, tableName)

tableName: str

the name of the table to use as the current table.

If not successful, check status() for the code or statusMsg() for human readable description.


Set the currently active table by opening it.

Return int value: the status code of the operation.

select(self, tableName)

tableName: str

the name of the table to use as the current table.

If not successful, check status() for the code or statusMsg() for human readable description.


Identifical to open().  Set the currently active table by opening it.

Return int value: the status code of the operation.

connected(self)

Check to make sure the database connection is working.

Return bool value: True if db responding to our requests

pack(self)

Pack the database (remove deleted records), if the database supports this.

Otherwise, it is ignored.

Return bool value: True upon success, False upon failure (see statusMsg())

close(self, specifiedTable)

specifiedTable: str


Signal to close this database table.

@param table name of the table to close; if none, then last table used

Return bool value: True upon success, False upon failure (see statusMsg())

getTableList(self)

Get the list of defined tables.

Return value: the list of tables in the database

addField(self, fieldName, type, size, table, isIndex)

fieldName: str

name of field for operation

type

type of field (string, int, float)

size: int

(optional) size of field in bytes

table: str

name of table for operation

Default value:

isIndex: bool

True if this field is an index for the table

Default value: False


Obsolete. Add a field to the named database table.

Return 0 value: field id of new field

getFieldId(self, fieldName, table)

fieldName: str

name of the field for which to get the fieldid

table: str

name of table for operation

Default value:


Query field id from field name for the named table.

Return int value: nonzero on success, 0 on failure

addFieldEnum(self, fieldName, enumName, enumId, table)

fieldName: str

id of the enum field

enumName: str

name/identifier for enum

enumId: int

(optional) integer value to use for enum

table: str

name of table for operation

Default value:


Obsolete.  Add field enumeration to the nanmed table.

Return int value: new enum value

getFieldType(self, fieldName, table)

fieldName: str

id of the enum field

table: str

name of table for operation

Default value:


Query a field type (string, float, etc) for the provided field name in the provided table.

Return value: the field type

addRecord(self, data, recno, table)

data

any data to pre-populate the record

recno: int

(optional) id for the record

Default value: 0

table: str

name of table for operation

Default value:


Add/Append a new record to the table provided, populated with the data provided.

Return value: new record number added

deleteRecord(self, recno, table)

recno

number of the record to delete

table: str

name of table for operation

Default value:


Delete a record in the named table.

Return bool value: transaction status (see statusMsg())

lockRecord(self, recno, table)

recno

number of the record to lock

table: str

name of table for operation

Default value:


Lock a record in the named table; prevent other applications from modifying this record until it is unlocked.

Return bool value: transaction status (see statusMsg())

unlockRecord(self, recno, table)

recno

number of the record to unlock

table: str

name of table for operation

Default value:


Unlock a record in the named table, allowing other applications to now modify it.

Return bool value: transaction status (see statusMsg())

clearField(self, recno, fieldName, table)

recno

number of the record containing the field

fieldName: str

name of the field to clear

table: str

name of table for operation

Default value:


clear/empty the value for the field with this field name

Return bool value: transaction status (see statusMsg())

setValue(self, recno, fieldName, value, table)

recno

number of the record in which to set the value

fieldName: str

value

the value to set

table: str

name of table for operation

Default value:


change a string value identified by field ID

@param field name of the field in which to set the value

Return bool value: transaction status (see statusMsg())

setRecord(self, recno, newValues, table)

recno

number of the record in which to set the value

newValues

table: str

name of table for operation

Default value:


change several field values at once

@param newValue key/value pairs for new field/value changes

Return bool value: transaction status (see statusMsg())

getFieldInt(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get an int field value identified by field name

Return int value: the int value or -1 if unsuccessful

getFieldString(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get a string field value identified by field name

Return str value: the string value or zero length string if unsuccessful

getFieldFloat(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get a float field value identified by field name

Return float value: the float value or ??? if unsuccessful

getFieldEnumValue(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get an enum value identified by field name

Return str value: the enum value or zero length string if unsuccessful

getRecord(self, recno, fields, table)

recno

number of the record containing the value

fields

Default value: []

table: str

name of table for operation

Default value:


get an int field value identified by field name

@param fieldName name of the field to get

Return value: key/value pairs of field/value values from record.  Error if empty, check status()/statusMsg().

getFieldEnumValueAsInt(self, recno, fieldName, table)

recno

number of the record containing the value

fieldName: str

name of the field to get

table: str

name of table for operation

Default value:


get an enum value as an int identified by field name

Return int value: the enum value or zero length string if unsuccessful

queryRecordsEnum(self, fieldName, value, sortby, table)

fieldName: str

name of field to search

value: str

enum value to search for

sortby: str

Default value:

table: str

name of table for operation

Default value:


simple query for enum value by field name

Return list value: list of record numbers matching criteria

queryRecords(self, fieldName, value, sortby, table)

fieldName: str

Name of field to search, paired with the value; alternatively fieldName can be an XMLData object with key/value pairs to search for (if so, value is ignored)

value: str

string value to search for

Default value:

sortby: str

Default value:

table: str

name of table for operation

Default value:


simple query for string value by field name

Return list value: list of record numbers matching criteria

queryRecords2(self, criteria, ANDed, sortby, table)

criteria

ANDed: bool

Default value: True

sortby: str

Default value:

table: str

name of table for operation

Default value:


compound query for a field value

@param list list of field key/value pairs to be searched for

Return list value: list of record numbers matching criteria

queryExpr(self, expression, fields, sortby, table)

expression: str

using field names, comparison operators, and logic operators, specify which records match the query

fields: list

a list of fields to return

Default value: 'Id'

sortby: str

field name to use to sort the results start with + (default) for ascending sort, - for descending sort

Default value:

table: str

name of table for operation

Default value:


Using an expression, query records and return the requested fields, sorted if specified.

@param results - (output) a list of records and their fields that matched

Return bool value: True upon success

queryAllRecords(self, sortby, table)

sortby: str

Default value:

table: str

Default value:


query for all records in the named (or current) table

Return list value: recList with results which will be empty if unsuccessful

queryFieldNames(self, table)

table: str

the name of the table to query for fields

Default value:


query for all field names and types

Return value: XMLData which will be empty if unsuccessful. Otherwise key is field name, value is field type.

queryFieldIds(self, table)

table: str

the name of the table to query for fields

  1. @return XMLData which will be empty if unsuccessful. Otherwise key is field name, value is field id.

Default value:


query for all field names and types

connect(self)

Connect to database server.

In actuality, this only checks to make sure we're connected to the MAE daemon, commhub.

Return bool value: True on success; False on failure

doCommand(self, cmd, params)

cmd: str

params

Default value: None


Send a command for dbbroker that has no parameters. And wait for the reply.

Return bool value: True on success; False on failure

send(self, params)

params


Send data to commhub for DB operation

Return bool value: True if sent; False if failed

receive(self)

Wait for a dbbroker response from commhub.

Return bool value: True if reply received; False if not

encodeNewline(self, text)

text: str

the text to encode


commhub wants a comment to have new \n characters, so encode them

unencodeNewline(self, text)

text: str

the text to unencode


commhub didn't let dbbroker send any \n characters, so unencode them

Class HashArray

Super class: dict

Summary

This class behaves a lot like the dict class, but with more control over the value types.

Note that all keys are strings.

Using HashArray

The HashArray data type is a key-value container.

It is typeless, but a specific type can be asserted (e.g. setBool()) or retrieved (e.g. getBool(), getInt(), etc).  It is up the the application to store/retrieve by type consistently.

This data type is very convenient for messaging.  Calling the toString() method converts the HashArray into a string.  Using the fromString() method or constructor converts it back.

Caveats

  1. Numerical keys are not handled rigorously; unless numerical keys are set sequentially, you may get inconsistencies.
  2. When used inside XMLData, keys must be identifers with alphanumeric characters; if non-alphanumerics are given, they will be converted to underscores when converted using toString().  XMLData requires keys to be valid XML tag identifiers.

Public Methods

__init__(self, value, separator)

value: str

Default value:

separator: str

Default value: '\n'


Constructor

setProps(self, other)

other


Set the properties of the other HashArray into this HashArray, replacing any previous values

size(self)

Return the number of key-value pairs.

Return int value: # keys in hash array

empty(self)

Determine if there are no key-value pairs in the hash array.

Return bool value: True if there are no key-value pairs, False if there's at least one

set(self, key, value)

key: str

name of the key to set

value

value to set to key


Assign a value into the dict

setBool(self, key, value)

key: str

name of the key to set

value: bool

value to set to key


Assign a boolean value to a key.

unset(self, key)

key: str

name of the key to unset


Remove a key/value pair from the dict

get(self, key)

key: str

name of the key to unset


Get a string value from the dict key

Return str value:

getInt(self, key)

key: str

name of the key to unset


Get a integer value from the dict key

Return int value:

getFloat(self, key)

key: str

name of the key to unset


Get a floating point value from the dict key

Return float value:

getDouble(self, key)

key: str

name of the key to unset


Get a double precision floating point value from the dict key. Same as getFloat().

Return float value:

getBool(self, key)

key: str

name of the key to unset


Get a boolean value from the dict key

Return bool value:

toString(self, separator)

separator: str

text that separates each key/value pair.

Default value: '\n'


Serialize the HashArray into a string.

isHashArray(text)

text: str

a text string to examine


Examine the text string provided and determine if it's a HashArray or not.

Return bool value: True if text string is a serialized HashArray, False otherwise

fromString(self, text, separatorCharacter)

text: str

the text string to decode

separatorCharacter: str

the text that separated key/value pairs

Default value: '\n'


Take a text string that was generated by toString() and restore the data inside HashArray.

Return bool value: True if text could be fully decoded.

Class ImageLib

Using ImageLib

This class holds a reference to and then ultimately delivers the binary content of an image in the Image Library (the ImageLib table).  This class holds the image id, name, category, image type, height and width of the image.

Public Methods

__init__(self, id)

id


__init__(self, name, category)

name: str

category: str


clear(self)

__init__(self, data)

data


set(self, data)

data


append(self)

save(self)

toHashArray(self, forDB)

forDB: bool


load(self, id)

id


Return bool value:

toString(self)

Return str value:

fromString(self, data)

data: str


Return bool value:

calcChecksum(self)

Return int value:

getName(self, id)

id


Return str value:

getHeightWidth(self, id, height, width)

id

height: int

width: int


Return bool value:

getType(self, id)

id


Return str value:

find(self, name, category)

name: str

category: str


Class Image

Summary

This class represents images within the MAE system.

Images may be drawn by the app or pulled from ImageLib database table.

Drawn images draw into a coordinate system with the size (height, width) and origin specified by the application.  For example, to create an image with a coordinate system that is 5 units wide and 4 units tall with the origin(0,0) in the center, you specify setSize(5, 4) and setOrigin(-2.5,-2).  How large the image is when it is displayed depends upon the unit size. If you'd like your 5 unit wide image to be 50 pixes wide, then specify setSize(5, 4, 10).

To display an image to the user, see the UserDevice class.

Use this class to communicate with imager, which renders them appropriately for the user.

Using Image

This data structure abstracts a vector image.  The API is used to describe the image.  It is not rendered into JPG, PNG, SVG, or other specific image technology until it is ready to be rendered to the end-user.  Rendering is performed by the imager daemon.

The API could be richer, but the API must be able to render to each of the ultimate image types.

The Image class may refer to an existing image file in a specific format via ImageLib class, which specifies where to retrieve the image and the image's size.

Graphics Commnds

setSize()

setSize(double newWidth, double newHeight, int newUnitSize)

Set the canvas dimensions and specify how many pixes per unit.  For example, a 4.0x5.0 image where unit size is 10 would create a 40x50 pixel image.

setOrigin()

setOrigin(double newOriginX, double newOriginY)

Specify how many units over the origin should be located if (0,0) is the lower left

setWindow()

setWindow(double minX, double minY, double maxX, double maxY, int newUnitSize)

Specify the width and origin implicitly by specifying the window into the view.  Use this instead of setSize() setOrigin()

drawBox()

drawBox([[#Point]] corner1, Point corner2, string color, bool fill, string link)

Draw a rectangle with the corners specified.  Default color is black.  The box may be an outline or solid/fiilled.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawLine()

drawLine([[#Point]] p1, Point p2, string color, string link)

Draw a line from p1 to p2 of the color specified.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawCircle()

drawCircle([[#Point]] center, double radius, string color, bool fill, string link)

Draw a full circle with the specified center and radius.  The default color is black.  The circle may be an outline or solid/fiilled.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawText()

drawText([[#Point]] start, string text, string color, string link)

Draw text into the image with the lower left corner of the text at the start point.

drawArc()

bool drawArc([[#Point]] center, double startang, double endang, double radius, string color, bool fill)

drawPolygon()

drawPolygon([[#Point]]List p, string color, bool fill, string link)

Given a series of points, draw the enclosed polygon.  The default color is black.  The polygon may be an outline or solid/fiilled.

An optional link (e.g. URL) may be provided if resulting image supports linking.

drawPolyline()

drawPolyline([[#Point]]List p, string color, string link)

Given a series of points, the the line that connects them from start to end.  The default color is black.

An optional link (e.g. URL) may be provided if resulting image supports linking.

Public Methods

__init__(self, group_id, imageName, module)

group_id: int

this is an application-specific number to differentiate this image name from others; it is used to help create a unique image name for the user's display device

Default value: 0

imageName: str

this is the application-specific name given to the image

Default value:

module: str

this is the application-specific category for the image, such as the application's name

Default value:


Construct an empty image.

valid()

Query if the current image is valid.

Return bool value: True if valid; False if invalid

Class MAEApp

Super class: MAE

Summary

This class builds on top of the MAE class. It ensures MAE knows that your MAE task is an app and supports it appropriately. An app is a persistent program servicing user requests via UI.

Public Methods

__init__(self, programName, appchannels)

programName: str

the name of the task as registered inside MAE

appchannels: str

a comma separated list of message channels used. Default is one channel using the program's name.

Default value:


Declare your app MAE instance of this task.

Class MAEConn

Super class: Socket

Summary

This class handles the communication layer between a MAE daemon/app and CommHub.

The challenge that this class faces is that CommHub communicates asynchronously with its client daemons/app, so an app may have sent a DB request (for example) and while wating for the DB response, it may receive some messages, an RPC request, or control message (perhaps initiated by the user).  So, this class has to remember those messages and then process them after the DB response arrives.

Internally, MAEConn discerns these logical communication categories:

Public Properties

dbPrefix

Default value: "Db"

msgPrefix

Default value: "Msg"

rpcPrefix

Default value: "Rpc"

commhub

Default value: []

db

Default value: []

msg

Default value: []

rpc

Default value: []

tapf

Default value: None

COMMHUB_LINE_NOFMT

CommHub line protocol characters

Default value: 0

COMMHUB_LINE_TEXT

Default value: ' '

COMMHUB_LINE_CHUNK

Default value: '='

COMMHUB_LINE_BINARY

Default value: 'x'

COMMHUB_LINE_SUCCESS

Default value: '+'

COMMHUB_LINE_FAILURE

Default value: '-'


Public Methods

__init__(self, host, port)

host: str

The hostname to connect to (if empty, then localhost)

Default value:

port: int

The remote TCP port to connect to

Default value: 0


Prepare for a TCP socket connection

Return value: instance of Socket to open().  If FALSE, check errno().

writeLine(self, text)

text: str


Send text to commhub

Any \n will be converted to text (and later back)

Return bool value:

read(self)

Read any inbound text.

Use its callback (if defined) to process the inbound text.

Return int value: socket status (-1 EOF) - messages ready to be ready (with no callback)

readCommHub(self, wait, rcLineOnly)

wait: bool

block until we have input from commhub

Default value: False

rcLineOnly: bool

wait until we get a response line (starts with + or -) and return that; other lines are queued

Default value: False


Wait for text from commhub.

Read text up to a newline.

Return str value: the string read.  If empty, check errno().

readDB(self, wait, lockoutCallbacks)

wait: bool

Default value: False

lockoutCallbacks: bool

Default value: False


Wait for DB response.

Read DB response text up to a newline.

Return str value: the string read.  If empty, check errno().

readMsg(self, wait, queueOk)

wait: bool

Set to True to wait until there's valid input, False if just checking quickly

Default value: False

queueOk: bool

Set to True if it's OK to pull queued/pending messages (this is normal/default)

Default value: True


Wait for text message.

Read a Message text up to a newline.

Return str value: the string read.  If empty, check errno().

readRpc(self, wait, lockoutCallbacks, queueOk)

wait: bool

Set to True to wait until there's valid input, False if just checking quickly

Default value: False

lockoutCallbacks: bool

Set to prevent other requests from being serviced while waiting

Default value: False

queueOk: bool

Set to True if it's OK to pull queued/pending messages (this is normal/default)

Default value: True


Wait for text message.

Read an RPC text up to a newline.

Return str value: the string read.  If empty, check errno().

readyCommHub(self)

Return True if commhub command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

readyDB(self)

Return True if DB command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

readyMsg(self)

Return True if msgbroker message command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

readyRpc(self)

Return True if RPC command queue has a command ready to be processed

Return bool value: True if there's 1+ backlog commands

msgSize(self)

Get size of msg backlog queue

Return int value: size of the queue

dbSize(self)

Get size of db backlog queue

Return int value: size of the queue

rpcSize(self)

Get size of rpc backlog queue

Return int value: size of the queue

setCommHubCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the commhub callback

setDBCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the DB callback

setMsgCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the msgbroker message callback

setRpcCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the RPC request callback

setRpcRespCB(self, cb, data)

cb

callback function

Default value: None

data

callback data

Default value: None


Setup the RPC response callback

getMsgCB(self)

Get the msgbroker message callback method

Return value: the msgbroker message callback method

readLine(self, wait, lockoutCallbacks)

wait: bool

Default value: False

lockoutCallbacks: bool

Default value: False


Read text up to a newline.

  1. Figure out which queue the message is bound for, and push it into that queue.

Return bool value: True if something read

processLine(self, line, lockoutCallbacks)

line: str

the line from commhub to process

lockoutCallbacks: bool

True if no callbacks should be called to immediately handle a message

Default value: False


Put line into right queue or send to callback (if not locked out/blocked)

getCmdCount(self)

of lines received

Return int value:

servicePendingCallbacks(self, includingCommHub)

includingCommHub: bool

Default value: True


If any callbacks are configured and data is pending, service them.

Return bool value:

setDbPrefix(self, prefix)

prefix: str

the new prefix


If a different DB prefix is needed, configure new prefix here

setMsgPrefix(self, prefix)

prefix: str

the new prefix


If a different msgbroker message prefix is needed, configure new prefix here

setRpcPrefix(self, prefix)

prefix: str

the new prefix


If a different RPC prefix is needed, configure new prefix here

recordLine(self, send, text)

send: bool

True is message is outbound, False if message is inbound

text: str

the message


Save a message out to tap file

setTap(self, tap)

tap

Default value: None


Useful for monitoring all socket communication - a socket tap

will record all read/write activity (set to NULL to disable)

Use msgplayer to replay messages for testing/debugging.

getTap(self)

Query the tap's file pointer

tapActive(self)

Determine if tap is active

Return bool value:

Class MAEDaemon

Super class: MAE

Summary

This class builds on top of the MAE class. It ensures MAE knows that your MAE task is an app and supports it appropriately. A daemon is a persistent program providing support to other MAE tasks.

Public Methods

__init__(self, programName, appchannels)

programName: str

the name of the task as registered inside MAE

appchannels: str

a comma separated list of message channels used. Default is one channel using the program's name.

Default value:


Declare your daemon MAE instance of this task.

Class MAE

Super class: MAETask

Summary

This class is the starting point of the MAE platform.  Create a single instance for MAE to operate correctly in your main source file. More than likely, you'll instead declare a sub-class - MAEApp, MAEDaemon, or MAEUtility - which is tailored to your tasks's purpose.

Public Properties

tasktype

The type of task: app/daemon/utility

Default value: 'daemon'

instance

The task instance (0 is base)

Default value: 0

channellist

The channels used for communicating

Default value: []

tdir

Path MAE support files

Default value: '/usr/mae'

forkit

Flag: should we fork() when we run?

Default value: False


Public Methods

__init__(self, module, name, channels)

module: str

the name of the module where the app runs (used for callbacks)

name: str

the name of the task as registered inside MAE

channels: str

a comma separated list of message channels used. Default is one channel using the program's name.

Default value:


Constructor for integration with MAE.

setName(name)

name: str


Set the MAE task name (with an instance, if non-0). This is the name used to communicate with commhub. The name is often the same as the program's filesystem name, but it is not required to be so.

getName()

Get our MAE task name, including instance if non-0.

Return str value: the MAE task name

getInstance()

Query the instance of this task

Return int value: the instance of the task/app; note that 0 is for the base app

setDaemon()

Declare this task as a daemon - a persistent program providing support to other MAE tasks.

setApp()

Declare this task as an app - a persistent program servicing user requests via UI.

setUtility()

Declare this task as a utility - a one-shot program that performs a task and exits.

isDaemon()

Query if the current task behaves like a daemon.

Return bool value: True if the task is a daemon (because setDaemon() was called), False otherwise.

isApp()

Query if the current task behaves like an app.

Return bool value: True if the task is a daemon (because setApp() was called), False otherwise.

isUtility()

Query if the current task behaves like a utility.

Return bool value: True if the task is a daemon (because setUtility() was called), False otherwise.

init()

MAE calls this when the task environment is setup to let task initialize itself. The Python application needs to define this.

main()

MAE calls this once this task's environment is fully initialized.

This is where your task performs its main functionality.

The Python application needs to define this.

quit(rc, msg)

rc

the program's exit code (0 means normal exit, 1+ means err exit)

Default value: 0

msg

an explanation why the app is shutting down

Default value:


Either the user or the ecosystem has initiated a task exit. The Python application needs to define this.

dbglog(message)

message: str

the message to write to log file


Output a log message to the debug-only log file - if debug mode is on. When debug mode is off, the message is ignored. The log file is /usr/mae/log/<appname>dbg.log

dbgflush()

This is handy to do just before a program crash to ensure all debug messages have been written to the debug log file. This methods makes sure no messages are in-memory in a buffer, but written to the file.

toggleDebug()

Toggle the debug mode for the program.

Ensures debug.dbgf is pointing to a valid log file, e.g. /usr/mae/log/<taskname>dbg.log

getBroadcast()

Future feature.

Class MAETask

Summary

MAETask is the class used to communicate with CommHub. It sends status and MAE platform commands (such as messages, RPC calls, database queries, global parameter queries). And it handles the responses and commands from CommHub.

Public Properties

COMMHUB_PORT

Default value: 4847

CACHEMAX

Default value: 20000

TDIR

Default value: '/usr/mae'

MAECommand

Default value: Enum('MAECommand', ['TaskSuspend',

messenger

Default value: None


Public Methods

__init__()

The constructor

By default, task is not a daemon

By default, task is not managed

init()

An app calls this when the task immediately starts.

This moves the task into 'Initializing' state

If managed and commhub can't run, this will cause exit(227)

Return bool value: Flag: True if connected to CommHub, False if failed to connect

log(text)

text: str

the message to log


Log any messages here (commhub logs them)

dbglog(message)

message: str

the message to write to log file


Output a log message to the debug-only log file - if debug mode is on. When debug mode is off, the message is ignored. The log file is /usr/mae/log/<appname>dbg.log

dbgflush()

This is handy to do just before a program crash to ensure all debug messages have been written to the debug log file. This methods makes sure no messages are in-memory in a buffer, but written to the file.

fd()

This is a file descriptor for select() so the task can monitor for control communication.

Return int value: OS file descriptor of connection to CommHub

isCommHub()

Return True when CommHub is using this class (commhub/MAETask.h returns True)

Return bool value: False for all tasks/apps except commhub.

suspendable(ok)

ok: bool

Default value: True


The daemon app calls this if your daemon is suspendable

if it is not, it will never receive the TaskSuspend command

isSuspended()

Ask if we're currently suspended.

Return bool value: True if current setting is that the task/app can be suspended

pidUpdate(forcePid)

forcePid: int

the OS process id of the task

Default value: 0


An app calls this after fork()ing to notify CommHub of its new pid.

ok(msg)

msg: str

a status message, e.g. 'Ready'


The app calls this when the task has finished initializing or to simply report updated run status.

degraded(msg)

msg: str

a status message, e.g. 'Lost connection to ServiceNow'


The app calls this when the task realizes it is performing suboptimally.

failed(msg)

msg: str

a status message, e.g. 'Unable to connect to port tcp/80'


The app calls this when the task has failed and cannot continue

done(msg)

msg: str

a status message, e.g. 'Complete'


Call this when the task has completed successfully

setQuit(cbfn)

cbfn

static method or function to call, e.g. void exitNow(int n)


Setup callback when CommHub sends Quit.

Default action: call exit(0).

setSuspend(cbfn)

cbfn

static method or function to call, e.g. void suspendNow(int n)


Setup callback when CommHub sends Suspend.

Default action: call ignored

setResume(cbfn)

cbfn

static method or function to call, e.g. void resumeNow(int n)


Setup callback when CommHub sends Resume.

Default action: call ignored

setDebug(cbfn)

cbfn

static method or function to call, e.g. void toggleDebug(int n)


Setup callback when commhub sends Debug.

Default action: toggle debug_on

fork()

Detach from parent process

process(forever, justone)

forever: bool

if True, process() never returns if False, process() returns immediately, possibly after processing a command

Default value: True

justone: bool

if True, process() exits after processing just one message

Default value: False


Handle events from commhub (perhaps forever) until quit sent. Gets all events or just one event.

openControl(commhubHost)

commhubHost: str

Default value:


Connect via TCP to CommHub, the control daemon.

Return bool value: Flag: True upon success False upon failure

controlConnect(startIfNoAnswer, hostname)

startIfNoAnswer: bool

Flag: True if we should launch commhub when it's not running

Default value: False

hostname: str

the IP host where CommHub is running

Default value:


Connect to commhub (and start it if we can't connect.

Return bool value: Flag: True upon success False upon failure

controlStart(name)

name: str

name of task to start


Start the named daemon

Return bool value: tuple of (success (True/False), status of task after started)

controlStartInstance(name, instanceId)

name: str

name of task to start

instanceId: int

instance for task to start, e.g. 1+


Return str value: tuple of (success (True/False), status of task after started)

controlStop(name)

name: str

the name of the daemon, possibly with instance apended, e.g. maeterm.1


Request that CommHub stop the named daemon instance.

Return bool value: Flag: tuple of (success (True/False), status of task after started)

controlSuspend(name)

name: str

the name of the daemon, possibly with instance apended, e.g. maeterm.1


Request that CommHub suspend the named daemon instance.

Return bool value: tuple of (success (True/False), status of task after started)

controlResume(name)

name: str

the name of the daemon, possibly with instance apended, e.g. maeterm.1


Request that CommHub resume the named daemon instance.

Return bool value: tuple of (success (True/False), status of task after started)

controlStatus(name)

name: str

the name of the daemon, possibly with instance apended, e.g. maeterm.1


Get the named daemon's status

Return bool value: tuple of (success (True/False), status of task after started). Status information in the format: <name> <pid> <cluster> <state> <msg>

controlInstances(name)

name: str

name of task to query


Get the list of instances for the named daemon

Return bool value: tuple of (success (True/False), list of instances running)

commhubStat(status)

status: str

(output) text output with a table of connections


Get CommHub communication statistics.

Return bool value: tuple of (success (True/False), status of task after started)

commhubSpokes(node, status)

node: str

name of the node to query, e.g. root

status: str


Get a list of connected CommHub spokes.

Return bool value: tuple of (success (True/False), list of spokes)

controlStatusName(status)

status: str


Get daemon status details

Return str value:

controlStatusPid(status)

status: str


Return int value: the task's pid

controlStatusCluster(status)

status: str


Return str value:

controlStatusState(status)

status: str


Return str value:

controlStatusMsg(status)

status: str


Return str value:

controlDebug(name, msg, level)

name: str

the name of the daemon, possibly with instance apended, e.g. maeterm.1

msg: str

(output) additional information about the request

level: int

Level 0 is off level -1 means toggle on/off level 1-4 are various increased debug levels.

Default value: -1


Request to change the debug mode of the named daemon.

Return bool value: tuple of (Flag: True upon success or False upon failure, status message)

controlTap(name, msg)

name: str

the name of the daemon, possibly with instance apended, e.g. maeterm.1

msg: str

(output) additional information about the request


Request to tap into the CommHub messages of the named daemon.

Return bool value: tuple of (Flag: True upon success or False upon failure, status message)

controlNewTask(name, msg)

name: str

the name of the daemon

msg: str

(output) additional information about the request


Tell commhub a new task exists

Return bool value: tuple of (Flag: True upon success or False upon failure, status message)

controlDeleteTask(name, msg)

name: str

the name of the daemon

msg: str

(output) additional information about the request


Tell commhub an old task is deleted

Return bool value: tuple of (Flag: True upon success or False upon failure, status message)

controlQuit()

The big STOP button - stop commhub and everything else

Return bool value: tuple of (Flag: True upon success or False upon failure, status message)

controlCommand(cmd)

cmd: str

the command/request to send it must not include any newline characters


General method to send a command/request to CommHub.

@Return tuple with two values:

Flag: True if command return code is True, False otherwise return the response from commhub (minus the lead char)

Response from command

Return bool value:

sayHello(daemon, quitIfNoAnswer)

daemon: bool

Flag: True if we are a daemon False if we a one-shot program

quitIfNoAnswer: bool

Flag: if True, then force program to exit if False, let program keep running

Default value: True


Our first message to CommHub: Declare our identity.

Return bool value: Flag: True if connected to CommHub and CommHub allows our connection

getCommand(wait)

wait: bool

Flag: wait for something from CommHub (or return immediately)

Default value: False


Call this routine to get a CommHub (single keyword) control command from the MAETask.socket.

Return MAECommand value: the command code received, e.g. TaskExit, TaskNop, etc.

getTaskControlArgs()

Get control command arguments

Return str value: the command arguments

setName(newname)

newname: str

the new task name


If you want to change the name of this task, use this method

setInstance(newInstance)

newInstance: int

a number representing the task's instance

Default value: 0


Set the instance id for this task (default is 0).

getName()

Query the name of this task.

Return str value: the name of the task/app

getInstance()

Query the instance of this task

Return int value: the instance of the task/app; note that 0 is for the base app

isInstance()

Query if the current task is an instance (versus the base task:

Return bool value: True if the current task is an instance, False if base task

taskBaseName(taskname)

taskname: str

Default value:


Query the task's name without its instance id.

Return str value: the base task name

setAppId(appid)

appid: str

the id / message channel.


Set the app id / messenge channel. Set this before calling init().

getAppId()

Query the app id / message channel in use.

Return str value: the id / message channel

setType(newtype)

newtype: str

the new application type


FUTURE USE. To change the application type of this task, use this method

setStatus(msg, state, extra)

msg: str

state: str

extra: str

Default value:


Set the current status into the database.

Return str value:

setManaged(isManaged)

isManaged: bool


Configure if this task is managed. (Default: no:

A managed task has status in taskdb

setDaemon(isDaemon)

isDaemon: bool


Configure if this task is a daemon. (Default: no:

A daemon talks to the task manager.

@param isDameon -

isDaemon()

Query if this task is a daemon that runs until told to stop.

Return bool value:

setClusterName(name)

name: str


Configure if this task is part of a cluster. (Default: no:

A cluster member is a thread inside a VM

getSystemParameter(parameterName, taskname)

parameterName: str

taskname: str

Default value:


Query a system value for this task (not from data store)

In general, you should need to use this

Return str value:

setSystemParameter(parameterName, parameterValue, taskname)

parameterName: str

parameterValue: str

taskname: str

Default value:


Set a system value for this task (not from data store)

In general, you should need to use this

Return bool value:

quit(rc, msg)

rc: int

Default value: 0

msg: str

Default value:


Quit the service

suspend()

Suspend the service

resume()

Resume the service

toggleTap(_unused)

_unused: int

Default value: 0


Toggle message tapping mode

getConfDir()

Get the directory with Configuration files

Return str value: conf directory

getLogDir()

Get the directory with log files

Return str value: log directory

setupAt(triggerTime, cbfn, data, triggerLabel)

triggerTime: int

the future time when the timer goes off

cbfn

the method to call when the timer goes off

data

callback data to provide to the timer

triggerLabel: str

the unique name of the timer (useful for tracking timers)


Setup a one-time timer event for a specific time point in the future.

Return bool value: True if timer successfully setup

doAfter(delay, cbfn, data, triggerLabel)

delay: int

the number of seconds in the future the timer should go off

cbfn

the method to call when the timer goes off

data

callback data to provide to the timer

triggerLabel: str

the unique name of the timer (useful for tracking timers)


Setup a one-time timer event after a delay of specified seconds.

Return bool value: True if timer successfully setup

setupPeriodic(seconds, cbfn, data, triggerLabel)

seconds: int

the number of seconds between repeating timer triggers

cbfn

the method to call when the timer goes off

data

callback data to provide to the timer

triggerLabel: str

the unique name of the timer (useful for tracking timers)


Setup a time to trigger every so many seconds.

Return bool value: True if timer successfully setup

signalRaised()

Query if a timer has been triggered.

Return bool value: True if a timer has been triggered and not serviced yet

serviceTimer()

Service all outstanding timers

Return int value: the number of timers serviced

getTimerState()

Get the list of future times in a dict.

The key is the triggerLabel, the value is the number of seconds to go before it triggers.

Return dict value: a dict with each trigger's time till it goes off

Class MAEUtility

Super class: MAE

Summary

This class builds on top of the MAE class. It ensures MAE knows that your MAE task is an utility and supports it appropriately. A utility is a one-shot program that performs a task and exits.

Public Methods

__init__(self, programName)

programName: str

the name of the task as registered inside MAE


Declare your utility MAE instance of this task.

Class Messenger

Summary

Class to handle MAE (one-way) messages between MAE apps.

Messages are routed by MsgBroker.

This class works in conjunction with the MAETask class, which maintains the connection to CommHub, which is required to reach the MsgBroker daemon.

The MAE class class sets up message channels for your app and code generated by genmae uses this class to send messages.

Public Properties

list

Default value: []


Public Methods

__init__(self)

Constructor. Connects to app MAETask class instance.

By default, sent messages will be sent on the task's first registered channel.

__del__(self)

Desctructor.  Disconnects from app MAETask class instance.

closeAll()

Close all open channels.

get(channel)

channel: str

the Messenger channel to find.


Get Messenger instance of channel

Return value: the instance Messenger registered to the named channel

getChannels()

Get list of all channels open for listening

Return value: a list of all registered channels

open(self, channel, persist, cbfn)

channel: str

the unique channel name for listening (this is is registered with MsgBroker)

persist: bool

True if MsgBroker should queue up messages to this channel even when the channel is off-line

cbfn

specify the message handler that will process the messages, typically handleMessage()


MAE calls this for your app; your app should not call it.

Start listening to a channel.

(Only listen to one channel per instance of Messenger)

Return bool value:

send(self, dest, request, data)

dest: str

the name of the channel to send this message to

request: str

the message type or name of the request being sent (a keyword)

data

the data/payload of the message. You should make sure it is compatbile with the app that is receiving the request to make sure they key-value pairs in the payload can be processed by the receiving app


Send a message

Return bool value: True if message sent

sendError(self, dest, errorMessage)

dest: str

the name of the channel to send this message to

errorMessage: str

the message to send to the destination channel


Send an error back to the calling app

Return bool value: True if message sent

close(self)

Close the current channel.

Return bool value:

cease(self)

Close a persistent channel.  MsgBroker will stop queuing messages for this channel.

Return bool value:

mastercb(sock, intext)

sock

the socket for communication with commhub

intext: str


Master callback handler for inbound messages

@param text - the message to handle

@param data - callback data

Class

Class MgmtClient

Public Methods

__init__(self)

__init__(self, channel)

channel: str


setChannel(self, newChannel)

newChannel: str

the new channel to use


Set the channel name

getChannel(self)

Get the channel name

Return str value: the channel name

addFixedGetParameter(self, category, newParam, fixedValue)

category: str

newParam: str

fixedValue: str


These variables have fixed values

Return bool value:

addGetParameter(self, category, newParam, getFunction)

category: str

newParam: str

getFunction


These variables are provided by function call because they're involved

Return bool value:

addSetParameter(self, category, newParam, setFunction)

category: str

newParam: str

setFunction


Declare the variables that can be changed (after calling respective addGet*()

Return bool value:

getParameter(self, category, qparam)

category: str

qparam: str


locate the parameter

Return str value:

parameterExists(self, category, qparam, get)

category: str

qparam: str

get: bool


locate the parameter

Return bool value:

setParameter(self, category, setparam, value)

category: str

setparam: str

value


locate the parameter

Return bool value:

ensureInit(self)

initIntrinsics(self)

getCategories(self, get)

get: bool


Return list value:

getNames(self, get, category)

get: bool

category: str


handleMesssage(self, cmdparam)

cmdparam: dict


Return bool value:

uptime(self)

Return str value:

incrementInboundRequestCount(self)

Report another inbound message request

incrementInboundBroadcastCount(self)

Report another inbound broadcast message request

incrementInputCount(self)

Report another inbound user response

incrementInboundErrorCount(self)

Report an inbound message that was erroneous

incrementInputErrorCount(self)

Report an inbound user response that could not be processed

Class

Class MsgImage

Summary

This is used as a cache to construct an image being received.

Public Methods

__init__(self)

Constructor.

getId(self)

Get the image's id

Return str value: the image's id

See also: Image

reset(self)

Prepare to receive a new image; reset any previous image out

imageCommand(self, msgr, src, iid, image_id, param)

msgr

instance of Messenger

  • @param src - the source message channel sending the image
  • @param iid - the transmission image id
  • @param image_id - the image id
  • @param param - the message data (image data)

src: str

iid: int

image_id: str

param


Message handling method to receive image fragement messages.

__init__(self)

Constructor to send an image through MAE messaging system.

size(self)

Get the size of the Image cache.

Return int value: the cache size

setSize(max_size)

max_size: int

maximum images to receive simultaneously


Set the cache size for the number of images to receive simultaneously

isImageCmd(self, request, param, msgr, src)

request: str

the message request coming in

  • @param param - the parameters with the request
  • @param msgr - instance of Messenger
  • @param src - the source message channel sending the image
  • @return True if was handled by us, False if not intended for usa

param

msgr

src: str


Check if the inbound message request/command is intended for us. If it is, process it.

Return bool value:

addImageLib(self, lib_id)

lib_id


Fetch an image from ImageLib, queue it for sending, and return its image id.

Return str value: the image id

getImage(self, image_id, deleteAfterGet)

image_id: str

the image id to pull from the cache

  • @param deleteAfterGet - Flag: True to delete the image from the cache after it has been fetched or False to leave it in the cache
  • @return the fetched Image

deleteAfterGet: bool


Get the received image with the provided image_id.

getImageRW(self, image_id)

image_id: str

the image id to pull from the cache

  • @param deleteAfterGet - Flag: True to delete the image from the cache after it has been fetched or False to leave it in the cache
  • @return the fetched Image, which can be altered

Get the received image with the provided image_id.

dumpImageCache(self)

sendImage(self, destination, request, params, image, errmsg, group)

destination: str

MAE channel to send the image to

  • @param request - request keyword for receiving app
  • @param params - additional data for the request to send with image
  • @param image - the image to send
  • @param errmsg - (output) an error message if image not sent
  • @param group - routing group

request: str

params

image

errmsg: str

group: str


Send the provided image to the destination.

Return bool value:

Class

Class PointList

Summary

This class is handy for representing a point in 3-D space. It's just as handy for representing just a point in 2-D space, too.

It holds the (x,y,z) value so a variety of methods can operate on it or between it and other points.

Public Properties

p

Default value: None

invalid

Default value: None


Public Methods

__init__(self, pt)

pt: str

Default value: None


Construct a point from the inputs.

if the inupt is text, it takes the form of (<number>,<number>) or (<number>,<number>,<number>) as produced by toString().  y and z are ignored.

If the input is a Point, it is copied.  y and z are ignored.

If the input is a float, then all three inputs are taken as the Point's (x,y,z) values.

@param text - the string to convert to a point

getX(self)

Get the x coordinate value

Return float value: x

getY(self)

Get the y coordinate value

Return float value: y

getZ(self)

Get the z coordinate value

Return float value: z

setX(self, value)

value: float

the new x value


Set the x coordinate value

Return value: an instance of this point

setY(self, value)

value: float

the new y value


Set the y coordinate value

Return value: an instance of this point

setZ(self, value)

value: float

the new z value


Set the z coordinate value

Return value: an instance of this point

set(self, newX, newY, newZ)

newX: float

the new x value

newY: float

the new y value

newZ: float

the new z value

Default value: 0.0


Set the (x,y,z) coordinates for this point

Return value: an instance of this point

setPoint(self)

Set the (x,y,z) coordinates for this point from another point

@param p - the point to copy (x,y,z) from

Return value: an instance of this point

Shift(self)

Translate/Shift this point by the Point given.  The (x,y,z) of the new Point is added to this Point.

@param p - the Point with the amount to shift

Return value: an instance of this point

ShiftXY(self, dx, dy)

dx: float

the amount to add to this->x

dy: float

the amount to add to this->y


Translate/Shift the point by the (dx,dy) given.  The (dx,dy) is added to this Point.

Return value: an instance of this point

ShiftXYZ(self, dx, dy, dz)

dx: float

the amount to add to this->x

dy: float

the amount to add to this->y

dz: float


Translate/Shift the point by the (dx,dy,dz) given.  The (dx,dy,dz) is added to this Point.

Return value: an instance of this point

ShiftPolar(self, radius, theta)

radius: float

amount to move

theta: float

direction to move, in radians


Adjust/translate point relative to old using polar coordinates given.

Return value: an instance of this point

translate(self)

Given a point, return the translated point.

@param p - the Point with the amount to translate

Return value: the translated point

offsetFrom(self)

Reverse-shift thie point by the amount in the Point provided.  The (x,y,z) of the new Point is subtracted from this Point to form a new point.

@param p - the Point with the amount to subtract

Return value: the offset Point

distance(self)

Calculate the distance from this Point to the Point provided

@param p - the other Point

Return float value: the distance between the points

distanceXZ(self)

Calculate the distance on the XZ plane from this Point to the Point provided, ignoring any y-axis difference.

@param p - the other Point

Return float value: the distance between the points

distanceXY(self)

Calculate the distance on the XY plane from this Point to the Point provided, ignoring any z-axis difference.

@param p - the other Point

Return float value: the distance between the points

deltax(self)

Determine the difference between the x values of the two points

@param p - the other Point

Return float value: the difference in x

deltay(self)

Determine the difference between the y values of the two points

@param p - the other Point

Return float value: the difference in y

deltaz(self)

Determine the difference between the z values of the two points

@param p - the other Point

Return float value: the difference in z

distancex(self)

The absolute (positive) distance between the x values of the two points.

@param p - the other Point

Return float value: the absolute distance in x (0 or positive)

distancey(self)

The absolute (positive) distance between the y values of the two points.

@param p - the other Point

Return float value: the absolute distance in y (0 or positive)

distancez(self)

The absolute (positive) distance between the z values of the two points.

@param p - the other Point

Return float value: the absolute distance in z (0 or positive)

snapToPrecision(self, precision)

precision: float

the precision to use


Adjust point to align with precision

origin(self)

Return the point at the origin.

Return value: a Point at the origin

valid(self)

Test if the point is valid

Return bool value: True if point is valid (not invalid)

isOrigin(self)

Test if the point is at the origin.

Return bool value: True if this Point is at the origin

invalidPoint(self)

Return an invalid point. That is, this point returns True when passed to isInvalid().

Return value: the invalid point

isInvalid(self)

Test if the point is invalid

Return bool value: True if point is invalid

inclination(self)

Test if the point is invalid

Return float value: True if point is invalid

azimuth(self)

Calculate phi, the aizmuth angle to p, where current point is focus.  Useful for creating 3-D polar coordinates.

@param p - the other Point

Return float value: the angle

angleXY(self)

Calculate phi, angle to p, where current point is focus, on the XY plane.

@param p - the other Point

Return float value: the angle, phi

angleXZ(self)

Return float value:

angleZY(self)

Calcualted angle to p, if current point is focus, on the ZY plane.

@param p - the other Point

Return float value: the angle

angle(self)

Calculate phi, angle to p, where current point is focus, on the XY plane.

@param p - the other Point

Return float value: the angle, phi

same(self, tolerance)

tolerance: float

the precision to use

Default value: POINT_PRECISION


Determine if this (x,y,z) point and the provided (x,y,z) point are the same, within a precision tolerance

@param p - the other Point

Return bool value: True if both points are the same, within tolerance

samexy(self, tolerance)

tolerance: float

the precision to use

Default value: POINT_PRECISION


Determine if this (x,y) point and the provided (x,y) point are the same, within a precision tolerance

@param p - the other Point

Return bool value: True if both points are the same, within tolerance

equal(self)

Determine if this point is equal to the provided point. This is not best practice for comparing values; instead use same().

@param p - the other Point

Return bool value: True if both points are equal

flat(self, tolerance)

tolerance: float

the precision to use

Default value: POINT_PRECISION


Determine if this point and the provided point lie in the same x-y plane (same z value) within the tolerance provided.

@param p - the other Point

Return bool value: True if both points have the same z value within tolerance

rotateRight(self, theta, focus)

theta: float

amount to rotate

focus

point to rotate around


Rotate the point clockwise around focus

rotateCW(self, theta, focus)

theta: float

amount to rotate

focus

point to rotate around


Rotate the point clockwise around focus

rotateLeft(self, theta, focus)

theta: float

amount to rotate

focus

point to rotate around


Rotate the point counter-clockwise around focus

rotateCCW(self, theta, focus)

theta: float

amount to rotate

focus

point to rotate around


Rotate the point counter-clockwise around focus

round(self, accuracy)

accuracy

the accuracy to use


Round the Point to the accuracy

Return value: the Point, rounded

midpoint(self, fraction)

fraction: float

the fraction of the way from this Point to other Point to calculate

Default value: .5


Determine a midpoint a certain fraction of the way from this point to p

If fraction not specified, then half-way point returned

@param p - the other Point

__add__(self)

Add two points together and return the new point

@param a - the other Point

Return value: the new point

__sub__(self)

Subtract the provided Point from this Point

@param a - the other Point (on the right)

Return value: the updated Point

__rsub__(self)

Subtract the provided Point from this Point

@param a - the other Point (on the left)

Return value: the updated Point

__mul__(self)

Scale this point out by the amount provided from the origin.

@param a - the amount to scale the point

Return value: the updated Point

morphPoints(self, pts, focus, angle, scale)

pts

a list of Points (is modified)

focus

a Point of focus for rotation and scale

angle: float

the amount to rotate each p[] around the focus

scale: float

the amount to scale each p[] from the focus


Given a list of Points, rotate and scale them around a focus Point.

@param n - the number of Points in array

morphPoint(self, pt, focus, angle, scale)

pt

the Point (is modified)

focus

a Point of focus for rotation and scale

angle: float

the amount to rotate pt around the focus

scale: float

the amount to scale pt from the focus


Given a Point, rotate and scale it around a focus Point.

Return value: the morphed Point

fromString(self, text)

text: str


Convert text in the form of (x,y) or (x,y,z) or x,y or x,y,z into a Point

toString(self)

Convert the Point to a text string.

Return str value: a text representation of the point

__init__(self, pts)

pts

Default value: []


Create a PointList from an array of Points

@param list - an array of Points

@param size - the size of the array

fromString(self, text)

text: str


Convert a string that was output by toString() back into a PointList

toString(self)

Convert the PointList into a string.

Return str value: a string

Class RemoteService

Summary

Class to handle MAE (two-way) messages between MAE apps.

Synchronous messages are managed by RpcBroker.

This class works in conjunction with the MAETask class, which maintains the connection to CommHub, which is required to reach the RpcBroker daemon.

Caution about using remote services: A calling app suspends execution until the response comes back. If the daemon handling the service makes a service call to the app (or perhaps indirectly through a third daemon), you'll have a deadlock condition, causing a timeout.

To register to receive and process these messages, the registering daemon creates an instance of RemoteService; as long as that instance exists, the daemon will be registered to receive the requests; when the instance is destroyed, the daemon will no longer receive requests to process the service.

Public Properties

list

Default value: []


Public Methods

__init__(self, service, cbfn, cbdata, timeout)

service: str

the unique (within MAE) name of the service to register (a keyword)

cbfn

the method to handle all requests for this service

cbdata

any data to accompany the method call

timeout: int

number of seconds to allow for a response before issuing a timeout to the calling app


Setup/Register a new remote service

__del__(self)

Destructor for the service. The app will no longer recognize and process the service setup by the constructor.

lineEncode(text)

text: str

the message to send


Prepare a message to be sent through commhub

Return str value: encoded text that is compatible for transmission

lineDecode(text)

text: str

the message that was sent


Process a message sent from commhub to restore it to the original request.

Return str value: decoded text that is restored and ready for processing

call(service, params)

service: str

the name of the service requested

params

the input paramters to that service


Call a remote service with the provided service name and parameters.  This is synchronous SOA.  If the service has been registered with RpcBroker, then the registered daemon will process the request and send back a response. Otherwise, an error is returned.

Return value: the response from that service (status, return data); if an error occured, result["rpc_error"] holds the error message. The response comes directly from the registered daemin, with these additional XML fields:

Same as service

rpc_request_id

RpcBroker id for the transaction

rpc_app_id

Id of the registered daemon that serviced that request


mastercb(sock, text, data)

sock

the socket for communication with commhub

text: str

the message to handle

data

callback data

Default value: None


Master callback handler for inbound RPC responses

setError(result, error)

result

a structure that will be passed back as a result

error: str

the error message to insert into the structure


Set error message into response

Return value: updqated result

getServiceName(self)

Get the name of this remote service.

Return str value: the name of the service.

getError(result)

result

the value returned by call()


Get the error message after a call

Return str value: a string that is the error message

Class Socket

Summary

This class abstracts a socket connection to another process via TCP, UDP, Unix domain socket, etc., providing a higher level interface that is easier for an application to manage.

Public Properties

limit

Default value: 100


Public Methods

__init__(self, host, port)

host: str

The hostname to socket.connect to (if empty, then localhost)

Default value:

port: int

The remote TCP port to socket.connect to

Default value: 0


Prepare for a TCP socket socket.connection

Return value: instance of Socket to open()

open(self, host, port)

host: str

The hostname to connect to (if empty, then localhost)

Default value:

port: int

The remote TCP port to connect to

Default value: 0


Open a TCP socket connection

Return bool value: True if connected, False otherwise

__del__(self)

Finish using (close) a socket socket.connection.

close(self)

Close the TCP socket.connection

Return bool value: True if closed, False otherwise

isClosed(self)

Determine if socket is open/active

Return bool value: True if socket is closed

eof(self)

Determine if the socket socket.connection has hit EOF

Return bool value: True if EOF detected

fd(self)

Get the file descriptor (for select() of socket)

Return int value: file descriptor

getErrno(self)

Get the last known error state after a Socket method is called

Return int value: the value of errno after the last I/O call

sleep(self, seconds, useconds, exitOnInterrupt)

seconds: int

Default value: 0

useconds: int

Default value: 0

exitOnInterrupt: bool

Default value: False


return True if sleep lasted whole time, False if sleep was interrupted

Return bool value:

isReadReady(self, wait)

wait: bool

True if this routine should wait until it's ready

Default value: False


Determine if socket is ready to be read (it has input)

@return -1 on error (EOF), 1 if ready, 0 if not ready

Return int value: 1 if data ready to be read, 0 if it's not ready, -1 on error or EOF

isWriteReady(self, wait)

wait: bool

Default value: False


Determine if socket is ready to be written

Return int value: 1 if data ready to be written, 0 if not ready (or EOF), -1 see errno

signalRaised(self)

Check if an alarm signal was received during I/O

Return bool value: True if an alarm signal was signal.raised

clearSignal(self)

Clear the flag that a signal was signal.raised

signalLock(self, locked)

locked: bool


Signal is locked when being serviced

writeBytes(self, text)

text: str

The text scring to write


Write out the specified bytes to the socket

Return int value: the number of bytes successfully written

write(self)

Write out a single character to socket

@param c the character to write

Return int value: the number of characters successfully written (1 or 0)

readLine(self, wait, ignoreSignal)

wait: bool

True if this routine should wait until there's a response

Default value: True

ignoreSignal: bool

True if signals should not be serviced

Default value: False


Read text up to a newline.

Return str value: the string read.  If empty, check self.getErrno().

setTcpNoDelay(self, nodelay)

nodelay: bool


Disable buffering on socket.

Return bool value: True if operation successful, False otherwise

clearErrno(self)

Class Stopwatch

Summary

This class is handy for timing things, like with a stopwatch. It measures the amount of time between the start() call and the stop() call at the microsecond level.

Public Methods

__init__(self, startImmediately)

startImmediately: bool

Flag: True to start the stopwatch immediately, False to wait

Default value: True


Instantiate the stopwatch. By default, it starts starts immediately.

start(self)

Start or restart the stopwatch. Time elapsed will be counted from this point.

Return bool value: True if the stopwatch was reset, False if the stopwatch was not previously running

restart(self)

Restart the stopwatch to count time from this point.

Return bool value: True if the stopwatch was reset, False if the stopwatch was not previously running

stop(self)

Stop the stopwatch.  Elapsed time will no longer be counted.

Return bool value: True if it was stopped False if it was already stopped

elapsed(self)

Return the amount of time (in seconds) for the elapsed time

If the stopwatch is running, calling this method does not change its run status

Return float value: seconds of elapsed time

startTime(self)

Return the time (in epoch/unix time) in seconds when the stopwatch began

Return float value: the time (in epoch/unix time) when the stopwatch began, accurate to microsecond

calcValue(self)

Calculate the elapsed time and put it in the this.value

Class StrExt

Summary

This class provides conversion, parsing and other useful additions for string manipulation. Member functions defined in this class should be all static. These functions were wrapped by this class for organization purposes.

Public Properties

whitespaceChars

Default value: " \t\r\n\f"


Public Methods

split(input, delimiter)

input: str

the text string to split apart

delimiter: str

the text separator


Tokenize a string using the char parameter as a delimiter, and put each sub string into a vector of strings.

Return value: the vector of strings

concat(textlist, delimiter)

textlist

a series of strings to combine

delimiter: str

the delimiter to insert between the strings


Combine an array of strings and insert delimiters between them.

This is the complement of split().

Return value: a single string

tokenCount(input, separator)

input: str

the string to analyze

separator: int

the character that separates the tokens


How many tokens are in this string?

Return int value: the count of the number of tokens; if the string is blank, 0 is returned

getTokenAt(input, delimiter, pos, honorEscape)

input: str

the text string to split apart

delimiter: str

the text separator

pos: int

the token to return, e.g. 0+. If it doesn't exist, null string returned

honorEscape: bool

if True and separator is preceded by \, then it's not a separator; note that the \ is removed from the result

Default value: False


Tokenize a string using split() and then return the nth token at pos.

Return str value: the nth token from input string; or null string

stripLeading(strToStrip, charsToStrip)

strToStrip: str

the string to be stripped (in place)

charsToStrip: str

contains all chars to be stripped


Strip specified chars from beginning of string

Return str value: ref to string passed in, now stripped

stripLeadingWhitespace(strToStrip)

strToStrip: str

the string to be stripped (in place)


Strip whitespace from beginning of string

Return str value: ref to string passed in, now stripped

stripTrailing(strToStrip, charsToStrip)

strToStrip: str

the string to be stripped (in place)

charsToStrip: str

contains all chars to be stripped


Strip specified chars from end of string

Return str value: ref to string passed in, now stripped

stripTrailingWhitespace(strToStrip)

strToStrip: str

the string to be stripped (in place)


Strip whitespace from end of string

Return str value: ref to string passed in, now stripped

stripLeadingTrailing(strToStrip, charsToStrip)

strToStrip: str

the string to be stripped (in place)

charsToStrip: str

contains all chars to be stripped


Strip specified chars from beginning and end of string

Return str value: ref to string passed in, now stripped

stripLeadingTrailingWhitespace(strToStrip)

strToStrip: str

the string to be stripped (in place)


Strip whitespace from beginning and end of string

Return str value: ref to string passed in, now stripped

startsWith(input, start)

input: str

the long string

start: str

the text to match at start


Check if input tring starts with text that matches

Return bool value: T/F if input string starts with /start/ string

endsWith(input, ending)

input: str

the long string

ending: str

the text to match at start


Check if input tring ends with text that matches

Return bool value: T/F if input string starts with /start/ string

trimLeft(text, length)

text: str

length: int

the number of characters to remove from the front


Remove characters from beginning of input string.

@param input input string being reduced

Return str value: the input string minus strlen(token) off the front

trimRight(text, length)

text: str

length: int

the number of characters to remove from the end


Remove characters from end of input string.

@param input input string being reduced

Return str value: the input string minus strlen(token) off the end

trimToken(text, token, trimWhite)

text: str

token: str

the token string being removed from input string

trimWhite: bool

flag to remove whitespace after removed token

Default value: True


Remove token from beginning of input string.

Note, no matching is performed to see if token really begins

the string or not.  This is simply a convenience for length counting.

@param input input string being reduced

Return str value: the input string minus strlen(token) off the front

trimQuotedToken(input, token, trimWhite)

input: str

input string being reduced

token: str

the token string being removed from input st

trimWhite: bool

Default value: True


Remove token from nextQuotedToken() from beginning of input string.

Note, no matching is performed to see if token really begins

the string or not.  This is simply a convenience for length counting.

A check is performed, however, to see if input string has quotes; if so,

2 extra characters are trimmed in addition to token.

Return str value:

trimIfLeading(input, textToTrim)

input: str

input string being reduced

textToTrim: str

the token string being removed from input string


Remove leading text from input string if text present, otherwise

leave input string alone.

Return str value: the input string minus textToTrim off the front

trimIfTrailing(input, textToTrim)

input: str

input string being reduced

textToTrim: str

the token string being removed from input string


Remove trailing text from input string if text present, otherwise

leave input string alone.

Return str value: the input string minus textToTrim off the front

nextToken(text)

text: str


Get first/next token (up to whitespace) in input string

Use trimToken() to remove the token; token not removed from input.

@param input the string being parsed

Return str value: the first token in the string.

extractToken(text, trimWhite)

text: str

trimWhite: bool

Default value: True


Returns a tuple - (text, token) - with the modified text plus the extracted token

nextIdentifier(input, allowClass)

input: str

the string being parsed

allowClass: bool

flag to allow classname:: to precede identifier; if True, class name and identifier are returned

Default value: False


Get first/next identifier in input string. An identifier starts with an alphabetic character (or _) and is optionally followed by more characters, which  may be alphanumeric or _.

Use trimToken() to remove the token; token not removed from input.

Return str value: the first identifier in the string.

extractIdentifier(input, trimWhite, allowClass)

input: str

the string being parsed and token removed (in place)

trimWhite: bool

flag to remove whitespace after removed identifer

allowClass: bool

flag to allow classname:: to precede identifier; if True, class name and identifier are returned

Default value: False


Extract and return first/next identifier in input string.

Convenience over using nextIdentifier() and trimToken().

Return value: the first identifier in the string.

nextQuotedToken(input, removeQuotes)

input: str

the string being parsed

removeQuotes: bool

Default value: True


Get first/next token in input string that may be quote contained.

No quotes means just call nextToken().  Quotes may be " or '.

Quotes inside quoted string must be escaped.

Use trimToken() to remove the token; token not removed from input.

Return str value: the first token in the string.

extractQuotedToken(input, removeQuotes)

input: str

the string being parsed and token removed (in place)

removeQuotes: bool

specify whether to remove the quotes from result

Default value: True


Extract and return first/next quoted string in input string

Convenience over using nextQuotedToken() and trimToken().  Quotes may be " or '.

Quotes inside quoted string must be escaped.

Return value: the first token in the string.

toInt(input)

input: str


Convert a string into an integer as best as possible; default is 0

Return int value:

toFloat(input)

input: str


Convert a string into an float as best as possible; default is 0.0

Return float value:

toBool(value)

value: str


Get a boolean value from the input

Return bool value:

findAndReplace(input, findThis, replaceWith, startNdx, maxReplacements)

input: str

string to be modified

findThis: str

the substring to search for in input

replaceWith: str

the substring to replace findThis with

startNdx: int

the index into input at which to begin searching

Default value: 0

maxReplacements: int

the max number of replacements to perform, 0 means replace all

Default value: 0


Replace occurences of a specified substring within a string with another string

Return value: reference to input string, now potentially modified

escapeNewline(stringToEscape)

stringToEscape: str

string with \n


Escape any newline characters.

This converts the new line character to the two characters "".

And converts the two characters "" to "\".

And converts the three characters "\" to "\\".  Etc.

Return str value: the string with \n's removed and escaped

unescapeNewline(stringToUnescape)

stringToUnescape: str

escaped string


Unescape any newline characters.

This converts the two characters "" to the new line character.

And converts the three characters "\" to "".

And converts the four characters "\\" to "\".  Etc.

Return str value: the string with \n's escaped

Class StringList

Super class: list

Summary

A class to manage an ordered list of strings. This is not a set; a string may appear on the list multiple times.

Note: by default, a string must not contain a comma to leverage this class's full functionality. A different separator character can be used if commas are needed in the strings.

Public Methods

__init__(self, text, separator)

text: str

separator: int


Constructor. Create a StringList from a vector of string

@param list - a vector of strings to convert

toString(self, separator)

separator: str

the separator token

Default value: '


Serialize the string list.

Return str value: a string with the ordered list of strings in it

fromString(self, text, separator)

text: str

a serialized list of strings, which may optionally be enclosed in double quotes

separator: str

the character that separates the strings

Default value: '


Reload the string list from the serialized string list in text.

add(self, element)

element: str

the new string to add


Add a new string to the list.

Return bool value: True if element is not empty

hasElement(self, element)

element: str

a string to check


Determine if a specific string is in the list. A literal comparison

is performed, case sensitive.

Return bool value: True if element is already in the list (literal)

contains(self, element)

element: str

a string to check


Determine if a specific string is in the list. A literal comparison

is performed, case sensitive.

Return bool value: True if element is already in the list (literal)

find(self, element)

element: str

a string to check


Locate the position of a string in the string list.

Return int value: the position, 0+ or -1 on error

remove(self, element)

element: str


Remove a single string or a list of strings from the list.

@param other_list - the list of string to remove

Return bool value: True if string at least one string was found and removed

replace(self, oldtext, newtext, all)

oldtext: str

the string to locate

newtext: str

the replacement string

all: bool

if True, check whole list (don't stop at first match)


Replace a string in the list with a new string.

Return bool value: True if at least one string was found and replaced

sort(self)

Alphabetically sort the list of strings.

Return value: the instance back

Class Timer

Summary

Class to manage multiple timers, whether one-shot or periodic.

Unlike the Unix timer, this class provides app-provided callback data when each timer trigters.

This class is useful when you have multiple timed activities that need to happen at various times. When the time comes, the callback function is called.

It's also useful for event-driven programming where execution hangs off a select() statement.

Note: Only use one instance of this class. It claims the alarm() signal. If you use multiple instances, only the last instance invoked will be handled.

Public Properties

TIMER_END_OF_TIME

A special number to represent the end of time

Default value: 999999

secondsTillEndOfTime

A special number to represent how many seconds till the end of time

Default value: 999999


Class

Class

Class UserDevice

Using UserDevice

This class abstracts the end-user's device, which is presumably a web browser, but may be something else. The user views information, enters responses, selects users controls (buttons, pull-downs, etc), uploads data, and downloads data.

The UserDevice class is used to identify an I/O endpoint abstractly so an application can have a handle to that endpoint without needing to understand protocols, terminal information, graphics standards, etc.  This class abstracts all of that.

An I/O endpoint is a user.  The user operatates in a role, presently the roles are dm (referee) and pc (player).  A pc is unique to a setting or game milieux/environment/system.  A dm may referee multiple settings.  A pc  connection may be from the owning user id, a proxy user id (friend), or the dm.

An I/O endpoint runs one or more applications inside the system.  This is called the app mode.

The UserDevice class captures the role, user id, pc id, setting id, and app mode.  Those elements uniquely identify a endpoint/connection.

The endpoint has predefined elements: menus, attention box, and chat box. The menus are implmented using the local graphics system.  Menus are only two-levels.  An attention box is a prominent way to present a message/alert to the user.  The chat box is used for communicating among multiple users.

The UserDevice class also has an optional pararameter known as a region. This is an area/hotspot/named element of the interface.  To format text into something attractive, the various elements of the screen/page/display are named.  Text is sent to that named region so output appears comprehensible (and hopefully user-friendly!) to the end-user.  When the user enters data, clicks or otherwise activates an element of the interface, that element's name is passed through UserDevice as the region.

The UserDevice class has a method toString() which can be later passed to instantiate another UserDevice with all the key information.

Format

Syntax:

This string follows the format:

role:/userid/pcid/wid/app[/region[/group]

where

Term

Description

role

The role is either dm or pc.  In DM role, the userid must be non-zero; and the pcid is 0.

userid

The id from the User datastore. In PC role, the userid may be 0 to broadcast something to all endpoints in used by the pc.  In PC role, pcid must be non-zero.

pcid

The id from the PC datastore.  In DM mode, the pcid is 0 for privileged/referee interaction.

wid

The id from the Setting datastore.

appmode

The appmode can be one of:  console, userman, mapedit, hexit, market, supervisor.

The label for the appmode may be 100 characters or less.

region

The region varies based upon the appmode.  It identifies the UI area of focus, whether for input or output. The region 'attn' is common to all apps; it represents the attention box.

The label for the region may be 100 characters or less.

group

This is an internal value used for routing.


Examples

Example UserDevice endpoint identification strings:

dm:/1/0/console

pc:/1/3/console

pc:/3/3/3/console//E3

pc:/3/3/3/console/attn/E3

pc:/3/3/console/attn

Notes

UserDevice is implmented using messages across a message bus to two daemons: usergw (channel: display) and guibroker (channel: input, gui).  The usergw daemon is like a device driver - it knows how to convert the request into the graphical display's protocol/API/syntax.  It also knows how to take input from the endpoint and standardize it into an understandable input in this system.  It forwards those inputs to the guibroker daemon.  The guibroker daemon plays two key roles:  it responds to user input (such as user keystroke, mouse click, hotspot activiaction or command request) and it handles non-simple I/O (such as prompting user with a question, sending a user interface control (selector, textbox), or handling a form with multiple input entry areas).  The guibroker daemon is more abstract than the device-aware usergw daemon.

Input initiated by the user and non-simple I/O is then translated into requests on the message bus to which system applications subscribe and process.  For example, the setting daemon as a SettingApp class with a method to process messages on the 'setting' channel.  These messages often come from guibroker, but they may come from other daemons in the system as well.  The SettingApp daemon acts as a setting processor that responds to its defined set of requests.

Public Properties

cbfn

Callback to call for UI events

Default value: None

formcbfn

Callback to handle a submitted form

Default value: None


Public Methods

valid(self)

Determine if this is a valid UserDevice session or not.

Manipulating an invalid session is pointless.

Return bool value: True if this UserDevice is a valid session

__init__(self, user_id, pc_id, setting_id, appmode, region, group)

user_id

the database record id in the User table of the user on this device. Alternately, if this is text, it is taken as a previously serialized instance of UserDevice and unserialized (and rest of params are ignored)

Default value: 0

pc_id: int

a secondary database record id of this user

Default value: 0

setting_id: int

a context id of this user, e.g. group id, company id, project id, etc.

Default value: 0

appmode: str

the channel of the primary app responsible for managing interaction with this user

Default value:

region: str

the named region where the last user interaction happened

Default value:

group: str

name of server group handling this user's session

Default value:


Constructor for structure to manage user interactions.

fromString(self, text)

text: str


Unserialize a serialized instance of UserDevice.

Example strings:

dm:/1/0/3/console

pc:/1/3/3/console

pc:/3/3/3/console#E3

pc:/3/3/3/console/attn/E3

pc:/3/3/console/attn

Syntax:  dm|pc :/<userid>/<wid>/<app>[/<region>]

toString(self)

Serialize the UserDevice class into a string so it can be communicated

to another MAE app.  See:ructor that takes a lone string.

Return str value: a string representation of UserDevice

copy(self)

Make a copy of ourself

getUserId(self)

Get the relevant user's DB table User id for this session.

Return int value: the user's record id, 0 for public or invalid session

getConnectionId(self)

If the User id is 0, it may be a public (non authorized) session.

If so, the ConnectionId will be non-zero.

Return int value: the unqiue connection id (only valid if User id is 0)

getPlayerId(self)

The Arana app doubles the connection id with the PC id.

Return int value: the database table PC id of content being displayed

getSettingId(self)

The Arana app maintains a game session, which is the database

table Setting id.

Return int value: the game Setting id

getAppMode(self)

The application mode is set by the application and used to route

user responses to the correct app.  It is actually the application

channel handled by msgbroker.

Return str value: the application mode

getServerGroup(self)

When scaling MAE deployments, we track which group of servers is

handling this user's session.

Return str value: the server group name

getRegion(self)

Return the current region to control or the last region the user

interacted with. This region may have dashes in it, but no spaces.

The region is sometimes referred to as a display tag.

Return str value: the region name

isDM(self)

Determine if this is an elevated privilege session.

Return bool value: True if session is elevated in privilege

isPlayer(self)

Determine if this is not an elevated privilege session.

Return bool value: True if session is not elevated in privilege

isConnection(self)

Determine if this is an unauthorized but valid user session.

Such connections are considered public or anonymous because we

don't have information on who the user is.

Return bool value: True if session is public

isUser(self)

Determine if this is an authorized session where a person has

authenticated and we know who the user is.

Return bool value: True if this is an authorized session

setUserId(self, newId)

newId: int

a valid id from the User table


Set the database table User id for this session.

This is typically set by the device gateway daemon, e.g. usergw.

Return value: this UserDevice instance back

setConnectionId(self, newId)

newId: int

a valid connection id


Set the connection id for this ession.

This is typically set by the device gateway daemon, e.g. usergw.

Return value: this UserDevice instance back

setPlayerId(self, newId)

newId: int

a valid PC table id


For the Arana app, set PC table id, which is the context for the displayed content.

This is typically set by the device gateway daemon, e.g. usergw.

Return value: this UserDevice instance back

setSettingId(self, newId)

newId: int

a valid Setting table id


For the Arana app, set the Setting table id (game id).

This is typically set by the device gateway daemon, e.g. usergw.

Return value: this UserDevice instance back

setAppMode(self, newMode)

newMode: str

an application where users responses are managed


Set the application mode for this session.

This is typically set by the device gateway daemon, e.g. usergw.

If an app sets it, it must know that the use device is also monitoring

the new application mode, otherwise the user will never see the

intended output.

Return value: this UserDevice instance back

setServerGroup(self, newGroup)

newGroup: str

an application where users responses are managed


Set the server group managing this user session.

This is typically set by the device gateway daemon, e.g. usergw.

If an app sets it, it must know that the use device is inside

the group, otherwise the user will never see the  intended output.

Return value: this UserDevice instance back

setRegion(self, newRegion)

newRegion: str

the name of new target region (aka display tag); size limited to 100 chars


Specify the target display region that successive plans are

controlling/displaying output to.

Return value: this UserDevice instance back

clearRegion(self)

Clear the name of the target display region.

An unnamed region cannot be controlled. Only named regions can

be controlled.

Return value: this UserDevice instance back

setDM(self, yes)

yes: bool

True for privileged connection, False for non-privileged

Default value: True


Set user privileged mode for this session.

This is typically set by the device gateway daemon, e.g. usergw.

Return value: this UserDevice instance back

setPC(self, yes)

yes: bool

True for non-privileged connection, False for privileged

Default value: True


Set user unprivileged mode for this session.

This is typically set by the device gateway daemon, e.g. usergw.

Return value: this UserDevice instance back

setUserVariable(self, variable, value)

variable: str

the end-user device variable to set; two reserved variables: WID (Setting id) and pc (Player id)

value: str

the new value of the variable


Set a session-specific variable for this app mode.

Return bool value:

getUserVariable(self, variable)

variable: str

the end-user device variable to set; two reserved variables: WID and pc


Complement to setUserVariable(): pull the current variable value for the app mode specific session. This may be handy for sharing certain state between multiple apps that operator together for an application. Or for one app to remember state between calls.

Return str value: the current value (string) of the named variable

getUserVariableInt(self, variable)

variable: str

the end-user device variable to set; two reserved variables: WID and pc


Complement to setUserVariable(): pull the current variable value for the app mode specific session. This may be handy for sharing certain state between multiple apps that operator together for an application. Or for one app to remember state between calls.

Return value: the current value (int) of the named variable

pushSettingId(self, newSettingId)

newSettingId: int

the new id the user should use

Default value: 0


Change the active tenant id (in Arana app, the setting id) on the user's device. Going forward, user responses will designate the new tenant id.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device)

pushPlayerId(self, newPlayerId)

newPlayerId: int

the new id the user should use

Default value: 0


Change the active display context for the user.  (In Arana app, this is the player id on the user's device.) Going forward, user responses will designate the new player id in UserDevice.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device)

setfield(self, table, field, value)

table: str

field: str

the name of the field in the group to update

value: str

the new (string) value to display (the old value is cleared)


Update a specific display tag (field) of a group of value values. If you setup your display areas using group_field, then use setfield to set its value on the user's display.

@param group - the name for the group of fields

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

settext(self, value, tag, style)

value: str

tag: str

the name of the region to update

Default value:

style: str

The formatting style name to assert for this region of the display

Default value:


Update the display with plain text at the tagged location (replace previous text).

@param text - the new plain text

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

write(self, text, tag, style)

text: str

the text to add to the display region

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:


Add more text to the display at the tagged location.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

writeln(self, text, tag, style)

text: str

the text to add to the display region

Default value:

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:


Add more text and a line break to the display at the tagged location.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

writewiki(self, text, tag)

text: str

wiki formatted text

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Add formatted text using simple wiki formatting.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

addhotspot(self, text, action, cbdata, tag, style)

text: str

the text to display to the user

action: str

the action to take (message received by app)

cbdata

callback data included in message for app

tag: str

Default value:

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:


Create an actionable hotspot in output stream at display region.

If cbdata['device'] is set, it overrides the user's input device.

An action may be a keyword processed in guibroker:hotspot.py, but

it may also be cmd:..., click:..., key:...; see guibroker:ioConsole.py

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

button(self, text, action, cbdata, tag)

text: str

the label for the button

action: str

the action to take (message received by app)

cbdata

callback data included in message for app

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Display a button on the end-user device; when the user click on it, it will trigger an action (a message to the calling app)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

style(self, styleName, tag)

styleName: str

configured in /usr/mae/html/ (in css file)

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Set the display style for the display region. Existing text will be re-displayed using next style.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

attention(self, text)

text: str


Send a message to the attention! box to call it out to the user.

param text - The message to display.

return True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

Return bool value:

record(self, recordName, values, tag, overwrite)

recordName: str

template file from /usr/mae/html/record/

values: HashArray

key/value pairs to assert into the record

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:

overwrite: bool

True if existing content at tag should be cleared first; otherwise this record is added to that display region

Default value: True


Output a record of information.

When recordName contains a period, the tag prefixes are truncated there.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

recordTemplate(self, recordName, idmap, values, tag, overwrite)

recordName: str

template file from /usr/mae/html/record/

idmap: HashArray

key/value pairs for mapping the keys of values to the keys in the record (key/value is: values key / recordName id)

values: HashArray

key/value pairs to assert into the record

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:

overwrite: bool

True if existing content at tag should be cleared first; otherwise this record is added to that display region

Default value: True


Output a record of information using a templte to map old UI ids to new ones

for idmap, the key is the old id and the value is the new id

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

selection(self, value, tag)

value: str

a valid selector option of the tag'ed selector

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Set the selection value for a selector.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

chat(self, fromuser, text)

fromuser: str

the name of the sender of the message

text: str

the text of the message


Send a chat message to a PC (if PC=0, then from DM).

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

report(self, reportName, table, table_id, tag)

reportName: str

table: str

the group name / table name

table_id

table record id of data to display

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Future feature (not implemented). Output a report of information

@param report - the name of the report to use

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

addRegion(self, tag, styleName, size)

tag: str

the name of the new region

styleName: str

configured in /usr/mae/html/ (as css file)

Default value:

size: int

(optional) expected size (in characters), 0 means dynamic

Default value: 0


Create an ad hoc region right here (size is charater allocation for region) inside the current region.

Return value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

clear(self, tag)

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Update the display by clearing all text in the target region.

Return value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

show(self, tag)

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Show/unhide a tagged region or display block

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

hide(self, tag)

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Hide a tagged region or display block

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

setMenu(self, menu, option, action)

menu: str

Name of menu

option: str

Text of option under menu name

action: str

message to send to app when menu selected


Enable a menu option; your app gets a message (action) when option selected by user.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

unsetMenu(self, menu, option)

menu: str

Name of menu

option: str

Text of option under menu name; if none, then all options disabled

Default value:


Disable a menu option

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

setWindow(self, windowName)

windowName: str

the name of the window to create or switch to


Enable a window option or create a window, return the device handle for the window

Create a new region that is a window in a set of windows

Return value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

unsetWindow(self, windowName)

windowName: str

the name of the window to unset; if none, then all

Default value:


Disable a window option

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

setIndex(self, indexName)

indexName: str

the name of the index to create or switch to


Enable a window option or create a window, return the device handle for the window

Create a new region that is an index in a set of indices

Return value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

unsetIndex(self, indexName)

indexName: str

the name of the index to unset; if none, then all

Default value:


Disable a index option

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

newTable(self, name, tableType, rows, columns)

name: str

the unique name for the table (used by setTable())

tableType: str

is for future use

Default value:

rows: int

number of rows, if known

Default value: 1

columns: int

number of columns, if known

Default value: 1


Create a table of rows and columns; it is created inside the current display region.

Create a new region that is a table of cells. Each cell in the table is its own display region.

Return value: the device handle for the table

setTable(self, name)

name: str

the name of the table


Reference an existing table, return the device handle for the table

Return value: the device handle for the table

tableRowColumn(self, row, column)

row: int

The row number (starting at 1)

column: int

The column number (starting at 1)

Default value: 1


Return a UserDevice pointer to a cell of the table

This operates on a UserDevice that is a table (row 1+, column 1+).

If you request one column beyond the current column count, a new column is allocated for it.

If you request one row beyond the current row count, a new row is allocated for it.

Return value: the device handle for the table at the specific row and column

newSection(self, title, sectionType, tag)

title: str

title to display for this section

sectionType: str

An example type is 'h3,collapsable', which styles the name has h3 and adds interface compontent to expand/collapse the section

tag: str

region name in which new section should be placed

Default value:


Create a display section, which the user can control whether its hidden or not

Return value: the device handle for the section

getSection(self, title, tag)

title: str

title to display for this section

tag: str

region name in which the section was placed

Default value:


Get a previously devined section. Note: if the tag was specified before, it must be specified again to find the right section.

Return value: the device handle for the section

collapseSection(self)

Display a collapsable section as collapsed

Return value: the device handle for the section

expandSection(self)

Display a collapsable section as expanded

Return value: the device handle for the sectio

rmSection(self, title, tag)

title: str

title to display for this section

tag: str

region name in which the section was placed

Default value:


Remove a section

Return value: the device handle for the section

newList(self, name, items)

name: str

the unique list name

items: int

a count of the number of items in the list

Default value: 1


Create a new region that is a list of list items. No bullets implied.

Return value: the device handle for the list

listItem(self, item_no)

item_no: int

the item position (starting at 1)


Return a UserDevice pointing to a list item of the list. Each list item is its own region.

This operates on a UserDevice that is a list.

Return value: the device handle for the list item

newImage(self, imageName, module)

imageName: str

the name/keyword of the image

module: str

the name of the module that is creating the image; interpretation by app

Default value:


Create an image buffer to manipulate

Return value: an initialized Image structure to use to create an image to display

drawImage(self, image, tag)

image

an image created by newImage()

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Display a created image to the user (apps call this)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

addimagehotspot(self, image, action, cbdata, tag)

image

the image to display to the user

action: str

the action to take (message received by app)

cbdata

callback data included in message for app

tag: str

the name of the region to update; if blank, use last setRegion() tag


Create an actionable image hotspot in output stream at display region.

This hotspot will return mouse (x,y) coordnates where the click occurred.

If cbdata['device'] is set, it overrides the user's input device.

An action may be a keyword processed in guibroker:hotspot.py, but

it may also be cmd:..., click:..., key:...; see guibroker:ioConsole.py

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

addhinttext(self, text, tag)

text: str

the help/hint text for user

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


If supported on end-user device, display some help/hint text to user for this region, perhaps when the user hovers over the text.

Return bool value:

bufferImage(self, imageName, image_type, width, height, size, data, binary)

imageName: str

the name/keyword of the image

image_type: str

type of image, e.g. png, jpg, gif

width: int

width of image in pixels

height: int

heigh of image in pixels

size: int

size of image in bytes

data

the raw image

binary: bool

set to True if raw image data is binary

Default value: True


Send an image to be displayed (does not display image) on display channel (usergw)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

displayImage(self, image_id, action, cbdata, tag)

image_id

image's id in Image Library

action: str

the action to take (message received by app)

cbdata

callback data included in message for app

tag: str

the name of the region to update; if blank, use last setRegion() tag

Default value:


Display an image out of the Image Library (ImageLib DB table).

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

playAudio(self, audioName)

audioName: str

the audio sound's name (or HTML tag, e.g. audio_audioName)


Play the referenced audio sound.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

upload(self, imageName, image_type)

imageName: str

the base name of the suggested filename

image_type: str

the type (file extension) of image sent


Upload a buffered image (or content) in out-of-band from the display to upload it to the user

Return bool value:

download(self, query, cbtag, cbdata, fileclass, tag)

query: str

the prompt for the user

cbtag: str

cbdata

callback data included in message for app

fileclass: list

Default value: []

tag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:


Download a file from the user. Creates a special download region which the user uses to send a file to MAE.

@param action - the action to take (message received by app)

@param types - a list of file types that may be received

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

downloadImageLib(query, action, cbdata, tag)

query: str

the prompt for the user

action: str

the action to take (message received by app)

cbdata

callback data included in message for app

tag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:


Download a file from the user and transfer it to the Image Library. Creates a special download region which the user uses to send a file to MAE.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to display channel (usergw)

registerMenu(menuname, submenuname, action, appmode)

menuname: str

Name of menu

submenuname: str

Text of option under menu name; if none, then all options disabled

action: str

message to send to app when menu selected

appmode: str

the app mode for this menu option

Default value:


Register a Menu option for guibroker to manage. When the user first connects to the appmode/channel, guibroker will setup the mneu system automatically.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

registerKey(keystroke, action, appmode)

keystroke: str

a key may be 'a' or 'ctrl-a' or 'alt-a' etc.

action: str

message to send to app when keystroke typed

appmode: str

the app mode for this keystroke

Default value:


Register a keystroke for guibroker to manage. When the user first connects to the appmode/channel, guibroker will setup the keystrokes automatically.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

registerHotspot(region, action, appmode)

region: str

a display region name

action: str

message to send to app when clicked upon

appmode: str

the app mode for this click

Default value:


Register a hotspot for guibroker to manage. When the user first connects to the appmode/channel, guibroker will setup the keystrokes automatically.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

redirectHotspot(region, otherapp, appmode)

region: str

a display region name

otherapp: str

the channel of where to send the click

appmode: str

the app mode for this click

Default value:


Register a hotspot for guibroker to manage and when clicked upon, redirect to a different app. When the user first connects to the appmode/channel, guibroker will setup the keystrokes automatically.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

registerMouse(region, action, appmode)

region: str

a display region name

action: str

message to send to app when clicked upon

appmode: str

the app mode for this click

Default value:


Register a hotspot for guibroker to manage; when the user clicks upon it, they (x,y) coordinates in the region are sent. When the user first connects to the appmode/channel, guibroker will setup the keystrokes automatically.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

registerCommand(cmd, cbdata, appmode)

cmd: str

the action/request to permit

cbdata

the parameters to send with the command

Default value: XMLData()

appmode: str

the app mode for this command

Default value:


Register a valid command from the user device. If an action is initiated from the display that was not otherwise registered, this call permits it to pass through to the app.

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

run(self, appname, params)

appname: str

the new app to switch to (appmode)

params

parameters to pass to the called app

Default value: XMLData()


Switch to a different application - this is the one for you to call

guibroker handles this first to clean up the GUI before switching to the new app

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)p

webpage(self, url)

url: str

a website URL on the Internet


Pull up a webpage from another site

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

quit(self)

Stop running the current application - switch to default/home app

guibroker handles this first to clean up the GUI before switching to the new app

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

logout(self)

Stop running all applications, de-authenticate user, and switch to default/home pages

guibroker handles this first to clean up the GUI before switching to the new app

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

query(self, question, prefillAnswer, queryType, cbtag, cbdata, displayTag, style)

question: str

Text to appear next to the prompt

prefillAnswer: str

the default answer for the user; in a form, this is the previous value

queryType: str

queryType may be:  text - a text string; YN - prompt for yes or no response; int - prompt for an integer; select - prompt for a selection; textarea - prompt for a block of text; (die roll, e.g. Dice.toString()) - prompt player to roll dice

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:


Send a query for the user to respond to and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryText(self, question, cbtag, cbdata, displayTag)

question: str

Text to appear next to the prompt

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:


Send a query for the user to respond to with a short text answer and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryRoll(self, question, dieRoll, cbtag, cbdata, displayTag)

question: str

Text to appear next to the prompt

dieRoll

the dice range, e.g. Dice('2d4+2')

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:


Send a query for the user to respond to with a dir roll (number) and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryYN(self, question, cbtag, cbdata, displayTag)

question: str

Text to appear next to the prompt

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:


Send a query for the user to respond to with a yes or no and specify how to receive response.

Appends (Y/N) to question. Verifies answer starts with Y/y or N/n.

The response text will be either 'Y' or 'N' (not the user's actual text).

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryInt(self, question, cbtag, cbdata, displayTag, prefillAnswer)

question: str

Text to appear next to the prompt

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:

prefillAnswer: int

the default answer for the user; in a form, this is the previous value

Default value: 0


Send a query for the user to respond to with an integer and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

querySelection(self, question, choices, cbtag, cbdata, displayTag, defaultValue)

question: str

Text to appear next to the prompt

choices

a list or key/value pairs are the selection choices; the keys are displayed; the appropriate value is returned as response

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:

defaultValue: str

the default answer (value) for the user

Default value:


Send a pull-down query for the user to respond to with a selection from the provided list and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryCheckbox(self, question, cbtag, cbdata, displayTag, defaultValue, style)

question: str

Text to appear next to the prompt

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:

defaultValue: bool

the default answer (value) for the user, True or False

Default value: False

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:


Send a checkbox query for the user to respond to and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryTextarea(self, question, origText, cbtag, cbdata, displayTag, style, saveButtonLabel)

question: str

Text to appear next to the prompt

origText: str

the default answer (value) for the user, True or False

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:

saveButtonLabel: str

label for Save button next to text; blank for no button

Default value: 'Save'


Send a long text query for the user to respond to and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

queryPassword(self, question, cbtag, cbdata, displayTag, style, prefillAnswer)

question: str

Text to appear next to the prompt

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:

style: str

The formatting style name to assert for this region of the display; if blank, don't change existing style

Default value:

prefillAnswer: str

the default answer for the user; in a form, this is the previous value; it will display as stars; it is not transmitted to the user

Default value:


Send a query for the user to respond to with a password and specify how to receive response.

The cbtag is first processed in InputApp::userInputResponse() (post error-checking) which should send a message to the app with the response. Typically the app that sent the query processes the response.  If so, that app receives the response in its handleMessage() message handler, which routes the response to the appropriate callback.  Cbtag is used instead of callback routines to preserve stateless continuity (the app can restart and the callback is still processed correctly.)

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

form(self, formName, formDefaults, cbtag, cbdata, displayTag)

formName: str

the name of the form from /usr/mae/html/form/

formDefaults

key/value pairs for display area tags and their default values

cbtag: str

the action to take (message received by app)

cbdata

callback data included in message for app

displayTag: str

the name of the region for the upload control; if blank, use last setRegion() tag

Default value:


A multi-part query - a form.  When the user hits submit, then all the values of the form are sent as a message to the app.

Note that all the formDefault values will be merged into the cbdata hash array.  Don't use the same keys!

  1. error check

Return bool value: True if message successfully transmitted (not a guarantee of delivery to end user device) to gui channel (guibroker)

setQueryCB(newcbfn)

newcbfn


Specify the handleInputResponse() method to use.

MAE sets this up for you, but you may override it with your callback.  This callback tells your app the user's answer to your query.

@param cbfn - the callback function pointer

Return bool value: True

setFormCB(newcbfn)

newcbfn


Specify the handleInputFormResponse() method to use.

MAE sets this up for you, but you may override it with your callback.  This callback tells your app the user's answer to your query.

@param cbfn - the callback function pointer

Return bool value: True

isQueryCB(messenger, src, dest, request, param)

messenger

handle to Messenger service

src: str

the source channel that sent the message

dest: str

the destination channel for the message, e.g. storyedit

request: str

the action/keyword/request for this message

param

the data payload for this request


Check if a handleMessage() message is actually a input response that needs to be routed to handleInputResponse(). When True, handleInputResponse() is called implicitly.

Return bool value: True if it's a user response and handleInputResponse() handled it

invalidate()

Invalidate the UserDevice instance to make it unusable.

cleanTag(self, tag)

tag: str

the region name to clean up


Given a region name (tag), modify it so it doesn't break any downstream use.

Basically, get rid of whitespace and punctuation.

Return str value: a clean region name