当前位置: 首页>>代码示例>>Python>>正文


Python message.RawMessage类代码示例

本文整理汇总了Python中boto.sqs.message.RawMessage的典型用法代码示例。如果您正苦于以下问题:Python RawMessage类的具体用法?Python RawMessage怎么用?Python RawMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RawMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: enqueueNotification

def enqueueNotification(phoneNumber, name, messageType = 'text'):
    config = configparser.RawConfigParser()
    config.read(os.path.join(os.getcwd() + '/django_drf_starter_project/scripts/','settings.cfg'))
    region = config.get('AWS', 'region')
    queueName = config.get('AWS', 'queue')
    accessKey = config.get('AWS', 'accessKey')
    secretKey = config.get('AWS', 'secretKey')
    pprint(accessKey)
    pprint(secretKey)

    conn = boto.sqs.connect_to_region(region,aws_access_key_id=accessKey,aws_secret_access_key=secretKey) ##change before final
    q = conn.create_queue(queueName) #10-second message visibility

    if len(phoneNumber) > 10:
        phoneNumberNoCountryCode = phoneNumber[1:]
    else:
        phoneNumberNoCountryCode = phoneNumber
    data = {
        'phoneNumber': str(phoneNumberNoCountryCode),
        'name': str(name),
        'type': str(messageType)
    }

    m = RawMessage()
    m.set_body(json.dumps(data))
    q.write(m)
开发者ID:AustinMutschler,项目名称:mlp,代码行数:26,代码来源:enqueue.py

示例2: sendMessageToInputQueue

def sendMessageToInputQueue(q, anim_name,frame_file,type,userid):
    # Data required by the API
    if type == 'Frame':
        data = {
            'msgtype': str(type),
            'submitdate': time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
            'key': str(uuid.uuid1()),#secret key/anwer to s3 instead of boto config file 
            'userid': str(userid), #or bucketname attribute
            'anim_name':str(anim_name),
            'frame_file': str(frame_file)
        }
    elif type == 'killCommand':
        data = {
            'msgtype': str(type),
            'submitdate': time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
            'key': str(uuid.uuid1()),#secret key/anwer to s3 instead of boto config file 
            'userid': str(userid), #or bucketname attribute
            'command': str(message)
        }
    # Connect to SQS and open the queue
 
    # Put the message in the queue
    m = RawMessage()
    m.set_body(json.dumps(data))
    status = q.write(m)
开发者ID:helenaford,项目名称:ShadowCaster,代码行数:25,代码来源:queueOperator.py

示例3: run

def run():
	conn = boto.sqs.connect_to_region("us-west-2")
	requestQueue = conn.get_queue('GredientRequest')
	requestQueue.set_message_class(RawMessage)
	while (True):
		rs = requestQueue.get_messages(1)
		if (len(rs) != 0):
			m = rs[0]
			body = m.get_body()
			foodName = body.split('_')[0]
			requestQueue.delete_message(m)
			here = body.split('_')[1]
			responseQueue = conn.get_queue(body.split('_')[2])
			if responseQueue is not None:
				responseQueue.set_message_class(RawMessage)
				response = RawMessage()
				markets = database.getMarkets(foodName)
				if len(markets) == 0:
					response.set_body(foodName+" is not found in our database!!")
				else:
					nearest = getNearestMarket(here, markets)
					name = nearest['Name']
					address = nearest['Address']
					dis = nearest['Distance']
					response.set_body(foodName+" @ "+name+" @ "+address + " @ "+ dis)
				responseQueue.write(response)
开发者ID:ylyhlh,项目名称:recipe_aws,代码行数:26,代码来源:main.py

示例4: ApprovalProcess

