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

# AKA resonator local curriculum resolver/worker

import beanstalkc
from pattern.web import URL, plaintext, URLError, MIMETYPE_WEBPAGE, MIMETYPE_PLAINTEXT, HTTPError
from urlparse import urlparse as parse
import sys


beanstalk = beanstalkc.Connection(host='localhost', port=14711)
while beanstalk.peek_ready():
    job = beanstalk.reserve()
    output = open('test_output_redis.txt','w')
    # print url
    url = URL(job.body)
    try:
        # s = url.download(timeout=2500)
        s = url.download()
        # the_type = url.mimetype
        print the_type
        if (url.mimetype in MIMETYPE_WEBPAGE) or (url.mimetype in MIMETYPE_PLAINTEXT):
            s = plaintext(s)
            output.write(s.encode('ascii','ignore'))
            print s
            c = c+1
            print c
        else:
            'we failed the mimetype test again wtf'
    # except URLError, e:
    except HTTPError:
        e = sys.exc_info()[0]
        # print 'URLError on ', url
        print e
    output.close()
    job.delete()
<commit_msg>mimetype validation is failing<commit_after>#!/usr/bin/env python

# AKA resonator local curriculum resolver/worker

import beanstalkc
from pattern.web import URL, plaintext, URLError, MIMETYPE_WEBPAGE, MIMETYPE_PLAINTEXT, HTTPError
from urlparse import urlparse as parse
import sys


beanstalk = beanstalkc.Connection(host='localhost', port=14711)
while beanstalk.peek_ready():
    job = beanstalk.reserve()
    output = open('test_output_redis.txt','w')
    # print url
    url = URL(job.body)
    try:
        # s = url.download(timeout=2500)
        s = url.download()
        # the_type = url.mimetype
        print the_type
        if (url.mimetype in MIMETYPE_WEBPAGE) or (url.mimetype in MIMETYPE_PLAINTEXT):
            s = plaintext(s)
            output.write(s.encode('ascii','ignore'))
            print s
            c = c+1
            print c
        else:
            'we failed the mimetype test again wtf'
    # except URLError, e:
    except HTTPError, e:
        # e = sys.exc_info()[0]
        # print 'URLError on ', url
        print e
    output.close()
    job.delete()

{'fraction_non_alphanumeric': 0.09953917050691244, 'fraction_numerical': 0.010138248847926268, 'mean_word_length': 2.4791666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4907188', 'n_tokens_mistral': 735, 'n_tokens_neox': 702, 'n_words': 180}