multicast
Submodules
Package Contents
Classes
Class for Multicast tools. |
Data
The package of this program. |
|
The module of this program. |
|
The name of this program. |
|
The version of this program. |
|
The one-line description or summary of this program. |
|
Arbitrary buffer size to use by default, though any value below 65507 should work. |
|
Arbitrary port to use by default, though any dynamic and free port would work. |
|
Arbitrary group to use by default, though any mcst grp would work. |
|
Arbitrary TTL time to live to use by default, though any small (1-126) TTL would work. A Value of 1 (one TTL) is chosen as per RFC1112 Sec 6.1 on the rational that an explicit value that could traverse byond the local connected network should be chosen by the caller rather than the default value. This is inline with the principle of none, one or many. |
|
Arbitrary blank string. |
|
See multicast.exceptions.EXIT_CODES. |
|
See multicast.exceptions.EXCEPTION_EXIT_CODES. |
|
See multicast.exceptions.CommandExecutionError Class. |
|
See multicast.exceptions.get_exit_code_from_exception function. |
|
See multicast.exceptions.exit_on_exception function. |
|
See multicast.skt.genSocket. |
|
See multicast.skt.endSocket. |
API
- multicast.__all__[source]
[’package’, ‘module’, ‘name’, ‘version’, ‘prologue’, ‘doc’, ‘exceptions’, ‘e…
- multicast.__package__[source]
‘multicast’
The package of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast as _multicast >>> >>> _multicast.__package__ is not None True >>>
- multicast.__module__[source]
‘multicast’
The module of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast as _multicast >>> >>> _multicast.__module__ is not None True >>>
- multicast.__name__[source]
‘multicast’
The name of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast as _multicast >>> >>> _multicast.__name__ is not None True >>>
- multicast.__version__[source]
‘2.0.6’
The version of this program.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast as _multicast >>> >>> _multicast.__version__ is not None True >>>
- multicast.__prologue__[source]
None
The one-line description or summary of this program.
- multicast.__doc__[source]
None
- multicast._MCAST_DEFAULT_BUFFER_SIZE[source]
1316
Arbitrary buffer size to use by default, though any value below 65507 should work.
Minimal Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>>Testcase 0: Multicast should have a default buffer size. A: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is initialized. B: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is an int.
>>> multicast._MCAST_DEFAULT_BUFFER_SIZE is not None True >>> type(multicast._MCAST_DEFAULT_BUFFER_SIZE) is type(1) True >>> >>> multicast._MCAST_DEFAULT_BUFFER_SIZE > int(1) True >>>Testcase 1: Multicast should validate buffer size constraints. A: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is initialized. B: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is an int. C: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is RFC-791 & RFC-768 compliant. D: Test that the _MCAST_DEFAULT_BUFFER_SIZE attribute is a smaller than fragment thresholds for typical ethernet MTUs by default.
>>> multicast._MCAST_DEFAULT_BUFFER_SIZE is not None True >>> type(multicast._MCAST_DEFAULT_BUFFER_SIZE) is type(1) True >>> >>> multicast._MCAST_DEFAULT_BUFFER_SIZE >= int(56) True >>> >>> multicast._MCAST_DEFAULT_BUFFER_SIZE <= int(65527) True >>> >>> multicast._MCAST_DEFAULT_BUFFER_SIZE <= int(1500) True >>>
- multicast._MCAST_DEFAULT_PORT[source]
59259
Arbitrary port to use by default, though any dynamic and free port would work.
Minimal Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>>Testcase 0: Multicast should have a default port. A: Test that the _MCAST_DEFAULT_PORT attribute is initialized. B: Test that the _MCAST_DEFAULT_PORT attribute is an int.
>>> multicast._MCAST_DEFAULT_PORT is not None True >>> type(multicast._MCAST_DEFAULT_PORT) is type(1) True >>> >>> multicast._MCAST_DEFAULT_PORT > int(1024) True >>>Testcase 1: Multicast should have a default port. A: Test that the _MCAST_DEFAULT_PORT attribute is initialized. B: Test that the _MCAST_DEFAULT_PORT attribute is an int. C: Test that the _MCAST_DEFAULT_PORT attribute is RFC-6335 compliant.
>>> multicast._MCAST_DEFAULT_PORT is not None True >>> type(multicast._MCAST_DEFAULT_PORT) is type(1) True >>> >>> multicast._MCAST_DEFAULT_PORT >= int(49152) True >>> >>> multicast._MCAST_DEFAULT_PORT <= int(65535) True >>>
- multicast._MCAST_DEFAULT_GROUP[source]
‘224.0.0.1’
Arbitrary group to use by default, though any mcst grp would work.
The Value of “224.0.0.1” is chosen as a default multicast group as per RFC-5771 on the rational that this group address will be treated as a local-net multicast (caveat: one should use link-local for ipv6)
Minimal Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>>Testcase 0: Multicast should have a default port. A: Test that the _MCAST_DEFAULT_GROUP attribute is initialized. B: Test that the _MCAST_DEFAULT_GROUP attribute is an IP string.
>>> multicast._MCAST_DEFAULT_GROUP is not None True >>> type(multicast._MCAST_DEFAULT_GROUP) is type(str) True >>>
- multicast._MCAST_DEFAULT_TTL[source]
‘int(…)’
Arbitrary TTL time to live to use by default, though any small (1-126) TTL would work. A Value of 1 (one TTL) is chosen as per RFC1112 Sec 6.1 on the rational that an explicit value that could traverse byond the local connected network should be chosen by the caller rather than the default value. This is inline with the principle of none, one or many.
Minimal Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>>Testcase 0: Multicast should have a default TTL. A: Test that the _MCAST_DEFAULT_TTL attribute is initialized. B: Test that the _MCAST_DEFAULT_TTL attribute is an int. c: Test that the _MCAST_DEFAULT_TTL attribute is default of 1.
>>> multicast._MCAST_DEFAULT_TTL is not None True >>> type(multicast._MCAST_DEFAULT_TTL) is type(1) True >>> (int(multicast._MCAST_DEFAULT_TTL) >= int(0)) True >>> (int(multicast._MCAST_DEFAULT_TTL) <= int(2)) True >>>
- multicast._BLANK[source]
‘str(…)’
Arbitrary blank string.
Minimal Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>> _BLANK = multicast._BLANKTestcase 0: Multicast should have a default port. A: Test that the _BLANK attribute is initialized. B: Test that the _BLANK attribute is an empty string.
>>> _BLANK is not None True >>> type(_BLANK) is type(str) True >>> >>> len(_BLANK) <= 0 True >>>
- multicast.EXIT_CODES[source]
None
See multicast.exceptions.EXIT_CODES.
- multicast.EXCEPTION_EXIT_CODES[source]
None
See multicast.exceptions.EXCEPTION_EXIT_CODES.
- multicast.CommandExecutionError[source][source]
None
See multicast.exceptions.CommandExecutionError Class.
- multicast.get_exit_code_from_exception[source][source]
None
See multicast.exceptions.get_exit_code_from_exception function.
- multicast.exit_on_exception[source][source]
None
See multicast.exceptions.exit_on_exception function.
- multicast._config[source]
‘load_config(…)’
- class multicast.mtool[source][source]
Bases:
abc.ABCClass for Multicast tools.
Utility class for CLI tools of the Multicast package. setupArgs() and doStep() are abstract and need to be implemented by subclasses. Minimal Acceptance Testing: First set up test fixtures by importing multicast. >>> import multicast >>> multicast.mtool is not None True >>>- __module__[source]
‘multicast’
- __proc__[source]
None
- __prologue__[source]
‘Add a prologue here.’
- __epilogue__[source]
‘Add an epilogue here.’
- classmethod buildArgs(calling_parser_group)[source][source]
Will build the argparse parser.
Utility Function to build the argparse parser; see argparse.ArgumentParser for more. returns argparse.ArgumentParser - the ArgumentParser to use.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>> multicast.mtool is not None True >>>Testcase 0: buildArgs should return an ArgumentParser. A: Test that the multicast.mtool component is initialized. B: Test that the mtool.buildArgs component is initialized.
>>> multicast.mtool is not None True >>> type(multicast.mtool) #doctest: +ELLIPSIS <...abc.ABCMeta...> >>> multicast.mtool.buildArgs is not None True >>> class test_tool_fixture(multicast.mtool): ... def doStep(self, *args): ... pass ... ... @classmethod ... def setupArgs(cls, parser): ... return parser ... >>> >>> type(test_tool_fixture.buildArgs(None)) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <...ArgumentParser...> >>> >>>
- classmethod parseArgs(arguments)[source][source]
Will attempt to parse the given CLI arguments.
See argparse.ArgumentParser for more. param str - arguments - the array of arguments to parse. Usually sys.argv[1:] returns argparse.Namespace - the Namespace parsed with the key-value pairs.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>> multicast.mtool is not None True >>>Testcase 0: parseArgs should return a namespace. A: Test that the multicast.mtool component is initialized. B: Test that the multicast.mtool.parseArgs component is initialized.
>>> multicast.mtool is not None True >>> multicast.mtool.parseArgs is not None True >>> class test_tool_fixture(multicast.mtool): ... def doStep(self, *args): ... pass ... ... @classmethod ... def setupArgs(cls, parser): ... parser.add_parser("NOOP", help="Does Nothing.") ... return parser ... >>> >>> tst_fxtr_args = ['''NOOP''', '''--port=1234''', '''--iface=127.0.0.1'''] >>> test_fixture = test_tool_fixture.parseArgs(tst_fxtr_args) >>> test_fixture is not None True >>> type(test_fixture) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <...tuple...> >>> tst_fxtr_args_2 = ['''NOOP''', '''--junk''', '''--more-trash=stuff'''] >>> (test_fixture_2, test_ignore_extras) = test_tool_fixture.parseArgs(tst_fxtr_args_2) >>> test_fixture_2 is not None True >>> type(test_fixture_2) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS <...Namespace...> >>>
- classmethod checkToolArgs(args)[source][source]
Will handle the None case for arguments.
Used as a helper function.
Minimal Acceptance Testing:
First set up test fixtures by importing multicast.
>>> import multicast >>>Testcase 0: multicast.mtool should have a doctests.
>>> import multicast >>> multicast.mtool is not None True >>> multicast.mtool.__class__ is not None True >>> >>> multicast.mtool.__doc__ is not None True >>>Testcase 1: multicast.checkToolArgs should return an array.
>>> import multicast >>> multicast.mtool.checkToolArgs(None) is not None True >>> type(multicast.mtool.checkToolArgs(None)) is type([None]) True >>>Testcase 2: multicast.checkToolArgs should return an array.
>>> import multicast >>> type(multicast.mtool.checkToolArgs(["arg1", "arg2"])) is type(["strings"]) True >>> type(multicast.mtool.checkToolArgs([0, 42])) is type([int(1)]) True >>>
- __call__(*args, **kwargs)[source][source]
Call self as a function.
Default implementation simply calls the abstract function doStep and passes the given positional arguments, thus key-word arguments will be silently ignored. Subclasses should not reimplement __call__ directly and instead should implement necessary logic in the abstract doStep() function.
- abstractmethod classmethod setupArgs(parser)[source][source]
Abstract hook for setting up the tool’s arguments.
- abstractmethod doStep(*args, **kwargs)[source][source]
Abstracts the call behavior for sub-classing the tool.
This method should be overridden by subclasses to implement the specific functionality of each multicast tool. It accepts variable positional and keyword arguments as needed by the specific implementation.
Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments.
Returns: tuple: A tuple containing a status indicator and a result message.
Raises: NotImplementedError: If the subclass does not implement this method.