-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the listen-local-network.py script as a dev helper
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
/dist | ||
/pycalaos.egg-info | ||
__pycache__ | ||
|
||
/credentials-*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |