eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 9bbe366f9e4e4d2a2f4d8619391665503b354740
parent 0c5f205f917e54e13224c8c793e6d7723f5cd698
Author: Daniel Barlow <dan@telent.net>
Date:   Thu, 29 Jan 2026 12:17:30 +0000

make eculocate usable as module

run code at startup only if main

Diffstat:
Mclient/eculocate.py | 52++++++++++++++++++++++------------------------------
1 file changed, 22 insertions(+), 30 deletions(-)

diff --git a/client/eculocate.py b/client/eculocate.py @@ -98,33 +98,25 @@ class Client(): -# ./eculocate "service name" 60 # connect to service name, record for 60s - -# discover zeroconf until we have the requested service name - -name = sys.argv[1] -timeout = int(sys.argv[2]) - -fqname = f"{name}._keihin._udp.local." -client = Client() - -exists = False - -while not exists: - time.sleep(2) - exists = client.knows_service(fqname) -client.select_service_name(fqname) - -print("record") -start_time = time.time() -client.start_recording() -while time.time() < start_time + timeout: - time.sleep(1) - print(f"{client.bytes_recorded} bytes received") - -client.stop_recording() -print("fin") - -# register session -# start to record to stdout -# stop after requested time or 15s +if __name__ == '__main__': + name = sys.argv[1] + timeout = int(sys.argv[2]) + + fqname = f"{name}._keihin._udp.local." + client = Client() + + exists = False + while not exists: + time.sleep(2) + exists = client.knows_service(fqname) + client.select_service_name(fqname) + + print("record") + start_time = time.time() + client.start_recording() + while time.time() < start_time + timeout: + time.sleep(1) + print(f"{client.bytes_recorded} bytes received") + + client.stop_recording() + print("fin")