Created
January 21, 2014 23:49
-
-
Save enachb/8550884 to your computer and use it in GitHub Desktop.
shortcut to connect to a non-AWS SQS install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from boto.sqs import regioninfo | |
| import logging | |
| from boto.sqs.jsonmessage import JSONMessage | |
| # useful for debugging boto connect | |
| #logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG) | |
| logger = logging.getLogger(__name__) | |
| def cmb_cxn(key_id, secret_key, name='cmb', | |
| endpoint='localhost', port='6059', is_secure=False): | |
| """ | |
| A convenience function for creating a connection to CMB via boto | |
| """ | |
| fake_region = regioninfo.SQSRegionInfo(name=name, endpoint=endpoint) | |
| logger.info("Create connection to cmb:%s at: %s:%s", name, endpoint, port) | |
| cxn = fake_region.connect(aws_access_key_id=key_id, | |
| aws_secret_access_key=secret_key, | |
| port=port, is_secure=is_secure) | |
| return cxn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment