botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
BotSense.BotSenseTypes.BsClient Class Reference

Public Member Functions

def __init__ (self, clientName='bsclient')
 
def __del__ (self)
 
def __sizeof__ (self)
 
def AttrGetName (self)
 
def AttrGetTraceState (self, hndVConn)
 
def AttrGetVConnCount (self)
 
def AttrHasVConn (self, hndVConn)
 
def AttrGetDevName (self, hndVConn)
 
def AttrGetModName (self, hndVConn)
 
def AttrSetLogging (self, nLevel)
 
def AttrGetConnState (self)
 
def AttrGetTimeouts (self)
 
def AttrSetTimeouts (self, reqTimeout, rspTimeout)
 
def GetMsgName (self, hndVConn, msgId)
 
def Trans (self, hndVConn, reqMsgId, reqBuf, rspMsgId, rspMaxSize=bsCore.BSPROXY_MSG_BODY_MAX)
 

Static Public Member Functions

def ChkClient (obj)
 

Public Attributes

 pClient
 Pointer to opaque object.
 

Detailed Description

BotSense Client Wrapper Class.

    The BsClient class provides a safe wrapper around the BsClient_T *
    opaque object.

Definition at line 72 of file BotSenseTypes.py.

Constructor & Destructor Documentation

def BotSense.BotSenseTypes.BsClient.__init__ (   self,
  clientName = 'bsclient' 
)
  Create and initialize BotSense client instance.

  Parameters:
clientName  - Proxied client name string.

Definition at line 80 of file BotSenseTypes.py.

80  def __init__(self, clientName='bsclient'):
81  """
82  Create and initialize BotSense client instance.
83 
84  Parameters:
85  clientName - Proxied client name string.
86  """
87  ## Pointer to opaque object
88  self.pClient = None
89 
90  pClient = bsCore.bsClientNew(clientName)
91  if not pClient:
92  raise bsError.BotSenseError(BS_ECODE_NO_RSRC, "Failed to create client.")
93 
94  self.pClient = pClient
pClient
Pointer to opaque object.
def __init__(self, clientName='bsclient')
def BotSense.BotSenseTypes.BsClient.__del__ (   self)
Delete BotSense client instance. 

Definition at line 98 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient.pClient.

98  def __del__(self):
99  """ Delete BotSense client instance. """
100  if self.pClient is not None:
101  bsCore.bsClientDelete(self.pClient)
102  self.pClient = None
pClient
Pointer to opaque object.

Member Function Documentation

def BotSense.BotSenseTypes.BsClient.__sizeof__ (   self)
x.__sizeof__() -- size of swig object, in bytes. 

Definition at line 106 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient.pClient.

Referenced by BotSense.BotSenseTypes.ByteBuf.sizeof().

106  def __sizeof__(self):
107  """ x.__sizeof__() -- size of swig object, in bytes. """
108  if self.pClient is not None:
109  return 1 # opaque size
110  else:
111  return 0 # opaque size
pClient
Pointer to opaque object.
def BotSense.BotSenseTypes.BsClient.AttrGetConnState (   self)
Get the client's connection state.

Return:
  Dictionary specifying connection state.

Definition at line 232 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

232  def AttrGetConnState(self):
233  """ Get the client's connection state.
234 
235  Return:
236  Dictionary specifying connection state.
237  """
238  self._ChkSelf()
239  connstate = bsCore.BsClientConnState_T()
240  bsCore.bsClientAttrGetConnState(self.pClient, connstate)
241  d = {}
242  if connstate.m_bIsConnected:
243  d['is_connected'] = True
244  else:
245  d['is_connected'] = False
246  d['server_hostname'] = connstate.m_sServerHostName
247  return d
pClient
Pointer to opaque object.
def BotSense.BotSenseTypes.BsClient.AttrGetDevName (   self,
  hndVConn 
)
Get the proxied device name associated with the given handle.

Parameters:
  hndVConn  - Virtual connection handle.

Return:
  On success, returns the device URI string. If no device is found,
  then '#nodev#' is returned.
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 182 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

182  def AttrGetDevName(self, hndVConn):
183  """ Get the proxied device name associated with the given handle.
184 
185  Parameters:
186  hndVConn - Virtual connection handle.
187 
188  Return:
189  On success, returns the device URI string. If no device is found,
190  then '#nodev#' is returned.
191  On parameter check failure, a BotSenseError exception is raised.
192  """
193  self._ChkSelf()
194  devName = bsCore.bsClientAttrGetDevName(self.pClient, hndVConn)
195  if not devName:
196  devName = '#nodev#'
197  return devName
pClient
Pointer to opaque object.
def AttrGetDevName(self, hndVConn)
def BotSense.BotSenseTypes.BsClient.AttrGetModName (   self,
  hndVConn 
)
Get the proxied interface module name associated with the given
handle.

Parameters:
  hndVConn  - Virtual connection handle.

Return:
  On success, returns the I/F module URI string. If no module is
  found, then '#nomod#' is returned.
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 201 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

