Пример #1
0
def handle_plugreload(bot, ievent):
    """ arguments: <list of plugnames> - reload list of plugins. """
    try: pluglist = ievent.args
    except (TypeError, IndexError): ievent.missing('<list of plugnames>') ; return
    ievent.untildone = True
    reloaded = []
    errors = []
    for plug in pluglist:
        if not plug: logging.error("empty plug name in %s" % str(pluglist)) ; continue
        modname = bot.plugs.getmodule(plug)
        if not modname: errors.append("can't find %s plugin" % plug) ; continue
        try:
            loaded = bot.plugs.reload(modname, force=True, showerror=True)
            for plug in loaded:
                if plug:
                    reloaded.append(plug)
                    logging.warn("%s reloaded" % plug) 
                else: logging.error("got no result for %s reload" % modname)
        except RequireError as ex: errors.append(str(ex)) ; continue
        except NoSuchPlugin: errors.append("can't find %s plugin" % plug) ; continue
        except ImportError as ex:
            if plug in str(ex):
                logging.warn('%s - %s' % (modname, str(ex)))
                continue
            errors.append(exceptionmsg())
    if False and opts.dosave:
        for modname in reloaded:
           if modname: update_mod(modname)
    if errors:
         logging.error("there were errors: %s" %  str(errors))
         ievent.reply('errors: ', errors)
    if reloaded: ievent.reply('reloaded: ', reloaded)
    ievent.done()
Пример #2
0
def silent_import(name):
    from tl.utils.exception import exceptionmsg
    try: return _import(name)
    except Exception as ex: logging.error(exceptionmsg())