def ApprovalProcess(msg):
    data = dict()
    # The messages received from the imageresult queue
    # ???? format ??? str or int
    data['imagekey'] = str(msg['imagekey'])
    data['imageheight'] = str(msg['imageheight'])
    data['imagewidth'] = str(msg['imagewidth'])

    # retrive rest data from simpleDB 
    domain = _getImageDomain()
    item = domain.get_item(msg['imagekey'])

    data['imageURL'] = item['imageurl']
    data['tag'] = item['tag']
    data['description'] = item['description']
    data['submituser'] = item['submituser']
    data['submitdate'] = item['submitdate']

    # Connect to SQS and create the approval process queue
    sqs = boto.connect_sqs(AWSKey, AWSSecret)
    q = sqs.create_queue(approvalprocessQueue)

    # Put the message in the queue
    # m is raw message object
    # queue only accept message object
    m = RawMessage()
    m.set_body(json.dumps(data))
    # add comment to Queue
    status = q.write(m)
开发者ID:yuanzheng,项目名称:BYU,代码行数:29,代码来源:funcs.py

示例5: WriteToWriteQueue

  def WriteToWriteQueue(self, action, endpoint, body, headers, message_id, output_queue):

    writeQ = self.conn.get_queue(str(output_queue))

    m = RawMessage()
    response =''

    if (action == 'GET'):
      response = requests.get(endpoint, headers=headers)

    elif (action == 'PUT'):
      response = requests.put(endpoint, data = json.dumps(body), headers=headers)

    elif(action == 'POST'):
      response = requests.post(endpoint, data = json.dumps(body),  headers=headers)

    elif (action == 'DELETE'):
      response = requests.delete(endpoint, headers=headers)

    print response.text

    response_final = {
      'messageId': str(message_id),
      'response': str(response.text)
    }

    m.set_body(json.dumps(response_final)) 
    writeQ.write(m)
开发者ID:jhn,项目名称:generic,代码行数:28,代码来源:sqs_setup.py

示例6: connectAndWriteToSQS

def connectAndWriteToSQS(queue, data):
    sqs = boto.connect_sqs()
    sqs = boto.sqs.connect_to_region('us-west-1')   
    q = sqs.create_queue(queue)
    m = RawMessage()
    m.set_body(json.dumps(data))
    q.write(m)
开发者ID:minicoder,项目名称:minbackup,代码行数:7,代码来源:aws_commons.py

示例7: append_to_queue

def append_to_queue(content, queue, raw=False): 
    '''Queues a message to SQS with a specific message'''
    body = json.dumps(content)
    m = RawMessage() if raw else Message()
    m.set_body(body)
    receipt = queue.write(m)
    return receipt
开发者ID:EdgeSW,项目名称:edge-analysis,代码行数:7,代码来源:mySQS.py

示例8: queue

def queue(request, queue_name):
    conn = connector()
    queue = conn.get_all_queues(prefix=queue_name)[0]
    if request.POST:
        if '_clear' in request.POST:
            queue.clear()
            return redirect('/sqs/queues/' + queue_name)
        # will have to wait for s3 integration
        #if '_dump' in request.POST:
        #    queue.save_to_s3('sqs_dump')
        elif '_delete' in request.POST:
            queue.delete()
            return redirect('/sqs/queues/')
        form = AddMessageForm(request.POST)
        if form.is_valid():
            m = RawMessage()
            m.set_body(form.cleaned_data['message']) 
            count = form.cleaned_data['count']
            while count: 
                queue.write(m)
                count -= 1
            return redirect('/sqs/queues/' + queue_name)
    else:
        form = AddMessageForm()

    item = queue.get_attributes()
    item['name'] = queue.name

    return render(request, 'sqs/queue.html', {
            'queue': item,
            'form': form,
        })  
开发者ID:fo0nikens,项目名称:awsomer,代码行数:32,代码来源:views.py

示例9: commentsubmit

