Package lyntin :: Module engine :: Class Engine
[show private | hide private]
[frames | no frames]

Class Engine


This is the engine class. There should be only one engine.
Method Summary
  __init__(self)
Initializes the engine.
  addManager(self, name, manager)
Adds a manager to our list.
  changeSession(self, name)
Changes the current session to another named session.
list of strings checkHooks(self)
Goes through all the hooks and returns a list of strings of basic information about them.
list of strings checkthreads(self)
Calls the Thread Manager checkthreads method which goes through and checks the status of all the threads registered with the Thread Manager.
boolean closeSession(self, ses)
Closes down a session.
session.Session instance createSession(self, name)
Creates a new session by copying the common session and registers the new session with the engine.
  flushUI(self)
Tells the ui to flush its output.
  getConfigManager(self)
Returns the config manager.
string getDiagnostics(self)
Returns some basic diagnostic information in the form of a string.
utils.PriorityQueue getHook(self, hookname, newhook)
Retrieves the hook in question.
manager.Manager subclass or None getManager(self, name)
Retrieves a manager by name.
session.Session or None getSession(self, name)
Returns a named session.
list of strings getSessions(self)
Returns a list of session names.
list of strings getStatus(self, ses)
Gets the status for a specific session.
ui.base.BaseUI subclass getUI(self)
Returns the ui.
  handleMudData(self, session, text)
Handle input coming from the mud.
string handleUserData(self, input, internal, session)
This handles input lines from the user in a session-less context.
  hookRegister(self, hookname, func, place)
Registers a function with a hook.
  registerSession(self, session, name)
Registers a session with the engine.
boolean removeManager(self, name)
Removes a manager from our list.
  runengine(self)
This gets kicked off in a thread and just keep going through events until it detects a shutdown.
  runtimer(self)
This timer thread sleeps for a second, then calls everything in the queue with the current tick.
  set_current_session(self, newsession)
Changes the current session to another session.
  setUI(self, newui)
Sets the ui.
  shutdown(self, args)
Sets the shutdown status for the engine.
  startthread(self, name, func)
Starts a thread through the Thread Manager.
  tallyError(self)
Adds one to the error count.
  unregisterSession(self, ses)
Unregisters a session from the engine.
  writePrompt(self)
Tells the ui to print a prompt.
  writeSession(self, message)
Writes a message to the network socket.
  writeUI(self, text)
Writes a message to the ui.

Class Variable Summary
NoneType instance = None                                                                  

Method Details

__init__(self)
(Constructor)

Initializes the engine.

addManager(self, name, manager)

Adds a manager to our list.
Parameters:
name - the name of the manager to add
           (type=string)
manager - the manager instance to add
           (type=manager.Manager subclass)

changeSession(self, name='')

Changes the current session to another named session.

If they don't pass in a name, we get the next available non-common session if possible.
Parameters:
name - the name of the session to switch to
           (type=string)

checkHooks(self)

Goes through all the hooks and returns a list of strings of basic information about them.
Returns:
information about the hooks
           (type=list of strings)

checkthreads(self)

Calls the Thread Manager checkthreads method which goes through and checks the status of all the threads registered with the Thread Manager.
Returns:
one string for each thread indicating its status
           (type=list of strings)

closeSession(self, ses=None)

Closes down a session.
Parameters:
ses - the name of the session to close
           (type=string)
Returns:
1 if successful; 0 if not
           (type=boolean)

createSession(self, name)

Creates a new session by copying the common session and registers the new session with the engine.
Parameters:
name - the name of the session
           (type=string)
Returns:
the new session
           (type=session.Session instance)

flushUI(self)

Tells the ui to flush its output.

getConfigManager(self)

Returns the config manager.

getDiagnostics(self)

Returns some basic diagnostic information in the form of a string. This allows a user to monitor how Lyntin is doing in terms of events and other such erata.
Returns:
the complete the complete diagnostic data for our little happy mud client
           (type=string)

getHook(self, hookname, newhook=1)

Retrieves the hook in question. If the hook doesn't exist and newhook==1, then we'll create a new hook. Otherwise, we'll return None.
Parameters:
hookname - the name of the hook to retrieve
           (type=string)
