Example #1
0
File: aws.py Project: goswarm/swarm
    def _write(self, d):
#        if not self.queue:
#            self.initConnection()
        d['timestamp'] = utils.strftime()
        m = Message()
        p = jsontools.dumps(d)
        m.set_body(p)
        self.logger.debug("writing to aws: %s" % p)
        return self.sqs_conn.get_status('SendMessage', { "MessageBody": m.get_body_encoded() }, self.queuename)
Example #2
0
 def _push_batch(self, items):
     id_map = OrderedDict()
     payloads = []
     for item in items:
         message = Message()
         message.set_body(dumps(item))
         new_message_id = str(uuid1())
         id_map[new_message_id] = item
         payloads.append((new_message_id, message.get_body_encoded(), item.get('delay') or 0))
     response = self.queue.write_batch(payloads)
     success_ids = {success['id'] for success in response.results}
     return [(item, item_id in success_ids)
             for item_id, item in id_map.iteritems()]
Example #3
0
 def test_encode_string_message(self):
     message = Message()
     body = 'hello world'
     message.set_body(body)
     self.assertEqual(message.get_body_encoded(), 'aGVsbG8gd29ybGQ=')
Example #4
0
 def test_encode_bytes_message(self):
     message = Message()
     body = b'\x00\x01\x02\x03\x04\x05'
     message.set_body(body)
     self.assertEqual(message.get_body_encoded(), 'AAECAwQF')
Example #5
0
 def test_encode_string_message(self):
     message = Message()
     body = 'hello world'
     message.set_body(body)
     self.assertEqual(message.get_body_encoded(), 'aGVsbG8gd29ybGQ=')
Example #6
0
 def test_encode_bytes_message(self):
     message = Message()
     body = b'\x00\x01\x02\x03\x04\x05'
     message.set_body(body)
     self.assertEqual(message.get_body_encoded(), 'AAECAwQF')