コード例 #1
0
ファイル: server.py プロジェクト: YuriAR/Lab12and13
def number_of_messages(name):
	conn = get_conn()
	queue = conn.get_queue(name)
	if queue is None:
                resp = json.dumps("Queue not found\n")
	else:
		resp = json.dumps("Number of messages: " + str(queue.count()))
	return Response(response=resp,mimetype="application/json")
コード例 #2
0
ファイル: server.py プロジェクト: TaOnAs/lab1213
def count_messages(name):
    """
    Get number of messages
    curl -s -X GET -H 'Accept: application/json' http://localhost:5000/queues/<name>/msgs/count | python -mjson.tool
    """
    queue = conn.get_queue(name)
    messages = queue.count()
    return Response(response='{"response": "%s messages found"}' % messages, mimetype="application/json")
コード例 #3
0
ファイル: server.py プロジェクト: YuriAR/Lab12and13
def read_message(name):
	conn = get_conn()
	queue = conn.get_queue(name)
	if queue is None:
                resp = json.dumps("Queue not found\n")
	else:
		messages = queue.get_messages()
		if queue.count() > 0:
			resp = json.dumps("Message: " + messages[0].get_body())
		else:
			resp = json.dumps("No messages")
	return Response(response=resp,mimetype="application/json")
コード例 #4
0
ファイル: server.py プロジェクト: orlafahy/Lab12-13
def messages_count(name):
	"""
	Get message count for queue
	curl -X GET -H 'Accept: application/json' http://localhost:5000/queues/OrlaLab12and13/msgs/count
	"""

	conn = get_conn()
	queue = conn.get_queue(name)
	count = queue.count()
	
	resp = "Queue "+name+" has "+str(count)+" messages\n"
	return Response(response=resp, mimetype="application/json")	
コード例 #5
0
ファイル: server.py プロジェクト: Pridexs/dit
def count_msgs_queue(q_name):
    """
    Counts the number of messages in a queue

    curl -s -X GET -H 'Accept: application/json' http://localhost:5000/queues/<my-queue>/msgs/count
    """
    msg_count = 0
    conn = get_conn()
    queue = conn.get_queue(q_name)
    if (queue is not None):
        msg_count = queue.count()
    resp = '{"msg_count": "%d"}' % msg_count
    return Response(response=resp, mimetype="application/json")
コード例 #6
0
ファイル: server.py プロジェクト: alepmaros/dit
def count_msgs_queue(q_name):
    """
    Counts the number of messages in a queue

    curl -s -X GET -H 'Accept: application/json' http://localhost:5000/queues/<my-queue>/msgs/count
    """
    msg_count = 0
    conn = get_conn()
    queue = conn.get_queue(q_name)
    if (queue is not None):
        msg_count = queue.count()
    resp = '{"msg_count": "%d"}' % msg_count
    return Response(response=resp, mimetype="application/json")
コード例 #7
0
def messages_count(name):
    """
	Get message count for queue
	curl -X GET -H 'Accept: application/json' http://localhost:8080/queues/<queue>/msgs/count
	
	"""

    conn = get_conn()
    queue = conn.get_queue(name)
    count = queue.count()

    resp = "Queue " + name + " has " + str(count) + " messages\n"
    return Response(response=resp, mimetype="application/json")
コード例 #8
0
ファイル: server.py プロジェクト: maciekzdaleka/Lab12and13
def messages_count(name):
	"""
	Get message count for queue

	curl -X GET -H 'Accept: application/json' http://localhost:8080/queues/C13470112/msgs/count
	curl -X GET -H 'Accept: application/json' 83.212.127.232:8080/queues/C13470112/msgs/count
	"""

	conn = get_conn()
	queue = conn.get_queue(name)
	count = queue.count()
	
	resp = "Queue "+name+" has "+str(count)+" messages\n"
	return Response(response=resp, mimetype="application/json")	
コード例 #9
0
ファイル: server.py プロジェクト: ShayOLeary/lab12and13
def count_messages(name):
    """
    Get number of messages

    curl -s -X GET -H 'Accept: application/json' http://localhost:5000/queues/<name>/msgs/count | python -mjson.tool

    """
    
    queue = conn.get_queue(name)
    if(queue is not None):
        n = str(queue.count())
        resp = '%s Messages in the queue\n' % n
    else:
        resp = 'Queue %s was not Found\n' % name
    return Response(response=resp, mimetype="application/json")
コード例 #10
0
if (len(sys.argv) != 2):
    sys.ext('Usage: python count-aws-msgs.py queue_name')

queueName = sys.argv[1]

response = urllib2.urlopen(
    'http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key')
awsKey = response.read().split(':')
access_key_id = awsKey[0]
secret_access_key = awsKey[1]

conn = boto.sqs.connect_to_region('eu-west-1',
                                  aws_access_key_id=access_key_id,
                                  aws_secret_access_key=secret_access_key)

queue = conn.get_queue(queueName)
if (queue is not None):
    for i in range(1, queue.count()):
        try:
            msgs = conn.receive_message(queue,
                                        number_messages=queue.count(),
                                        attributes='All')
            if (len(msgs) > 0):
                print('The message = ' + msgs[i - 1].get_body())
            else:
                print('No message to be retrieved')
        except Exception, e:
            print(e)