201  def AttrGetModName(self, hndVConn):
202  """ Get the proxied interface module name associated with the given
203  handle.
204 
205  Parameters:
206  hndVConn - Virtual connection handle.
207 
208  Return:
209  On success, returns the I/F module URI string. If no module is
210  found, then '#nomod#' is returned.
211  On parameter check failure, a BotSenseError exception is raised.
212  """
213  self._ChkSelf()
214  modName = bsCore.bsClientAttrGetModName(self.pClient, hndVConn)
215  if not modName:
216  modName = '#nomod#'
217  return modName
pClient
Pointer to opaque object.
def AttrGetModName(self, hndVConn)
def BotSense.BotSenseTypes.BsClient.AttrGetName (   self)
Get the client's name.

Return:
  On success, returns client string name.
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 115 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

Referenced by BotSense.BotSenseTypes.BsClient.Trans().

115  def AttrGetName(self):
116  """ Get the client's name.
117 
118  Return:
119  On success, returns client string name.
120  On parameter check failure, a BotSenseError exception is raised.
121  """
122  self._ChkSelf()
123  clientName = bsCore.bsClientAttrGetName(self.pClient)
124  if not clientName:
125  clientName = 'unknown'
126  return clientName
pClient
Pointer to opaque object.
def BotSense.BotSenseTypes.BsClient.AttrGetTimeouts (   self)
Get the client's request and response timeouts in seconds.

Definition at line 251 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

251  def AttrGetTimeouts(self):
252  """ Get the client's request and response timeouts in seconds.
253  """
254  self._ChkSelf()
255  reqTimeout = bsCore.new_uintp();
256  rspTimeout = bsCore.new_uintp();
257  bsCore.bsClientAttrGetTimeouts(self.pClient, reqTimeout, rspTimeout)
258  ret = (bsCore.uintp_value(reqTimeout), bsCore.uintp_value(rspTimeout))
259  bsCore.delete_uintp(reqTimeout);
260  bsCore.delete_uintp(rspTimeout);
261  return ret
pClient
Pointer to opaque object.
def BotSense.BotSenseTypes.BsClient.AttrGetTraceState (   self,
  hndVConn 
)
Get a client's virtual connection trace state.

Parameters:
  hndVConn  - Virtual connection handle.

Return:
  On success, returns True (enabled) or False (disabled).
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 130 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

130  def AttrGetTraceState(self, hndVConn):
131  """ Get a client's virtual connection trace state.
132 
133  Parameters:
134  hndVConn - Virtual connection handle.
135 
136  Return:
137  On success, returns True (enabled) or False (disabled).
138  On parameter check failure, a BotSenseError exception is raised.
139  """
140  self._ChkSelf()
141  state = bsCore.bsClientAttrGetTraceState(self.pClient, hndVConn)
142  if state:
143  return True
144  else:
145  return False
pClient
Pointer to opaque object.
def AttrGetTraceState(self, hndVConn)
def BotSense.BotSenseTypes.BsClient.AttrGetVConnCount (   self)
Get a client's virtual connection trace state.

Return:
  On success, returns client's virtual connection count.
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 149 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

149  def AttrGetVConnCount(self):
150  """ Get a client's virtual connection trace state.
151 
152  Return:
153  On success, returns client's virtual connection count.
154  On parameter check failure, a BotSenseError exception is raised.
155  """
156  self._ChkSelf()
157  cnt = bsCore.bsClientAttrGetVConnCount(self.pClient)
158  return cnt
pClient
Pointer to opaque object.
def BotSense.BotSenseTypes.BsClient.AttrHasVConn (   self,
  hndVConn 
)
Check if the client has a virtual connection associated with the
given handle.

Parameters:
  hndVConn  - Virtual connection handle.

Return:
  On success, returns True or False.
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 162 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

162  def AttrHasVConn(self, hndVConn):
163  """ Check if the client has a virtual connection associated with the
164  given handle.
165 
166  Parameters:
167  hndVConn - Virtual connection handle.
168 
169  Return:
170  On success, returns True or False.
171  On parameter check failure, a BotSenseError exception is raised.
172  """
173  self._ChkSelf()
174  tf = bsCore.bsClientAttrHasVConn(self.pClient, hndVConn)
175  if tf:
176  return True
177  else:
178  return False
pClient
Pointer to opaque object.
def AttrHasVConn(self, hndVConn)
def BotSense.BotSenseTypes.BsClient.AttrSetLogging (   self,
  nLevel 
)
Set the client's diagnostic logging threshold.

Parameters:
  nLevel  - New logging threshold level.

Definition at line 221 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

221  def AttrSetLogging(self, nLevel):
222  """ Set the client's diagnostic logging threshold.
223 
224  Parameters:
225  nLevel - New logging threshold level.
226  """
227  self._ChkSelf()
228  bsCore.bsClientAttrSetLogging(self.pClient, nLevel)
pClient
Pointer to opaque object.
def AttrSetLogging(self, nLevel)
def BotSense.BotSenseTypes.BsClient.AttrSetTimeouts (   self,
  reqTimeout,
  rspTimeout 
)
Set the client's request and response timeouts in seconds.

Parameters:
  reqTimeout  - Request (write) timeout.
  rspTimeout  - Response (read) timeout.

