<commit_before>#!/usr/bin/env python3

import os
import irc.client
import itertools
import playpen
import requests
import shorten_key
import subprocess
import sys
import threading
import yaml
from urllib.parse import urlencode

irc_template = """\
#![feature(asm, globs, macro_rules, phase, simd, struct_variant, quad_precision_float)]

extern crate collections;
extern crate native;
extern crate rand;
#[phase(syntax)]
extern crate regex_macros;
extern crate regex;

#[allow(dead_code)]
static version: &'static str = "%(version)s";

#[allow(dead_code)]
fn show<T: std::fmt::Show>(e: T) { println!("{}", e) }

fn main() {
    let r = {
        %(input)s
    };
    println!("{}", r)
}"""

def pastebin(command):
    bitly = "https://api-ssl.bitly.com/v3/shorten"
    server = "http://play.rust-lang.org/?"

    params = urlencode({"code": command, "run": 1})
    url = server + params
    r = requests.get(bitly,
                     params={"access_token": shorten_key.key, "longUrl": url})
    response = r.json()

    if response["status_txt"] == "OK":
        return response["data"]["url"]
    else:
        return "failed to shorten url"

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:<commit_msg>irc: pastebin any output longer than 3 lines<commit_after>#!/usr/bin/env python3

import os
import irc.client
import itertools
import playpen
import requests
import shorten_key
import subprocess
import sys
import threading
import yaml
from urllib.parse import urlencode

irc_template = """\
#![feature(asm, globs, macro_rules, phase, simd, struct_variant, quad_precision_float)]

extern crate collections;
extern crate native;
extern crate rand;
#[phase(syntax)]
extern crate regex_macros;
extern crate regex;

#[allow(dead_code)]
static version: &'static str = "%(version)s";

#[allow(dead_code)]
fn show<T: std::fmt::Show>(e: T) { println!("{}", e) }

fn main() {
    let r = {
        %(input)s
    };
    println!("{}", r)
}"""

def pastebin(command):
    bitly = "https://api-ssl.bitly.com/v3/shorten"
    server = "http://play.rust-lang.org/?"

    params = urlencode({"code": command, "run": 1})
    url = server + params
    r = requests.get(bitly,
                     params={"access_token": shorten_key.key, "longUrl": url})
    response = r.json()

    if response["status_txt"] == "OK":
        return response["data"]["url"]
    else:
        return "failed to shorten url"

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:
{'fraction_non_alphanumeric': 0.15445607358071678, 'fraction_numerical': 0.009197589597209007, 'mean_word_length': 2.9228855721393034, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4746867', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1013, 'n_words': 286}