<commit_before>from time import time, sleep
import logging

from pylons import config
import amqplib.client_0_8 as amqp

log = logging.getLogger(__name__)
post_channel = None

def has_queue():
    return config.get('adhocracy.amqp.host') \
           is not None

def queue_name():
    return config.get('adhocracy.amqp.queue', 
                      'adhocracy.queue')

def exchange_name():
    return config.get('adhocracy.amqp.exchange', 
                      'adhocracy.exchange')

def create_connection():
    host = config.get('adhocracy.amqp.host')
    return amqp.Connection(host=host)
                           
def create_channel(read=False, write=False):
    conn = create_connection()
    channel = conn.channel()
    channel.access_request('/data', active=True, write=write, read=read)
    channel.exchange_declare(exchange_name(), 'direct', 
                             durable=True,
                             auto_delete=False)
    _, _, _ = channel.queue_declare(queue=queue_name(), 
                                    durable=True,
                                    exclusive=False, 
                                    auto_delete=False)<commit_msg>new config option adhocracy.amqp.port, #231<commit_after>from time import time, sleep
import logging

from pylons import config
import amqplib.client_0_8 as amqp

log = logging.getLogger(__name__)
post_channel = None

def has_queue():
    return config.get('adhocracy.amqp.host') \
           is not None

def queue_name():
    return config.get('adhocracy.amqp.queue', 
                      'adhocracy.queue')

def exchange_name():
    return config.get('adhocracy.amqp.exchange', 
                      'adhocracy.exchange')

def create_connection():
    host = config.get('adhocracy.amqp.host')
    port = config.get('adhocracy.amqp.port', '5672')
    return amqp.Connection(host="%s:%s" % (host,port))
                           
def create_channel(read=False, write=False):
    conn = create_connection()
    channel = conn.channel()
    channel.access_request('/data', active=True, write=write, read=read)
    channel.exchange_declare(exchange_name(), 'direct', 
                             durable=True,
                             auto_delete=False)
    _, _, _ = channel.queue_declare(queue=queue_name(), 
                                    durable=True,
                                    exclusive=False, 
                                    auto_delete=False)
{'fraction_non_alphanumeric': 0.10440456769983687, 'fraction_numerical': 0.004486133768352365, 'mean_word_length': 2.043424317617866, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857740', 'n_tokens_mistral': 720, 'n_tokens_neox': 659, 'n_words': 129}