Adding @stats. We're just going to assume the equivalent of /all on MUX since it's a lot more informative.

This commit is contained in:
Greg Taylor 2007-05-24 18:33:02 +00:00
parent bb0ff9f6ff
commit bfafdbf9c9
3 changed files with 53 additions and 25 deletions

View file

@ -64,6 +64,7 @@ ctable = {
"@reload": (commands_privileged.cmd_reload, ("genperms.process_control")),
"@set": (commands_privileged.cmd_set, None),
"@shutdown": (commands_privileged.cmd_shutdown, ("genperms.process_control")),
"@stats": (commands_privileged.cmd_stats, None),
"@teleport": (commands_privileged.cmd_teleport, ("genperms.builder")),
"@unlink": (commands_privileged.cmd_unlink, ("genperms.builder")),
"@wall": (commands_privileged.cmd_wall, ("genperms.announce")),

View file

@ -16,6 +16,20 @@ This file contains commands that require special permissions to use. These
are generally @-prefixed commands, but there are exceptions.
"""
def cmd_stats(cdat):
"""
Shows stats about the database.
4012 objects = 144 rooms, 212 exits, 613 things, 1878 players. (1165 garbage)
"""
session = cdat['session']
stats_dict = functions_db.object_totals()
session.msg("%d objects = %d rooms, %d exits, %d things, %d players. (%d garbage)" % (stats_dict["objects"],
stats_dict["rooms"],
stats_dict["exits"],
stats_dict["things"],
stats_dict["players"],
stats_dict["garbage"]))
def cmd_reload(cdat):
"""
Reloads all modules.
@ -351,11 +365,11 @@ def cmd_open(cdat):
new_object = functions_db.create_object(odat)
session.msg("You open an unlinked exit - %s" % (new_object,))
def cmd_link(cdat):
"""
Sets an object's home or an exit's destination.
Forms:
@link <Object>=<Target>
"""
@ -363,19 +377,19 @@ def cmd_link(cdat):
pobject = session.get_pobject()
server = cdat['server']
args = cdat['uinput']['splitted'][1:]
if len(args) == 0:
session.msg("Link what?")
return
eq_args = args[0].split('=')
target_name = eq_args[0]
dest_name = '='.join(eq_args[1:])
if len(target_name) == 0:
session.msg("What do you want to link?")
return
if len(eq_args) > 1:
target_obj = functions_db.standard_plr_objsearch(session, target_name)
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
@ -385,7 +399,7 @@ def cmd_link(cdat):
if not pobject.controls_other(target_obj):
session.msg(defines_global.NOCONTROL_MSG)
return
# If we do something like "@link blah=", we unlink the object.
if len(dest_name) == 0:
target_obj.set_home(None)
@ -396,15 +410,15 @@ def cmd_link(cdat):
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
if not destination:
return
target_obj.set_home(destination)
session.msg("You link %s to %s." % (target_obj,destination))
else:
# We haven't provided a target.
session.msg("You must provide a destination to link to.")
return
def cmd_unlink(cdat):
"""
Unlinks an object.
@ -437,14 +451,14 @@ def cmd_teleport(cdat):
pobject = session.get_pobject()
server = cdat['server']
args = cdat['uinput']['splitted'][1:]
if len(args) == 0:
session.msg("Teleport where/what?")
return
eq_args = args[0].split('=')
search_str = ''.join(args)
# If we have more than one entry in our '=' delimited argument list,
# then we're doing a @tel <victim>=<location>. If not, we're doing
# a direct teleport, @tel <destination>.
@ -454,7 +468,7 @@ def cmd_teleport(cdat):
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
if not victim:
return
destination = functions_db.standard_plr_objsearch(session, eq_args[1])
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
if not destination:
@ -476,7 +490,7 @@ def cmd_teleport(cdat):
# Kinda yucky I guess.
cdat2 = {"server": server, "uinput": 'look', "session": victim_session}
cmdhandler.handle(cdat2)
else:
# Direct teleport (no equal sign)
target_obj = functions_db.standard_plr_objsearch(session, search_str)
@ -500,7 +514,7 @@ def cmd_wipe(cdat):
pobject = session.get_pobject()
args = cdat['uinput']['splitted'][1:]
attr_search = False
if len(args) == 0:
session.msg("Wipe what?")
return
@ -524,7 +538,7 @@ def cmd_wipe(cdat):
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
if not target_obj:
return
if attr_search:
# User has passed an attribute wild-card string. Search for name matches
# and wipe.

View file

@ -3,7 +3,7 @@ from django.db import connection
from django.contrib.auth.models import User
from apps.objects.models import Object, Attribute
from apps.config.models import ConfigValue
import defines_global as global_defines
import defines_global as defines_global
import gameconf
"""
@ -19,13 +19,13 @@ def is_unsavable_flag(flagname):
"""
Returns TRUE if the flag is an unsavable flag.
"""
return flagname.upper() in global_defines.NOSAVE_FLAGS
return flagname.upper() in defines_global.NOSAVE_FLAGS
def is_modifiable_flag(flagname):
"""
Check to see if a particular flag is modifiable.
"""
if flagname.upper() not in global_defines.NOSET_FLAGS:
if flagname.upper() not in defines_global.NOSET_FLAGS:
return True
else:
return False
@ -36,7 +36,7 @@ def is_modifiable_attrib(attribname):
attribname: (string) An attribute name to check.
"""
if attribname.upper() not in global_defines.NOSET_ATTRIBS:
if attribname.upper() not in defines_global.NOSET_ATTRIBS:
return True
else:
return False
@ -50,7 +50,7 @@ def get_nextfree_dbnum():
"""
# First we'll see if there's an object of type 6 (GARBAGE) that we
# can recycle.
nextfree = Object.objects.filter(type__exact=global_defines.OTYPE_GARBAGE)
nextfree = Object.objects.filter(type__exact=defines_global.OTYPE_GARBAGE)
if nextfree:
# We've got at least one garbage object to recycle.
return nextfree[0]
@ -64,9 +64,9 @@ def global_object_name_search(ostring, exact_match=False):
Searches through all objects for a name match.
"""
if exact_match:
return Object.objects.filter(name__iexact=ostring).exclude(type=global_defines.OTYPE_GARBAGE)
return Object.objects.filter(name__iexact=ostring).exclude(type=defines_global.OTYPE_GARBAGE)
else:
return Object.objects.filter(name__icontains=ostring).exclude(type=global_defines.OTYPE_GARBAGE)
return Object.objects.filter(name__icontains=ostring).exclude(type=defines_global.OTYPE_GARBAGE)
def list_search_object_namestr(searchlist, ostring, dbref_only=False, limit_types=False, match_type="fuzzy"):
"""
@ -98,7 +98,7 @@ def player_search(searcher, ostring):
if len(alias_results) > 0:
return alias_results
else:
return local_and_global_search(searcher, ostring, limit_types=[global_defines.OTYPE_PLAYER])
return local_and_global_search(searcher, ostring, limit_types=[defines_global.OTYPE_PLAYER])
def standard_plr_objsearch(session, ostring, search_contents=True, search_location=True, dbref_only=False, limit_types=False):
"""
@ -122,6 +122,19 @@ def standard_plr_objsearch(session, ostring, search_contents=True, search_locati
else:
return results[0]
def object_totals():
"""
Returns a dictionary with database object totals.
"""
dbtotals = {}
dbtotals["objects"] = Object.objects.count()
dbtotals["things"] = Object.objects.filter(type=defines_global.OTYPE_THING).count()
dbtotals["exits"] = Object.objects.filter(type=defines_global.OTYPE_EXIT).count()
dbtotals["rooms"] = Object.objects.filter(type=defines_global.OTYPE_ROOM).count()
dbtotals["garbage"] = Object.objects.filter(type=defines_global.OTYPE_GARBAGE).count()
dbtotals["players"] = Object.objects.filter(type=defines_global.OTYPE_PLAYER).count()
return dbtotals
def alias_search(searcher, ostring):
"""
Search players by alias. Returns a list of objects whose "ALIAS" attribute