summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
591964e)
APIVERSION is now 2. modules written for 2 are compatible with 1;
however modules written for 1 need to be updated (by adding softdeps
to modinfo).
softdeps are loaded before the current module is started, when possible.
however, if they are disabled (by setting them to 0 in config
"[autoloads]"), or non-existent, they will be ignored. Additionally, if
they are unloaded at runtime any modules with softdeps on them will
continue to be loaded and are expected to not raise any errors.
13 files changed:
print "%09.3f [MOD] [?] Loading %s..." % (time.time() % 100000, modname),
modstatus = _load(parent, modname, dependent)
if not modstatus:
print "%09.3f [MOD] [?] Loading %s..." % (time.time() % 100000, modname),
modstatus = _load(parent, modname, dependent)
if not modstatus:
+ if dependent:
+ print "failed: %s)" % (modstatus),
+ else:
+ print "failed: %s." % (modstatus)
elif modstatus == True:
if dependent:
print "OK)",
else:
print "OK."
else:
elif modstatus == True:
if dependent:
print "OK)",
else:
print "OK."
else:
+ if dependent:
+ print "OK: %s)" % (modstatus),
+ else:
+ print "OK: %s." % (modstatus)
return modstatus
def _load(parent, modname, dependent=False):
return modstatus
def _load(parent, modname, dependent=False):
if not isloaded(modname):
try:
mod = __import__('modules.'+modname, globals(), locals(), ['*'], -1)
if not isloaded(modname):
try:
mod = __import__('modules.'+modname, globals(), locals(), ['*'], -1)
dependents[modname] = []
for dep in mod.modinfo['depends']:
dependents[modname] = []
for dep in mod.modinfo['depends']:
- if dep not in modules:
- depret = load(parent, dep, dependent=True)
- if depret is not None and not depret:
- return depret #TODO FIXME
+ if bool(int(parent.cfg.get('autoloads', dep, default=1))):
+ if dep not in modules:
+ depret = load(parent, dep, dependent=True)
+ if depret is not None and not depret:
+ return depret
+ else:
+ return modlib.error("dependent %s disabled" % (dep))
dependents[dep].append(modname)
dependents[dep].append(modname)
+ for dep in mod.modinfo['softdeps']:
+ if bool(int(parent.cfg.get('autoloads', dep, default=1))):
+ if dep not in modules:
+ depret = load(parent, dep, dependent=True)
+ if depret is not None:
+ if not depret:
+ successstatus.append("softdep %s failed" % (dep))
+ else:
+ successstatus.append("softdep %s disabled" % (dep))
+ #swallow errors loading - softdeps are preferred, not required
+
ret = mod.modstart(parent)
ret = mod.modstart(parent)
- if ret is not None and not ret:
+ if ret is None:
+ ret = True
+ if not ret:
del modules[modname]
del dependents[modname]
for dep in mod.modinfo['depends']:
dependents[dep].remove(modname)
del modules[modname]
del dependents[modname]
for dep in mod.modinfo['depends']:
dependents[dep].remove(modname)
+
+ successstatus = ';'.join(successstatus)
+ if len(successstatus) > 0 and ret:
+ if ret == True:
+ return successstatus
+ else:
+ return "%s (%s)" % (ret, successstatus)
+ else:
+ return ret
else: #if not isloaded...else:
return modlib.error('already loaded')
else: #if not isloaded...else:
return modlib.error('already loaded')
import bot, config, ctlmod
class Erebus(object): #singleton to pass around
import bot, config, ctlmod
class Erebus(object): #singleton to pass around
self.name = (name.split("."))[-1]
def modstart(self, parent):
self.name = (name.split("."))[-1]
def modstart(self, parent):
+ #modstart can return a few things...
+ # None: unspecified success
+ # False: unspecified error
+ # modlib.error (or anything else False-y): specified error
+ # True: unspecified success
+ # non-empty string (or anything else True-y): specified success
+ #"specified" values will be printed. unspecified values will result in "OK" or "failed"
self.parent = parent
for cmd, func in self.hooks.iteritems():
self.parent.hook(cmd, func)
self.parent = parent
for cmd, func in self.hooks.iteritems():
self.parent.hook(cmd, func)
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': [],
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
+ 'compatible': [1,2], # compatible module API versions
'depends': [], # other modules required to work properly?
'depends': [], # other modules required to work properly?
+ 'softdeps': ['help'], # modules which are preferred but not required
+# note: softdeps will be loaded before this module, IF not disabled in the configuration (autoload.module = 0) (and if it exists)
+# however, if it is disabled it will be silently ignored, and if it is unloaded at runtime it won't cause this one to unload.
+#
+# basically, softdeps are things this module will use if available, but does not require (no errors will occur if it's not loaded)
+# for example, @lib.help() will attempt to use the help module, but swallow errors if it is not loaded
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': [],
# Erebus IRC bot - Author: Erebus Team
# Erebus IRC bot - Author: Erebus Team
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': ['help'],
# Erebus IRC bot - Author: Erebus Team
# Erebus IRC bot - Author: Erebus Team
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': ['help'],
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': ['userinfo'], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': ['userinfo'],
+ 'softdeps': ['help'],
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': [],
}
# http://embed.ly/tools/generator
}
# http://embed.ly/tools/generator
# Erebus IRC bot - Author: Erebus Team
# Erebus IRC bot - Author: Erebus Team
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': ['help'],