Exemplo n.º 1
0
def get_online_users():
    output = common.shell(FS_CLI_COMMAND % "sofia status profile internal")
    items = re.findall("Call-ID.*?Auth-Realm:.*?\n", output, re.DOTALL)
    users = (line for line in (item.split("\n") for item in items))
    online_users = (dict((map(str.strip, entry.split(": ")) for entry in user if entry)) for user in users)
    ret = {}
    for user in online_users:
        extension = user["Auth-User"]
        ret[extension] = user
        ret[extension]["password"] = ExtensionFileHandler(extension).get()['password']
    
    return ret
Exemplo n.º 2
0
def get_conference_state():
    online_users = online_users = [(user.strip(), 1) for user in get_online_users().iterkeys()]
    rooms = {
        ConferenceOneHandler().get()['conferenceOneName']: None,
        ConferenceTwoHandler().get()['conferenceTwoName']: None
    }
    
    for room in rooms:
        users = common.shell("%s | grep %s | head -n 1" % (FS_CLI_COMMAND % 'show calls', room))
        users = users.split(",")
        users = [user for user in users if user in online_users]
        if users:
            rooms[room] = users
            
    for room in rooms.keys():
        if not rooms[room]:
            del rooms[room]
            
    return rooms
Exemplo n.º 3
0
 def write(self):
     XMLHandler.write(self)
     common.shell("touch " + SNOIP_VARS_PATH)
Exemplo n.º 4
0
 def write(self):
     XMLHandler.write(self)
     common.shell("touch " + FS_DIR_PATH)
Exemplo n.º 5
0
def fs_directory_range():
    xtns = (xtn.strip().replace(".xml", "") for xtn in common.shell("ls -m %s" % FS_DIR_PATH).strip().split(","))
    return map(int, (xtn for xtn in xtns if xtn.isdigit()))