botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
BotSense.bsNull Python Module

The bsNull module under the BotSense python package provides python applications an interface to communicate with proxied /dev/null devices. The underlining compiled extension module _bsNull.so library provides the provides the shim between python calling conventions and the C libbsclient_null.[a,so] library.

See also
BotSense.bsNull
Example:
#
# Example use of BotSense.bsNull Module
#
import sys
import BotSense.BotSenseTypes as bsTypes
import BotSense.BotSenseError as bsError
import BotSense.BotSenseServer as bsServer
import BotSense.bsNull as bsNull
# create a BotSense client
cli = bsTypes.BsClient('nullandvoid')
# connect to the bsProxy server using default IP address and port
try:
bsServer.ServerConnect(cli)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
# open a virtual connection to a proxied serial device
try:
hndVConn = bsNull.NullReqOpen(cli)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
print "Example: established virtual connection %d" % (hndVConn)
bitbucket = [
'into the bit bucket',
['a', 'b', 'c', 'd'],
'wheeee',
'\x01\x02\x03'
]
# write some data
for i in xrange(10):
j = i % len(bitbucket)
try:
n = bsNull.NullReqWrite(cli, hndVConn, bitbucket[j])
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
print "Example: %d: %s written" % (i, repr(bitbucket[j][:n]))
# close the virtual connection
try:
bsNull.NullReqClose(cli, hndVConn)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
# close the connection to the bsProxy server
try:
bsServer.ServerDisconnect(cli)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
# delete the client
del cli