Ejemplo n.º 1
0
def evaluate(code, nickname):
    if nickname == "rusti" or nickname == "playbot":
        version, _ = playpen.execute(
            "stable", "/bin/dash",
            ("-c", "--", "rustc -V | head -1 | tr -d '\n'"))
        code = irc_template % {"version": version.decode(), "input": code}

    out, _ = playpen.execute("stable", "/usr/local/bin/evaluate.sh", (
        "-C",
        "opt-level=2",
    ), code)

    if len(out) > 5000:
        return "more than 5000 bytes of output; bailing out"

    out = out.replace(b"\xff", b"", 1).decode(errors="replace")
    lines = out.splitlines()

    for line in lines:
        if len(line) > 150:
            return pastebin(code)

    limit = 3
    if len(lines) > limit:
        return "\n".join(lines[:limit - 1] + [pastebin(code)])

    return out
Ejemplo n.º 2
0
def evaluate(script, arguments, template):
    version, _ = playpen.execute("master", "/bin/dash", ("-c", "--", "rustc -v | tail | head -1 | tr -d '\n'"))
    out, _ = playpen.execute("master", script, arguments)
    n = 0

    if len(out) > 5000:
        return "more than 5000 bytes of output, bailing out"

    if out.count("\n") > 3:
        return pastebin(template % {"version": version, "input": arguments[-1]})

    for line in out.splitlines():
        if len(line) > 150:
            return pastebin(template % {"version": version, "input": arguments[-1]})

    return out
Ejemplo n.º 3
0
def execute(version, command, arguments, code, show_backtrace):
    if show_backtrace:
        escapedargs = ""
        for arg in arguments:
            escapedargs += " " + shlex.quote(arg)
        arguments = ("-c", "export RUST_BACKTRACE=1; " + command + escapedargs)
        command = "/usr/bin/dash"
    print("running:", version, command, arguments, file=sys.stderr, flush=True)
    return playpen.execute(version, command, arguments, code)
Ejemplo n.º 4
0
def execute(version, command, arguments, code, show_backtrace):
    if show_backtrace:
        escapedargs=""
        for arg in arguments:
            escapedargs += " " + shlex.quote(arg)
        arguments = ("-c", "export RUST_BACKTRACE=1; " + command + escapedargs) 
        command = "/usr/bin/dash"
    print("running:", version, command, arguments, file=sys.stderr, flush=True)
    return playpen.execute(version, command, arguments, code)
Ejemplo n.º 5
0
def evaluate(code, nickname):
    if nickname == "rusti":
        version, _ = playpen.execute("master", "/bin/dash",
                                     ("-c", "--", "rustc -v | tail | head -1 | tr -d '\n'"))
        code = irc_template % {"version": version.decode(), "input": code}

    out, _ = playpen.execute("master", "/usr/local/bin/evaluate.sh", ("2",), code)

    if len(out) > 5000:
        return "more than 5000 bytes of output, bailing out"

    if out.count(b"\n") > 3:
        return pastebin(code)

    for line in out.splitlines():
        if len(line) > 150:
            return pastebin(code)

    return out.replace(b"\xff", b"", 1).decode(errors="replace")
Ejemplo n.º 6
0
def evaluate(code, nickname):
    if nickname == "rusti":
        version, _ = playpen.execute("master", "/bin/dash",
                                     ("-c", "--", "rustc -v | tail | head -1 | tr -d '\n'"))
        arguments = ("2", irc_template % {"version": version.decode(), "input": code},)
    else:
        arguments = ("2", code)

    out, _ = playpen.execute("master", "/usr/local/bin/evaluate.sh", arguments)

    if len(out) > 5000:
        return "more than 5000 bytes of output, bailing out"

    if out.count(b"\n") > 3:
        return pastebin(arguments[-1])

    for line in out.splitlines():
        if len(line) > 150:
            return pastebin(arguments[-1])

    return out.replace(b"\xff", b"", 1).decode(errors="replace")
Ejemplo n.º 7
0
def evaluate(code, nickname):
    if nickname == "rusti" or nickname == "playbot":
        version, _ = playpen.execute("stable", "/bin/dash",
                                     ("-c", "--", "rustc -V | head -1 | tr -d '\n'"))
        code = irc_template % {"version": version.decode(), "input": code}

    out, _ = playpen.execute("stable", "/usr/local/bin/evaluate.sh", ("2",), code)

    if len(out) > 5000:
        return "more than 5000 bytes of output; bailing out"

    out = out.replace(b"\xff", b"", 1).decode(errors="replace")
    lines = out.splitlines()

    for line in lines:
        if len(line) > 150:
            return pastebin(code)

    limit = 3
    if len(lines) > limit:
        return "\n".join(lines[:limit - 1] + [pastebin(code)])

    return out
Ejemplo n.º 8
0
def evaluate(script, arguments, template):
    version, _ = playpen.execute(
        "master", "/bin/dash",
        ("-c", "--", "rustc -v | tail | head -1 | tr -d '\n'"))
    out, _ = playpen.execute("master", script, arguments)
    n = 0

    if len(out) > 5000:
        return "more than 5000 bytes of output, bailing out"

    if out.count("\n") > 5:
        return pastebin(template % {
            "version": version,
            "input": arguments[-1]
        })

    for line in out.splitlines():
        if len(line) > 150:
            return pastebin(template % {
                "version": version,
                "input": arguments[-1]
            })

    return out
Ejemplo n.º 9
0
def execute(version, command, arguments, code):
    print("running:", version, command, arguments, file=sys.stderr, flush=True)
    return playpen.execute(version, command, arguments, code)
Ejemplo n.º 10
0
def execute(version, command, arguments, code):
    print("running:", version, command, arguments, file=sys.stderr, flush=True)
    return playpen.execute(version, command, arguments, code)