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
|
|
@ -15,54 +15,54 @@ interaction with actual script methods should happen via calls to Objects.
|
|||
cached_scripts = {}
|
||||
|
||||
def scriptlink(source_obj, scriptname):
|
||||
"""
|
||||
Each Object will refer to this function when trying to execute a function
|
||||
contained within a scripted module. For the sake of ease of management,
|
||||
modules are cached and compiled as they are requested and stored in
|
||||
the cached_scripts dictionary.
|
||||
|
||||
Returns a reference to an instance of the script's class as per it's
|
||||
class_factory() method.
|
||||
|
||||
source_obj: (Object) A reference to the object being scripted.
|
||||
scriptname: (str) Name of the module to load (minus 'scripts').
|
||||
"""
|
||||
# The module is already cached, just return it rather than re-load.
|
||||
retval = cached_scripts.get(scriptname, False)
|
||||
if retval:
|
||||
return retval.class_factory(source_obj)
|
||||
"""
|
||||
Each Object will refer to this function when trying to execute a function
|
||||
contained within a scripted module. For the sake of ease of management,
|
||||
modules are cached and compiled as they are requested and stored in
|
||||
the cached_scripts dictionary.
|
||||
|
||||
Returns a reference to an instance of the script's class as per it's
|
||||
class_factory() method.
|
||||
|
||||
source_obj: (Object) A reference to the object being scripted.
|
||||
scriptname: (str) Name of the module to load (minus 'scripts').
|
||||
"""
|
||||
# The module is already cached, just return it rather than re-load.
|
||||
retval = cached_scripts.get(scriptname, False)
|
||||
if retval:
|
||||
return retval.class_factory(source_obj)
|
||||
|
||||
##
|
||||
## NOTE: Only go past here when the script isn't already cached.
|
||||
##
|
||||
|
||||
# Split the script name up by periods to give us the directory we need
|
||||
# to change to. I really wish we didn't have to do this, but there's some
|
||||
# strange issue with __import__ and more than two directories worth of
|
||||
# nesting.
|
||||
path_split = scriptname.split('.')
|
||||
newpath_str = '/'.join(path_split[:-1])
|
||||
# Lop the module name off the end.
|
||||
modname = path_split[-1]
|
||||
##
|
||||
## NOTE: Only go past here when the script isn't already cached.
|
||||
##
|
||||
|
||||
# Split the script name up by periods to give us the directory we need
|
||||
# to change to. I really wish we didn't have to do this, but there's some
|
||||
# strange issue with __import__ and more than two directories worth of
|
||||
# nesting.
|
||||
path_split = scriptname.split('.')
|
||||
newpath_str = '/'.join(path_split[:-1])
|
||||
# Lop the module name off the end.
|
||||
modname = path_split[-1]
|
||||
|
||||
try:
|
||||
# Change the working directory to the location of the script and import.
|
||||
os.chdir('%s/%s/' % (settings.SCRIPT_ROOT, newpath_str))
|
||||
functions_general.log_infomsg("SCRIPT: Caching and importing %s." % (modname))
|
||||
modreference = __import__(modname)
|
||||
# Store the module reference for later fast retrieval.
|
||||
cached_scripts[scriptname] = modreference
|
||||
except ImportError:
|
||||
functions_general.log_infomsg('Error importing %s: %s' % (modname, format_exc()))
|
||||
os.chdir(settings.BASE_PATH)
|
||||
return
|
||||
except OSError:
|
||||
functions_general.log_infomsg('Invalid module path: %s' % (format_exc()))
|
||||
os.chdir(settings.BASE_PATH)
|
||||
return
|
||||
try:
|
||||
# Change the working directory to the location of the script and import.
|
||||
os.chdir('%s/%s/' % (settings.SCRIPT_ROOT, newpath_str))
|
||||
functions_general.log_infomsg("SCRIPT: Caching and importing %s." % (modname))
|
||||
modreference = __import__(modname)
|
||||
# Store the module reference for later fast retrieval.
|
||||
cached_scripts[scriptname] = modreference
|
||||
except ImportError:
|
||||
functions_general.log_infomsg('Error importing %s: %s' % (modname, format_exc()))
|
||||
os.chdir(settings.BASE_PATH)
|
||||
return
|
||||
except OSError:
|
||||
functions_general.log_infomsg('Invalid module path: %s' % (format_exc()))
|
||||
os.chdir(settings.BASE_PATH)
|
||||
return
|
||||
|
||||
# Change back to the original working directory.
|
||||
os.chdir(settings.BASE_PATH)
|
||||
# Change back to the original working directory.
|
||||
os.chdir(settings.BASE_PATH)
|
||||
|
||||
# The new script module has been cached, return the reference.
|
||||
return modreference.class_factory(source_obj)
|
||||
# The new script module has been cached, return the reference.
|
||||
return modreference.class_factory(source_obj)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue