Updated commands to use the new objectdb.search API.

This commit is contained in:
Griatch 2013-05-11 23:22:02 +02:00
parent 218e4a149c
commit 78e7346962
11 changed files with 97 additions and 84 deletions

View file

@ -7,7 +7,6 @@ Admin commands
import time, re
from django.conf import settings
from django.contrib.auth.models import User
from src.players.models import PlayerDB
from src.server.sessionhandler import SESSIONS
from src.server.models import ServerConfig
from src.utils import utils, prettytable, search
@ -92,7 +91,6 @@ class CmdBoot(MuxCommand):
feedback += "\nReason given: %s" % reason
for session in boot_list:
name = session.uname
session.msg(feedback)
pobj.disconnect_session_from_player(session.sessid)
@ -287,12 +285,7 @@ class CmdDelPlayer(MuxCommand):
# We use player_search since we want to be sure to find also players
# that lack characters.
players = caller.search("*%s" % args)
if not players:
try:
players = PlayerDB.objects.filter(id=args)
except ValueError:
pass
players = caller.search_player(args, quiet=True)
if not players:
# try to find a user instead of a Player
@ -337,7 +330,6 @@ class CmdDelPlayer(MuxCommand):
player = players
user = player.user
character = player.character
if not player.access(caller, 'delete'):
string = "You don't have the permissions to delete that player."
@ -346,17 +338,14 @@ class CmdDelPlayer(MuxCommand):
uname = user.username
# boot the player then delete
if character and character.has_player:
self.msg("Booting and informing player ...")
string = "\nYour account '%s' is being *permanently* deleted.\n" % uname
if reason:
string += " Reason given:\n '%s'" % reason
character.msg(string)
# we have a bootable object with a connected player
sessions = SESSIONS.sessions_from_player(character.player)
for session in sessions:
session.msg(string)
session.disconnect()
self.msg("Informing and disconnecting player ...")
string = "\nYour account '%s' is being *permanently* deleted.\n" % uname
if reason:
string += " Reason given:\n '%s'" % reason
player.unpuppet_all()
for session in SESSIONS.sessions_from_player(player):
player.msg(string, sessid=session.sessid)
player.disconnect_session_from_player(session.sessid)
user.delete()
player.delete()
self.msg("Player %s was successfully deleted." % uname)
@ -466,7 +455,7 @@ class CmdNewPassword(MuxCommand):
return
# the player search also matches 'me' etc.
player = caller.search("*%s" % self.lhs, global_search=True, player=True)
player = caller.search_player(self.lhs)
if not player:
return
player.user.set_password(self.rhs)
@ -510,8 +499,10 @@ class CmdPerm(MuxCommand):
playermode = 'player' in self.switches or lhs.startswith('*')
# locate the object
obj = caller.search(lhs, global_search=True, player=playermode)
if playermode:
obj = caller.search_player(lhs)
else:
obj = caller.search(lhs, global_search=True)
if not obj:
return

View file

@ -499,9 +499,9 @@ class CmdDestroy(MuxCommand):
def delobj(objname, byref=False):
# helper function for deleting a single object
string = ""
obj = caller.search(objname, global_dbref=byref)
obj = caller.search(objname)
if not obj:
self.caller.msg(" (Objects to destroy must either be local or specified with a unique dbref.)")
self.caller.msg(" (Objects to destroy must either be local or specified with a unique #dbref.)")
return ""
if not "override" in self.switches and obj.dbid == int(settings.CHARACTER_DEFAULT_HOME.lstrip("#")):
return "\nYou are trying to delete CHARACTER_DEFAULT_HOME. If you want to do this, use the /override switch."
@ -1018,7 +1018,7 @@ class CmdOpen(ObjManipCommand):
# check if this exit object already exists at the location.
# we need to ignore errors (so no automatic feedback)since we
# have to know the result of the search to decide what to do.
exit_obj = caller.search(exit_name, location=location, ignore_errors=True)
exit_obj = caller.search(exit_name, location=location, quiet=True)
if len(exit_obj) > 1:
# give error message and return
caller.search(exit_name, location=location)
@ -1681,8 +1681,10 @@ class CmdExamine(ObjManipCommand):
self.player_mode = "player" in self.switches or obj_name.startswith('*')
obj = caller.search(obj_name, player=self.player_mode, global_dbref=True)
if self.player_mode:
obj = self.search_player(obj_name)
else:
obj = caller.search(obj_name)
if not obj:
continue

View file

@ -271,7 +271,7 @@ class CmdDrop(MuxCommand):
# Because the DROP command by definition looks for items
# in inventory, call the search function using location = caller
results = caller.search(self.args, location=caller, ignore_errors=True)
results = caller.search(self.args, location=caller, quiet=True)
# now we send it into the error handler (this will output consistent
# error messages if there are problems).

View file

@ -182,7 +182,6 @@ class CmdSetHelp(MuxCommand):
def func(self):
"Implement the function"
caller = self.caller
switches = self.switches
lhslist = self.lhslist

View file

@ -390,7 +390,7 @@ class CmdWho(MuxPlayerCommand):
plr_pobject = plr_pobject or session.get_player()
table.add_row([utils.crop(plr_pobject.name, width=25),
utils.time.format(delta_conn, 0),
utils,time_format(delta_cmd, 1)])
utils.time_format(delta_cmd, 1)])
string = "{wPlayers:{n\n%s\n%s unique accounts logged in." % (table, nplayers==1 and "One player" or nplayers)
self.msg(string)
@ -561,8 +561,6 @@ class CmdColorTest(MuxPlayerCommand):
def func(self):
"Show color tables"
player = self.caller
if self.args.startswith("a"):
# show ansi 16-color table
from src.utils import ansi

View file

@ -7,7 +7,6 @@ System commands
import traceback
import os, datetime, time
from time import time as timemeasure
from sys import getsizeof
import sys
import django, twisted