Definition at line 265 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), and BotSense.BotSenseTypes.BsClient.pClient.

265  def AttrSetTimeouts(self, reqTimeout, rspTimeout):
266  """ Set the client's request and response timeouts in seconds.
267 
268  Parameters:
269  reqTimeout - Request (write) timeout.
270  rspTimeout - Response (read) timeout.
271  """
272  self._ChkSelf()
273  bsCore.bsClientAttrSetTimeouts(self.pClient, reqTimeout, rspTimeout)
pClient
Pointer to opaque object.
def AttrSetTimeouts(self, reqTimeout, rspTimeout)
def BotSense.BotSenseTypes.BsClient.ChkClient (   obj)
static
Static check if object is a valid BsClient object.

Parameters:
    obj   - Object instance.

Definition at line 340 of file BotSenseTypes.py.

340  def ChkClient(obj):
341  """ Static check if object is a valid BsClient object.
342 
343  Parameters:
344  obj - Object instance.
345  """
346  bsError.ChkType(obj, BsClient)
347  obj._ChkSelf()
def BotSense.BotSenseTypes.BsClient.GetMsgName (   self,
  hndVConn,
  msgId 
)
Get the message name string.

For each (virtual connection, message id) 2-tuple, the message
name can be determinied (provided the msgid is valid and an
application provides the information).

Parameters:
  hndVConn  - Virtual connection handle.
  msgId     - Message id.

Return:
  On success, returns the message name string. If the name cannot
  be determined, then 'unknown' is returned.
  On parameter check failure, a BotSenseError exception is raised.

Definition at line 277 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), BotSense.BotSenseTypes.BsClient.pClient, and BotSense.BotSenseTypes.BsClient.Trans().

277  def GetMsgName(self, hndVConn, msgId):
278  """ Get the message name string.
279 
280  For each (virtual connection, message id) 2-tuple, the message
281  name can be determinied (provided the msgid is valid and an
282  application provides the information).
283 
284  Parameters:
285  hndVConn - Virtual connection handle.
286  msgId - Message id.
287 
288  Return:
289  On success, returns the message name string. If the name cannot
290  be determined, then 'unknown' is returned.
291  On parameter check failure, a BotSenseError exception is raised.
292  """
293  self._ChkSelf()
294  return bsCore.bsClientGetMsgName(self.pClient, hndVConn, msgId)
pClient
Pointer to opaque object.
def GetMsgName(self, hndVConn, msgId)
def BotSense.BotSenseTypes.BsClient.Trans (   self,
  hndVConn,
  reqMsgId,
  reqBuf,
  rspMsgId,
  rspMaxSize = bsCore.BSPROXY_MSG_BODY_MAX 
)
Execute a request - response transaction with the server.

The request message header is automatically generated. The response
message header is stripped off from the received response.

Raises a BotSenseError exception on failure.
 
Parameters:
  hndVConn    - Virtual connection handle.
  reqMsgId    - Virtual connection unique request message id.
  reqBuf      - Packed request message body.
  rspMsgId    - Virtual connection expected response message id.
  rspMaxSize  - Maximum expected response body size.

Return:
  Packed response message body buffer.

Definition at line 299 of file BotSenseTypes.py.

References BotSense.BotSenseTypes.BsClient._ChkSelf(), BotSense.BotSenseTypes.BsClient.AttrGetName(), BotSense.BotSenseTypes.BsClient.pClient, and BotSense.BotSenseTypes.sizeof().

Referenced by BotSense.BotSenseTypes.BsClient.GetMsgName().

299  rspMaxSize=bsCore.BSPROXY_MSG_BODY_MAX):
300  """ Execute a request - response transaction with the server.
301 
302  The request message header is automatically generated. The response
303  message header is stripped off from the received response.
304 
305  Raises a BotSenseError exception on failure.
306 
307  Parameters:
308  hndVConn - Virtual connection handle.
309  reqMsgId - Virtual connection unique request message id.
310  reqBuf - Packed request message body.
311  rspMsgId - Virtual connection expected response message id.
312  rspMaxSize - Maximum expected response body size.
313 
314  Return:
315  Packed response message body buffer.
316  """
317  self._ChkSelf()
318  reqByteBuf = ByteBuf.Clone(reqBuf)
319  # leave space in buffer to prepend request message header
320  reqByteBuf.copyToSwigObj(len(reqByteBuf), i=0, j=bsCore.BSPROXY_MSG_HDR_LEN)
321  rspByteBuf = ByteBuf(rspMaxSize)
322  n = bsCore.bsClientTrans(self.pClient, hndVConn,
323  reqMsgId, reqByteBuf.getSwigObj(), len(reqByteBuf),
324  rspMsgId, rspByteBuf.getSwigObj(), sizeof(rspByteBuf))
325  bsError.ChkReturnIsNonNeg(n,
326  "Client %s: Transaction request failed." % (self.AttrGetName()))
327  rspByteBuf.copyFromSwigObj(n)
328  return rspByteBuf.buf
pClient
Pointer to opaque object.

The documentation for this class was generated from the following file: