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

164
server.py
View file

@ -21,102 +21,102 @@ import initial_setup
class EvenniaService(service.Service):
def __init__(self, filename="blah"):
self.cmd_alias_list = {}
self.game_running = True
sys.path.append('.')
def __init__(self, filename="blah"):
self.cmd_alias_list = {}
self.game_running = True
sys.path.append('.')
# Database-specific startup optimizations.
if settings.DATABASE_ENGINE == "sqlite3":
self.sqlite3_prep()
# Database-specific startup optimizations.
if settings.DATABASE_ENGINE == "sqlite3":
self.sqlite3_prep()
# Wipe our temporary flags on all of the objects.
cursor = connection.cursor()
cursor.execute("UPDATE objects_object SET nosave_flags=''")
# Wipe our temporary flags on all of the objects.
cursor = connection.cursor()
cursor.execute("UPDATE objects_object SET nosave_flags=''")
print '-'*50
# Load command aliases into memory for easy/quick access.
self.load_cmd_aliases()
print '-'*50
# Load command aliases into memory for easy/quick access.
self.load_cmd_aliases()
if gameconf.get_configvalue('game_firstrun') == '1':
print ' Game started for the first time, setting defaults.'
initial_setup.handle_setup()
if gameconf.get_configvalue('game_firstrun') == '1':
print ' Game started for the first time, setting defaults.'
initial_setup.handle_setup()
self.start_time = time.time()
self.start_time = time.time()
print ' %s started on port(s):' % (gameconf.get_configvalue('site_name'),)
for port in settings.GAMEPORTS:
print ' * %s' % (port)
print '-'*50
scheduler.start_events()
print ' %s started on port(s):' % (gameconf.get_configvalue('site_name'),)
for port in settings.GAMEPORTS:
print ' * %s' % (port)
print '-'*50
scheduler.start_events()
"""
BEGIN SERVER STARTUP METHODS
"""
def load_cmd_aliases(self):
"""
Load up our command aliases.
"""
alias_list = CommandAlias.objects.all()
for alias in alias_list:
self.cmd_alias_list[alias.user_input] = alias.equiv_command
print ' Command Aliases Loaded: %i' % (len(self.cmd_alias_list),)
pass
"""
BEGIN SERVER STARTUP METHODS
"""
def load_cmd_aliases(self):
"""
Load up our command aliases.
"""
alias_list = CommandAlias.objects.all()
for alias in alias_list:
self.cmd_alias_list[alias.user_input] = alias.equiv_command
print ' Command Aliases Loaded: %i' % (len(self.cmd_alias_list),)
pass
def sqlite3_prep(self):
"""
Optimize some SQLite stuff at startup since we can't save it to the
database.
"""
cursor = connection.cursor()
cursor.execute("PRAGMA cache_size=10000")
cursor.execute("PRAGMA synchronous=OFF")
cursor.execute("PRAGMA count_changes=OFF")
cursor.execute("PRAGMA temp_store=2")
def sqlite3_prep(self):
"""
Optimize some SQLite stuff at startup since we can't save it to the
database.
"""
cursor = connection.cursor()
cursor.execute("PRAGMA cache_size=10000")
cursor.execute("PRAGMA synchronous=OFF")
cursor.execute("PRAGMA count_changes=OFF")
cursor.execute("PRAGMA temp_store=2")
"""
BEGIN GENERAL METHODS
"""
def shutdown(self, message='The server has been shutdown. Please check back soon.'):
functions_general.announce_all(message)
session_mgr.disconnect_all_sessions()
reactor.callLater(0, reactor.stop)
"""
BEGIN GENERAL METHODS
"""
def shutdown(self, message='The server has been shutdown. Please check back soon.'):
functions_general.announce_all(message)
session_mgr.disconnect_all_sessions()
reactor.callLater(0, reactor.stop)
def command_list(self):
"""
Return a string representing the server's command list.
"""
clist = cmdtable.ctable.keys()
clist.sort()
return clist
def command_list(self):
"""
Return a string representing the server's command list.
"""
clist = cmdtable.ctable.keys()
clist.sort()
return clist
def reload(self, session):
"""
Reload modules that don't have any variables that can be reset.
For changes to the scheduler, server, or session_mgr modules, a cold
restart is needed.
"""
reload_list = ['ansi', 'cmdhandler', 'commands.comsys', 'commands.general',
'commands.privileged', 'commands.unloggedin', 'defines_global',
'events', 'functions_db', 'functions_general', 'functions_comsys',
'functions_help', 'gameconf', 'session', 'apps.objects.models',
'apps.helpsys.models', 'apps.config.models']
def reload(self, session):
"""
Reload modules that don't have any variables that can be reset.
For changes to the scheduler, server, or session_mgr modules, a cold
restart is needed.
"""
reload_list = ['ansi', 'cmdhandler', 'commands.comsys', 'commands.general',
'commands.privileged', 'commands.unloggedin', 'defines_global',
'events', 'functions_db', 'functions_general', 'functions_comsys',
'functions_help', 'gameconf', 'session', 'apps.objects.models',
'apps.helpsys.models', 'apps.config.models']
for mod in reload_list:
reload(sys.modules[mod])
for mod in reload_list:
reload(sys.modules[mod])
session.msg("Modules reloaded.")
functions_general.log_infomsg("Modules reloaded by %s." % (session,))
session.msg("Modules reloaded.")
functions_general.log_infomsg("Modules reloaded by %s." % (session,))
def getEvenniaServiceFactory(self):
f = protocol.ServerFactory()
f.protocol = SessionProtocol
f.server = self
return f
def getEvenniaServiceFactory(self):
f = protocol.ServerFactory()
f.protocol = SessionProtocol
f.server = self
return f
"""
END Server CLASS
"""
"""
END Server CLASS
"""
application = service.Application('Evennia')
mud_service = EvenniaService('Evennia Server')
@ -124,4 +124,4 @@ mud_service = EvenniaService('Evennia Server')
# Sheet sheet, fire ze missiles!
serviceCollection = service.IServiceCollection(application)
for port in settings.GAMEPORTS:
internet.TCPServer(port, mud_service.getEvenniaServiceFactory()).setServiceParent(serviceCollection)
internet.TCPServer(port, mud_service.getEvenniaServiceFactory()).setServiceParent(serviceCollection)