<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json
import time
import urllib

from app.config import DRINKS
from app.celery import celery


def process_comment(comment):
    for drink in DRINKS:
        if '#' + drink[0].lower() in comment['message']:
            raise ValueError(drink)
    return comment


@celery.task
def PollPartyTask(user, since=0):
    #access_token = self.current_user.token XXX
    access_token = '<KEY>'
    #party_id = self.current_user.party_id XXX
    party_id = '417578625021950'
    resp = json.load(
            urllib.urlopen(
                'https://graph.facebok.com/' + party_id + '/feed?' +
                urllib.urlencode(dict(fields='comments,message',
                                      date_format='U',
                                      since=since,
                                      access_token=access_token))))
    posts = [p for p in resp['data']]
    comments = [p for p in posts if 'message' in p]

    [process_comment(c) for c in comments]

    # Reschedule next execution
    time.sleep(5)
    PollPartyTask.delay(user, posts[0]['created_time'] if posts else since)<commit_msg>Stay away from hurricanes for a while.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json
import time
import urllib

from app.config import DRINKS
from app.celery import celery


def process_comment(comment):
    for drink in DRINKS:
        if drink[0].lower() in comment['message']:
            raise ValueError(drink)
    return comment


@celery.task
def PollPartyTask(user, since=0):
    #access_token = self.current_user.token XXX
    access_token = '<KEY>'
    #party_id = self.current_user.party_id XXX
    party_id = '417578625021950'
    resp = json.load(
            urllib.urlopen(
                'https://graph.facebok.com/' + party_id + '/feed?' +
                urllib.urlencode(dict(fields='comments,message',
                                      date_format='U',
                                      since=since,
                                      access_token=access_token))))
    posts = [p for p in resp['data']]
    comments = [p for p in posts if 'message' in p]

    [process_comment(c) for c in comments]

    # Reschedule next execution
    time.sleep(5)
    PollPartyTask.delay(user, posts[0]['created_time'] if posts else since)
{'fraction_non_alphanumeric': 0.11035364294844482, 'fraction_numerical': 0.017043033659991477, 'mean_word_length': 2.172972972972973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1295282', 'n_tokens_mistral': 739, 'n_tokens_neox': 695, 'n_words': 179}