Exemplo n.º 1
0
def main():
    #datetime can be removed
    retrieve = Consumer(CONNECTION_URL, EXCHANGE, HOST, ROUTING_KEY, EXCHANGE_TYPE)
    try:
        retrieve.run()
    except KeyboardInterrupt:
        retrieve.stop()
Exemplo n.º 2
0
def run(ctx):
    """Run Bounced Email Service"""
    from handler import Handler
    from consumer import Consumer

    try:
        handler = Handler(ctx.obj)
        consumer = Consumer(ctx.obj, handler)
        consumer.run()
    except KeyboardInterrupt:
        consumer.stop()
Exemplo n.º 3
0
def run():
    consumer = Consumer('amqp://*****:*****@127.0.0.1:5672/%2F',
                        queue='text',
                        routing_key='example.text')
    consumer.run()
    print 'runed'
    #    kk = yield w.fetch("http://www.abercrombie.cn/on/demandware.store/Sites-abercrombie_cn-Site/en_CN/Product-Variation?pid=anf-87741&dwvar_anf-87741_4MPrmry=4080&dwvar_anf-87741_color=01&Quantity=1&format=ajax&_=1431591378963")
    kk = yield w.fetch(
        'http://www.abercrombie.cn/en_CN/mens-shorts-twill-classic-fit/aandf-classic-fit-shorts/anf-87743.html?dwvar_anf-87743_color=01#ict=ICT%3ASUM15%3AM%3AHT%3A1%3AT%3ASEA%3AShorts&start=1'
    )

    #kk = yield w.fetch('http://127.0.0.1:8000', method="POST", headers={'User-Agent':'F**K'})
    Handler.carters = Carters()
    Handler.sixpm = SixPM()
    application.listen(WEBSERVER_PORT)
Exemplo n.º 4
0
            config['iqas_request']['application_id'] = config['application_id']
            base_url_for_requests = "http://" + config[
                'iqas_api_endpoint'] + "/requests"
            status_code, response = HttpUtils.post_to_rest_endpoint(
                url=base_url_for_requests, dictionary=config['iqas_request'])
            config['request_id'] = response['request_id']

            if status_code == 200:
                ready = False
                retries = 0
                while not ready and retries < MAX_RETRIES:
                    status_code2, response2 = HttpUtils.get_from_rest_endpoint(
                        url=base_url_for_requests + "/" + config['request_id'])
                    if response2['current_status'] == 'ENFORCED':
                        break
                    else:
                        time.sleep(1)
                        retries += 1

            time.sleep(5)

            # Once the Request has been accepted, we can start consuming observations
            topics_to_subscribe = list()
            topics_to_subscribe.append(config['application_id'] + '_' +
                                       config['request_id'])

        consumer_thread = Consumer(config=config,
                                   topics_to_subscribe=topics_to_subscribe,
                                   logstash=test_logger)
        consumer_thread.run()
Exemplo n.º 5
0
def spawn_consumer(basepath, worker_config, worker_num, q):
    from consumer import Consumer
    cls = Consumer(basepath, worker_config, worker_num, q)
    cls.run()
Exemplo n.º 6
0
def _run_consumer():
    unlock = "UNLOCK" in os.environ
    c = Consumer(unlock=unlock)
    c.run()
Exemplo n.º 7
0
import argparse
import sys

from consumer import Consumer
from middleware import PORT

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--type",
                        help="type of producer: [temp, msg, weather]",
                        default="temp")
    args = parser.parse_args()

    if args.type not in Consumer.datatypes():
        print("Error: not a valid producer type")
        sys.exit(1)

    p = Consumer(args.type, PORT + 1)

    p.run()