Package SpecClient :: Module SpecMessage
[hide private]
[frames] | no frames]

Module SpecMessage

source code

SpecMessage module

This module defines classes and functions for creating messages from data received from Spec, and for generating messages to be sent to Spec.

It handles the different message versions (headers 2, 3 and 4).


Version: 1.0

Author: Matias Guijarro

Classes [hide private]
  SpecMessage
Base class for messages.
  message2
Version 2 message class
  message3
  message4
  anymessage
Functions [hide private]
 
message(*args, **kwargs)
Return a new SpecMessage object
source code
 
rawtodictonary(rawstring)
Transform a list as coming from a SPEC associative array to a dictonary - 2dim arrays are transformed top dict with dict entries.
source code
 
dictionarytoraw(dict)
Transform a Python dictionary object to the string format expected by Spec
source code
 
commandListToCommandString(cmdlist)
Convert a command list to a Spec command string.
source code
 
msg_cmd_with_return(cmd, version=4, order='<')
Return a command with return message
source code
 
msg_func_with_return(cmd, version=4, order='<')
Return a func with return message
source code
 
msg_cmd(cmd, version=4, order='<')
Return a command without reply message
source code
 
msg_func(cmd, version=4, order='<')
Return a func without reply message
source code
 
msg_chan_read(channel, version=4, order='<')
Return a property-reading message
source code
 
msg_chan_send(channel, value, version=4, order='<')
Return a property-setting message
source code
 
msg_event(channel, value, version=4, order='<')
Return an event message
source code
 
msg_register(channel, version=4, order='<')
Return a register message
source code
 
msg_unregister(channel, version=4, order='<')
Return an unregister message
source code
 
msg_close(version=4, order='<')
Return a close message
source code
 
msg_abort(version=4, order='<')
Return an abort message
source code
 
msg_hello(version=4, order='<')
Return a hello message
source code
 
msg_hello_reply(replyID, serverName, version=4, order='<') source code
 
message_with_reply(cmd, name, data, version=4, order='<')
Lower level call to send a message of a certain type
source code
 
message_no_reply(cmd, name, data, version=4, order='<')
Send a message which will not result in a reply from the server.
source code
 
reply_message(replyID, name, data, version=4, order='<') source code
 
error_message(replyID, name, data, version=4, order='<') source code
Variables [hide private]
  MAGIC_NUMBER = 4277009102
  NATIVE_HEADER_VERSION = 4
  NULL = '\x00'
  DELETED = 1
  ABORT = 2
  ASSOC = 4
  CHAN_READ = 11
  CHAN_SEND = 12
  CLOSE = 1
  CMD = 3
  CMD_WITH_RETURN = 4
  DOUBLE = 1
  ERROR = 3
  EVENT = 8
  FUNC = 9
  FUNC_WITH_RETURN = 10
  HELLO = 14
  HELLO_REPLY = 15
  REGISTER = 6
  REPLY = 13
  STRING = 2
  UNREGISTER = 7
  __package__ = 'SpecClient'
Function Details [hide private]

message(*args, **kwargs)

source code 

Return a new SpecMessage object

The returned SpecMessage object can be of any of the available message class. You can specify the desired message class with the 'version' keyword argument. If not specified, defaults to NATIVE_HEADER_VERSION.

Arguments are passed to the appropriate message constructor.

Keyword arguments: version -- message version, defaults to NATIVE_HEADER_VERSION. When reading messages from stream, you can set it to None and it will try to guess the suitable message class by reading the header version from Spec.

rawtodictonary(rawstring)

source code 

Transform a list as coming from a SPEC associative array to a dictonary - 2dim arrays are transformed top dict with dict entries. In SPEC the key contains

message_no_reply(cmd, name, data, version=4, order='<')

source code 

Send a message which will not result in a reply from the server. If a reply is sent depends only on the cmd and not on the method to send the message