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

import sys
from os import path
sys.path.append(path.normpath(path.join(path.dirname(__file__), '..', '..')))
from lib.database.backend_db import Db
import csv
import json
import requests
import datetime

_TIMEFRAME = 12 # Hours
_PAST_TIMEFRAME = 3 # Weeks



def main():
    input_db = Db('input')
    
    old_data_sql = """
        SELECT description
        FROM remote_feedback_response fr
        WHERE
        created > DATE_SUB(NOW(), INTERVAL :old WEEK) AND
        created < DATE_SUB(NOW(), INTERVAL :new HOUR)
        AND product LIKE 'firefox'
        AND locale = 'en-US'
        AND happy = 0
        AND (campaign IS NULL or campaign = '')
        AND (source IS NULL or source = '')
        AND (version NOT RLIKE '[^a.0-9]')
        AND (platform LIKE 'Windows%' OR platform LIKE 'OS X' OR platform LIKE 'OS X')
    """
    
    results = input_db.execute_sql(old_data_sql, old=_PAST_TIMEFRAME, new=_TIMEFRAME )

    for row in results:
        # Process stuff here
        print row
        
        
    new_data_sql = """
        SELECT description
        FROM remote_feedback_response fr
        WHERE
        created > DATE_SUB(NOW(), INTERVAL :new HOUR) AND
        created < NOW()
        AND product LIKE 'firefox'
        AND locale = 'en-US'
        AND happy = 0
        AND (campaign IS NULL or campaign = '')
        AND (source IS NULL or source = '')
        AND (version NOT RLIKE '[^a.0-9]')
        AND (platform LIKE 'Windows%' OR platform LIKE 'OS X' OR platform LIKE 'OS X')
    """
    
    results = input_db.execute_sql(new_data_sql, new=_TIMEFRAME)

    for row in results:
        # Process stuff here
        print row
        

if __name__ == '__main__':
    main()
<commit_msg>Testing out email stuff on server.<commit_after>#!/usr/local/bin/python

import sys
from os import path
sys.path.append(path.normpath(path.join(path.dirname(__file__), '..', '..')))
from lib.database.backend_db import Db
import csv
import json
import requests
import datetime
from email.mime.text import MIMEText
from subprocess import Popen, PIPE

_TIMEFRAME = 12 # Hours
_PAST_TIMEFRAME = 3 # Weeks



def main():
    input_db = Db('input')
    
    old_data_sql = """
        SELECT description
        FROM remote_feedback_response fr
        WHERE
        created > DATE_SUB(NOW(), INTERVAL :old WEEK) AND
        created < DATE_SUB(NOW(), INTERVAL :new HOUR)
        AND product LIKE 'firefox'
        AND locale = 'en-US'
        AND happy = 0
        AND (campaign IS NULL or campaign = '')
        AND (source IS NULL or source = '')
        AND (version NOT RLIKE '[^a.0-9]')
        AND (platform LIKE 'Windows%' OR platform LIKE 'OS X' OR platform LIKE 'OS X')
    """
    
    results = input_db.execute_sql(old_data_sql, old=_PAST_TIMEFRAME, new=_TIMEFRAME )

    for row in results:
        # Process stuff here
        # print row
        
        
    new_data_sql = """
        SELECT description
        FROM remote_feedback_response fr
        WHERE
        created > DATE_SUB(NOW(), INTERVAL :new HOUR) AND
        created < NOW()
        AND product LIKE 'firefox'
        AND locale = 'en-US'
        AND happy = 0
        AND (campaign IS NULL or campaign = '')
        AND (source IS NULL or source = '')
        AND (version NOT RLIKE '[^a.0-9]')
        AND (platform LIKE 'Windows%' OR platform LIKE 'OS X' OR platform LIKE 'OS X')
    """
    
    results = input_db.execute_sql(new_data_sql, new=_TIMEFRAME)

    for row in results:
        # Process stuff here
        # print row


    msg = MIMEText("Here is the body of my message")
    msg["From"] = "<EMAIL>"
    msg["To"] = "<EMAIL>"
    msg["Subject"] = "This is the subject."
    p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
    p.communicate(msg.as_string())
    

if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.10878552971576227, 'fraction_numerical': 0.004651162790697674, 'mean_word_length': 2.3085470085470083, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '235364', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1178, 'n_words': 385}