mirror of
https://codeberg.org/langfingaz/bbb-status
synced 2025-04-04 15:26:00 +02:00
107 lines
4.1 KiB
Python
107 lines
4.1 KiB
Python
from typing import List
|
|
from xml.etree import ElementTree
|
|
from datetime import datetime
|
|
|
|
from langfingaz.util import util
|
|
|
|
|
|
class Meeting(object):
|
|
def __init__(self, xml_meeting: ElementTree.Element):
|
|
self.meetingName: str = xml_meeting.find('meetingName').text
|
|
self.meetingID: str = xml_meeting.find('meetingID').text
|
|
self.internalMeetingID: str = xml_meeting.find('internalMeetingID').text
|
|
|
|
self.isRunning: bool = util.asBoolean(xml_meeting.find('running').text)
|
|
self.startTime: int = int(xml_meeting.find('startTime').text)
|
|
self.createTime: int = int(xml_meeting.find('createTime').text)
|
|
if self.isRunning:
|
|
self.endTime = None
|
|
else:
|
|
self.endTime = xml_meeting.find('endTime').text
|
|
|
|
# TODO: disable default meeting recordings (!)
|
|
self.isRecording: bool = util.asBoolean(xml_meeting.find('recording').text)
|
|
self.isBreakout: bool = util.asBoolean(xml_meeting.find('isBreakout').text)
|
|
|
|
self.participantCount: int = int(xml_meeting.find('participantCount').text)
|
|
self.listenerCount: int = int(xml_meeting.find('listenerCount').text)
|
|
self.voiceParticipantCount: int = int(xml_meeting.find('voiceParticipantCount').text)
|
|
self.videoCount: int = int(xml_meeting.find('videoCount').text)
|
|
self.maxUsers: int = int(xml_meeting.find('maxUsers').text)
|
|
self.moderatorCount: int = int(xml_meeting.find('moderatorCount').text)
|
|
|
|
self.attendees: List[Attendee] = [Attendee(xml_attendee) for xml_attendee in
|
|
xml_meeting.find('attendees').iter('attendee')]
|
|
|
|
def __str__(self):
|
|
return util.asString(self)
|
|
|
|
|
|
class Attendee(object):
|
|
def __init__(self, xml_attendee: ElementTree.Element):
|
|
# self.userID = xml_attendee.find('userID').text
|
|
# self.fullName = xml_attendee.find('fullName').text
|
|
self.role = xml_attendee.find('role').text
|
|
self.isPresenter: bool = util.asBoolean(xml_attendee.find('isPresenter').text)
|
|
self.isListeningOnly: bool = util.asBoolean(xml_attendee.find('isListeningOnly').text)
|
|
self.hasJoinedVoice: bool = util.asBoolean(xml_attendee.find('hasJoinedVoice').text)
|
|
self.hasVideo: bool = util.asBoolean(xml_attendee.find('hasVideo').text)
|
|
|
|
def __str__(self):
|
|
return util.asString(self)
|
|
|
|
|
|
class BbbStatus(object):
|
|
"""
|
|
Represents the status of one BBB server at one point of time.
|
|
It contains statistics about the running meetings on the server
|
|
and (TODO) it's CPU utilization and network usage.
|
|
"""
|
|
|
|
pointOfTime: datetime = None
|
|
|
|
@staticmethod
|
|
def getKey(bbbStatus):
|
|
"""
|
|
Returns the date of this object as key for sorting.
|
|
See also: https://docs.python.org/3.7/howto/sorting.html#key-functions
|
|
|
|
:return: Key that can be used for sorting
|
|
"""
|
|
return bbbStatus.pointOfTime
|
|
|
|
def __init__(self, meetings: List[Meeting], pointOfTime: datetime = None):
|
|
"""
|
|
:param meetings: All current meetings
|
|
:param pointOfTime: The date and time at which the information about
|
|
the running meetings has been captured / requested from the BBB instance
|
|
"""
|
|
self.meetings = meetings
|
|
self.pointOfTime = pointOfTime
|
|
|
|
self.recordingCount = 0
|
|
self.participantCount = 0
|
|
self.listenerCount = 0
|
|
self.voiceParticipantCount = 0
|
|
self.videoCount = 0
|
|
self.moderatorCount = 0
|
|
|
|
for meeting in meetings:
|
|
self.participantCount += meeting.participantCount
|
|
self.listenerCount += meeting.listenerCount
|
|
self.voiceParticipantCount += meeting.voiceParticipantCount
|
|
self.videoCount += meeting.videoCount
|
|
self.moderatorCount += meeting.moderatorCount
|
|
if meeting.isRecording:
|
|
self.recordingCount += 1
|
|
|
|
def __str__(self):
|
|
return util.asString(self)
|
|
|
|
|
|
def parseMeetingsData(dataStr: str) -> List[Meeting]:
|
|
tree = ElementTree.fromstring(dataStr)
|
|
xml_meetings = tree.find('meetings')
|
|
|
|
return [Meeting(xml_meeting) for xml_meeting in xml_meetings.iter('meeting')]
|