diff options
author | Leif Johansson <leifj@sunet.se> | 2012-02-07 09:13:04 +0100 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2012-02-07 09:13:04 +0100 |
commit | cfe4ddee2dff06465bf8c66e2e793ae1cf4368d5 (patch) | |
tree | e55a2da7dadd65151907e6a45e48514d09110dec /src/meetingtools/ac | |
parent | 4b3351e3e37eec11285ae47163df70c669fd19ea (diff) |
improved user count polling
Diffstat (limited to 'src/meetingtools/ac')
-rw-r--r-- | src/meetingtools/ac/api.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/meetingtools/ac/api.py b/src/meetingtools/ac/api.py index ebf38ea..0be2e6a 100644 --- a/src/meetingtools/ac/api.py +++ b/src/meetingtools/ac/api.py @@ -14,6 +14,7 @@ from lxml import etree from meetingtools.site_logging import logger import lxml from django.http import HttpResponseRedirect +from celery.execute import send_task class ACPException(Exception): def __init__(self, value): @@ -176,4 +177,24 @@ class ACPClient(): return self.add_remove_member(principal_id, group_id, True) def remove_member(self,principal_id,group_id): - return self.add_remove_member(principal_id, group_id, False)
\ No newline at end of file + return self.add_remove_member(principal_id, group_id, False) + + def user_counts(self,sco_id): + user_count = None + host_count = None + userlist = self.request('meeting-usermanager-user-list',{'sco-id': sco_id},False) + if userlist.status_code() == 'ok': + user_count = int(userlist.et.xpath("count(.//userdetails)")) + host_count = int(userlist.et.xpath("count(.//userdetails/role[text() = 'host'])")) + elif userlist.status_code() == 'no-access' and userlist.subcode() == 'not-available': #no active session + user_count = 0 + host_count = 0 + + return (user_count,host_count) + + def poll_user_counts(self,room,recheck=0): + (room.user_count,room.host_count) = self.user_counts(room.sco_id) + room.save() + if room.user_count > 0 or recheck > 0: + logging.debug("will recheck %d more times ..." % (recheck -1)) + send_task('meetingtools.apps.room.tasks.poll_user_counts',[room],{'recheck': recheck-1},countdown=2)
\ No newline at end of file |