def commentsubmit(req):
	sdb = boto.connect_sdb(AWSKey, AWSSecret)
	domain = sdb.get_domain('comment')
	form = req.form
	imagekey = form['imagekey']
	user = form['commentuser']
	cmt = form['comment']	
	import uuid
	from time import strftime
	guid = str(uuid.uuid1())
	item = domain.new_item(guid)
	item['submituser'] = user
	item['imagekey'] = imagekey
	item['comment'] = cmt
	item['status'] = "processing"
	item['submitdate'] = strftime("%Y-%m-%dT%H:%M:%S")
	item.save()
	sqsconn = SQSConnection(AWSKey, AWSSecret)
	q = sqsconn.get_queue('commentprocess')
	request = {}
	request['commentkey'] = guid
	request['submitdate'] = strftime("%Y-%m-%dT%H:%M:%S")
	request['comment'] = str(cmt)
	request['submituser'] = str(user)
	m = RawMessage()
	m.set_body(json.write(request))
	status = q.write(m)
	response = {}
	if status==m:
		response['complete'] = True
		response['commentkey'] = guid
	else:
		response['complete'] = False
	return json.write(response)
开发者ID:armstrow,项目名称:cs462-armstrow,代码行数:34,代码来源:index.py

示例10: emit

    def emit(self, record):
        if isinstance(record.args, dict):
            record.customer = record.args['customer']
        else:
            record.customer = 'Sender'

        #formatted_record = self.format(record)
        ct = '%Y/%m/%d %H:%M:%S'
        dtime = datetime.datetime.utcfromtimestamp(record.created)

        data = {}
        data['levelname'] = record.levelname
        data['asctime'] = dtime.strftime(ct)
        data['customer'] = record.customer
        data['message'] = record.msg
        data['name'] = record.name
        data['funcName'] = record.funcName
        data['filename'] = record.filename
        data['@timestamp'] = datetime.datetime.strptime(data['asctime'], '%Y/%m/%d %H:%M:%S').strftime('%Y-%m-%dT%H:%M:%SZ')

        msg = {}
        msg['_id'] = str(uuid.uuid4())
        msg['_index'] = "sqs-river-" + datetime.datetime.now().strftime("%Y.%m")
        msg['_type'] = "mailexpress"
        msg['_data'] = data

        #print json.dumps(msg)
        m = RawMessage()
        m.set_body(json.dumps(msg))
        self.q.write(m)
开发者ID:kassnl,项目名称:redis-handler-api,代码行数:30,代码来源:sqshandler.py

示例11: write_to_que

def write_to_que(data):
    conn = boto.sqs.connect_to_region("us-east-1")
    my_queue = conn.get_queue('email_queue')
    # Put the message in the queue
    m = RawMessage()
    m.set_body(json.dumps(data))
    status = my_queue.write(m)
开发者ID:rserna2010,项目名称:flask_beanstalk,代码行数:7,代码来源:application.py

示例12: setSQS

def setSQS(data, queue):
    # Put the message in the queue
    # m is raw message object
    # queue only accept message object
    m = RawMessage()
    m.set_body(json.dumps(data))
    # add comment to Queue
    status = queue.write(m)
开发者ID:yuanzheng,项目名称:BYU,代码行数:8,代码来源:funcs.py

示例13: to_queue

def to_queue(obj, queue_name):
    if environment.local:
        print('[queue] {}'.format(queue_name))
    else:
        queue = sqs.get_queue(queue_name)
        message = RawMessage()
        message.set_body(json.dumps(obj))
        queue.write(message)
开发者ID:debrouwere,项目名称:pollster,代码行数:8,代码来源:persistence.py

示例14: write_msg

 def write_msg(self, queue, msg):
     """ Write SQS message as JSON. """
     m = RawMessage()
     m.set_body(base64.b64encode(json.dumps(msg)))
     q = self.conn.lookup(queue)
     msg_sent = q.write(m)
     print("Sent Msg; queue={0}, msg={1.id}".format(queue, msg_sent))
     return msg_sent
开发者ID:rene00,项目名称:aws-sqs-test-widgets,代码行数:8,代码来源:sqs.py

示例15: AddData

    def AddData(self, data):
        """
        Adds the given scraped data to the queue

        data - A dictionary of scrape data to add to the queue
        """
        message = RawMessage()
        message.set_body(json.dumps(data))
        self.DataQueue.write(message)
开发者ID:SPRIME01,项目名称:pySpiderScrape,代码行数:9,代码来源:queue.py


注:本文中的boto.sqs.message.RawMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。