예제 #1
0
    def getACL(self, srvid, channelid):
        raw_acls, raw_groups, raw_inherit = self._getDbusServerObject(
            srvid).getACL(channelid)

        acls = [
            ObjectInfo(
                applyHere=bool(rule[0]),
                applySubs=bool(rule[1]),
                inherited=bool(rule[2]),
                userid=int(rule[3]),
                group=unicode(rule[4]),
                allow=int(rule[5]),
                deny=int(rule[6]),
            ) for rule in raw_acls
        ]

        groups = [
            ObjectInfo(
                name=unicode(group[0]),
                inherited=bool(group[1]),
                inherit=bool(group[2]),
                inheritable=bool(group[3]),
                add=[int(usrid) for usrid in group[4]],
                remove=[int(usrid) for usrid in group[5]],
                members=[int(usrid) for usrid in group[6]],
            ) for group in raw_groups
        ]

        return acls, groups, bool(raw_inherit)
예제 #2
0
 def getRegistration(self, srvid, mumbleid):
     reg = self._getIceServerObject( srvid ).getRegistration( mumbleid )
     user = ObjectInfo( userid=mumbleid, name="", email="", comment="", hash="", pw="" )
     import Murmur
     if Murmur.UserInfo.UserName    in reg: user.name    = reg[Murmur.UserInfo.UserName]
     if Murmur.UserInfo.UserEmail   in reg: user.email   = reg[Murmur.UserInfo.UserEmail]
     if Murmur.UserInfo.UserComment in reg: user.comment = reg[Murmur.UserInfo.UserComment]
     if Murmur.UserInfo.UserHash    in reg: user.hash    = reg[Murmur.UserInfo.UserHash]
     return user
예제 #3
0
 def getRegistration(self, srvid, mumbleid):
     user = self._getIceServerObject(srvid).getRegistration(mumbleid)
     return ObjectInfo(
         userid=mumbleid,
         name=user.name,
         email=user.email,
         pw='',
     )
예제 #4
0
 def getRegistration(self, srvid, mumbleid):
     user = self._getDbusServerObject(srvid).getRegistration(
         dbus.Int32(mumbleid))
     return ObjectInfo(
         userid=mumbleid,
         name=unicode(user[1]),
         email=unicode(user[2]),
         pw='',
     )
예제 #5
0
    def getRegisteredPlayers(self, srvid, filter=''):
        users = self._getDbusServerObject(srvid).getRegisteredPlayers(filter)
        ret = {}

        for user in users:
            ret[int(user[0])] = ObjectInfo(userid=int(user[0]),
                                           name=unicode(user[1]),
                                           email=unicode(user[2]),
                                           pw=unicode(user[3]))

        return ret
예제 #6
0
    def getRegisteredPlayers(self, srvid, filter=''):
        users = self._getIceServerObject(srvid).getRegisteredUsers(
            filter.encode("UTF-8"))
        ret = {}

        for id in users:
            ret[id] = ObjectInfo(userid=id,
                                 name=unicode(users[id], "utf8"),
                                 email='',
                                 pw='')

        return ret
예제 #7
0
    def getRegisteredPlayers(self, srvid, filter=''):
        users = self._getIceServerObject(srvid).getRegisteredPlayers(
            filter.encode("UTF-8"))
        ret = {}

        for user in users:
            ret[user.playerid] = ObjectInfo(userid=int(user.playerid),
                                            name=unicode(user.name, "utf8"),
                                            email=unicode(user.email, "utf8"),
                                            pw=unicode(user.pw, "utf8"))

        return ret
예제 #8
0
    def getChannels(self, srvid):
        chans = self._getDbusServerObject(srvid).getChannels()

        ret = {}

        for channel in chans:
            ret[channel[0]] = ObjectInfo(
                id=int(channel[0]),
                name=unicode(channel[1]),
                parent=int(channel[2]),
                links=[int(lnk) for lnk in channel[3]],
            )

        return ret
