Exemplo n.º 1
0
 def test_post_request(self):
     self.assertFalse(is_get_request(sample_log[4]))
Exemplo n.º 2
0
channel = connection.channel()
channel.queue_declare(queue='log-analysis')

# Read weblogs

f = open('weblogs.log', 'r', errors='ignore')

while True:
    try:
        msg = f.readline()

        if not msg:
            break
        #If message is GET request, ingest it into the queue
        if is_get_request(msg):
            # Parse GET request for relevant information
            day, status, source = parse_log(msg)

            # Store in RabbitMQ
            body = json.dumps({
                'day': str(day),
                'status': status,
                'source': source
            })
            channel.basic_publish(exchange='',
                                  routing_key='log-analysis',
                                  body=body)

    except:
        print("Unexpected error:" + sys.exc_info()[0])
Exemplo n.º 3
0
 def test_get_request(self):
     self.assertTrue(is_get_request(sample_log[0]))