Indentation change 3-4 spaces.

Possible files that need to be cleanedup;
commands/info.py:cmd_list
commands/general.py:cmd_who
commands/comsys.py:cmd_who

cmdtable.py
ansi.py
This commit is contained in:
loki77 2008-06-13 19:52:29 +00:00
parent 740d715c72
commit 3fe644ef17
31 changed files with 1856 additions and 1856 deletions

View file

@ -9,94 +9,94 @@ Session manager, handles connected players.
session_list = []
def add_session(session):
"""
Adds a session to the session list.
"""
session_list.insert(0, session)
functions_general.log_infomsg('Sessions active: %d' % (len(get_session_list(return_unlogged=True),)))
"""
Adds a session to the session list.
"""
session_list.insert(0, session)
functions_general.log_infomsg('Sessions active: %d' % (len(get_session_list(return_unlogged=True),)))
def get_session_list(return_unlogged=False):
"""
Lists the connected session objects.
"""
if return_unlogged:
return session_list
else:
return [sess for sess in session_list if sess.is_loggedin()]
"""
Lists the connected session objects.
"""
if return_unlogged:
return session_list
else:
return [sess for sess in session_list if sess.is_loggedin()]
def disconnect_all_sessions():
"""
Cleanly disconnect all of the connected sessions.
"""
for sess in get_session_list():
sess.handle_close()
"""
Cleanly disconnect all of the connected sessions.
"""
for sess in get_session_list():
sess.handle_close()
def disconnect_duplicate_session(session):
"""
Disconnects any existing session under the same object. This is used in
connection recovery to help with record-keeping.
"""
sess_list = get_session_list()
new_pobj = session.get_pobject()
for sess in sess_list:
if new_pobj == sess.get_pobject() and sess != session:
sess.msg("Your account has been logged in from elsewhere, disconnecting.")
sess.disconnectClient()
return True
return False
"""
Disconnects any existing session under the same object. This is used in
connection recovery to help with record-keeping.
"""
sess_list = get_session_list()
new_pobj = session.get_pobject()
for sess in sess_list:
if new_pobj == sess.get_pobject() and sess != session:
sess.msg("Your account has been logged in from elsewhere, disconnecting.")
sess.disconnectClient()
return True
return False
def check_all_sessions():
"""
Check all currently connected sessions and see if any are dead.
"""
idle_timeout = int(gameconf.get_configvalue('idle_timeout'))
"""
Check all currently connected sessions and see if any are dead.
"""
idle_timeout = int(gameconf.get_configvalue('idle_timeout'))
if len(session_list) <= 0:
return
if len(session_list) <= 0:
return
if idle_timeout <= 0:
return
for sess in get_session_list(return_unlogged=True):
if (time.time() - sess.cmd_last) > idle_timeout:
sess.msg("Idle timeout exceeded, disconnecting.")
sess.handle_close()
if idle_timeout <= 0:
return
for sess in get_session_list(return_unlogged=True):
if (time.time() - sess.cmd_last) > idle_timeout:
sess.msg("Idle timeout exceeded, disconnecting.")
sess.handle_close()
def remove_session(session):
"""
Removes a session from the session list.
"""
try:
session_list.remove(session)
functions_general.log_infomsg('Sessions active: %d' % (len(get_session_list()),))
except:
#functions_general.log_errmsg("Unable to remove session: %s" % (session,))
pass
"""
Removes a session from the session list.
"""
try:
session_list.remove(session)
functions_general.log_infomsg('Sessions active: %d' % (len(get_session_list()),))
except:
#functions_general.log_errmsg("Unable to remove session: %s" % (session,))
pass
def session_from_object(targobject):
"""
Return the session object given a object (if there is one open).
session_list: (list) The server's session_list attribute.
targobject: (Object) The object to match.
"""
results = [prospect for prospect in session_list if prospect.get_pobject() == targobject]
if results:
return results[0]
else:
return False
"""
Return the session object given a object (if there is one open).
session_list: (list) The server's session_list attribute.
targobject: (Object) The object to match.
"""
results = [prospect for prospect in session_list if prospect.get_pobject() == targobject]
if results:
return results[0]
else:
return False
def session_from_dbref(dbstring):
"""
Return the session object given a dbref (if there is one open).
dbstring: (int) The dbref number to match against.
"""
if is_dbref(dbstring):
results = [prospect for prospect in session_list if prospect.get_pobject().dbref_match(dbstring)]
if results:
return results[0]
else:
return False
"""
Return the session object given a dbref (if there is one open).
dbstring: (int) The dbref number to match against.
"""
if is_dbref(dbstring):
results = [prospect for prospect in session_list if prospect.get_pobject().dbref_match(dbstring)]
if results:
return results[0]
else:
return False