Skip to content

Commit

Permalink
add the listen-local-network.py script as a dev helper
Browse files Browse the repository at this point in the history
  • Loading branch information
willoma committed Mar 11, 2024
1 parent c64f768 commit b78f774
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/dist
/pycalaos.egg-info
__pycache__

/credentials-*.json
36 changes: 36 additions & 0 deletions listen-local-network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3

import json, time

from pycalaos import discover, Client

ip_address = discover(5)

if ip_address == "":
ip_address = input(f"Please provide the Calaos server IP address: ")

try:
f = open(f"credentials-{ip_address}.json")
credentials = json.load(f)
username = credentials["username"]
password = credentials["password"]
except:
username = input(f"Please provide the username for {ip_address}: ")
password = input(f"Please provide the password for {ip_address}: ")

f = open(f"credentials-{ip_address}.json", mode="w")
json.dump({"username": username, "password": password}, f)

print("Connecting...")
client = Client("https://"+ip_address, username, password)
print("Connected.", end="", flush=True)

while True:
time.sleep(0.5)
events = client.poll()
if len(events) > 0:
print("\n")
for ev in events:
print(ev)
else:
print(".", end="", flush=True)

0 comments on commit b78f774

Please sign in to comment.