projects
/
mudpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Switch password handler to passlib's PBKDF2
[mudpy.git]
/
lib
/
mudpy
/
misc.py
diff --git
a/lib/mudpy/misc.py
b/lib/mudpy/misc.py
index
2bec9bf
..
0843586
100644
(file)
--- a/
lib/mudpy/misc.py
+++ b/
lib/mudpy/misc.py
@@
-1,7
+1,6
@@
-# -*- coding: utf-8 -*-
"""Miscellaneous functions for the mudpy engine."""
"""Miscellaneous functions for the mudpy engine."""
-# Copyright (c) 2004-201
4
Jeremy Stanley <fungi@yuggoth.org>. Permission
+# Copyright (c) 2004-201
5
Jeremy Stanley <fungi@yuggoth.org>. Permission
# to use, copy, modify, and distribute this software is granted under
# terms provided in the LICENSE file distributed with this software.
# to use, copy, modify, and distribute this software is granted under
# terms provided in the LICENSE file distributed with this software.
@@
-384,11
+383,15
@@
class Universe:
filename = os.path.join(self.startdir, filename)
self.filename = filename
if load:
filename = os.path.join(self.startdir, filename)
self.filename = filename
if load:
- self.load()
+ # make sure to preserve any accumulated log entries during load
+ self.setup_loglines += self.load()
def load(self):
"""Load universe data from persistent storage."""
def load(self):
"""Load universe data from persistent storage."""
+ # it's possible for this to enter before logging configuration is read
+ pending_loglines = []
+
# the files dict must exist and filename needs to be read-only
if not hasattr(
self, "files"
# the files dict must exist and filename needs to be read-only
if not hasattr(
self, "files"
@@
-410,9
+413,13
@@
class Universe:
# make a list of inactive avatars
inactive_avatars = []
for account in self.categories["account"].values():
# make a list of inactive avatars
inactive_avatars = []
for account in self.categories["account"].values():
- inactive_avatars += [
- (self.contents[x]) for x in account.getlist("avatars")
- ]
+ for avatar in account.get("avatars"):
+ try:
+ inactive_avatars.append(self.contents[avatar])
+ except KeyError:
+ pending_loglines.append((
+ "Missing avatar \"%s\", possible data corruption" %
+ avatar, 6))
for user in self.userlist:
if user.avatar in inactive_avatars:
inactive_avatars.remove(user.avatar)
for user in self.userlist:
if user.avatar in inactive_avatars:
inactive_avatars.remove(user.avatar)
@@
-432,6
+439,7
@@
class Universe:
for element in self.contents.values():
element.update_location()
element.clean_contents()
for element in self.contents.values():
element.update_location()
element.clean_contents()
+ return pending_loglines
def new(self):
"""Create a new, empty Universe (the Big Bang)."""
def new(self):
"""Create a new, empty Universe (the Big Bang)."""
@@
-968,11
+976,14
@@
class User:
def list_avatar_names(self):
"""List names of assigned avatars."""
def list_avatar_names(self):
"""List names of assigned avatars."""
- return [
- universe.contents[avatar].get(
- "name"
- ) for avatar in self.account.getlist("avatars")
- ]
+ avatars = []
+ for avatar in self.account.get("avatars"):
+ try:
+ avatars.append(universe.contents[avatar].get("name"))
+ except KeyError:
+ log("Missing avatar \"%s\", possible data corruption." %
+ avatar, 6)
+ return avatars
def broadcast(message, add_prompt=True):
def broadcast(message, add_prompt=True):
@@
-2456,6
+2467,11
@@
def setup():
global universe
universe = Universe(conffile, True)
global universe
universe = Universe(conffile, True)
+ # report any loglines which accumulated during setup
+ for logline in universe.setup_loglines:
+ log(*logline)
+ universe.setup_loglines = []
+
# log an initial message
log("Started mudpy with command line: " + " ".join(sys.argv))
# log an initial message
log("Started mudpy with command line: " + " ".join(sys.argv))