cis_interface.interface package¶
Submodules¶
cis_interface.interface.PsiInterface module¶
-
class
cis_interface.interface.PsiInterface.
PsiAsciiFileInput
(name, src_type=1, matlab=False)[source]¶ Bases:
object
Class for generic ASCII input from either a file or message queue.
Parameters:
-
class
cis_interface.interface.PsiInterface.
PsiAsciiFileOutput
(name, dst_type=1, matlab=False)[source]¶ Bases:
object
Class for generic ASCII output to either a local file or message queue.
Parameters:
-
class
cis_interface.interface.PsiInterface.
PsiAsciiTableInput
(name, src_type=1, matlab=False)[source]¶ Bases:
object
Class for handling table-like formatted input.
Parameters:
-
class
cis_interface.interface.PsiInterface.
PsiAsciiTableOutput
(name, fmt, dst_type=1, matlab=False)[source]¶ Bases:
object
Class for handling table-like formatted output.
Parameters: - name (str) – The path to the local file where output should be saved (if dst_type == 0) or the name of the message queue where the output should be sent.
- fmt (str) – A C style format string specifying how each ‘row’ of output should be formated. This should include the newline character.
- dst_type (int, optional) – If 0, output is sent to a local file. Otherwise, the output is sent to a message queue. Defaults to 1.
-
send_array
(arr)[source]¶ Output an array of table data to either a local file or message sueue.
Parameters: arr (numpy.ndarray) – Array of table data. The first dimension is assumed to be table rows and the second dimension is assumed to be table columns. Returns: Success or failure of outputing the array. Return type: bool
-
class
cis_interface.interface.PsiInterface.
PsiInput
(name, matlab=False)[source]¶ Bases:
object
Class for handling input from a message queue.
Parameters: name (str) – The name of the message queue. Combined with the suffix ‘_INT’, it should match an environment variable containing a message queue key. -
name
¶ str – The name of the message queue.
-
qname
¶ str – The name of the message queue combined with the suffix ‘_IN’.
-
q
¶ sysv_ipc.MessageQueue
– Message queue.
-
name
= None
-
q
= None
-
qName
= None¶
-
-
cis_interface.interface.PsiInterface.
PsiMatlab
(_type, args)[source]¶ Short interface to identify functions called by Matlab.
Parameters: - _type (str) – Name of class that should be returned.
- args (list) – Additional arguments that should be passed to class initializer.
Returns: An instance of the requested class.
Return type: obj
-
class
cis_interface.interface.PsiInterface.
PsiOutput
(name, matlab=False)[source]¶ Class for handling output to a message queue.
Parameters: name (str) – The name of the message queue. Combined with the suffix ‘_OUT’, it should match an environment variable containing a message queue key. -
name
¶ str – The name of the message queue.
-
qname
¶ str – The name of the message queue combined with the suffix ‘_OUT’.
-
q
¶ sysv_ipc.MessageQueue
– Message queue.
-
-
class
cis_interface.interface.PsiInterface.
PsiPickleInput
(name, src_type=1, matlab=False)[source]¶ Bases:
object
Class for handling pickled input.
Parameters:
-
class
cis_interface.interface.PsiInterface.
PsiPickleOutput
(name, dst_type=1, matlab=False)[source]¶ Bases:
object
Class for handling pickled output.
Parameters: - name (str) – The path to the local file where output should be saved (if dst_type == 0) or the name of the message queue where the output should be sent.
- fmt (str) – A C style format string specifying how each ‘row’ of output should be formated. This should include the newline character.
- dst_type (int, optional) – If 0, output is sent to a local file. Otherwise, the output is sent to a message queue. Defaults to 1.
-
class
cis_interface.interface.PsiInterface.
PsiRpc
(outname, outfmt, inname, infmt, matlab=False)[source]¶ Bases:
object
Class for sending a message and then receiving a response.
Parameters: - outname (str) – The name of the output message queue.
- outfmt (str) – Format string used to format variables in a message sent to the output message queue.
- inname (str) – The name of the input message queue.
- infmt (str) – Format string used to recover variables from messages received from the input message queue.
-
rpcCall
(*args)[source]¶ Send arguments using the output format string to format a message and then receive values back by parsing the response message with the input format string.
Parameters: *args – All arguments are formatted using the output format string to create the message. Returns: - Success or failure of receiving a message and
- the tuple of arguments retreived by parsing the message using the input format string.
Return type: tuple (bool, tuple)
-
class
cis_interface.interface.PsiInterface.
PsiRpcClient
(name, outfmt, infmt, matlab=False)[source]¶ Bases:
cis_interface.interface.PsiInterface.PsiRpc
Class for handling requests and response to an RPC Server from a client.
Parameters:
-
class
cis_interface.interface.PsiInterface.
PsiRpcServer
(name, infmt, outfmt, matlab=False)[source]¶ Bases:
cis_interface.interface.PsiInterface.PsiRpc
Class for handling requests and response for an RPC Server.
Parameters:
cis_interface.interface.scanf module¶
Small scanf implementation.
Python has powerful regular expressions but sometimes they are totally overkill when you just want to parse a simple-formatted string. C programmers use the scanf-function for these tasks (see link below).
This implementation of scanf translates the simple scanf-format into regular expressions. Unlike C you can be sure that there are no buffer overflows possible.
- For more information see
- Original code from:
- http://code.activestate.com/recipes/502213-simple-scanf-implementation/
Modified original to make the %f more robust, as well as added %* modifier to skip fields.
Version: 1.3.3
- Releases:
- 1.0
- 2010-10-11
- Initial release
- 1.1
- 2010-10-13
- Changed regex from ‘match’ (only matches at beginning of line) to ‘search’ (matches anywhere in line)
- Bugfix - ignore cast for skipped fields
- 1.2
- 2013-05-30
- Added ‘collapseWhitespace’ flag (defaults to True) to take the search string and replace all whitespace with regex string to match repeated whitespace. This enables better matching in log files where the data has been formatted for easier reading. These cases have variable amounts of whitespace between the columns, depending on the number of characters in the data itself.
- 1.3
- 2016-01-18
- Add ‘extractdata’ function.
- 1.3.1
- 2016-06-23
- Release to PyPi, now including README.md
-
cis_interface.interface.scanf.
scanf
(format, s=None, collapseWhitespace=True)[source]¶ - scanf supports the following formats:
- %c One character %5c 5 characters %d, %i int value %7d, %7i int value with length 7 %f float value %o octal value %X, %x hex value %s string terminated by whitespace
Examples: >>> scanf(“%s - %d errors, %d warnings”, “/usr/sbin/sendmail - 0 errors, 4 warnings”) (‘/usr/sbin/sendmail’, 0, 4) >>> scanf(“%o %x %d”, “0123 0x123 123”) (66, 291, 123)
If the parameter s is a file-like object, s.readline is called. If s is not specified, stdin is assumed.
The function returns a tuple of found values or None if the format does not match.
-
cis_interface.interface.scanf.
scanf_compile
(format, collapseWhitespace=True)[source]¶ Translate the format into a regular expression
For example: >>> format_re, casts = _scanf_compile(‘%s - %d errors, %d warnings’) >>> print format_re.pattern (S+) - ([+-]?d+) errors, ([+-]?d+) warnings
Translated formats are cached for faster reuse
Module contents¶
Routines for interfacing with framework from Python/C/C++/Matlab.
-
class
cis_interface.interface.
PsiInput
(name, matlab=False)[source]¶ Bases:
object
Class for handling input from a message queue.
Parameters: name (str) – The name of the message queue. Combined with the suffix ‘_INT’, it should match an environment variable containing a message queue key. -
name
¶ str – The name of the message queue.
-
qname
¶ str – The name of the message queue combined with the suffix ‘_IN’.
-
q
¶ sysv_ipc.MessageQueue
– Message queue.
-
name
= None
-
q
= None
-
qName
= None¶
-
-
class
cis_interface.interface.
PsiOutput
(name, matlab=False)[source]¶ Class for handling output to a message queue.
Parameters: name (str) – The name of the message queue. Combined with the suffix ‘_OUT’, it should match an environment variable containing a message queue key. -
name
¶ str – The name of the message queue.
-
qname
¶ str – The name of the message queue combined with the suffix ‘_OUT’.
-
q
¶ sysv_ipc.MessageQueue
– Message queue.
-
-
class
cis_interface.interface.
PsiRpc
(outname, outfmt, inname, infmt, matlab=False)[source]¶ Bases:
object
Class for sending a message and then receiving a response.
Parameters: - outname (str) – The name of the output message queue.
- outfmt (str) – Format string used to format variables in a message sent to the output message queue.
- inname (str) – The name of the input message queue.
- infmt (str) – Format string used to recover variables from messages received from the input message queue.
-
rpcCall
(*args)[source]¶ Send arguments using the output format string to format a message and then receive values back by parsing the response message with the input format string.
Parameters: *args – All arguments are formatted using the output format string to create the message. Returns: - Success or failure of receiving a message and
- the tuple of arguments retreived by parsing the message using the input format string.
Return type: tuple (bool, tuple)