Add function to get all devices
This commit is contained in:
parent
7064d6f615
commit
5365b942ce
@ -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…
Reference in New Issue
Block a user