예제 #9
0
def run_murmur(version):
    """ Run the given Murmur version as a subprocess.

        Either returns a Popen object or raises an EnvironmentError.
    """

    murmur_root = join(settings.TEST_MURMUR_LAB_DIR, version)
    if not exists(murmur_root):
        raise EnvironmentError(
            "This version could not be found: '%s' does not exist!" %
            murmur_root)

    binary_candidates = ('murmur.64', 'murmur.x86', 'murmurd')

    for binname in binary_candidates:
        if exists(join(murmur_root, binname)):
            process = subprocess.Popen((join(murmur_root, binname), '-fg'),
                                       stdin=None,
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.STDOUT,
                                       cwd=murmur_root)

            # Check capabilities by waiting for certain lines to show up.
            capa = ObjectInfo(has_dbus=False,
                              has_ice=False,
                              has_instance=False,
                              has_users=False)

            def canRead(self, timeout=1):
                rdy_read, rdy_write, rdy_other = select([self.stdout], [], [],
                                                        timeout)
                return self.stdout in rdy_read

            setattr(subprocess.Popen, 'canRead', canRead)

            while process.canRead(0.5):
                line = process.stdout.readline()
                #print "read line:", line
                if line == 'DBus registration succeeded\n':
                    capa.has_dbus = True
                elif line == 'MurmurIce: Endpoint "tcp -h 127.0.0.1 -p 6502" running\n':
                    capa.has_ice = True
                elif line == '1 => Server listening on 0.0.0.0:64738\n':
                    capa.has_instance = True
                elif "> Authenticated\n" in line:
                    capa.has_users = True

            process.capabilities = capa

            return process

    raise EnvironmentError("Murmur binary not found. (Tried %s)" %
                           unicode(binary_candidates))
예제 #10
0
    def getACL(self, srvid, channelid):
        # need to convert acls to say "userid" instead of "playerid". meh.
        raw_acls, raw_groups, raw_inherit = self._getIceServerObject(
            srvid).getACL(channelid)

        acls = [
            ObjectInfo(
                applyHere=rule.applyHere,
                applySubs=rule.applySubs,
                inherited=rule.inherited,
                userid=rule.playerid,
                group=rule.group,
                allow=rule.allow,
                deny=rule.deny,
            ) for rule in raw_acls
        ]

        return acls, raw_groups, raw_inherit
예제 #11
0
    def getPlayers(self, srvid):
        players = self._getDbusServerObject(srvid).getPlayers()

        ret = {}

        for playerObj in players:
            ret[int(playerObj[0])] = ObjectInfo(session=int(playerObj[0]),
                                                mute=bool(playerObj[1]),
                                                deaf=bool(playerObj[2]),
                                                suppress=bool(playerObj[3]),
                                                selfMute=bool(playerObj[4]),
                                                selfDeaf=bool(playerObj[5]),
                                                channel=int(playerObj[6]),
                                                userid=int(playerObj[7]),
                                                name=unicode(playerObj[8]),
                                                onlinesecs=int(playerObj[9]),
                                                bytespersec=int(playerObj[10]))

        return ret
예제 #12
0
    def getPlayers(self, srvid):
        users = self._getIceServerObject(srvid).getPlayers()

        ret = {}

        for useridx in users:
            user = users[useridx]
            ret[user.session] = ObjectInfo(session=user.session,
                                           userid=user.playerid,
                                           mute=user.mute,
                                           deaf=user.deaf,
                                           suppress=user.suppressed,
                                           selfMute=user.selfMute,
                                           selfDeaf=user.selfDeaf,
                                           channel=user.channel,
                                           name=user.name,
                                           onlinesecs=user.onlinesecs,
                                           bytespersec=user.bytespersec)

        return ret
예제 #13
0
 def getRegistration(self, srvid, mumbleid):
     reg = self._getIceServerObject(srvid).getRegistration(mumbleid)
     user = ObjectInfo(userid=mumbleid,
                       name="",
                       email="",
                       comment="",
                       hash="",
                       pw="")
     import Murmur
     if Murmur.UserInfo.UserName in reg:
         user.name = reg[Murmur.UserInfo.UserName]
     if Murmur.UserInfo.UserEmail in reg:
         user.email = reg[Murmur.UserInfo.UserEmail]
     if Murmur.UserInfo.UserComment in reg:
         user.comment = reg[Murmur.UserInfo.UserComment]
     if Murmur.UserInfo.UserHash in reg:
         user.hash = reg[Murmur.UserInfo.UserHash]
     return user