view data/plugin/macro/ @ 614:81cb72cfddac

bbb: don't crash because of wrong salt
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 15 Aug 2012 13:36:59 +0200
parents 8cc90eda0688
children 127da830be6c
line wrap: on
line source
# -*- coding: utf-8 -*-
    MoinMoin - checks activity of BigBlueButton meetings

    @copyright: 2012 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
import urllib
from MoinMoin import wikiutil
from MoinMoin.Page import Page
# pip install bigbluebutton
    from bigbluebutton import Meeting
except ImportError:
    Meeting = None
    import bbb_settings
except ImportError:
    bbb_settings = None

def macro_bbb(macro):
    Shows a list of all meetings with amount of participant and moderator
    On same directory as you need
    a "" module with the SALT and the BBB_API_URL.
    if Meeting is None or bbb_settings is None:
        return u""
    request = macro.request
    _ = request.getText
    meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
    all_sessions = meeting.get_meetings()
    txt = ['= No active Meetings =']
    txt.append('(!) Create or Recreate a meeting')
    if all_sessions:
        txt = ['= Currently active Meetings =']
    if all_sessions:
        txt.append('|| meeting id || participation count || moderator count || users ||')
        for session in all_sessions:
            meeting_id = session["info"]['meeting_id']
            participation_count = session["info"]['participant_count']
            moderator_count = session["info"]['moderator_count']
            users = session["info"]["users"]
            users_in_meeting = ["%s %s" % (user["name"], user["role"][0]) for user in users]

            txt.append('|| %(meeting_id)s || %(participation_count)s|| %(moderator_count)s || %(users)s ||' % {"meeting_id": meeting_id,
                                                                                              "participation_count": participation_count,
                                                                                              "moderator_count": moderator_count,
                                                                                              "users": '<<BR>>'.join(users_in_meeting)

    raw = '\n'.join(txt)
    Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser",['format'])
    return wikiutil.renderText(request, Parser, raw)