From d07fcb6853b6793b89485f4f1c0bbeddddb4c83f Mon Sep 17 00:00:00 2001 From: Agie Ashwood Date: Thu, 1 Aug 2024 21:09:50 +0000 Subject: [PATCH] Clean docs --- .gitignore | 6 +++--- builddocs | 2 +- docs/Daisy/Daisy.md | 2 ++ docs/Packets/{SubPackets.md => SubMessage.md} | 4 ++++ docs/Packets/SubPacket.md | 4 ++++ docs/Splash/serve.md | 4 ++-- docs/Sponge/base.md | 18 +++++++++++++---- docs/readme.md | 13 ++++++------ docs/run.md | 10 +++------- src/Cryptography/WhaleSong.py | 3 +-- src/Packets/SubMessage.py | 4 ++++ .../{SubPackets.rst => SubMessage.rst} | 3 +++ src/Packets/SubPacket.py | 4 ++++ src/Packets/SubPacket.rst | 3 +++ src/Packets/SubPackets.py | 0 src/Sponge/Protocols/bubble.py | 2 ++ src/Sponge/Protocols/catch.py | 2 ++ src/Sponge/Protocols/cryptography.py | 5 ++--- src/Sponge/Protocols/map.py | 2 ++ src/Sponge/base.py | 8 +++++--- src/Sponge/base.rst | 13 +++++------- src/conf.py | 1 + src/run.py | 20 +++++++++---------- src/ui.py | 4 ++-- 24 files changed, 85 insertions(+), 52 deletions(-) rename docs/Packets/{SubPackets.md => SubMessage.md} (57%) create mode 100644 src/Packets/SubMessage.py rename src/Packets/{SubPackets.rst => SubMessage.rst} (51%) delete mode 100644 src/Packets/SubPackets.py diff --git a/.gitignore b/.gitignore index 2a77a8b0..b8c1466b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,9 @@ bin/ lib* share/ **/__pycache__/ -src/webui/build/ -src/webui/htmx-extensions/ -src/webui/res/js/node_modules/ +src/Splash/build/ +src/Splash/htmx-extensions/ +src/Splash/res/js/node_modules/ src/daisy/ src/catch/ src/logs/ diff --git a/builddocs b/builddocs index 725bb352..5e064098 100755 --- a/builddocs +++ b/builddocs @@ -6,4 +6,4 @@ mv docs.tmp/* docs rm -rf docs.tmp mv docs/index.md docs/readme.md sed -i '1s;^;![PierMesh logo](https://git.utopic.work/PierMesh/piermesh/raw/branch/main/piermeshicon.png)\n\n;' docs/readme.md -sed -i '1s;^;![Daisy logo](https://git.utopic.work/PierMesh/piermesh/raw/branch/main/imgs/daisydisplay.png)\n\n;' docs/Components/daisy.md +sed -i '1s;^;![Daisy logo](https://git.utopic.work/PierMesh/piermesh/raw/branch/main/imgs/daisydisplay.png)\n\n;' docs/Daisy/Daisy.md diff --git a/docs/Daisy/Daisy.md b/docs/Daisy/Daisy.md index 88bccce3..f4fae3db 100644 --- a/docs/Daisy/Daisy.md +++ b/docs/Daisy/Daisy.md @@ -1,3 +1,5 @@ +![Daisy logo](https://git.utopic.work/PierMesh/piermesh/raw/branch/main/imgs/daisydisplay.png) + Schemaless binary database base class ========================== diff --git a/docs/Packets/SubPackets.md b/docs/Packets/SubMessage.md similarity index 57% rename from docs/Packets/SubPackets.md rename to docs/Packets/SubMessage.md index 5023c8e8..370f56ce 100644 --- a/docs/Packets/SubPackets.md +++ b/docs/Packets/SubMessage.md @@ -1,3 +1,7 @@ SubPackets for handling full submessages ======================= + +### *class* Packets.SubMessage.SubMessage + +TODO diff --git a/docs/Packets/SubPacket.md b/docs/Packets/SubPacket.md index d2ce8502..3fcba041 100644 --- a/docs/Packets/SubPacket.md +++ b/docs/Packets/SubPacket.md @@ -1,3 +1,7 @@ SubPacket for handling individual packets of submessages ================================= + +### *class* Packets.SubPacket.SubPacket + +TODO diff --git a/docs/Splash/serve.md b/docs/Splash/serve.md index 2f23ccbc..d2928a1d 100644 --- a/docs/Splash/serve.md +++ b/docs/Splash/serve.md @@ -1,6 +1,6 @@ # serve: Web UI server -### *class* Splash.serve.Server(transmitter, catch, onodeID, network, cLog) +### *class* Splash.serve.Server(transceiver, catch, onodeID, network, cLog) Web server that serves the web ui and provides web to node communication @@ -42,7 +42,7 @@ Microdot server instance #### catch -Reference to our Catch Cache instance to pull from for servijg Catchs +Reference to our Catch Cache instance to pull from for serving Catchs * **Type:** [Daisy.Catch.Catch](/PierMesh/piermesh/src/branch/main/docs/Daisy/Catch.md#Daisy.Catch.Catch) diff --git a/docs/Sponge/base.md b/docs/Sponge/base.md index 178f4d91..c9063bb6 100644 --- a/docs/Sponge/base.md +++ b/docs/Sponge/base.md @@ -6,6 +6,8 @@ Dispatches to Protocols Packet filtering orchestration +[🔗 Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/Sponge/base.py) + cLog : Reference to run.Node.cLog for logging @@ -45,18 +47,26 @@ Check if this is a self packet, if so skip Base filtering logic, takes a single MeshTastic packet -### *class* Sponge.Protocols.bubble.filter(completeMessage, recipient, recipientNode, onodeID, todo) +#### *async* bubble.filter(recipient, recipientNode, onodeID, todo) Peer to peer protol -### *class* Sponge.Protocols.catch.filter(completeMessage, recipient, recipientNode, todo) +[🔗 Bubble Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/src/Sponge/Protocols/bubble.py) + +#### *async* catch.filter(recipient, recipientNode, todo) Catch exchange protocol -### *class* Sponge.Protocols.cryptography.filter(completeMessage, recipientNode, todo) +[🔗 Catch Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/Sponge/Protocols/catch.py) + +#### *async* cryptography.filter(recipientNode, todo) Cryptographic operations protocol -### *class* Sponge.Protocols.map.filter(completeMessage, todo) +[🔗 Cryptography Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/Sponge/Protocols/cryptography.py) + +#### *async* map.filter(todo) Network mapping protocol + +[🔗 Source](https://git.utopic.work/PierMesh/piermesh/src/branch/main/Sponge/Protocols/map.py) diff --git a/docs/readme.md b/docs/readme.md index 4f740b2f..113b1455 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -17,7 +17,7 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. --> * [`Node.cache`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.cache) * [`Node.nodeInfo`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.nodeInfo) * [`Node.onodeID`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.onodeID) - * [`Node.oTransmitter`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.oTransmitter) + * [`Node.oTransceiver`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.oTransceiver) * [`Node.processed`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.processed) * [`Node.proc`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.proc) * [`Node.mTasks`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.mTasks) @@ -27,7 +27,6 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. --> * [`Node.action_sendCatch()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.action_sendCatch) * [`Node.action_sendToPeer()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.action_sendToPeer) * [`Node.cLog()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.cLog) - * [`Node.monitor()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.monitor) * [`Node.spongeListen()`](/PierMesh/piermesh/src/branch/main/docs/run.md#run.Node.spongeListen) * [ui: TUI application](/PierMesh/piermesh/src/branch/main/docs/ui.md) * [`TUI`](/PierMesh/piermesh/src/branch/main/docs/ui.md#ui.TUI) @@ -109,10 +108,10 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. --> * [`Filter.protoRoute()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.base.Filter.protoRoute) * [`Filter.selfCheck()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.base.Filter.selfCheck) * [`Filter.sieve()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.base.Filter.sieve) -* [`filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.bubble.filter) -* [`filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.catch.filter) -* [`filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.cryptography.filter) -* [`filter`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.map.filter) +* [`bubble.filter()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.bubble.filter) +* [`catch.filter()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.catch.filter) +* [`cryptography.filter()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.cryptography.filter) +* [`map.filter()`](/PierMesh/piermesh/src/branch/main/docs/Sponge/base.md#Sponge.Protocols.map.filter) * [Header packet: Metadata packet](/PierMesh/piermesh/src/branch/main/docs/Packets/HeaderPacket.md) * [`Header`](/PierMesh/piermesh/src/branch/main/docs/Packets/HeaderPacket.md#Packets.HeaderPacket.Header) * [`Header.sender`](/PierMesh/piermesh/src/branch/main/docs/Packets/HeaderPacket.md#Packets.HeaderPacket.Header.sender) @@ -134,6 +133,8 @@ sphinx-quickstart on Fri Jul 26 23:30:55 2024. --> * [`Packet.dump()`](/PierMesh/piermesh/src/branch/main/docs/Packets/Packet.md#Packets.Packet.Packet.dump) * [`Packet.parsePayload()`](/PierMesh/piermesh/src/branch/main/docs/Packets/Packet.md#Packets.Packet.Packet.parsePayload) * [`SinglePacket`](/PierMesh/piermesh/src/branch/main/docs/Packets/SinglePacket.md) +* [`SubMessage`](/PierMesh/piermesh/src/branch/main/docs/Packets/SubMessage.md) +* [`SubPacket`](/PierMesh/piermesh/src/branch/main/docs/Packets/SubPacket.md) * [Layer 0 data transceiving](/PierMesh/piermesh/src/branch/main/docs/Transceiver/Transceiver.md) * [`Transceiver`](/PierMesh/piermesh/src/branch/main/docs/Transceiver/Transceiver.md#Transceiver.Transceiver.Transceiver) * [`Transceiver.cLog`](/PierMesh/piermesh/src/branch/main/docs/Transceiver/Transceiver.md#Transceiver.Transceiver.Transceiver.cLog) diff --git a/docs/run.md b/docs/run.md index db85aa77..6c5fa821 100644 --- a/docs/run.md +++ b/docs/run.md @@ -62,12 +62,12 @@ PierMesh node ID * **Type:** str -#### oTransmitter +#### oTransceiver -LoRa transmitter Transmitter +LoRa transceiver Transceiver * **Type:** - Transmitter + [Transceiver](/PierMesh/piermesh/src/branch/main/docs/Transceiver/Transceiver.md#Transceiver.Transceiver.Transceiver) #### processed @@ -145,10 +145,6 @@ Convenience function that logs to the ui and log files * **Return type:** None -#### *async* monitor() - -Monitor and log ram and cpu usage - #### *async* spongeListen() Loop to watch for tasks to do diff --git a/src/Cryptography/WhaleSong.py b/src/Cryptography/WhaleSong.py index 3a2b8f95..34dc5d3d 100755 --- a/src/Cryptography/WhaleSong.py +++ b/src/Cryptography/WhaleSong.py @@ -184,8 +184,7 @@ class DHEFern: publicKey = privateKey.public_key() if setSelf: self.publicKey = publicKey - self.updateStore( - "key", + self.stores["key"].update( "self", { "publicKey": self.publicKey.public_bytes( diff --git a/src/Packets/SubMessage.py b/src/Packets/SubMessage.py new file mode 100644 index 00000000..31a144b1 --- /dev/null +++ b/src/Packets/SubMessage.py @@ -0,0 +1,4 @@ +class SubMessage: + """ + TODO + """ diff --git a/src/Packets/SubPackets.rst b/src/Packets/SubMessage.rst similarity index 51% rename from src/Packets/SubPackets.rst rename to src/Packets/SubMessage.rst index 5023c8e8..6ea82643 100644 --- a/src/Packets/SubPackets.rst +++ b/src/Packets/SubMessage.rst @@ -1,3 +1,6 @@ SubPackets for handling full submessages ======================= + +.. autoclass:: Packets.SubMessage.SubMessage + :members: diff --git a/src/Packets/SubPacket.py b/src/Packets/SubPacket.py index e69de29b..5bf8209f 100644 --- a/src/Packets/SubPacket.py +++ b/src/Packets/SubPacket.py @@ -0,0 +1,4 @@ +class SubPacket: + """ + TODO + """ diff --git a/src/Packets/SubPacket.rst b/src/Packets/SubPacket.rst index d2ce8502..cccb518f 100644 --- a/src/Packets/SubPacket.rst +++ b/src/Packets/SubPacket.rst @@ -1,3 +1,6 @@ SubPacket for handling individual packets of submessages ================================= + +.. autoclass:: Packets.SubPacket.SubPacket + :members: diff --git a/src/Packets/SubPackets.py b/src/Packets/SubPackets.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Sponge/Protocols/bubble.py b/src/Sponge/Protocols/bubble.py index fb7a5874..80906b14 100644 --- a/src/Sponge/Protocols/bubble.py +++ b/src/Sponge/Protocols/bubble.py @@ -1,6 +1,8 @@ async def filter(completeMessage, recipient, recipientNode, onodeID, todo): """ Peer to peer protol + + `🔗 Bubble Source `_ """ m = completeMessage if recipientNode == onodeID: diff --git a/src/Sponge/Protocols/catch.py b/src/Sponge/Protocols/catch.py index d61d147e..31d04b64 100644 --- a/src/Sponge/Protocols/catch.py +++ b/src/Sponge/Protocols/catch.py @@ -1,6 +1,8 @@ async def filter(completeMessage, recipient, recipientNode, todo): """ Catch exchange protocol + + `🔗 Catch Source `_ """ m = completeMessage # TODO: Sending to other nodes clients diff --git a/src/Sponge/Protocols/cryptography.py b/src/Sponge/Protocols/cryptography.py index a7035cfd..f135a812 100644 --- a/src/Sponge/Protocols/cryptography.py +++ b/src/Sponge/Protocols/cryptography.py @@ -1,9 +1,8 @@ -import logging - - async def filter(completeMessage, recipientNode, todo): """ Cryptographic operations protocol + + `🔗 Cryptography Source `_ """ todo.append( { diff --git a/src/Sponge/Protocols/map.py b/src/Sponge/Protocols/map.py index 9f5dee2d..2f9baf80 100644 --- a/src/Sponge/Protocols/map.py +++ b/src/Sponge/Protocols/map.py @@ -1,6 +1,8 @@ async def filter(completeMessage, todo): """ Network mapping protocol + + `🔗 Source `_ """ m = completeMessage todo.append( diff --git a/src/Sponge/base.py b/src/Sponge/base.py index 03dd5950..bb498cd9 100644 --- a/src/Sponge/base.py +++ b/src/Sponge/base.py @@ -12,6 +12,8 @@ class Filter: """ Packet filtering orchestration + `🔗 Source `_ + cLog Reference to `run.Node.cLog` for logging @@ -138,10 +140,10 @@ class Filter: # responseLoop(packets_id) pass completeMessage = self.messages[packetsID] - completeMessage["data"] = Packets.reassemble(None, completeMessage) + completeMessage["data"] = Message.reassemble(None, completeMessage) del self.messages[packetsID] self.completed.append(packetsID) self.cLog(20, "Assembly completed, routing") await self.protoRoute(completeMessage) - except Exception as e: - self.cLog(30, traceback.print_exc()) + except Exception: + self.cLog(30, traceback.format_exc()) diff --git a/src/Sponge/base.rst b/src/Sponge/base.rst index 7c468f12..dfd96ef9 100644 --- a/src/Sponge/base.rst +++ b/src/Sponge/base.rst @@ -5,14 +5,11 @@ Dispatches to Protocols .. autoclass:: Sponge.base.Filter :members: -.. autoclass:: Sponge.Protocols.bubble.filter - :members: +.. automethod:: Sponge.Protocols.bubble.filter -.. autoclass:: Sponge.Protocols.catch.filter - :members: +.. automethod:: Sponge.Protocols.catch.filter -.. autoclass:: Sponge.Protocols.cryptography.filter - :members: +.. automethod:: Sponge.Protocols.cryptography.filter + +.. automethod:: Sponge.Protocols.map.filter -.. autoclass:: Sponge.Protocols.map.filter - :members: diff --git a/src/conf.py b/src/conf.py index c1cba4bc..d7310e6f 100644 --- a/src/conf.py +++ b/src/conf.py @@ -23,6 +23,7 @@ extensions = [ "sphinx_markdown_builder", "sphinx.ext.autodoc", "sphinx.ext.napoleon", + "sphinx.ext.viewcode", ] templates_path = ["_templates"] diff --git a/src/run.py b/src/run.py index cb29db1d..b1e463ff 100755 --- a/src/run.py +++ b/src/run.py @@ -150,9 +150,6 @@ class Node: """ while True: if tuiOb != None: - if tuiOb.done: - print("Terminating PierMesh service...") - self.proc.terminate() await asyncio.sleep(10) memmb = self.proc.memory_info().rss / (1024 * 1024) memmb = round(memmb, 2) @@ -270,7 +267,9 @@ async def logPassLoop(): await asyncio.sleep(1) if tuiOb == None or nodeOb == None: await asyncio.sleep(1) - elif tuiOb.done == True: + elif tuiOb.done: + tuiOb.exit() + os.system("reset") print("Terminating PierMesh service...") nodeOb.proc.terminate() else: @@ -315,10 +314,8 @@ async def main(): nodeOb.mTasks["announce"] = asyncio.create_task(nodeOb.oTransceiver.announce()) await asyncio.sleep(1) await nodeOb.server.app.start_server(port=int(sys.argv[2]), debug=True) - except KeyboardInterrupt: - sys.exit() except Exception: - nodeOb.cLog(20, traceback.format_exc()) + logging.log(20, traceback.format_exc()) if __name__ == "__main__": @@ -330,7 +327,8 @@ if __name__ == "__main__": tuiOb = TUI() tuiOb.nodeOb = nodeOb tuiOb.run() - except KeyboardInterrupt: - nodeOb.cLog(30, "Terminating PierMesh service...") - except Exception: - nodeOb.cLog(30, sys.gettrace()) + except: + try: + nodeOb.cLog(30, traceback.format_exc()) + except: + logging.log(30, traceback.format_exc()) diff --git a/src/ui.py b/src/ui.py index 0c81a59a..93678570 100644 --- a/src/ui.py +++ b/src/ui.py @@ -57,9 +57,9 @@ class TUI(App): run.monitor """ self.done = True - sys.exit("Terminating TUI...") + # sys.exit("Terminating TUI...") - def compose(self) -> ComposeResult: + def compose(self): """ Build the TUI """