test get class

This commit is contained in:
2026-02-05 13:01:16 +01:00
parent 64e2cb2dee
commit cec56ff249
5 changed files with 127 additions and 30 deletions

View File

@@ -3,10 +3,9 @@ import sys
import time
import logging
import json
import requests
import xmltodict
from pyutils.utils import *
import projrequest as projrequest
from utils import *
from influxdb_client_3 import InfluxDBClient3, Point
# Get environment variables
@@ -29,6 +28,32 @@ def main() -> int:
finally:
LOGGER.info(f"InfluxDB Connected: [{env['INFLUXDB_URL']}/{env['INFLUXDB_DATABASE']}]")
##############################
########## MAIN LOOP #########
##############################
last: float = 0
handler: SignalHandler = SignalHandler(LOGGER)
projector: projrequest.ProjectorConnection = projrequest.ProjectorConnection(
ip=env['PROJECTOR_IP'],
username=env['PROJECTOR_USER'],
password=env['PROJECTOR_PASSWORD']
)
while handler.running:
try:
now:float = time.time()
resp = projector.get(path=['status', 'storage', 'info'], params={"area":"DCP"})
if resp is not None:
print(json.dumps(resp, indent=2))
last: float = time.time()
cycle_time: float = last - now
LOGGER.debug(f"Cycle Time: {cycle_time:4.3f}")
time.sleep(INTERVAL-cycle_time)
time.sleep(INTERVAL-cycle_time)
except Exception as e:
print(f"Unexpected exception: [{e}]")
return 1
pass
return 0
if __name__ == "__main__":