ci: Add and configure PyLint, and make it happy
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
"""Example SSB Client"""
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import logging
|
||||
import struct
|
||||
import time
|
||||
@@ -10,26 +14,28 @@ from ssb.muxrpc import MuxRPCAPI, MuxRPCAPIException
|
||||
from ssb.packet_stream import PacketStream, PSMessageType
|
||||
from ssb.util import load_ssb_secret
|
||||
|
||||
import hashlib
|
||||
import base64
|
||||
|
||||
|
||||
api = MuxRPCAPI()
|
||||
|
||||
|
||||
@api.define("createHistoryStream")
|
||||
def create_history_stream(connection, msg):
|
||||
def create_history_stream(connection, msg): # pylint: disable=unused-argument
|
||||
"""Handle the createHistoryStream RPC call"""
|
||||
|
||||
print("create_history_stream", msg)
|
||||
# msg = PSMessage(PSMessageType.JSON, True, stream=True, end_err=True, req=-req)
|
||||
# connection.write(msg)
|
||||
|
||||
|
||||
@api.define("blobs.createWants")
|
||||
def create_wants(connection, msg):
|
||||
def create_wants(connection, msg): # pylint: disable=unused-argument
|
||||
"""Handle the createWants RPC call"""
|
||||
|
||||
print("create_wants", msg)
|
||||
|
||||
|
||||
async def test_client():
|
||||
"""The actual client implementation"""
|
||||
|
||||
async for msg in api.call(
|
||||
"createHistoryStream",
|
||||
[{"id": "@1+Iwm79DKvVBqYKFkhT6fWRbAVvNNVH4F2BSxwhYmx8=.ed25519", "seq": 1, "live": False, "keys": False}],
|
||||
@@ -63,7 +69,9 @@ async def test_client():
|
||||
f.write(img_data)
|
||||
|
||||
|
||||
async def main():
|
||||
async def main(keypair):
|
||||
"""The main function to run"""
|
||||
|
||||
client = SHSClient("127.0.0.1", 8008, keypair, bytes(keypair.verify_key))
|
||||
packet_stream = PacketStream(client)
|
||||
await client.open()
|
||||
@@ -89,8 +97,8 @@ if __name__ == "__main__":
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(ch)
|
||||
|
||||
keypair = load_ssb_secret()["keypair"]
|
||||
ssb_keypair = load_ssb_secret()["keypair"]
|
||||
|
||||
loop = get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
loop.run_until_complete(main(ssb_keypair))
|
||||
loop.close()
|
||||
|
@@ -1,5 +1,7 @@
|
||||
"""Test SSB server"""
|
||||
|
||||
import logging
|
||||
from asyncio import gather, get_event_loop, ensure_future
|
||||
from asyncio import get_event_loop
|
||||
|
||||
from colorlog import ColoredFormatter
|
||||
|
||||
@@ -12,6 +14,8 @@ api = MuxRPCAPI()
|
||||
|
||||
|
||||
async def on_connect(conn):
|
||||
"""Incoming connection handler"""
|
||||
|
||||
packet_stream = PacketStream(conn)
|
||||
api.add_connection(packet_stream)
|
||||
|
||||
@@ -22,6 +26,7 @@ async def on_connect(conn):
|
||||
|
||||
|
||||
async def main():
|
||||
"""The main function to run"""
|
||||
server = SHSServer("127.0.0.1", 8008, load_ssb_secret()["keypair"])
|
||||
server.on_connect(on_connect)
|
||||
await server.listen()
|
||||
|
Reference in New Issue
Block a user