Skip to content

Commit

Permalink
doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Jul 24, 2023
1 parent 40645ea commit f851db6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 0 additions & 4 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ Asynchronous server
^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../../examples/server_async.py

Build bcd Payload
^^^^^^^^^^^^^^^^^
.. literalinclude:: ../../examples/build_bcd_payload.py

Callback Server example
^^^^^^^^^^^^^^^^^^^^^^^
.. literalinclude:: ../../examples/server_callback.py
Expand Down
15 changes: 10 additions & 5 deletions examples/message_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def decode(self, message):
print("-" * 80)
try:
decoder.addToFrame(message)
if decoder.checkFrame():
if decoder.checkFrame(): # pragma no cover
slave = decoder._header.get( # pylint: disable=protected-access
"uid", 0x00
)
decoder.advanceFrame()
decoder.processIncomingPacket(message, self.report, slave)
else:
else: # pragma no cover
self.check_errors(decoder, message)
except Exception: # pylint: disable=broad-except
self.check_errors(decoder, message)
Expand All @@ -98,7 +98,7 @@ def check_errors(self, decoder, message):
txt = f"Unable to parse message - {message} with {decoder}"
_logger.error(txt)

def report(self, message):
def report(self, message): # pragma no cover
"""Print the message information"""
print(
"%-15s = %s" # pylint: disable=consider-using-f-string
Expand Down Expand Up @@ -146,7 +146,7 @@ def parse_messages(cmdline=None):
"""Do a helper method to generate the messages to parse"""
args = get_commandline(cmdline=cmdline)
_logger.setLevel(args.log.upper())
if not args.message:
if not args.message: # pragma no cover
_logger.error("Missing --message.")
return

Expand All @@ -162,5 +162,10 @@ def parse_messages(cmdline=None):
decoder.decode(raw_message)


def main(cmdline=None):
"""Run program"""
parse_messages(cmdline=cmdline)


if __name__ == "__main__":
parse_messages() # pragma: no cover
main() # pragma: no cover
2 changes: 1 addition & 1 deletion examples/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ async def run_simulator():


if __name__ == "__main__":
asyncio.run(run_simulator(), debug=True)
asyncio.run(run_simulator(), debug=True) # pragma no cover
6 changes: 3 additions & 3 deletions test/sub_examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from examples.client_payload import main as main_payload_calls
from examples.datastore_simulator import main as main_datastore_simulator
from examples.message_generator import generate_messages
from examples.message_parser import parse_messages
from examples.message_parser import main as main_parse_messages
from examples.server_async import run_async_server, setup_server
from examples.server_callback import run_callback_server
from examples.server_payload import setup_payload_server
Expand Down Expand Up @@ -57,8 +57,8 @@ def test_message_generator(self, framer):

def test_message_parser(self):
"""Test message parser."""
parse_messages(["--framer", "socket", "-m", "000100000006010100200001"])
parse_messages(["--framer", "socket", "-m", "00010000000401010101"])
main_parse_messages(["--framer", "socket", "-m", "000100000006010100200001"])
main_parse_messages(["--framer", "socket", "-m", "00010000000401010101"])

@pytest.mark.parametrize(
("use_comm", "use_framer", "use_port"),
Expand Down

0 comments on commit f851db6

Please sign in to comment.