else:
    print('Queue ' + queueName + ' not found')
コード例 #11
0
ファイル: count-aws-msgs.py プロジェクト: alepmaros/dit
###############################

import sys
import boto.sqs
import boto.sqs.queue
import urllib2
from boto.sqs.message import Message
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError

if (len(sys.argv) != 2):
    sys.exit('Usage: python count-aws-msgs.py queue_name')

queueName = sys.argv[1]

response = urllib2.urlopen('http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key')
awsKey = response.read().split(':')
access_key_id = awsKey[0]
secret_access_key = awsKey[1]

conn = boto.sqs.connect_to_region('eu-west-1', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

queue = conn.get_queue(queueName)
if (queue is not None):
    try:
        print('Messages in the queue = ' + str(queue.count()))
    except Exception, e:
        print(e)
else:
    print('Queue ' + queueName + ' not found')
コード例 #12
0
ファイル: count-aws-msgs.py プロジェクト: AriPerkkio/Lab11
import boto.sqs
import boto.sqs.queue
from boto.sqs.message import Message
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError
import sys
import urllib2

response = urllib2.urlopen('http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key')
key = response.read()
access_key_id = key[0:20] 
secret_access_key = key[21:]

conn = boto.sqs.connect_to_region("eu-west-1", aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

queue = conn.get_queue(sys.argv[1])
count = queue.count()



print("Number of messages for queue "+sys.argv[1])
print(count)
コード例 #13
0
ファイル: count-aws-queue.py プロジェクト: jamalm/Lab11
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError
import sys
import urllib2

url = 'http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key'
req = urllib2.Request(url)
res = urllib2.urlopen(req)
key = res.read()
split = ':'
i = key.find(split)
word1 = key[:i]
word2 = key[i+len(split):]
res.close()

# Get the keys from a specific url and then use them to connect to AWS Service 
access_key_id = word1
secret_access_key = word2

# Set up a connection to the AWS service. 
conn = boto.sqs.connect_to_region("eu-west-1", aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

# Gets a queue and prints a message along side it 
student_no = 'c13730921-'

q_name = student_no + sys.argv[1]

queue = conn.get_queue(q_name)

print "Number of messages in queue ", queue, ": ", str(queue.count())
コード例 #14
0
from boto.sqs.message import Message
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError

if (len(sys.argv) != 2):
    sys.ext('Usage: python count-aws-msgs.py queue_name')

queueName = sys.argv[1]

response = urllib2.urlopen('http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key')
awsKey = response.read().split(':')
access_key_id = awsKey[0]
secret_access_key = awsKey[1]

conn = boto.sqs.connect_to_region('eu-west-1', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

queue = conn.get_queue(queueName)
if (queue is not None):
	for i  in range(0,queue.count()) :
		try:
			msgs = conn.receive_message(queue, number_messages=queue.count(),attributes='All')
			if(len(msgs) > 0):
				print('The message = ' + msgs[i-1].get_body())
			else:
				print('No message to be retrieved')
		except Exception, e:
			print(e)
else:
    print('Queue ' + queueName + ' not found')

コード例 #15
0
ファイル: count-aws-msg.py プロジェクト: TaOnAs/lab11
import boto.sqs
import boto.sqs.queue
from boto.sqs.message import Message
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError
import sys
import requests

r = requests.get("http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key")
str = r.content.split(":", 1)

queue_name = sys.argv[1]


# Get the keys from a specific url and then use them to connect to AWS Service
access_key_id = str[0]
secret_access_key = str[1]

# Set up a connection to the AWS service.
conn = boto.sqs.connect_to_region("eu-west-1", aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

# delete a queue


queue = conn.get_queue(queue_name)

messages = queue.count()

print ("Messages")
print messages
コード例 #16
0

import sys
import boto.sqs
import boto.sqs.queue
import urllib2
from boto.sqs.message import Message
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError

name = sys.argv[1]

response = urllib2.urlopen('http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key')
html = response.read().split(':')
access_key_id = html[0]
secret_access_key = html[1]

conn = boto.sqs.connect_to_region('eu-west-1', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

queue = conn.get_queue(name)

message_count = queue.count()

print("The number of messages is " + str(message_count))
コード例 #17
0
ファイル: .py プロジェクト: emmethanratty/lab11
import urllib2
from boto.sqs.message import Message
from boto.sqs.connection import SQSConnection
from boto.exception import SQSError

if (len(sys.argv) != 2):
    sys.ext('Usage: python count-aws-msgs.py queue_name')

queueName = sys.argv[1]

response = urllib2.urlopen('http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key')
awsKey = response.read().split(':')
access_key_id = awsKey[0]
secret_access_key = awsKey[1]

conn = boto.sqs.connect_to_region('eu-west-1', aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

queue = conn.get_queue(queueName)
if (queue is not None):
	for i in queue.count() :
		try:
			msgs = conn.receive_message(queue, number_messages=1,attributes='All')
			if(len(msgs) > 0):
				print('The message = ' + msgs[i].get_body())
			else:
				print('No message to be retrieved')
		except Exception, e:
			print(e)
else:
    print('Queue ' + queueName + ' not found')