From 12f8241dd80abfc42d69626737977ae54451adb2 Mon Sep 17 00:00:00 2001 From: John Andersen Date: Mon, 16 Oct 2023 03:45:52 -0700 Subject: [PATCH] minor edits to be rebased back into prev commits Signed-off-by: John Andersen --- docs/federation_activitypub.md | 8 ++++++-- scitt_emulator/federation_activitypub_bovine.py | 11 ++++------- scitt_emulator/server.py | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/federation_activitypub.md b/docs/federation_activitypub.md index 132fabee..4b631908 100644 --- a/docs/federation_activitypub.md +++ b/docs/federation_activitypub.md @@ -99,6 +99,8 @@ $ hypercorn app:app -b 0.0.0.0:5000 [2023-10-16 02:44:48 -0700] [36467] [INFO] Running on http://0.0.0.0:5000 (CTRL + C to quit) ``` +> Cleanup: `rm -f *sqlite* federation_*/config.toml` + ### Bring up Bob's SCITT Instance Populate Bob's federation config @@ -118,7 +120,8 @@ Start the server ```console $ rm -rf workspace_bob/ $ mkdir -p workspace_bob/storage/operations -$ scitt-emulator server --workspace workspace_bob/ --tree-alg CCF --port 6000 \ +$ BOVINE_DB_URL="sqlite://${PWD}/bovine.sqlite3" scitt-emulator server \ + --workspace workspace_bob/ --tree-alg CCF --port 6000 \ --federation scitt_emulator.federation_activitypub_bovine:SCITTFederationActivityPubBovine \ --federation-config-path federation_bob/config.json ``` @@ -157,7 +160,8 @@ Start the server ```console $ rm -rf workspace_alice/ $ mkdir -p workspace_alice/storage/operations -$ scitt-emulator server --workspace workspace_alice/ --tree-alg CCF --port 7000 \ +$ BOVINE_DB_URL="sqlite://${PWD}/bovine.sqlite3" scitt-emulator server \ + --workspace workspace_alice/ --tree-alg CCF --port 7000 \ --federation scitt_emulator.federation_activitypub_bovine:SCITTFederationActivityPubBovine \ --federation-config-path federation_alice/config.json ``` diff --git a/scitt_emulator/federation_activitypub_bovine.py b/scitt_emulator/federation_activitypub_bovine.py index 60b3be73..b68080c3 100644 --- a/scitt_emulator/federation_activitypub_bovine.py +++ b/scitt_emulator/federation_activitypub_bovine.py @@ -76,9 +76,6 @@ def __init__( ) def initialize_service(self): - # read, self.write = multiprocessing.Pipe(duplex=False) - # reader_process = multiprocessing.Process(target=self.reader, args=(read,)) - # TODO Avoid creating user if already exists cmd = [ sys.executable, @@ -86,7 +83,7 @@ def initialize_service(self): "mechanical_bull.add_user", "--accept", self.handle_name, - domain, + self.domain, ] add_user_output = subprocess.check_output( cmd, @@ -104,7 +101,7 @@ def initialize_service(self): "bovine_tool.register", self.handle_name, "--domain", - domain, + self.domain, ] register_output = subprocess.check_output( cmd, @@ -116,7 +113,7 @@ def initialize_service(self): sys.executable, "-um", "bovine_tool.manage", - self.handle_name, + bovine_name, "--did_key", "key0", did_key, @@ -148,7 +145,7 @@ def initialize_service(self): def created_entry(self, entry_id: str, receipt: bytes): with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: - client.connect(self.federate_created_entries_socket_path) + client.connect(str(self.federate_created_entries_socket_path.resolve())) client.send(receipt) client.close() diff --git a/scitt_emulator/server.py b/scitt_emulator/server.py index f4d5e012..42475d31 100644 --- a/scitt_emulator/server.py +++ b/scitt_emulator/server.py @@ -46,16 +46,17 @@ def create_flask_app(config): federation = None if app.config.get("federation", None): - federation = app.config["federation"]( + app.federation = app.config["federation"]( config_path=app.config.get("federation_config_path", None), storage_path=storage_path, service_parameters_path=app.service_parameters_path ) + app.federation.initialize_service() app.scitt_service = clazz( storage_path=storage_path, service_parameters_path=app.service_parameters_path, - federation=federation, + federation=app.federation, ) app.scitt_service.initialize_service() print(f"Service parameters: {app.service_parameters_path}")