Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connections[i] = conn.get_connection()
# TODO: Set timeouts; check for mixed connection types
if isinstance(connections[0]._sw_connection, rest.REST_CASConnection):
for item in connections:
yield getone(item)
return
_sw_watcher = errorcheck(clib.SW_CASConnectionEventWatcher(len(connections), timeout,
a2n(connections[
0]._soptions),
connections[0]._sw_error),
connections[0]._sw_error)
for item in connections:
errorcheck(_sw_watcher.addConnection(item._sw_connection), _sw_watcher)
try:
while True:
i = errorcheck(_sw_watcher.wait(), _sw_watcher)
# finished
if i == -2:
break
# timeout / retry
if i == -1:
yield [], None
yield getone(connections[i], datamsghandler=datamsghandler)
def reason(self):
''' Disposition reason '''
return errorcheck(a2u(self._sw_response.getDispositionReason(), 'utf-8'),
self._sw_response)
def updateflags(self):
''' Return a set of update flags '''
flags = set()
nflags = errorcheck(self._sw_response.getNUpdateFlags(), self._sw_response)
for i in range(nflags):
flags.add(errorcheck(
a2u(self._sw_response.getNextUpdateFlag(), 'utf-8'), self._sw_response))
return flags
Parameters
----------
_name_ : string
Name of the action.
**kwargs : any, optional
Arbitrary keyword arguments.
Returns
-------
:obj:`self`
'''
if isinstance(self._sw_connection, rest.REST_CASConnection):
errorcheck(self._sw_connection.invoke(a2n(_name_), kwargs),
self._sw_connection)
else:
errorcheck(self._sw_connection.invoke(a2n(_name_),
py2cas(self._soptions,
self._sw_error, **kwargs)),
self._sw_connection)
return self
Returns
-------
int
The next position in the list to set
'''
if isinstance(key, (binary_types, text_types)):
key = keywordify(a2n(key, 'utf-8'))
if item is True or item is False:
errorcheck(_sw_values.setBoolean(i, key, item and 1 or 0),
_sw_values)
i = i + 1
elif isinstance(item, blob):
errorcheck(_sw_values.setBlob(i, key, item), _sw_values)
i = i + 1
elif isinstance(item, text_types):
errorcheck(_sw_values.setString(i, key, a2n(item, 'utf-8')),
_sw_values)
i = i + 1
elif isinstance(item, binary_types):
errorcheck(_sw_values.setString(i, key, a2n(item, 'utf-8')),
_sw_values)
i = i + 1
elif isinstance(item, int64_types):
errorcheck(_sw_values.setInt64(i, key, int64(item)), _sw_values)
i = i + 1
elif isinstance(item, int32_types):
if item > MAX_INT32 or item < MIN_INT32:
errorcheck(_sw_values.setInt64(i, key, int64(item)), _sw_values)
else:
'''
for name, value in six.iteritems(kwargs):
name = str(name)
typ = errorcheck(self._sw_connection.getOptionType(name),
self._sw_connection)
try:
if typ == 'boolean':
if value in [True, False, 1, 0]:
errorcheck(self._sw_connection.setBooleanOption(name,
value and 1 or 0),
self._sw_connection)
else:
raise SWATError('%s is not a valid boolean value' % value)
elif typ == 'string':
if isinstance(value, (binary_types, text_types)):
errorcheck(self._sw_connection.setStringOption(name, a2n(value)),
self._sw_connection)
else:
errorcheck(self._sw_connection.setStringOption(name, value),
self._sw_connection)
elif typ == 'int32':
errorcheck(self._sw_connection.setInt32Option(name, int32(value)),
self._sw_connection)
elif typ == 'int64':
errorcheck(self._sw_connection.setInt64Option(name, int64(value)),
self._sw_connection)
elif typ == 'double':
errorcheck(self._sw_connection.setDoubleOption(name, float64(value)),
self._sw_connection)
except TypeError:
raise SWATError('%s is not the correct type' % value)
return True
connection._sw_connection)
if _sw_message:
mtype = _sw_message.getType()
if mtype == 'response':
_sw_response = errorcheck(_sw_message.toResponse(
connection._sw_connection), _sw_message)
if _sw_response is not None:
output = CASResponse(_sw_response, connection=connection), connection
elif mtype == 'request' and datamsghandler is not None:
_sw_request = errorcheck(_sw_message.toRequest(
connection._sw_connection), _sw_message)
if _sw_request is not None:
req = CASRequest(_sw_request)
output = datamsghandler(req, connection)
elif mtype == 'request':
_sw_request = errorcheck(_sw_message.toRequest(
connection._sw_connection), _sw_message)
if _sw_request is not None:
req = CASRequest(_sw_request)
output = req, connection
if datamsghandler is not None:
errorcheck(connection._sw_connection.disableDataMessages(),
connection._sw_connection)
# Raise exception as needed
if isinstance(output[0], CASResponse):
exception_on_severity = get_option('cas.exception_on_severity')
if exception_on_severity is not None and \
output[0].disposition.severity >= exception_on_severity:
raise SWATCASActionError(output[0].disposition.status, output[0], output[1])