multicast.send
Provides multicast broadcast features.
Caution: See details regarding dynamic imports documented in this module.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast
>>>
Testcase 1: Send should be automatically imported.
A: Test that the send component is initialized.
B: Test that the send.__MAGIC__ components are initialized.
>>> multicast.send is not None
True
>>>
>>> multicast.send.__doc__ is not None
True
>>>
>>> multicast.send.__module__ is not None
True
>>>
>>> multicast.send.McastSAY is not None
True
>>>
Module Contents
Classes
Multicast Broacaster tool. |
Data
The package of this program. |
|
The module of this program. |
|
The file of this component. |
|
The name of this component. |
API
- multicast.send.__package__[source]
‘multicast’
The package of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast >>>Testcase 1: Send should be automatically imported.
>>> multicast.send.__package__ is not None True >>> >>> multicast.send.__package__ == multicast.__package__ True >>>
- multicast.send.__module__[source]
‘multicast’
The module of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast >>>Testcase 1: Send should be automatically imported.
>>> multicast.send.__module__ is not None True >>>
- multicast.send.__file__[source]
‘multicast/send.py’
The file of this component.
- multicast.send.__name__[source]
‘multicast.send’
The name of this component.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
Testcase 0: Multicast should be importable.
>>> import multicast >>>Testcase 1: Send should be automatically imported.
>>> multicast.send.__name__ is not None True >>>
- class multicast.send.McastSAY[source][source]
Bases:
multicast.multicast.mtoolMulticast Broacaster tool.
Testing: Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.send is not None True >>> multicast._MCAST_DEFAULT_PORT is not None True >>> multicast._MCAST_DEFAULT_GROUP is not None True >>> multicast._MCAST_DEFAULT_TTL is not None True >>> Testcase 1: Recv should be detailed with some metadata. A: Test that the __MAGIC__ variables are initialized. B: Test that the __MAGIC__ variables are strings. >>> multicast.send is not None True >>> multicast.send.McastSAY is not None True >>> multicast.send.McastSAY.__module__ is not None True >>> multicast.send.McastSAY.__proc__ is not None True >>> multicast.send.McastSAY.__prologue__ is not None True >>>- __module__[source]
‘multicast.send’
- __name__[source]
‘multicast.send.McastSAY’
- __proc__[source]
‘SAY’
- __prologue__[source]
‘Python Multicast Broadcaster.’
- classmethod setupArgs(parser)[source][source]
Will attempt add send args.
Testing: Testcase 0: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.send is not None True >>> multicast.send.McastSAY is not None True >>> Testcase 1: main should return an int. A: Test that the multicast component is initialized. B: Test that the send component is initialized. C: Test that the main(say) function is initialized. D: Test that the main(say) function returns an int 0-3. >>> multicast.send is not None True >>> multicast.__main__.main is not None True >>> tst_fxtr_args = ['''SAY''', '''--port=1234''', '''--message''', '''is required'''] >>> (test_fixture, junk_ignore) = multicast.__main__.main(tst_fxtr_args) >>> test_fixture is not None True >>> type(test_fixture) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <...int...> >>> int(test_fixture) >= int(0) True >>> int(test_fixture) < int(4) True >>> Testcase 2: setupArgs should return None untouched. A: Test that the multicast component is initialized. B: Test that the send component is initialized. C: Test that the McastSAY.setupArgs() function is initialized. D: Test that the McastSAY.setupArgs() function yields None. >>> multicast.send is not None True >>> multicast.send.McastSAY is not None True >>> multicast.send.McastSAY.setupArgs is not None True >>> tst_fxtr_null_args = None >>> test_fixture = multicast.send.McastSAY.setupArgs(tst_fxtr_null_args) >>> test_fixture is not None False >>> type(test_fixture) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <...None...> >>> tst_fxtr_null_args == test_fixture True >>> tst_fxtr_null_args is None True >>> >>> test_fixture is None True >>>
- static _sayStep(group, port, data)[source][source]
Internal method to send a message via multicast.
Will send the given data over the given port to the given group. The actual magic is handled here.
Args: group (str): Multicast group address to send the message to. port (int): Port number to use for sending. data (str): Message data to be sent.
Returns: bool: True if the message was sent successfully, False otherwise.
- doStep(*args, **kwargs)[source][source]
Execute the SAY operation to send multicast messages.
Overrides the
doStepmethod frommtoolto send messages based on provided arguments.Args: *args: Variable length argument list containing command-line arguments. **kwargs: Arbitrary keyword arguments. - group (str): Multicast group address (default: multicast._MCAST_DEFAULT_GROUP) - port (int): Port number (default: multicast._MCAST_DEFAULT_PORT) - data (str, list, or bytes): Message to be sent. If set to [‘-‘], reads from stdin.
Returns: tuple: A tuple containing a status indicator and optional error message.