How to use the pynetdicom.utils.validate_ae_title function in pynetdicom

To help you get started, we’ve selected a few pynetdicom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pydicom / pynetdicom / pynetdicom / DULparameters.py View on Github external
def CalledAETitle(self, value):
        if value is not None:
            self.__called_ae_title = validate_ae_title(value)
        else:
            self.__called_ae_title = None
github pydicom / pynetdicom / pynetdicom / PDU.py View on Github external
def calling_ae_title(self, s):
        """
        Set the CallingAETitle parameter to a 16-byte length byte string
        
        Parameters
        ----------
        s : str or bytes
            The calling AE title value you wish to set
        """
        if isinstance(s, str):
            s = bytes(s, 'utf-8')

        self._calling_aet = validate_ae_title(s)
github pydicom / pynetdicom / pynetdicom / pdu.py View on Github external
Will be converted to a fixed length 16-byte value (padded with trailing
        spaces ``0x20``). Leading and trailing spaces are non-significant and a
        value of 16 spaces is not allowed.

        Parameters
        ----------
        ae_title : str or bytes
            The value you wish to set. A value consisting of spaces is not
            allowed and values longer than 16 characters will be truncated.
        """
        # pylint: disable=attribute-defined-outside-init
        if isinstance(ae_title, str):
            ae_title = codecs.encode(ae_title, 'ascii')

        self._called_aet = validate_ae_title(ae_title)
github pydicom / pynetdicom / pynetdicom / DULparameters.py View on Github external
def CallingAETitle(self, value):
        if value is not None:
            self.__calling_ae_title = validate_ae_title(value)
        else:
            self.__calling_ae_title = None
github pydicom / pynetdicom / pynetdicom / ae.py View on Github external
Returns
        -------
        transport.ThreadedAssociationServer or None
            If `block` is ``False`` then returns the server instance, otherwise
            returns ``None``.
        """
        # If the SCP has no supported SOP Classes then there's no point
        #   running as a server
        if not contexts and not self.supported_contexts:
            msg = "No supported Presentation Contexts have been defined"
            LOGGER.error(msg)
            raise ValueError(msg)

        if ae_title:
            ae_title = validate_ae_title(ae_title)
        else:
            ae_title = self.ae_title

        contexts = contexts or self.supported_contexts

        bad_contexts = []
        for cx in contexts:
            roles = (cx.scu_role, cx.scp_role)
            if None in roles and roles != (None, None):
                bad_contexts.append(cx.abstract_syntax)

        if bad_contexts:
            msg = (
                "The following presentation contexts have inconsistent "
                "scu_role/scp_role values (if one is None, both must be):\n  "
            )
github pydicom / pynetdicom / pynetdicom / pdu.py View on Github external
Will be converted to a fixed length 16-byte value (padded with trailing
        spaces ``0x20``). Leading and trailing spaces are non-significant and a
        value of 16 spaces is not allowed.

        Parameters
        ----------
        ae_title : str or bytes
            The value you wish to set. A value consisting of spaces is not
            allowed and values longer than 16 characters will be truncated.
        """
        # pylint: disable=attribute-defined-outside-init
        if isinstance(ae_title, str):
            ae_title = codecs.encode(ae_title, 'ascii')

        self._calling_aet = validate_ae_title(ae_title)
github pydicom / pynetdicom / pynetdicom / pdu_primitives.py View on Github external
def called_ae_title(self, value):
        """Set the Called AE Title parameter.

        Parameters
        ----------
        value : str or bytes
            The Called AE Title as a string or bytes object. Cannot be an empty
            string and will be truncated to 16 characters long
        """
        # pylint: disable=attribute-defined-outside-init
        if isinstance(value, str):
            value = codecs.encode(value, 'ascii')

        if value is not None:
            self._called_ae_title = validate_ae_title(value)
        else:
            self._called_ae_title = None
github pydicom / pynetdicom / pynetdicom / dimse_primitives.py View on Github external
def MoveDestination(self, value):
        """Set the *Move Destination*.

        Parameters
        ----------
        bytes or str
            The value to use for the *Move Destination* parameter. Cannot
            be an empty string and will be truncated to 16 characters long
        """
        if isinstance(value, str):
            value = codecs.encode(value, 'ascii')

        if value is not None:
            self._move_destination = validate_ae_title(
                value, _config.USE_SHORT_DIMSE_AET
            )
        else:
            self._move_destination = None
github pydicom / pynetdicom / pynetdicom / ae.py View on Github external
raise TypeError("'port' must be a valid port number")

        # Association
        assoc = Association(self, MODE_REQUESTOR)

        # Set the thread name
        timestamp = datetime.strftime(datetime.now(), "%Y%m%d%H%M%S")
        assoc.name = "RequestorThread@{}".format(timestamp)

        # Setup the association's communication socket
        sock = AssociationSocket(assoc, address=bind_address)
        sock.tls_args = tls_args or {}
        assoc.set_socket(sock)

        # Association Acceptor object -> remote AE
        assoc.acceptor.ae_title = validate_ae_title(ae_title)
        assoc.acceptor.address = addr
        assoc.acceptor.port = port

        # Association Requestor object -> local AE
        assoc.requestor.address = sock.get_local_addr()
        assoc.requestor.port = bind_address[1]
        assoc.requestor.ae_title = self.ae_title
        assoc.requestor.maximum_length = max_pdu
        assoc.requestor.implementation_class_uid = (
            self.implementation_class_uid
        )
        assoc.requestor.implementation_version_name = (
            self.implementation_version_name
        )
        for item in (ext_neg or []):
            assoc.requestor.add_negotiation_item(item)
github pydicom / pynetdicom / pynetdicom / PDU.py View on Github external
def called_ae_title(self, s):
        """
        Set the CalledAETitle parameter to a 16-byte length byte string
        
        Parameters
        ----------
        s : str or bytes
            The called AE title value you wish to set
        """
        if isinstance(s, str):
            s = bytes(s, 'utf-8')

        self._called_aet = validate_ae_title(s)