mirror of
https://git.clerie.de/clerie/mitel_ommclient2.git
synced 2026-01-03 04:38:12 +00:00
Add function to get all devices
This commit is contained in:
parent
7064d6f615
commit
5365b942ce
1 changed files with 22 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from .connection import Connection
|
||||
from . import exceptions
|
||||
from . import messages
|
||||
|
||||
class OMMClient2:
|
||||
|
|
@ -71,6 +72,27 @@ class OMMClient2:
|
|||
return None
|
||||
return r.pp[0]
|
||||
|
||||
def get_devices(self):
|
||||
"""
|
||||
Get all PP devices
|
||||
"""
|
||||
next_ppn = 0
|
||||
while True:
|
||||
r = self.connection.request(messages.GetPPDev(next_ppn, maxRecords=20))
|
||||
try:
|
||||
r.raise_on_error()
|
||||
except exceptions.ENoEnt:
|
||||
# No more devices to fetch
|
||||
break
|
||||
|
||||
# Output all found devices
|
||||
for pp in r.pp:
|
||||
yield pp
|
||||
|
||||
# Determine next possible ppn
|
||||
next_ppn = int(pp["ppn"]) + 1
|
||||
|
||||
|
||||
def ping(self):
|
||||
"""
|
||||
Is OMM still there?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue