示例#1
0
def handle_plugupgrade(bot, ievent):
    alreadygot = []
    upgraded = []
    plugs = []
    if ievent.rest:
        plugs.extend(ievent.rest.split())
    else:
        for name, plug in plugins.plugs.iteritems():
            if hasattr(plug, 'upgrade'):
                plugs.append(name)    
    ievent.reply('starting plugin upgrade for plugins: ', plugs, dot=True)
    errors = []
    for plug in plugs:
        try:
            s = plugins.plugs[plug].size()
        except AttributeError:
            s = 0
        if s and not '-f' in ievent.optionset:
            alreadygot.append(plug)
            continue
        try:
            plugins.plugs[plug].upgrade()
            plugins.reload('gozerplugs', plug)
            ievent.reply('upgraded %s' % plug)
            upgraded.append(plug)
        except AttributeError:
            continue
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
示例#2
0
def handle_plugenable(bot, ievent):
    doall = False
    if '-a' in ievent.optionset:
        doall = True
    if not ievent.rest and not doall:
        ievent.missing('<plugname>')
        return
    try:
        plugs = gozer_import('gozerplugs').__plugs__
    except ImportError:
        ievent.reply("no gozerplugs package detected")
        return
    if not doall:
        plugs = ievent.rest.split()
    ievent.reply("trying to reload: ", plugs, dot=True)
    errors = []
    reloaded = []
    failed = []
    for plug in plugs:
        try:
            reloaded.extend(plugins.reload('gozerplugs', plug))
        except ImportError, ex:
            errors.append(str(ex))
            failed.append(plug)
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
            failed.append(plug)
示例#3
0
def handle_plugupgrade(bot, ievent):
    alreadygot = []
    upgraded = []
    plugs = []
    if ievent.rest:
        plugs.extend(ievent.rest.split())
    else:
        for name, plug in plugins.plugs.iteritems():
            if hasattr(plug, 'upgrade'):
                plugs.append(name)
    ievent.reply('starting plugin upgrade for plugins: ', plugs, dot=True)
    errors = []
    for plug in plugs:
        try:
            s = plugins.plugs[plug].size()
        except AttributeError:
            s = 0
        if s and not '-f' in ievent.optionset:
            alreadygot.append(plug)
            continue
        try:
            plugins.plugs[plug].upgrade()
            plugins.reload('gozerplugs', plug)
            ievent.reply('upgraded %s' % plug)
            upgraded.append(plug)
        except AttributeError:
            continue
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
示例#4
0
def handle_plugenable(bot, ievent):
    doall = False
    if '-a' in ievent.optionset:
        doall = True
    if not ievent.rest and not doall:
        ievent.missing('<plugname>')
        return
    try:
        plugs = gozer_import('gozerplugs').__plugs__
    except ImportError:
        ievent.reply("no gozerplugs package detected")
        return
    if not doall:
        plugs = ievent.rest.split()
    ievent.reply("trying to reload: ", plugs, dot=True)
    errors = []
    reloaded = []
    failed = []
    for plug in plugs:
        try:
            reloaded.extend(plugins.reload('gozerplugs', plug))
        except ImportError, ex:
            errors.append(str(ex))
            failed.append(plug)
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
            failed.append(plug)
示例#5
0
def handle_testsrun(bot, ievent):
    if not ievent.isdcc:
        ievent.reply('use this command in a /dcc chat with the bot')
        return
    errors = []
    toolate = []
    err = {}
    try:
        loop = ievent.options['--loop']
        loop = int(loop)
    except (KeyError, ValueError):
        loop = 1
    teller = 0
    for nr in range(loop):
        for i in range(len(tests.tests)):
            test = tests.tests[i]
            if ievent.rest and ievent.rest not in test.plugin:
                continue
            if test.expect:
                teller += 1
            try:
                starttime = time.time()
                result = test.run(bot, ievent)
                finished = time.time()
                if finished - starttime > 5:
                    toolate.append(test.execstring)
                if not result:
                    continue
                if not result.error:
                    ievent.reply("OK %s ==> %s" %
                                 (test.execstring, test.response))
                else:
                    errors.append(test)
                    ievent.reply('ERROR %s (%s): %s ==> %s (%s)' %
                                 (test.error, test.where, test.execstring,
                                  test.response, test.expect))
            except Exception, ex:
                errors.append(test)
                test.error = exceptionmsg()
                err[test.execstring] = test.error
                ievent.reply(test.error)
        ievent.reply('%s tests run .. %s errors' % (teller, len(errors)))
示例#6
0
def handle_testsrun(bot, ievent):
    if not ievent.isdcc:
        ievent.reply('use this command in a /dcc chat with the bot')
        return
    errors = []
    toolate = []
    err = {}
    try:
        loop = ievent.options['--loop']
        loop = int(loop)
    except (KeyError, ValueError):
        loop = 1
    teller = 0
    for nr in range(loop):
        for i in range(len(tests.tests)):
            test = tests.tests[i]
            if ievent.rest and ievent.rest not in test.plugin:
                continue
            if test.expect:
                teller += 1
            try:
                starttime = time.time()
                result = test.run(bot, ievent)
                finished = time.time()
                if finished - starttime > 5:
                    toolate.append(test.execstring)
                if not result:
                    continue
                if not result.error:
                    ievent.reply("OK %s ==> %s" % (test.execstring, test.response))
                else:
                    errors.append(test)
                    ievent.reply('ERROR %s (%s): %s ==> %s (%s)' % (test.error, test.where, test.execstring, test.response, test.expect))
            except Exception, ex:
                errors.append(test)
                test.error = exceptionmsg()
                err[test.execstring] = test.error
                ievent.reply(test.error)
        ievent.reply('%s tests run .. %s errors' % (teller, len(errors)))