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:
parent
740d715c72
commit
3fe644ef17
31 changed files with 1856 additions and 1856 deletions
|
|
@ -9,19 +9,19 @@ modules to be reloaded at @reload.
|
|||
# These are custom modules that have classes requiring state-saving.
|
||||
# These modules are reloaded before those in no_cache.
|
||||
cache = {
|
||||
# This should be a dict of lists of tuples
|
||||
# with the module name as a key, a list of tuples
|
||||
# with the class name as the first element of the
|
||||
# tuple, and True or False if this is a model
|
||||
# for the database, like so:
|
||||
#
|
||||
# 'modulename' : [ ('ModelA', True), ('ClassA', False) ],
|
||||
# 'anothermod' : [ ('ClassB', False), ('ClassC', False) ],
|
||||
}
|
||||
# This should be a dict of lists of tuples
|
||||
# with the module name as a key, a list of tuples
|
||||
# with the class name as the first element of the
|
||||
# tuple, and True or False if this is a model
|
||||
# for the database, like so:
|
||||
#
|
||||
# 'modulename' : [ ('ModelA', True), ('ClassA', False) ],
|
||||
# 'anothermod' : [ ('ClassB', False), ('ClassC', False) ],
|
||||
}
|
||||
|
||||
# This is a list of modules that need to be reloaded at @reload. There
|
||||
# is no state-saving, and these are reloaded after those cached above.
|
||||
no_cache = [
|
||||
# 'modulename',
|
||||
# 'anothermod',
|
||||
]
|
||||
# 'modulename',
|
||||
# 'anothermod',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
import functions_general
|
||||
|
||||
class ReloadManager(object):
|
||||
objects_cache = {}
|
||||
failed = []
|
||||
objects_cache = {}
|
||||
failed = []
|
||||
|
||||
models = {}
|
||||
models = {}
|
||||
|
||||
def __init__(self, server):
|
||||
self.server = server
|
||||
def __init__(self, server):
|
||||
self.server = server
|
||||
|
||||
def do_cache(self):
|
||||
for module, info in self.models.iteritems():
|
||||
module_obj = __import__(module)
|
||||
for ituple in info:
|
||||
mclass = getattr(module_obj, info[0])
|
||||
for instance in mclass.__instances__():
|
||||
instance.cache(self, do_save=ituple[1])
|
||||
def do_cache(self):
|
||||
for module, info in self.models.iteritems():
|
||||
module_obj = __import__(module)
|
||||
for ituple in info:
|
||||
mclass = getattr(module_obj, info[0])
|
||||
for instance in mclass.__instances__():
|
||||
instance.cache(self, do_save=ituple[1])
|
||||
|
||||
def do_reload(self):
|
||||
self.do_cache()
|
||||
self.server.reload()
|
||||
self.reload_objects()
|
||||
def do_reload(self):
|
||||
self.do_cache()
|
||||
self.server.reload()
|
||||
self.reload_objects()
|
||||
|
||||
def cache_object(self, obj):
|
||||
obj_dict = {}
|
||||
for key, value in obj.__dict__.iteritems():
|
||||
if not callable(obj[key]):
|
||||
obj_dict[key] = value
|
||||
def cache_object(self, obj):
|
||||
obj_dict = {}
|
||||
for key, value in obj.__dict__.iteritems():
|
||||
if not callable(obj[key]):
|
||||
obj_dict[key] = value
|
||||
|
||||
self.objects_cache[obj] = obj_dict
|
||||
self.objects_cache[obj] = obj_dict
|
||||
|
||||
def reload_objects(self):
|
||||
for obj, cache in self.objects_cache.iteritems():
|
||||
try:
|
||||
obj.reload(cache)
|
||||
except:
|
||||
functions_general.log_errmsg("Failed to reload cache for object: %s." % (obj,))
|
||||
self.failed.append(obj)
|
||||
raise
|
||||
def reload_objects(self):
|
||||
for obj, cache in self.objects_cache.iteritems():
|
||||
try:
|
||||
obj.reload(cache)
|
||||
except:
|
||||
functions_general.log_errmsg("Failed to reload cache for object: %s." % (obj,))
|
||||
self.failed.append(obj)
|
||||
raise
|
||||
|
||||
self.objects_cache = {}
|
||||
self.objects_cache = {}
|
||||
|
||||
for obj in self.failed:
|
||||
try:
|
||||
obj.__dict__.update(cache)
|
||||
except:
|
||||
functions_general.log_errmsg("Failed to update object %s, giving up." %s (obj,))
|
||||
raise
|
||||
for obj in self.failed:
|
||||
try:
|
||||
obj.__dict__.update(cache)
|
||||
except:
|
||||
functions_general.log_errmsg("Failed to update object %s, giving up." %s (obj,))
|
||||
raise
|
||||
|
||||
self.failed = []
|
||||
self.failed = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue