Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
------
AttributeError
If the corresponding event is not due to one of the DIMSE requests
with a dataset-like parameter.
"""
try:
bytestream = getattr(self.request, attr)
# If no change in encoded data then return stored decode
if self._hash == hash(bytestream):
return self._decoded
# Some dataset-like parameters are optional
if bytestream and bytestream.getvalue() != b'':
# Dataset-like parameter has been used
t_syntax = self.context.transfer_syntax
ds = decode(bytestream,
t_syntax.is_implicit_VR,
t_syntax.is_little_endian)
ds.is_little_endian = t_syntax.is_little_endian
ds.is_implicit_VR = t_syntax.is_implicit_VR
# Store the decoded dataset in case its accessed again
self._decoded = ds
else:
# Dataset-like parameter hasn't been used
self._decoded = Dataset()
self._hash = hash(bytestream)
return self._decoded
except AttributeError:
----------
req : dimse_primitives.C_FIND
The C-FIND request primitive received from the peer.
context : presentation.PresentationContext
The presentation context that the SCP is operating under.
"""
# Build C-FIND response primitive
rsp = C_FIND()
rsp.MessageID = req.MessageID
rsp.MessageIDBeingRespondedTo = req.MessageID
rsp.AffectedSOPClassUID = req.AffectedSOPClassUID
# Decode and log Identifier
transfer_syntax = context.transfer_syntax[0]
try:
identifier = decode(req.Identifier,
transfer_syntax.is_implicit_VR,
transfer_syntax.is_little_endian)
LOGGER.info('Find SCP Request Identifiers:')
LOGGER.info('')
LOGGER.debug('# DICOM Dataset')
for elem in identifier.iterall():
LOGGER.info(elem)
LOGGER.info('')
except Exception as ex:
LOGGER.error("Failed to decode the request's Identifier dataset.")
LOGGER.exception(ex)
# Failure - Unable to Process - Failed to decode Identifier
rsp.Status = 0xC310
rsp.ErrorComment = 'Unable to decode the dataset'
self.dimse.send_msg(rsp, context.context_id)
return
----------
req : dimse_primitives.C_MOVE
The C-MOVE request primitive sent by the peer.
context : presentation.PresentationContext
The presentation context that the SCP is operating under.
"""
# Build C-MOVE response primitive
rsp = C_MOVE()
rsp.MessageID = req.MessageID
rsp.MessageIDBeingRespondedTo = req.MessageID
rsp.AffectedSOPClassUID = req.AffectedSOPClassUID
# Attempt to decode the request's Identifier dataset
transfer_syntax = context.transfer_syntax[0]
try:
identifier = decode(req.Identifier,
transfer_syntax.is_implicit_VR,
transfer_syntax.is_little_endian)
LOGGER.info('Move SCP Request Identifier:')
LOGGER.info('')
LOGGER.debug('# DICOM Data Set')
for elem in identifier.iterall():
LOGGER.info(elem)
LOGGER.info('')
except Exception as exc:
LOGGER.error("Failed to decode the request's Identifier dataset")
LOGGER.exception(exc)
# Failure: Cannot Understand - Dataset decoding error
rsp.Status = 0xC510
rsp.ErrorComment = 'Unable to decode the dataset'
self.dimse.send_msg(rsp, context.context_id)
return
* DICOM Standard, Part 4, :dcm:`Annex II`
* DICOM Standard, Part 7, Sections
:dcm:`9.1.2`,
:dcm:`9.3.2` and
:dcm:`Annex C`
"""
# Build C-FIND response primitive
rsp = C_FIND()
rsp.MessageID = req.MessageID
rsp.MessageIDBeingRespondedTo = req.MessageID
rsp.AffectedSOPClassUID = req.AffectedSOPClassUID
# Decode and log Identifier
transfer_syntax = context.transfer_syntax[0]
try:
identifier = decode(req.Identifier,
transfer_syntax.is_implicit_VR,
transfer_syntax.is_little_endian)
LOGGER.info('Find SCP Request Identifiers:')
LOGGER.info('')
LOGGER.debug('# DICOM Dataset')
for elem in identifier.iterall():
LOGGER.info(elem)
LOGGER.info('')
except Exception as ex:
LOGGER.error("Failed to decode the request's Identifier dataset.")
LOGGER.exception(ex)
# Failure - Unable to Process - Failed to decode Identifier
rsp.Status = 0xC310
rsp.ErrorComment = 'Unable to decode the dataset'
self.dimse.send_msg(rsp, context.context_id)
return