Esempio n. 1
0
def plpaste(text, bot):
    """<command> - pastes the plugin file that contains <command>
    :type text: str
    :type bot: ralybot.bot.Ralybot
    """
    if text in bot.plugin_manager.commands:
        file_path = bot.plugin_manager.commands[text].plugin.file_path
        with open(file_path) as f:
            return web.paste(f.read(), ext='py')
    elif text + ".py" in listdir('plugins/'):
        with open('plugins/{}.py'.format(text)) as f:
            return web.paste(f.read(), ext='py')
    else:
        return "Could not find specified plugin."
Esempio n. 2
0
def get_thread_dump():
    code = []
    threads = [(get_name(thread_id), traceback.extract_stack(stack))
               for thread_id, stack in sys._current_frames().items()]
    for thread_name, stack in threads:
        code.append("# {}".format(thread_name))
        for filename, line_num, name, line in stack:
            code.append("{}:{} - {}".format(filename, line_num, name))
            if line:
                code.append("    {}".format(line.strip()))
        code.append("")  # new line
    return web.paste("\n".join(code), ext='txt')
Esempio n. 3
0
def python(text):
    """<python code> - executes <python code> using eval.appspot.com"""

    output = web.pyeval(text, pastebin=False)

    if '\n' in output:
        if 'Traceback (most recent call last):' in output:
            status = 'Error: '
        else:
            status = 'Success: '
        return status + web.paste(output)
    else:
        return output