X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Fmisc.py;h=b83215c535fb8075c060ae67f7d91cfd602bc9a3;hp=62501d493a733c6623f8df69c9aca311d13c6535;hb=9e752a06cae971045047583823f3ca9a667c0d44;hpb=5576b96f9280d8b9598d4b4806a016854b6a1c65 diff --git a/mudpy/misc.py b/mudpy/misc.py index 62501d4..b83215c 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -457,10 +457,8 @@ class Universe: self.listening_socket.listen(1) # note that we're now ready for user connections - log( - "Listening for Telnet connections on: " + - host + ":" + str(port) - ) + log("Listening for Telnet connections on %s port %s" % ( + host, str(port))) def get_time(self): """Convenience method to get the elapsed time counter.""" @@ -1889,11 +1887,32 @@ def handler_active(user): command = find_command(command_name) # if it's allowed, do it + ran = False if actor.can_run(command): - exec(command.get("action")) - - # otherwise, give an error - elif command_name: + # dereference the relative object path for the requested function + action = mudpy + action_fname = command.get("action", command.key) + for component in action_fname.split("."): + try: + action = getattr(action, component) + ran = True + except AttributeError: + log('Could not find action function "%s" for command "%s"' + % (action_fname, command_name)) + action = None + break + if action: + try: + action(actor, parameters) + except Exception: + log('Command string "%s" from user %s raised an ' + 'exception...\n%s' % ( + input_data, actor.owner.account.get("name"), + traceback.format_exc())) + mudpy.command.error(actor, input_data) + + # if the command was not run, give an error + if not ran: mudpy.command.error(actor, input_data) # if no input, just idle back with a prompt @@ -2059,8 +2078,9 @@ def setup(): log("Import path: %s" % ", ".join(sys.path), 1) log("Installed dependencies: %s" % universe.versions.dependencies_text, 1) log("Other python packages: %s" % universe.versions.environment_text, 1) - log("Started %s with command line: %s" % ( - universe.versions.version, " ".join(sys.argv)), 1) + log("Running version: %s" % universe.versions.version, 1) + log("Initial directory: %s" % universe.startdir, 1) + log("Command line: %s" % " ".join(sys.argv), 1) # pass the initialized universe back return universe