Returns:
the hook by name
           (type=utils.PriorityQueue)

getManager(self, name)

Retrieves a manager by name.
Parameters:
name - the name of the manager to retrieve
           (type=string)
Returns:
the manager instance or None
           (type=manager.Manager subclass or None)

getSession(self, name)

Returns a named session.
Parameters:
name - the name of the session to retrieve
           (type=string)
Returns:
the session of that name or None
           (type=session.Session or None)

getSessions(self)

Returns a list of session names.
Returns:
all the session names
           (type=list of strings)

getStatus(self, ses)

Gets the status for a specific session.
Parameters:
ses - the session to get status for
           (type=session.Session)
Returns:
the status of the session
           (type=list of strings)

getUI(self)

Returns the ui.
Returns:
the ui
           (type=ui.base.BaseUI subclass)

handleMudData(self, session, text)

Handle input coming from the mud. We toss this to the current session to deal with.
Parameters:
session - the session this mud data applies to
           (type=session.Session instance)
text - the text coming from the mud
           (type=string)

handleUserData(self, input, internal=0, session=None)

This handles input lines from the user in a session-less context. The engine.handleUserData deals with global stuff and then passes the modified input to the session for session-oriented handling. The session can call this method again with expanded input--this method is considered recursive.

internal tells whether to spam the input hook and things of that nature.
Parameters:
input - the data from the user
           (type=string)
internal - whether this should be executed internally or not. 0 if we should spam the input hook and record the input to the historymanager; 1 if we shouldn't
           (type=boolean)
session - the session scoping to execute this user input in
           (type=session.Session instance)
Returns:
the commands that were actually executed (may not be exactly what the user typed--this is for the history manager)
           (type=string)

hookRegister(self, hookname, func, place=99)

Registers a function with a hook.
Parameters:
hookname - the name of the hook
           (type=string)
func - the function to register with the hook
           (type=function)
place - the function will get this place in the call order. functions with the same place specified will get arbitrary ordering. defaults to constants.LAST.
           (type=int)

registerSession(self, session, name)

Registers a session with the engine.
Parameters:
session - the session to register
           (type=session.Session instance)
name - the name of the session
           (type=string)
Raises:
ValueError - if the session has a non-unique name

removeManager(self, name)

Removes a manager from our list.
Parameters:
name - the name of the manager to remove
           (type=string)
Returns:
0 if nothing happened, 1 if the manager was removed
           (type=boolean)

runengine(self)

This gets kicked off in a thread and just keep going through events until it detects a shutdown.

runtimer(self)

This timer thread sleeps for a second, then calls everything in the queue with the current tick.

Note: This will almost always be slightly behind and will get worse as there are more things that get executed each tick.

set_current_session(self, newsession)

Changes the current session to another session.
Parameters:
newsession - the session to change to
           (type=session.Session instance)

setUI(self, newui)

Sets the ui.
Parameters:
newui - the new ui to set
           (type=ui.base.BaseUI subclass)

shutdown(self, args)

Sets the shutdown status for the engine.

startthread(self, name, func)

Starts a thread through the Thread Manager.
Parameters:
name - the name of the thread to start
           (type=string)
func - the function to run in the thread
           (type=function)

tallyError(self)

Adds one to the error count. If we see more than 20 errors, we shutdown.

unregisterSession(self, ses)

Unregisters a session from the engine.
Parameters:
ses - the session to unregister
           (type=session.Session instance)

writePrompt(self)

Tells the ui to print a prompt.

writeSession(self, message)

Writes a message to the network socket. The message should be a string. Otherwise, it's unhealthy.
Parameters:
message - the text to write to the mud
           (type=string)

writeUI(self, text)

Writes a message to the ui.

This method uses a lock so that multiple threads can write to the ui without intersecting and crashing the python process.

Theoretically you should use the exported module to write things to the ui--it calls this method.
Parameters:
text - the message to write to the ui
           (type=string or ui.base.Message)

Class Variable Details

instance

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.1 on Mon Aug 9 09:17:41 2004 http://epydoc.sf.net