def func(self): """ Get all connected players by polling session. """ player = self.player session_list = SESSIONS.get_sessions() session_list = sorted(session_list, key=lambda o: o.player.key) if self.cmdstring == "doing": show_session_data = False else: show_session_data = player.check_permstring( "Immortals") or player.check_permstring("Wizards") nplayers = (SESSIONS.player_count()) if show_session_data: # privileged info table = prettytable.PrettyTable([ "{wPlayer Name", "{wOn for", "{wIdle", "{wPuppeting", "{wRoom", "{wCmds", "{wProtocol", "{wHost" ]) for session in session_list: if not session.logged_in: continue delta_cmd = time.time() - session.cmd_last_visible delta_conn = time.time() - session.conn_time player = session.get_player() puppet = session.get_puppet() location = puppet.location.key if puppet else "None" table.add_row([ utils.crop(player.name, width=25), utils.time_format(delta_conn, 0), utils.time_format(delta_cmd, 1), utils.crop(puppet.key if puppet else "None", width=25), utils.crop(location, width=25), session.cmd_total, session.protocol_key, isinstance(session.address, tuple) and session.address[0] or session.address ]) else: # unprivileged table = prettytable.PrettyTable( ["{wPlayer name", "{wOn for", "{wIdle"]) for session in session_list: if not session.logged_in: continue delta_cmd = time.time() - session.cmd_last_visible delta_conn = time.time() - session.conn_time player = session.get_player() table.add_row([ utils.crop(player.key, width=25), utils.time_format(delta_conn, 0), utils.time_format(delta_cmd, 1) ]) isone = nplayers == 1 string = "{wPlayers:{n\n%s\n%s unique account%s logged in." % ( table, "One" if isone else nplayers, "" if isone else "s") self.msg(string)
def func(self): """ Get all connected players by polling session. """ caller = self.caller session_list = SESSIONS.get_sessions() if self.cmdstring == "doing": show_session_data = False else: show_session_data = caller.check_permstring("Immortals") or caller.check_permstring("Wizards") if show_session_data: table = [["Player Name"], ["On for"], ["Idle"], ["Room"], ["Cmds"], ["Host"]] else: table = [["Player Name"], ["On for"], ["Idle"]] for session in session_list: if not session.logged_in: continue delta_cmd = time.time() - session.cmd_last_visible delta_conn = time.time() - session.conn_time plr_pobject = session.get_character() if not plr_pobject: plr_pobject = session.get_player() show_session_data = False table = [["Player Name"], ["On for"], ["Idle"]] if show_session_data: table[0].append(plr_pobject.name[:25]) table[1].append(utils.time_format(delta_conn, 0)) table[2].append(utils.time_format(delta_cmd, 1)) table[3].append(plr_pobject.location and plr_pobject.location.id or "None") table[4].append(session.cmd_total) table[5].append(session.address[0]) else: table[0].append(plr_pobject.name[:25]) table[1].append(utils.time_format(delta_conn,0)) table[2].append(utils.time_format(delta_cmd,1)) stable = [] for row in table: # prettify values stable.append([str(val).strip() for val in row]) ftable = utils.format_table(stable, 5) string = "" for ir, row in enumerate(ftable): if ir == 0: string += "\n" + "{w%s{n" % ("".join(row)) else: string += "\n" + "".join(row) nplayers = (SESSIONS.player_count()) if nplayers == 1: string += '\nOne player logged in.' else: string += '\n%d players logged in.' % nplayers caller.msg(string)
def func(self): """ Get all connected players by polling session. """ player = self.player session_list = SESSIONS.get_sessions() session_list = sorted(session_list, key=lambda o: o.player.key) if self.cmdstring == "doing": show_session_data = False else: show_session_data = player.check_permstring("Immortals") or player.check_permstring("Wizards") nplayers = (SESSIONS.player_count()) if show_session_data: # privileged info table = prettytable.PrettyTable(["{wPlayer Name", "{wOn for", "{wIdle", "{wPuppeting", "{wRoom", "{wCmds", "{wProtocol", "{wHost"]) for session in session_list: if not session.logged_in: continue delta_cmd = time.time() - session.cmd_last_visible delta_conn = time.time() - session.conn_time player = session.get_player() puppet = session.get_puppet() location = puppet.location.key if puppet else "None" table.add_row([utils.crop(player.name, width=25), utils.time_format(delta_conn, 0), utils.time_format(delta_cmd, 1), utils.crop(puppet.key if puppet else "None", width=25), utils.crop(location, width=25), session.cmd_total, session.protocol_key, isinstance(session.address, tuple) and session.address[0] or session.address]) else: # unprivileged table = prettytable.PrettyTable(["{wPlayer name", "{wOn for", "{wIdle"]) for session in session_list: if not session.logged_in: continue delta_cmd = time.time() - session.cmd_last_visible delta_conn = time.time() - session.conn_time player = session.get_player() table.add_row([utils.crop(player.key, width=25), utils.time_format(delta_conn, 0), utils.time_format(delta_cmd, 1)]) isone = nplayers == 1 string = "{wPlayers:{n\n%s\n%s unique account%s logged in." % (table, "One" if isone else nplayers, "" if isone else "s") self.msg(string)
def webclient(request): """ Webclient page template loading. """ # as an example we send the number of connected players to the template pagevars = {'num_players_connected': SESSIONS.player_count()} context_instance = RequestContext(request) return render_to_response('webclient.html', pagevars, context_instance)
def webclient(request): """ Webclient page template loading. """ # analyze request to find which port we are on if int(request.META["SERVER_PORT"]) == 8000: # we relay webclient to the portal port print "Called from port 8000!" #return redirect("http://localhost:8001/webclient/", permanent=True) # as an example we send the number of connected players to the template pagevars = {'num_players_connected': SESSIONS.player_count()} context_instance = RequestContext(request) return render_to_response('webclient.html', pagevars, context_instance)
def webclient(request): """ Webclient page template loading. """ # analyze request to find which port we are on if int(request.META["SERVER_PORT"]) == 8000: # we relay webclient to the portal port print "Called from port 8000!" # return redirect("http://localhost:8001/webclient/", permanent=True) # as an example we send the number of connected players to the template pagevars = {"num_players_connected": SESSIONS.player_count()} context_instance = RequestContext(request) return render_to_response("webclient.html", pagevars, context_instance)