├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── boto ├── __init__.py ├── auth.py ├── auth_handler.py ├── cacerts │ ├── __init__.py │ └── cacerts.txt ├── cloudformation │ ├── __init__.py │ ├── connection.py │ ├── stack.py │ └── template.py ├── cloudfront │ ├── __init__.py │ ├── distribution.py │ ├── exception.py │ ├── identity.py │ ├── invalidation.py │ ├── logging.py │ ├── object.py │ ├── origin.py │ └── signers.py ├── connection.py ├── contrib │ ├── __init__.py │ ├── m2helpers.py │ └── ymlmessage.py ├── dynamodb │ ├── __init__.py │ ├── batch.py │ ├── exceptions.py │ ├── item.py │ ├── layer1.py │ ├── layer2.py │ ├── schema.py │ └── table.py ├── ec2 │ ├── __init__.py │ ├── address.py │ ├── autoscale │ │ ├── __init__.py │ │ ├── activity.py │ │ ├── group.py │ │ ├── instance.py │ │ ├── launchconfig.py │ │ ├── policy.py │ │ ├── request.py │ │ ├── scheduled.py │ │ └── tag.py │ ├── blockdevicemapping.py │ ├── bundleinstance.py │ ├── buyreservation.py │ ├── cloudwatch │ │ ├── __init__.py │ │ ├── alarm.py │ │ ├── datapoint.py │ │ ├── dimension.py │ │ ├── listelement.py │ │ └── metric.py │ ├── connection.py │ ├── ec2object.py │ ├── elb │ │ ├── __init__.py │ │ ├── healthcheck.py │ │ ├── instancestate.py │ │ ├── listelement.py │ │ ├── listener.py │ │ ├── loadbalancer.py │ │ ├── policies.py │ │ └── securitygroup.py │ ├── image.py │ ├── instance.py │ ├── instanceinfo.py │ ├── instancestatus.py │ ├── keypair.py │ ├── launchspecification.py │ ├── networkinterface.py │ ├── placementgroup.py │ ├── regioninfo.py │ ├── reservedinstance.py │ ├── securitygroup.py │ ├── snapshot.py │ ├── spotdatafeedsubscription.py │ ├── spotinstancerequest.py │ ├── spotpricehistory.py │ ├── tag.py │ ├── volume.py │ └── zone.py ├── ecs │ ├── __init__.py │ └── item.py ├── emr │ ├── __init__.py │ ├── bootstrap_action.py │ ├── connection.py │ ├── emrobject.py │ ├── instance_group.py │ ├── step.py │ └── tests │ │ └── test_emr_responses.py ├── exception.py ├── file │ ├── README │ ├── __init__.py │ ├── bucket.py │ ├── connection.py │ ├── key.py │ └── simpleresultset.py ├── fps │ ├── __init__.py │ ├── connection.py │ └── test │ │ ├── __init__.py │ │ ├── test_install_caller_instruction.py │ │ └── test_verify_signature.py ├── gs │ ├── __init__.py │ ├── acl.py │ ├── bucket.py │ ├── connection.py │ ├── key.py │ ├── resumable_upload_handler.py │ └── user.py ├── handler.py ├── https_connection.py ├── iam │ ├── __init__.py │ ├── connection.py │ └── summarymap.py ├── jsonresponse.py ├── manage │ ├── __init__.py │ ├── cmdshell.py │ ├── propget.py │ ├── server.py │ ├── task.py │ ├── test_manage.py │ └── volume.py ├── mashups │ ├── __init__.py │ ├── interactive.py │ ├── iobject.py │ ├── order.py │ └── server.py ├── mturk │ ├── __init__.py │ ├── connection.py │ ├── notification.py │ ├── price.py │ ├── qualification.py │ ├── question.py │ └── test │ │ ├── .gitignore │ │ ├── __init__.py │ │ ├── _init_environment.py │ │ ├── all_tests.py │ │ ├── cleanup_tests.py │ │ ├── common.py │ │ ├── create_free_text_question_regex.doctest │ │ ├── create_hit.doctest │ │ ├── create_hit_binary.doctest │ │ ├── create_hit_external.py │ │ ├── create_hit_from_hit_type.doctest │ │ ├── create_hit_test.py │ │ ├── create_hit_with_qualifications.py │ │ ├── hit_persistence.py │ │ ├── mocks.py │ │ ├── reviewable_hits.doctest │ │ ├── run-doctest.py │ │ ├── search_hits.doctest │ │ ├── selenium_support.py │ │ ├── support.py │ │ └── test_disable_hit.py ├── plugin.py ├── provider.py ├── pyami │ ├── __init__.py │ ├── bootstrap.py │ ├── config.py │ ├── copybot.cfg │ ├── copybot.py │ ├── helloworld.py │ ├── installers │ │ ├── __init__.py │ │ └── ubuntu │ │ │ ├── __init__.py │ │ │ ├── apache.py │ │ │ ├── ebs.py │ │ │ ├── installer.py │ │ │ ├── mysql.py │ │ │ └── trac.py │ ├── launch_ami.py │ ├── scriptbase.py │ └── startup.py ├── rds │ ├── __init__.py │ ├── dbinstance.py │ ├── dbsecuritygroup.py │ ├── dbsnapshot.py │ ├── event.py │ ├── parametergroup.py │ └── regioninfo.py ├── regioninfo.py ├── resultset.py ├── roboto │ ├── __init__.py │ ├── awsqueryrequest.py │ ├── awsqueryservice.py │ └── param.py ├── route53 │ ├── __init__.py │ ├── connection.py │ ├── exception.py │ ├── hostedzone.py │ └── record.py ├── s3 │ ├── __init__.py │ ├── acl.py │ ├── bucket.py │ ├── bucketlistresultset.py │ ├── connection.py │ ├── deletemarker.py │ ├── key.py │ ├── lifecycle.py │ ├── multidelete.py │ ├── multipart.py │ ├── object_hooks.py │ ├── prefix.py │ ├── resumable_download_handler.py │ └── user.py ├── sdb │ ├── __init__.py │ ├── connection.py │ ├── db │ │ ├── __init__.py │ │ ├── blob.py │ │ ├── key.py │ │ ├── manager │ │ │ ├── __init__.py │ │ │ ├── pgmanager.py │ │ │ ├── sdbmanager.py │ │ │ └── xmlmanager.py │ │ ├── model.py │ │ ├── property.py │ │ ├── query.py │ │ ├── sequence.py │ │ └── test_db.py │ ├── domain.py │ ├── item.py │ ├── queryresultset.py │ └── regioninfo.py ├── services │ ├── __init__.py │ ├── bs.py │ ├── message.py │ ├── result.py │ ├── service.py │ ├── servicedef.py │ ├── sonofmmm.cfg │ ├── sonofmmm.py │ └── submit.py ├── ses │ ├── __init__.py │ ├── connection.py │ └── exceptions.py ├── sns │ ├── __init__.py │ └── connection.py ├── sqs │ ├── __init__.py │ ├── attributes.py │ ├── batchresults.py │ ├── connection.py │ ├── jsonmessage.py │ ├── message.py │ ├── queue.py │ └── regioninfo.py ├── storage_uri.py ├── sts │ ├── __init__.py │ ├── connection.py │ └── credentials.py ├── utils.py └── vpc │ ├── __init__.py │ ├── customergateway.py │ ├── dhcpoptions.py │ ├── internetgateway.py │ ├── routetable.py │ ├── subnet.py │ ├── vpc.py │ ├── vpnconnection.py │ └── vpngateway.py ├── botornado ├── __init__.py ├── connection.py ├── s3 │ ├── __init__.py │ ├── bucket.py │ ├── connection.py │ └── key.py ├── sqs │ ├── __init__.py │ ├── connection.py │ ├── jsonmessage.py │ ├── message.py │ └── queue.py └── test │ ├── __init__.py │ ├── s3 │ ├── __init__.py │ └── connection_test.py │ └── sqs │ └── __init__.py ├── examples ├── s3_get_all_buckets.py └── sqs_get_all_queues.py ├── requirements.txt └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.BAK 2 | *.bak 3 | *.pyc 4 | *.pyo 5 | *.swo 6 | *.swp 7 | *.orig 8 | /*.egg 9 | /*.egg-info 10 | /build 11 | /dist 12 | /tmp 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | install: pip install -r requirements.txt --use-mirrors 3 | script: python setup.py test 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015 Yamashita, Yuu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # botornado 2 | 3 | ## Overview 4 | 5 | An asynchronous AWS client on Tornado. 6 | 7 | This is a dirty work to move boto onto Tornado ioloop. 8 | Only SQS and S3 have been implemented as of 2012/Jan/26. 9 | 10 | 11 | ## Requirements 12 | 13 | * boto (https://github.com/boto/boto) 14 | * tornado (https://github.com/facebook/tornado) 15 | 16 | 17 | ## Samples 18 | 19 | almost all options are same with boto other than callback. 20 | 21 | sample S3 client. 22 | 23 | import os, sys 24 | from botornado.s3.connection import AsyncS3Connection 25 | client = AsyncS3Connection(aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), 26 | aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY')) 27 | # getting all your buckets 28 | def cb1(buckets): 29 | print 'your buckets:', buckets 30 | client.get_all_buckets(callback=cb1) 31 | 32 | sample SQS client. 33 | 34 | import os, sys 35 | import botornado.sqs 36 | client = botornado.sqs.connect_to_region('ap-northeast-1', 37 | aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), 38 | aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY')) 39 | def cb2(queues): 40 | print 'your queues:', queues 41 | client.get_all_queues(callback=cb2) 42 | 43 | 44 | ## License 45 | 46 | MIT 47 | 48 | 49 | ## Author 50 | 51 | * Copyright (C) 2015 Yamashita, Yuu 52 | -------------------------------------------------------------------------------- /boto/auth_handler.py: -------------------------------------------------------------------------------- 1 | # Copyright 2010 Google Inc. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Defines an interface which all Auth handlers need to implement. 24 | """ 25 | 26 | from plugin import Plugin 27 | 28 | class NotReadyToAuthenticate(Exception): 29 | pass 30 | 31 | class AuthHandler(Plugin): 32 | 33 | capability = [] 34 | 35 | def __init__(self, host, config, provider): 36 | """Constructs the handlers. 37 | :type host: string 38 | :param host: The host to which the request is being sent. 39 | 40 | :type config: boto.pyami.Config 41 | :param config: Boto configuration. 42 | 43 | :type provider: boto.provider.Provider 44 | :param provider: Provider details. 45 | 46 | Raises: 47 | NotReadyToAuthenticate: if this handler is not willing to 48 | authenticate for the given provider and config. 49 | """ 50 | pass 51 | 52 | def add_auth(self, http_request): 53 | """Invoked to add authentication details to request. 54 | 55 | :type http_request: boto.connection.HTTPRequest 56 | :param http_request: HTTP request that needs to be authenticated. 57 | """ 58 | pass 59 | -------------------------------------------------------------------------------- /boto/cacerts/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2010 Google Inc. 2 | # All rights reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | # 23 | -------------------------------------------------------------------------------- /boto/cloudformation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010-2011 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010-2011, Eucalyptus Systems, Inc. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | 23 | # this is here for backward compatibility 24 | # originally, the SNSConnection class was defined here 25 | from connection import CloudFormationConnection 26 | -------------------------------------------------------------------------------- /boto/cloudformation/template.py: -------------------------------------------------------------------------------- 1 | from boto.resultset import ResultSet 2 | 3 | class Template: 4 | def __init__(self, connection=None): 5 | self.connection = connection 6 | self.description = None 7 | self.template_parameters = None 8 | 9 | def startElement(self, name, attrs, connection): 10 | if name == "Parameters": 11 | self.template_parameters = ResultSet([('member', TemplateParameter)]) 12 | return self.template_parameters 13 | else: 14 | return None 15 | 16 | def endElement(self, name, value, connection): 17 | if name == "Description": 18 | self.description = value 19 | else: 20 | setattr(self, name, value) 21 | 22 | class TemplateParameter: 23 | def __init__(self, parent): 24 | self.parent = parent 25 | self.default_value = None 26 | self.description = None 27 | self.no_echo = None 28 | self.parameter_key = None 29 | 30 | def startElement(self, name, attrs, connection): 31 | return None 32 | 33 | def endElement(self, name, value, connection): 34 | if name == "DefaultValue": 35 | self.default_value = value 36 | elif name == "Description": 37 | self.description = value 38 | elif name == "NoEcho": 39 | self.no_echo = bool(value) 40 | elif name == "ParameterKey": 41 | self.parameter_key = value 42 | else: 43 | setattr(self, name, value) 44 | -------------------------------------------------------------------------------- /boto/cloudfront/exception.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | from boto.exception import BotoServerError 23 | 24 | class CloudFrontServerError(BotoServerError): 25 | 26 | pass 27 | -------------------------------------------------------------------------------- /boto/cloudfront/logging.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class LoggingInfo(object): 23 | 24 | def __init__(self, bucket='', prefix=''): 25 | self.bucket = bucket 26 | self.prefix = prefix 27 | 28 | def startElement(self, name, attrs, connection): 29 | return None 30 | 31 | def endElement(self, name, value, connection): 32 | if name == 'Bucket': 33 | self.bucket = value 34 | elif name == 'Prefix': 35 | self.prefix = value 36 | else: 37 | setattr(self, name, value) 38 | 39 | -------------------------------------------------------------------------------- /boto/cloudfront/object.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | from boto.s3.key import Key 23 | 24 | class Object(Key): 25 | 26 | def __init__(self, bucket, name=None): 27 | Key.__init__(self, bucket, name=name) 28 | self.distribution = bucket.distribution 29 | 30 | def __repr__(self): 31 | return '' % (self.distribution.config.origin, self.name) 32 | 33 | def url(self, scheme='http'): 34 | url = '%s://' % scheme 35 | url += self.distribution.domain_name 36 | if scheme.lower().startswith('rtmp'): 37 | url += '/cfx/st/' 38 | else: 39 | url += '/' 40 | url += self.name 41 | return url 42 | 43 | class StreamingObject(Object): 44 | 45 | def url(self, scheme='rtmp'): 46 | return Object.url(self, scheme) 47 | 48 | 49 | -------------------------------------------------------------------------------- /boto/cloudfront/signers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class Signer: 23 | 24 | def __init__(self): 25 | self.id = None 26 | self.key_pair_ids = [] 27 | 28 | def startElement(self, name, attrs, connection): 29 | return None 30 | 31 | def endElement(self, name, value, connection): 32 | if name == 'Self': 33 | self.id = 'Self' 34 | elif name == 'AwsAccountNumber': 35 | self.id = value 36 | elif name == 'KeyPairId': 37 | self.key_pair_ids.append(value) 38 | 39 | class ActiveTrustedSigners(list): 40 | 41 | def startElement(self, name, attrs, connection): 42 | if name == 'Signer': 43 | s = Signer() 44 | self.append(s) 45 | return s 46 | 47 | def endElement(self, name, value, connection): 48 | pass 49 | 50 | class TrustedSigners(list): 51 | 52 | def startElement(self, name, attrs, connection): 53 | return None 54 | 55 | def endElement(self, name, value, connection): 56 | if name == 'Self': 57 | self.append(name) 58 | elif name == 'AwsAccountNumber': 59 | self.append(value) 60 | 61 | -------------------------------------------------------------------------------- /boto/contrib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | -------------------------------------------------------------------------------- /boto/contrib/m2helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Jon Colverson 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | This module was contributed by Jon Colverson. It provides a couple of helper 24 | functions that allow you to use M2Crypto's implementation of HTTPSConnection 25 | rather than the default version in httplib.py. The main benefit is that 26 | M2Crypto's version verifies the certificate of the server. 27 | 28 | To use this feature, do something like this: 29 | 30 | from boto.ec2.connection import EC2Connection 31 | 32 | ec2 = EC2Connection(ACCESS_KEY_ID, SECRET_ACCESS_KEY, 33 | https_connection_factory=https_connection_factory(cafile=CA_FILE)) 34 | 35 | See http://code.google.com/p/boto/issues/detail?id=57 for more details. 36 | """ 37 | from M2Crypto import SSL 38 | from M2Crypto.httpslib import HTTPSConnection 39 | 40 | def secure_context(cafile=None, capath=None): 41 | ctx = SSL.Context() 42 | ctx.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, depth=9) 43 | if ctx.load_verify_locations(cafile=cafile, capath=capath) != 1: 44 | raise Exception("Couldn't load certificates") 45 | return ctx 46 | 47 | def https_connection_factory(cafile=None, capath=None): 48 | def factory(*args, **kwargs): 49 | return HTTPSConnection( 50 | ssl_context=secure_context(cafile=cafile, capath=capath), 51 | *args, **kwargs) 52 | return (factory, (SSL.SSLError,)) 53 | -------------------------------------------------------------------------------- /boto/contrib/ymlmessage.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Chris Moyer 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | This module was contributed by Chris Moyer. It provides a subclass of the 24 | SQS Message class that supports YAML as the body of the message. 25 | 26 | This module requires the yaml module. 27 | """ 28 | from boto.sqs.message import Message 29 | import yaml 30 | 31 | class YAMLMessage(Message): 32 | """ 33 | The YAMLMessage class provides a YAML compatible message. Encoding and 34 | decoding are handled automaticaly. 35 | 36 | Access this message data like such: 37 | 38 | m.data = [ 1, 2, 3] 39 | m.data[0] # Returns 1 40 | 41 | This depends on the PyYAML package 42 | """ 43 | 44 | def __init__(self, queue=None, body='', xml_attrs=None): 45 | self.data = None 46 | Message.__init__(self, queue, body) 47 | 48 | def set_body(self, body): 49 | self.data = yaml.load(body) 50 | 51 | def get_body(self): 52 | return yaml.dump(self.data) 53 | -------------------------------------------------------------------------------- /boto/dynamodb/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | # 23 | 24 | -------------------------------------------------------------------------------- /boto/dynamodb/exceptions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Exceptions that are specific to the dynamodb module. 3 | """ 4 | from boto.exception import BotoServerError, BotoClientError 5 | 6 | class DynamoDBExpiredTokenError(BotoServerError): 7 | """ 8 | Raised when a DynamoDB security token expires. This is generally boto's 9 | (or the user's) notice to renew their DynamoDB security tokens. 10 | """ 11 | pass 12 | 13 | 14 | class DynamoDBKeyNotFoundError(BotoClientError): 15 | """ 16 | Raised when attempting to retrieve or interact with an item whose key 17 | can't be found. 18 | """ 19 | pass -------------------------------------------------------------------------------- /boto/dynamodb/schema.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | # 23 | 24 | class Schema(object): 25 | """ 26 | Represents a DynamoDB schema. 27 | 28 | :ivar hash_key_name: The name of the hash key of the schema. 29 | :ivar hash_key_type: The DynamoDB type specification for the 30 | hash key of the schema. 31 | :ivar range_key_name: The name of the range key of the schema 32 | or None if no range key is defined. 33 | :ivar range_key_type: The DynamoDB type specification for the 34 | range key of the schema or None if no range key is defined. 35 | :ivar dict: The underlying Python dictionary that needs to be 36 | passed to Layer1 methods. 37 | """ 38 | 39 | def __init__(self, schema_dict): 40 | self._dict = schema_dict 41 | 42 | def __repr__(self): 43 | if self.range_key_name: 44 | s = 'Schema(%s:%s)' % (self.hash_key_name, self.range_key_name) 45 | else: 46 | s = 'Schema(%s)' % self.hash_key_name 47 | return s 48 | 49 | @property 50 | def dict(self): 51 | return self._dict 52 | 53 | @property 54 | def hash_key_name(self): 55 | return self._dict['HashKeyElement']['AttributeName'] 56 | 57 | @property 58 | def hash_key_type(self): 59 | return self._dict['HashKeyElement']['AttributeType'] 60 | 61 | @property 62 | def range_key_name(self): 63 | name = None 64 | if 'RangeKeyElement' in self._dict: 65 | name = self._dict['RangeKeyElement']['AttributeName'] 66 | return name 67 | 68 | @property 69 | def range_key_type(self): 70 | type = None 71 | if 'RangeKeyElement' in self._dict: 72 | type = self._dict['RangeKeyElement']['AttributeType'] 73 | return type 74 | 75 | -------------------------------------------------------------------------------- /boto/ec2/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | """ 23 | This module provides an interface to the Elastic Compute Cloud (EC2) 24 | service from AWS. 25 | """ 26 | from boto.ec2.connection import EC2Connection 27 | 28 | def regions(**kw_params): 29 | """ 30 | Get all available regions for the EC2 service. 31 | You may pass any of the arguments accepted by the EC2Connection 32 | object's constructor as keyword arguments and they will be 33 | passed along to the EC2Connection object. 34 | 35 | :rtype: list 36 | :return: A list of :class:`boto.ec2.regioninfo.RegionInfo` 37 | """ 38 | c = EC2Connection(**kw_params) 39 | return c.get_all_regions() 40 | 41 | def connect_to_region(region_name, **kw_params): 42 | """ 43 | Given a valid region name, return a 44 | :class:`boto.ec2.connection.EC2Connection`. 45 | Any additional parameters after the region_name are passed on to 46 | the connect method of the region object. 47 | 48 | :type: str 49 | :param region_name: The name of the region to connect to. 50 | 51 | :rtype: :class:`boto.ec2.connection.EC2Connection` or ``None`` 52 | :return: A connection to the given region, or None if an invalid region 53 | name is given 54 | """ 55 | for region in regions(**kw_params): 56 | if region.name == region_name: 57 | return region.connect(**kw_params) 58 | return None 59 | 60 | def get_region(region_name, **kw_params): 61 | """ 62 | Find and return a :class:`boto.ec2.regioninfo.RegionInfo` object 63 | given a region name. 64 | 65 | :type: str 66 | :param: The name of the region. 67 | 68 | :rtype: :class:`boto.ec2.regioninfo.RegionInfo` 69 | :return: The RegionInfo object for the given region or None if 70 | an invalid region name is provided. 71 | """ 72 | for region in regions(**kw_params): 73 | if region.name == region_name: 74 | return region 75 | return None 76 | 77 | -------------------------------------------------------------------------------- /boto/ec2/address.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents an EC2 Elastic IP Address 24 | """ 25 | 26 | from boto.ec2.ec2object import EC2Object 27 | 28 | class Address(EC2Object): 29 | 30 | def __init__(self, connection=None, public_ip=None, instance_id=None): 31 | EC2Object.__init__(self, connection) 32 | self.connection = connection 33 | self.public_ip = public_ip 34 | self.instance_id = instance_id 35 | self.domain = None 36 | self.allocation_id = None 37 | self.association_id = None 38 | 39 | def __repr__(self): 40 | return 'Address:%s' % self.public_ip 41 | 42 | def endElement(self, name, value, connection): 43 | if name == 'publicIp': 44 | self.public_ip = value 45 | elif name == 'instanceId': 46 | self.instance_id = value 47 | elif name == 'domain': 48 | self.domain = value 49 | elif name == 'allocationId': 50 | self.allocation_id = value 51 | elif name == 'associationId': 52 | self.association_id = value 53 | else: 54 | setattr(self, name, value) 55 | 56 | def release(self): 57 | return self.connection.release_address(self.public_ip) 58 | 59 | delete = release 60 | 61 | def associate(self, instance_id): 62 | return self.connection.associate_address(instance_id, self.public_ip) 63 | 64 | def disassociate(self): 65 | return self.connection.disassociate_address(self.public_ip) 66 | 67 | 68 | -------------------------------------------------------------------------------- /boto/ec2/autoscale/instance.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | 23 | class Instance(object): 24 | def __init__(self, connection=None): 25 | self.connection = connection 26 | self.instance_id = None 27 | self.health_status = None 28 | self.launch_config_name = None 29 | self.lifecycle_state = None 30 | self.availability_zone = None 31 | self.group_name = None 32 | 33 | def __repr__(self): 34 | r = 'Instance Creating New Volume' 6 | volume = Volume.create() 7 | print volume 8 | 9 | print '--> Creating New Server' 10 | server_list = Server.create() 11 | server = server_list[0] 12 | print server 13 | 14 | print '----> Waiting for Server to start up' 15 | while server.status != 'running': 16 | print '*' 17 | time.sleep(10) 18 | print '----> Server is running' 19 | 20 | print '--> Run "df -k" on Server' 21 | status = server.run('df -k') 22 | print status[1] 23 | 24 | print '--> Now run volume.make_ready to make the volume ready to use on server' 25 | volume.make_ready(server) 26 | 27 | print '--> Run "df -k" on Server' 28 | status = server.run('df -k') 29 | print status[1] 30 | 31 | print '--> Do an "ls -al" on the new filesystem' 32 | status = server.run('ls -al %s' % volume.mount_point) 33 | print status[1] 34 | 35 | -------------------------------------------------------------------------------- /boto/mashups/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | 24 | -------------------------------------------------------------------------------- /boto/mashups/interactive.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2003-2007 Robey Pointer 2 | # 3 | # This file is part of paramiko. 4 | # 5 | # Paramiko is free software; you can redistribute it and/or modify it under the 6 | # terms of the GNU Lesser General Public License as published by the Free 7 | # Software Foundation; either version 2.1 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 | # details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public License 16 | # along with Paramiko; if not, write to the Free Software Foundation, Inc., 17 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 18 | 19 | 20 | import socket 21 | import sys 22 | 23 | # windows does not have termios... 24 | try: 25 | import termios 26 | import tty 27 | has_termios = True 28 | except ImportError: 29 | has_termios = False 30 | 31 | 32 | def interactive_shell(chan): 33 | if has_termios: 34 | posix_shell(chan) 35 | else: 36 | windows_shell(chan) 37 | 38 | 39 | def posix_shell(chan): 40 | import select 41 | 42 | oldtty = termios.tcgetattr(sys.stdin) 43 | try: 44 | tty.setraw(sys.stdin.fileno()) 45 | tty.setcbreak(sys.stdin.fileno()) 46 | chan.settimeout(0.0) 47 | 48 | while True: 49 | r, w, e = select.select([chan, sys.stdin], [], []) 50 | if chan in r: 51 | try: 52 | x = chan.recv(1024) 53 | if len(x) == 0: 54 | print '\r\n*** EOF\r\n', 55 | break 56 | sys.stdout.write(x) 57 | sys.stdout.flush() 58 | except socket.timeout: 59 | pass 60 | if sys.stdin in r: 61 | x = sys.stdin.read(1) 62 | if len(x) == 0: 63 | break 64 | chan.send(x) 65 | 66 | finally: 67 | termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldtty) 68 | 69 | 70 | # thanks to Mike Looijmans for this code 71 | def windows_shell(chan): 72 | import threading 73 | 74 | sys.stdout.write("Line-buffered terminal emulation. Press F6 or ^Z to send EOF.\r\n\r\n") 75 | 76 | def writeall(sock): 77 | while True: 78 | data = sock.recv(256) 79 | if not data: 80 | sys.stdout.write('\r\n*** EOF ***\r\n\r\n') 81 | sys.stdout.flush() 82 | break 83 | sys.stdout.write(data) 84 | sys.stdout.flush() 85 | 86 | writer = threading.Thread(target=writeall, args=(chan,)) 87 | writer.start() 88 | 89 | try: 90 | while True: 91 | d = sys.stdin.read(1) 92 | if not d: 93 | break 94 | chan.send(d) 95 | except EOFError: 96 | # user hit ^Z or F6 97 | pass 98 | -------------------------------------------------------------------------------- /boto/mturk/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | 24 | -------------------------------------------------------------------------------- /boto/mturk/price.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class Price: 23 | 24 | def __init__(self, amount=0.0, currency_code='USD'): 25 | self.amount = amount 26 | self.currency_code = currency_code 27 | self.formatted_price = '' 28 | 29 | def __repr__(self): 30 | if self.formatted_price: 31 | return self.formatted_price 32 | else: 33 | return str(self.amount) 34 | 35 | def startElement(self, name, attrs, connection): 36 | return None 37 | 38 | def endElement(self, name, value, connection): 39 | if name == 'Amount': 40 | self.amount = float(value) 41 | elif name == 'CurrencyCode': 42 | self.currency_code = value 43 | elif name == 'FormattedPrice': 44 | self.formatted_price = value 45 | 46 | def get_as_params(self, label, ord=1): 47 | return {'%s.%d.Amount'%(label, ord) : str(self.amount), 48 | '%s.%d.CurrencyCode'%(label, ord) : self.currency_code} 49 | -------------------------------------------------------------------------------- /boto/mturk/test/.gitignore: -------------------------------------------------------------------------------- 1 | local.py 2 | -------------------------------------------------------------------------------- /boto/mturk/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyuu/botornado/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/mturk/test/__init__.py -------------------------------------------------------------------------------- /boto/mturk/test/_init_environment.py: -------------------------------------------------------------------------------- 1 | import os 2 | import functools 3 | 4 | live_connection = False 5 | mturk_host = 'mechanicalturk.sandbox.amazonaws.com' 6 | external_url = 'http://www.example.com/' 7 | 8 | try: 9 | local = os.path.join(os.path.dirname(__file__), 'local.py') 10 | execfile(local) 11 | except: 12 | pass 13 | 14 | if live_connection: 15 | #TODO: you must set the auth credentials to something valid 16 | from boto.mturk.connection import MTurkConnection 17 | else: 18 | # Here the credentials must be set, but it doesn't matter what 19 | # they're set to. 20 | os.environ.setdefault('AWS_ACCESS_KEY_ID', 'foo') 21 | os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'bar') 22 | from mocks import MTurkConnection 23 | 24 | SetHostMTurkConnection = functools.partial(MTurkConnection, host=mturk_host) 25 | -------------------------------------------------------------------------------- /boto/mturk/test/all_tests.py: -------------------------------------------------------------------------------- 1 | 2 | import unittest 3 | import doctest 4 | from glob import glob 5 | 6 | from create_hit_test import * 7 | from create_hit_with_qualifications import * 8 | from create_hit_external import * 9 | from create_hit_with_qualifications import * 10 | from hit_persistence import * 11 | 12 | doctest_suite = doctest.DocFileSuite( 13 | *glob('*.doctest'), 14 | optionflags=doctest.REPORT_ONLY_FIRST_FAILURE 15 | ) 16 | 17 | class Program(unittest.TestProgram): 18 | def runTests(self, *args, **kwargs): 19 | self.test = unittest.TestSuite([self.test, doctest_suite]) 20 | super(Program, self).runTests(*args, **kwargs) 21 | 22 | if __name__ == '__main__': 23 | Program() 24 | 25 | -------------------------------------------------------------------------------- /boto/mturk/test/cleanup_tests.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | 3 | from _init_environment import SetHostMTurkConnection 4 | 5 | def description_filter(substring): 6 | return lambda hit: substring in hit.Title 7 | 8 | def disable_hit(hit): 9 | return conn.disable_hit(hit.HITId) 10 | 11 | def dispose_hit(hit): 12 | # assignments must be first approved or rejected 13 | for assignment in conn.get_assignments(hit.HITId): 14 | if assignment.AssignmentStatus == 'Submitted': 15 | conn.approve_assignment(assignment.AssignmentId) 16 | return conn.dispose_hit(hit.HITId) 17 | 18 | def cleanup(): 19 | """Remove any boto test related HIT's""" 20 | 21 | global conn 22 | 23 | conn = SetHostMTurkConnection() 24 | 25 | 26 | is_boto = description_filter('Boto') 27 | print 'getting hits...' 28 | all_hits = list(conn.get_all_hits()) 29 | is_reviewable = lambda hit: hit.HITStatus == 'Reviewable' 30 | is_not_reviewable = lambda hit: not is_reviewable(hit) 31 | hits_to_process = filter(is_boto, all_hits) 32 | hits_to_disable = filter(is_not_reviewable, hits_to_process) 33 | hits_to_dispose = filter(is_reviewable, hits_to_process) 34 | print 'disabling/disposing %d/%d hits' % (len(hits_to_disable), len(hits_to_dispose)) 35 | map(disable_hit, hits_to_disable) 36 | map(dispose_hit, hits_to_dispose) 37 | 38 | total_hits = len(all_hits) 39 | hits_processed = len(hits_to_process) 40 | skipped = total_hits - hits_processed 41 | fmt = 'Processed: %(total_hits)d HITs, disabled/disposed: %(hits_processed)d, skipped: %(skipped)d' 42 | print fmt % vars() 43 | 44 | if __name__ == '__main__': 45 | cleanup() 46 | -------------------------------------------------------------------------------- /boto/mturk/test/common.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import uuid 3 | import datetime 4 | 5 | from boto.mturk.question import ( 6 | Question, QuestionContent, AnswerSpecification, FreeTextAnswer, 7 | ) 8 | from _init_environment import SetHostMTurkConnection 9 | 10 | class MTurkCommon(unittest.TestCase): 11 | def setUp(self): 12 | self.conn = SetHostMTurkConnection() 13 | 14 | @staticmethod 15 | def get_question(): 16 | # create content for a question 17 | qn_content = QuestionContent() 18 | qn_content.append_field('Title', 'Boto no hit type question content') 19 | qn_content.append_field('Text', 'What is a boto no hit type?') 20 | 21 | # create the question specification 22 | qn = Question(identifier=str(uuid.uuid4()), 23 | content=qn_content, 24 | answer_spec=AnswerSpecification(FreeTextAnswer())) 25 | return qn 26 | 27 | @staticmethod 28 | def get_hit_params(): 29 | return dict( 30 | lifetime=datetime.timedelta(minutes=65), 31 | max_assignments=2, 32 | title='Boto create_hit title', 33 | description='Boto create_hit description', 34 | keywords=['boto', 'test'], 35 | reward=0.23, 36 | duration=datetime.timedelta(minutes=6), 37 | approval_delay=60*60, 38 | annotation='An annotation from boto create_hit test', 39 | response_groups=['Minimal', 40 | 'HITDetail', 41 | 'HITQuestion', 42 | 'HITAssignmentSummary',], 43 | ) 44 | 45 | -------------------------------------------------------------------------------- /boto/mturk/test/create_hit_external.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import uuid 3 | import datetime 4 | from boto.mturk.question import ExternalQuestion 5 | 6 | from _init_environment import SetHostMTurkConnection, external_url 7 | 8 | class Test(unittest.TestCase): 9 | def test_create_hit_external(self): 10 | q = ExternalQuestion(external_url=external_url, frame_height=800) 11 | conn = SetHostMTurkConnection() 12 | keywords=['boto', 'test', 'doctest'] 13 | create_hit_rs = conn.create_hit(question=q, lifetime=60*65,max_assignments=2,title="Boto External Question Test", keywords=keywords,reward = 0.05, duration=60*6,approval_delay=60*60, annotation='An annotation from boto external question test', response_groups=['Minimal','HITDetail','HITQuestion','HITAssignmentSummary',]) 14 | assert(create_hit_rs.status == True) 15 | 16 | if __name__ == "__main__": 17 | unittest.main() 18 | -------------------------------------------------------------------------------- /boto/mturk/test/create_hit_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from boto.mturk.question import QuestionForm 4 | 5 | from common import MTurkCommon 6 | 7 | class TestHITCreation(MTurkCommon): 8 | def testCallCreateHitWithOneQuestion(self): 9 | create_hit_rs = self.conn.create_hit( 10 | question=self.get_question(), 11 | **self.get_hit_params() 12 | ) 13 | 14 | def testCallCreateHitWithQuestionForm(self): 15 | create_hit_rs = self.conn.create_hit( 16 | questions=QuestionForm([self.get_question()]), 17 | **self.get_hit_params() 18 | ) 19 | 20 | if __name__ == '__main__': 21 | unittest.main() 22 | -------------------------------------------------------------------------------- /boto/mturk/test/create_hit_with_qualifications.py: -------------------------------------------------------------------------------- 1 | from boto.mturk.connection import MTurkConnection 2 | from boto.mturk.question import ExternalQuestion 3 | from boto.mturk.qualification import Qualifications, PercentAssignmentsApprovedRequirement 4 | 5 | def test(): 6 | q = ExternalQuestion(external_url="http://websort.net/s/F3481C", frame_height=800) 7 | conn = MTurkConnection(host='mechanicalturk.sandbox.amazonaws.com') 8 | keywords=['boto', 'test', 'doctest'] 9 | qualifications = Qualifications() 10 | qualifications.add(PercentAssignmentsApprovedRequirement(comparator="GreaterThan", integer_value="95")) 11 | create_hit_rs = conn.create_hit(question=q, lifetime=60*65,max_assignments=2,title="Boto External Question Test", keywords=keywords,reward = 0.05, duration=60*6,approval_delay=60*60, annotation='An annotation from boto external question test', qualifications=qualifications) 12 | assert(create_hit_rs.status == True) 13 | print create_hit_rs.HITTypeId 14 | 15 | if __name__ == "__main__": 16 | test() 17 | -------------------------------------------------------------------------------- /boto/mturk/test/hit_persistence.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pickle 3 | 4 | from common import MTurkCommon 5 | 6 | class TestHITPersistence(MTurkCommon): 7 | def create_hit_result(self): 8 | return self.conn.create_hit( 9 | question=self.get_question(), **self.get_hit_params() 10 | ) 11 | 12 | def test_pickle_hit_result(self): 13 | result = self.create_hit_result() 14 | new_result = pickle.loads(pickle.dumps(result)) 15 | 16 | def test_pickle_deserialized_version(self): 17 | """ 18 | It seems the technique used to store and reload the object must 19 | result in an equivalent object, or subsequent pickles may fail. 20 | This tests a double-pickle to elicit that error. 21 | """ 22 | result = self.create_hit_result() 23 | new_result = pickle.loads(pickle.dumps(result)) 24 | pickle.dumps(new_result) 25 | 26 | if __name__ == '__main__': 27 | unittest.main() 28 | -------------------------------------------------------------------------------- /boto/mturk/test/mocks.py: -------------------------------------------------------------------------------- 1 | from boto.mturk.connection import MTurkConnection as RealMTurkConnection 2 | 3 | class MTurkConnection(RealMTurkConnection): 4 | """ 5 | Mock MTurkConnection that doesn't connect, but instead just prepares 6 | the request and captures information about its usage. 7 | """ 8 | 9 | def _process_request(self, *args, **kwargs): 10 | saved_args = self.__dict__.setdefault('_mock_saved_args', dict()) 11 | saved_args['_process_request'] = (args, kwargs) 12 | -------------------------------------------------------------------------------- /boto/mturk/test/run-doctest.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import argparse 4 | import doctest 5 | 6 | parser = argparse.ArgumentParser( 7 | description="Run a test by name" 8 | ) 9 | parser.add_argument('test_name') 10 | args = parser.parse_args() 11 | 12 | doctest.testfile( 13 | args.test_name, 14 | optionflags=doctest.REPORT_ONLY_FIRST_FAILURE 15 | ) -------------------------------------------------------------------------------- /boto/mturk/test/search_hits.doctest: -------------------------------------------------------------------------------- 1 | >>> from _init_environment import MTurkConnection, mturk_host 2 | >>> conn = MTurkConnection(host=mturk_host) 3 | 4 | # should have some HIT's returned by a search (but only if your account has existing HIT's) 5 | >>> search_rs = conn.search_hits() 6 | 7 | # this is a valid request 8 | >>> search_rs.status 9 | True 10 | 11 | >>> len(search_rs) > 1 12 | True 13 | 14 | >>> search_rs # doctest: +ELLIPSIS 15 | [= (2,7): 6 | import unittest 7 | else: 8 | import unittest2 as unittest 9 | -------------------------------------------------------------------------------- /boto/mturk/test/test_disable_hit.py: -------------------------------------------------------------------------------- 1 | from boto.mturk.test.support import unittest 2 | 3 | from common import MTurkCommon 4 | from boto.mturk.connection import MTurkRequestError 5 | 6 | class TestDisableHITs(MTurkCommon): 7 | def test_disable_invalid_hit(self): 8 | self.assertRaises(MTurkRequestError, self.conn.disable_hit, 'foo') 9 | 10 | if __name__ == '__main__': 11 | unittest.main() 12 | -------------------------------------------------------------------------------- /boto/plugin.py: -------------------------------------------------------------------------------- 1 | # Copyright 2010 Google Inc. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | 23 | """ 24 | Implements plugin related api. 25 | 26 | To define a new plugin just subclass Plugin, like this. 27 | 28 | class AuthPlugin(Plugin): 29 | pass 30 | 31 | Then start creating subclasses of your new plugin. 32 | 33 | class MyFancyAuth(AuthPlugin): 34 | capability = ['sign', 'vmac'] 35 | 36 | The actual interface is duck typed. 37 | 38 | """ 39 | 40 | import glob 41 | import imp, os.path 42 | 43 | class Plugin(object): 44 | """Base class for all plugins.""" 45 | 46 | capability = [] 47 | 48 | @classmethod 49 | def is_capable(cls, requested_capability): 50 | """Returns true if the requested capability is supported by this plugin 51 | """ 52 | for c in requested_capability: 53 | if not c in cls.capability: 54 | return False 55 | return True 56 | 57 | def get_plugin(cls, requested_capability=None): 58 | if not requested_capability: 59 | requested_capability = [] 60 | result = [] 61 | for handler in cls.__subclasses__(): 62 | if handler.is_capable(requested_capability): 63 | result.append(handler) 64 | return result 65 | 66 | def _import_module(filename): 67 | (path, name) = os.path.split(filename) 68 | (name, ext) = os.path.splitext(name) 69 | 70 | (file, filename, data) = imp.find_module(name, [path]) 71 | try: 72 | return imp.load_module(name, file, filename, data) 73 | finally: 74 | if file: 75 | file.close() 76 | 77 | _plugin_loaded = False 78 | 79 | def load_plugins(config): 80 | global _plugin_loaded 81 | if _plugin_loaded: 82 | return 83 | _plugin_loaded = True 84 | 85 | if not config.has_option('Plugin', 'plugin_directory'): 86 | return 87 | directory = config.get('Plugin', 'plugin_directory') 88 | for file in glob.glob(os.path.join(directory, '*.py')): 89 | _import_module(file) 90 | 91 | -------------------------------------------------------------------------------- /boto/pyami/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | -------------------------------------------------------------------------------- /boto/pyami/copybot.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Your AWS Credentials 3 | # 4 | [Credentials] 5 | aws_access_key_id = 6 | aws_secret_access_key = 7 | 8 | # 9 | # If you want to use a separate set of credentials when writing 10 | # to the destination bucket, put them here 11 | #dest_aws_access_key_id = 12 | #dest_aws_secret_access_key = 13 | 14 | # 15 | # Fill out this section if you want emails from CopyBot 16 | # when it starts and stops 17 | # 18 | [Notification] 19 | #smtp_host = 20 | #smtp_user = 21 | #smtp_pass = 22 | #smtp_from = 23 | #smtp_to = 24 | 25 | # 26 | # If you leave this section as is, it will automatically 27 | # update boto from subversion upon start up. 28 | # If you don't want that to happen, comment this out 29 | # 30 | [Boto] 31 | boto_location = /usr/local/boto 32 | boto_update = svn:HEAD 33 | 34 | # 35 | # This tells the Pyami code in boto what scripts 36 | # to run during startup 37 | # 38 | [Pyami] 39 | scripts = boto.pyami.copybot.CopyBot 40 | 41 | # 42 | # Source bucket and Destination Bucket, obviously. 43 | # If the Destination bucket does not exist, it will 44 | # attempt to create it. 45 | # If exit_on_completion is false, the instance 46 | # will keep running after the copy operation is 47 | # complete which might be handy for debugging. 48 | # If copy_acls is false, the ACL's will not be 49 | # copied with the objects to the new bucket. 50 | # If replace_dst is false, copybot will not 51 | # will only store the source file in the dest if 52 | # that file does not already exist. If it's true 53 | # it will replace it even if it does exist. 54 | # 55 | [CopyBot] 56 | src_bucket = 57 | dst_bucket = 58 | exit_on_completion = true 59 | copy_acls = true 60 | replace_dst = true 61 | -------------------------------------------------------------------------------- /boto/pyami/helloworld.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | from boto.pyami.scriptbase import ScriptBase 23 | 24 | class HelloWorld(ScriptBase): 25 | 26 | def main(self): 27 | self.log('Hello World!!!') 28 | 29 | -------------------------------------------------------------------------------- /boto/pyami/installers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | from boto.pyami.scriptbase import ScriptBase 23 | 24 | 25 | class Installer(ScriptBase): 26 | """ 27 | Abstract base class for installers 28 | """ 29 | 30 | def add_cron(self, name, minute, hour, mday, month, wday, who, command, env=None): 31 | """ 32 | Add an entry to the system crontab. 33 | """ 34 | raise NotImplementedError 35 | 36 | def add_init_script(self, file): 37 | """ 38 | Add this file to the init.d directory 39 | """ 40 | 41 | def add_env(self, key, value): 42 | """ 43 | Add an environemnt variable 44 | """ 45 | raise NotImplementedError 46 | 47 | def stop(self, service_name): 48 | """ 49 | Stop a service. 50 | """ 51 | raise NotImplementedError 52 | 53 | def start(self, service_name): 54 | """ 55 | Start a service. 56 | """ 57 | raise NotImplementedError 58 | 59 | def install(self): 60 | """ 61 | Do whatever is necessary to "install" the package. 62 | """ 63 | raise NotImplementedError 64 | 65 | -------------------------------------------------------------------------------- /boto/pyami/installers/ubuntu/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | -------------------------------------------------------------------------------- /boto/pyami/installers/ubuntu/apache.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2008 Chris Moyer http://coredumped.org 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | from boto.pyami.installers.ubuntu.installer import Installer 23 | 24 | class Apache(Installer): 25 | """ 26 | Install apache2, mod_python, and libapache2-svn 27 | """ 28 | 29 | def install(self): 30 | self.run("apt-get update") 31 | self.run('apt-get -y install apache2', notify=True, exit_on_error=True) 32 | self.run('apt-get -y install libapache2-mod-python', notify=True, exit_on_error=True) 33 | self.run('a2enmod rewrite', notify=True, exit_on_error=True) 34 | self.run('a2enmod ssl', notify=True, exit_on_error=True) 35 | self.run('a2enmod proxy', notify=True, exit_on_error=True) 36 | self.run('a2enmod proxy_ajp', notify=True, exit_on_error=True) 37 | 38 | # Hard reboot the apache2 server to enable these module 39 | self.stop("apache2") 40 | self.start("apache2") 41 | 42 | def main(self): 43 | self.install() 44 | -------------------------------------------------------------------------------- /boto/pyami/scriptbase.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from boto.utils import ShellCommand, get_ts 4 | import boto 5 | import boto.utils 6 | 7 | class ScriptBase: 8 | 9 | def __init__(self, config_file=None): 10 | self.instance_id = boto.config.get('Instance', 'instance-id', 'default') 11 | self.name = self.__class__.__name__ 12 | self.ts = get_ts() 13 | if config_file: 14 | boto.config.read(config_file) 15 | 16 | def notify(self, subject, body=''): 17 | boto.utils.notify(subject, body) 18 | 19 | def mkdir(self, path): 20 | if not os.path.isdir(path): 21 | try: 22 | os.mkdir(path) 23 | except: 24 | boto.log.error('Error creating directory: %s' % path) 25 | 26 | def umount(self, path): 27 | if os.path.ismount(path): 28 | self.run('umount %s' % path) 29 | 30 | def run(self, command, notify=True, exit_on_error=False, cwd=None): 31 | self.last_command = ShellCommand(command, cwd=cwd) 32 | if self.last_command.status != 0: 33 | boto.log.error('Error running command: "%s". Output: "%s"' % (command, self.last_command.output)) 34 | if notify: 35 | self.notify('Error encountered', \ 36 | 'Error running the following command:\n\t%s\n\nCommand output:\n\t%s' % \ 37 | (command, self.last_command.output)) 38 | if exit_on_error: 39 | sys.exit(-1) 40 | return self.last_command.status 41 | 42 | def main(self): 43 | pass 44 | 45 | -------------------------------------------------------------------------------- /boto/pyami/startup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | import sys 23 | import boto 24 | from boto.utils import find_class 25 | from boto import config 26 | from boto.pyami.scriptbase import ScriptBase 27 | 28 | 29 | class Startup(ScriptBase): 30 | 31 | def run_scripts(self): 32 | scripts = config.get('Pyami', 'scripts') 33 | if scripts: 34 | for script in scripts.split(','): 35 | script = script.strip(" ") 36 | try: 37 | pos = script.rfind('.') 38 | if pos > 0: 39 | mod_name = script[0:pos] 40 | cls_name = script[pos+1:] 41 | cls = find_class(mod_name, cls_name) 42 | boto.log.info('Running Script: %s' % script) 43 | s = cls() 44 | s.main() 45 | else: 46 | boto.log.warning('Trouble parsing script: %s' % script) 47 | except Exception, e: 48 | boto.log.exception('Problem Running Script: %s. Startup process halting.' % script) 49 | raise e 50 | 51 | def main(self): 52 | self.run_scripts() 53 | self.notify('Startup Completed for %s' % config.get('Instance', 'instance-id')) 54 | 55 | if __name__ == "__main__": 56 | if not config.has_section('loggers'): 57 | boto.set_file_logger('startup', '/var/log/boto.log') 58 | sys.path.append(config.get('Pyami', 'working_dir')) 59 | su = Startup() 60 | su.main() 61 | -------------------------------------------------------------------------------- /boto/rds/dbsnapshot.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class DBSnapshot(object): 23 | """ 24 | Represents a RDS DB Snapshot 25 | """ 26 | 27 | def __init__(self, connection=None, id=None): 28 | self.connection = connection 29 | self.id = id 30 | self.engine = None 31 | self.snapshot_create_time = None 32 | self.instance_create_time = None 33 | self.port = None 34 | self.status = None 35 | self.availability_zone = None 36 | self.master_username = None 37 | self.allocated_storage = None 38 | self.instance_id = None 39 | self.availability_zone = None 40 | 41 | def __repr__(self): 42 | return 'DBSnapshot:%s' % self.id 43 | 44 | def startElement(self, name, attrs, connection): 45 | pass 46 | 47 | def endElement(self, name, value, connection): 48 | if name == 'Engine': 49 | self.engine = value 50 | elif name == 'InstanceCreateTime': 51 | self.instance_create_time = value 52 | elif name == 'SnapshotCreateTime': 53 | self.snapshot_create_time = value 54 | elif name == 'DBInstanceIdentifier': 55 | self.instance_id = value 56 | elif name == 'DBSnapshotIdentifier': 57 | self.id = value 58 | elif name == 'Port': 59 | self.port = int(value) 60 | elif name == 'Status': 61 | self.status = value 62 | elif name == 'AvailabilityZone': 63 | self.availability_zone = value 64 | elif name == 'MasterUsername': 65 | self.master_username = value 66 | elif name == 'AllocatedStorage': 67 | self.allocated_storage = int(value) 68 | elif name == 'SnapshotTime': 69 | self.time = value 70 | else: 71 | setattr(self, name, value) 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /boto/rds/event.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class Event(object): 23 | 24 | def __init__(self, connection=None): 25 | self.connection = connection 26 | self.message = None 27 | self.source_identifier = None 28 | self.source_type = None 29 | self.engine = None 30 | self.date = None 31 | 32 | def __repr__(self): 33 | return '"%s"' % self.message 34 | 35 | def startElement(self, name, attrs, connection): 36 | pass 37 | 38 | def endElement(self, name, value, connection): 39 | if name == 'SourceIdentifier': 40 | self.source_identifier = value 41 | elif name == 'SourceType': 42 | self.source_type = value 43 | elif name == 'Message': 44 | self.message = value 45 | elif name == 'Date': 46 | self.date = value 47 | else: 48 | setattr(self, name, value) 49 | 50 | -------------------------------------------------------------------------------- /boto/rds/regioninfo.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | # 24 | 25 | from boto.regioninfo import RegionInfo 26 | 27 | class RDSRegionInfo(RegionInfo): 28 | 29 | def __init__(self, connection=None, name=None, endpoint=None): 30 | from boto.rds import RDSConnection 31 | RegionInfo.__init__(self, connection, name, endpoint, 32 | RDSConnection) 33 | -------------------------------------------------------------------------------- /boto/regioninfo.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | 24 | class RegionInfo(object): 25 | """ 26 | Represents an AWS Region 27 | """ 28 | 29 | def __init__(self, connection=None, name=None, endpoint=None, 30 | connection_cls=None): 31 | self.connection = connection 32 | self.name = name 33 | self.endpoint = endpoint 34 | self.connection_cls = connection_cls 35 | 36 | def __repr__(self): 37 | return 'RegionInfo:%s' % self.name 38 | 39 | def startElement(self, name, attrs, connection): 40 | return None 41 | 42 | def endElement(self, name, value, connection): 43 | if name == 'regionName': 44 | self.name = value 45 | elif name == 'regionEndpoint': 46 | self.endpoint = value 47 | else: 48 | setattr(self, name, value) 49 | 50 | def connect(self, **kw_params): 51 | """ 52 | Connect to this Region's endpoint. Returns an connection 53 | object pointing to the endpoint associated with this region. 54 | You may pass any of the arguments accepted by the connection 55 | class's constructor as keyword arguments and they will be 56 | passed along to the connection object. 57 | 58 | :rtype: Connection object 59 | :return: The connection to this regions endpoint 60 | """ 61 | if self.connection_cls: 62 | return self.connection_cls(region=self, **kw_params) 63 | 64 | 65 | -------------------------------------------------------------------------------- /boto/roboto/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /boto/route53/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | # 23 | 24 | # this is here for backward compatibility 25 | # originally, the Route53Connection class was defined here 26 | from connection import Route53Connection 27 | -------------------------------------------------------------------------------- /boto/route53/exception.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | 23 | from boto.exception import BotoServerError 24 | 25 | class DNSServerError(BotoServerError): 26 | 27 | pass 28 | -------------------------------------------------------------------------------- /boto/route53/hostedzone.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | # 24 | 25 | class HostedZone(object): 26 | 27 | def __init__(self, id=None, name=None, owner=None, version=None, 28 | caller_reference=None, config=None): 29 | self.id = id 30 | self.name = name 31 | self.owner = owner 32 | self.version = version 33 | self.caller_reference = caller_reference 34 | self.config = config 35 | 36 | def startElement(self, name, attrs, connection): 37 | if name == 'Config': 38 | self.config = Config() 39 | return self.config 40 | else: 41 | return None 42 | 43 | def endElement(self, name, value, connection): 44 | if name == 'Id': 45 | self.id = value 46 | elif name == 'Name': 47 | self.name = value 48 | elif name == 'Owner': 49 | self.owner = value 50 | elif name == 'Version': 51 | self.version = value 52 | elif name == 'CallerReference': 53 | self.caller_reference = value 54 | else: 55 | setattr(self, name, value) 56 | 57 | -------------------------------------------------------------------------------- /boto/s3/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | # 24 | 25 | -------------------------------------------------------------------------------- /boto/s3/deletemarker.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | from boto.s3.user import User 23 | 24 | class DeleteMarker: 25 | def __init__(self, bucket=None, name=None): 26 | self.bucket = bucket 27 | self.name = name 28 | self.version_id = None 29 | self.is_latest = False 30 | self.last_modified = None 31 | self.owner = None 32 | 33 | def startElement(self, name, attrs, connection): 34 | if name == 'Owner': 35 | self.owner = User(self) 36 | return self.owner 37 | else: 38 | return None 39 | 40 | def endElement(self, name, value, connection): 41 | if name == 'Key': 42 | self.name = value 43 | elif name == 'IsLatest': 44 | if value == 'true': 45 | self.is_latest = True 46 | else: 47 | self.is_latest = False 48 | elif name == 'LastModified': 49 | self.last_modified = value 50 | elif name == 'Owner': 51 | pass 52 | elif name == 'VersionId': 53 | self.version_id = value 54 | else: 55 | setattr(self, name, value) 56 | 57 | 58 | -------------------------------------------------------------------------------- /boto/s3/object_hooks.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | 24 | import xml.sax 25 | import urllib, base64 26 | import time 27 | import boto.utils 28 | from boto.connection import AWSAuthConnection 29 | from boto import handler 30 | from boto.s3.bucket import Bucket 31 | from boto.s3.key import Key 32 | from boto.resultset import ResultSet 33 | from boto.exception import BotoClientError 34 | 35 | ## connection.py 36 | def get_all_buckets_hook(body): 37 | rs = ResultSet([('Bucket', self.bucket_class)]) 38 | h = handler.XmlHandler(rs, self) 39 | xml.sax.parseString(body, h) 40 | return rs 41 | 42 | 43 | ## bucket.py 44 | def _get_all(element_map, initial_query_string='', 45 | headers=None, **params): 46 | l = [] 47 | for k, v in params.items(): 48 | k = k.replace('_', '-') 49 | if k == 'maxkeys': 50 | k = 'max-keys' 51 | if isinstance(v, unicode): 52 | v = v.encode('utf-8') 53 | if v is not None and v != '': 54 | l.append('%s=%s' % (urllib.quote(k), urllib.quote(str(v)))) 55 | if len(l): 56 | s = initial_query_string + '&' + '&'.join(l) 57 | else: 58 | s = initial_query_string 59 | response = self.connection.make_request('GET', self.name, 60 | headers=headers, 61 | query_args=s) 62 | body = response.read() 63 | boto.log.debug(body) 64 | if response.status == 200: 65 | rs = ResultSet(element_map) 66 | h = handler.XmlHandler(rs, self) 67 | xml.sax.parseString(body, h) 68 | return rs 69 | else: 70 | raise self.connection.provider.storage_response_error( 71 | response.status, response.reason, body) 72 | 73 | def get_all_hook(body): 74 | boto.log.debug(body) 75 | rs = ResultSet(element_map) 76 | h = handler.XmlHandler(rs, self) 77 | xml.sax.parseString(body, h) 78 | return rs 79 | 80 | 81 | -------------------------------------------------------------------------------- /boto/s3/prefix.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class Prefix(object): 23 | def __init__(self, bucket=None, name=None): 24 | self.bucket = bucket 25 | self.name = name 26 | 27 | def startElement(self, name, attrs, connection): 28 | return None 29 | 30 | def endElement(self, name, value, connection): 31 | if name == 'Prefix': 32 | self.name = value 33 | else: 34 | setattr(self, name, value) 35 | 36 | -------------------------------------------------------------------------------- /boto/s3/user.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class User: 23 | def __init__(self, parent=None, id='', display_name=''): 24 | if parent: 25 | parent.owner = self 26 | self.type = None 27 | self.id = id 28 | self.display_name = display_name 29 | 30 | def startElement(self, name, attrs, connection): 31 | return None 32 | 33 | def endElement(self, name, value, connection): 34 | if name == 'DisplayName': 35 | self.display_name = value 36 | elif name == 'ID': 37 | self.id = value 38 | else: 39 | setattr(self, name, value) 40 | 41 | def to_xml(self, element_name='Owner'): 42 | if self.type: 43 | s = '<%s xsi:type="%s">' % (element_name, self.type) 44 | else: 45 | s = '<%s>' % element_name 46 | s += '%s' % self.id 47 | s += '%s' % self.display_name 48 | s += '' % element_name 49 | return s 50 | -------------------------------------------------------------------------------- /boto/sdb/db/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /boto/sdb/db/blob.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | 23 | class Blob(object): 24 | """Blob object""" 25 | def __init__(self, value=None, file=None, id=None): 26 | self._file = file 27 | self.id = id 28 | self.value = value 29 | 30 | @property 31 | def file(self): 32 | from StringIO import StringIO 33 | if self._file: 34 | f = self._file 35 | else: 36 | f = StringIO(self.value) 37 | return f 38 | 39 | def __str__(self): 40 | return unicode(self).encode('utf-8') 41 | 42 | def __unicode__(self): 43 | if hasattr(self.file, "get_contents_as_string"): 44 | value = self.file.get_contents_as_string() 45 | else: 46 | value = self.file.getvalue() 47 | if isinstance(value, unicode): 48 | return value 49 | else: 50 | return value.decode('utf-8') 51 | 52 | 53 | def read(self): 54 | if hasattr(self.file, "get_contents_as_string"): 55 | return self.file.get_contents_as_string() 56 | else: 57 | return self.file.read() 58 | 59 | def readline(self): 60 | return self.file.readline() 61 | 62 | def next(self): 63 | return self.file.next() 64 | 65 | def __iter__(self): 66 | return iter(self.file) 67 | 68 | @property 69 | def size(self): 70 | if self._file: 71 | return self._file.size 72 | elif self.value: 73 | return len(self.value) 74 | else: 75 | return 0 76 | -------------------------------------------------------------------------------- /boto/sdb/db/key.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | class Key(object): 23 | 24 | @classmethod 25 | def from_path(cls, *args, **kwds): 26 | raise NotImplementedError, "Paths are not currently supported" 27 | 28 | def __init__(self, encoded=None, obj=None): 29 | self.name = None 30 | if obj: 31 | self.id = obj.id 32 | self.kind = obj.kind() 33 | else: 34 | self.id = None 35 | self.kind = None 36 | 37 | def app(self): 38 | raise NotImplementedError, "Applications are not currently supported" 39 | 40 | def kind(self): 41 | return self.kind 42 | 43 | def id(self): 44 | return self.id 45 | 46 | def name(self): 47 | raise NotImplementedError, "Key Names are not currently supported" 48 | 49 | def id_or_name(self): 50 | return self.id 51 | 52 | def has_id_or_name(self): 53 | return self.id != None 54 | 55 | def parent(self): 56 | raise NotImplementedError, "Key parents are not currently supported" 57 | 58 | def __str__(self): 59 | return self.id_or_name() 60 | -------------------------------------------------------------------------------- /boto/sdb/regioninfo.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | # 24 | 25 | from boto.regioninfo import RegionInfo 26 | 27 | class SDBRegionInfo(RegionInfo): 28 | 29 | def __init__(self, connection=None, name=None, endpoint=None): 30 | from boto.sdb.connection import SDBConnection 31 | RegionInfo.__init__(self, connection, name, endpoint, 32 | SDBConnection) 33 | -------------------------------------------------------------------------------- /boto/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | 24 | -------------------------------------------------------------------------------- /boto/services/message.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | from boto.sqs.message import MHMessage 23 | from boto.utils import get_ts 24 | from socket import gethostname 25 | import os, mimetypes, time 26 | 27 | class ServiceMessage(MHMessage): 28 | 29 | def for_key(self, key, params=None, bucket_name=None): 30 | if params: 31 | self.update(params) 32 | if key.path: 33 | t = os.path.split(key.path) 34 | self['OriginalLocation'] = t[0] 35 | self['OriginalFileName'] = t[1] 36 | mime_type = mimetypes.guess_type(t[1])[0] 37 | if mime_type == None: 38 | mime_type = 'application/octet-stream' 39 | self['Content-Type'] = mime_type 40 | s = os.stat(key.path) 41 | t = time.gmtime(s[7]) 42 | self['FileAccessedDate'] = get_ts(t) 43 | t = time.gmtime(s[8]) 44 | self['FileModifiedDate'] = get_ts(t) 45 | t = time.gmtime(s[9]) 46 | self['FileCreateDate'] = get_ts(t) 47 | else: 48 | self['OriginalFileName'] = key.name 49 | self['OriginalLocation'] = key.bucket.name 50 | self['ContentType'] = key.content_type 51 | self['Host'] = gethostname() 52 | if bucket_name: 53 | self['Bucket'] = bucket_name 54 | else: 55 | self['Bucket'] = key.bucket.name 56 | self['InputKey'] = key.name 57 | self['Size'] = key.size 58 | 59 | -------------------------------------------------------------------------------- /boto/services/sonofmmm.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Your AWS Credentials 3 | # You only need to supply these in this file if you are not using 4 | # the boto tools to start your service 5 | # 6 | #[Credentials] 7 | #aws_access_key_id = 8 | #aws_secret_access_key = 9 | 10 | # 11 | # Fill out this section if you want emails from the service 12 | # when it starts and stops 13 | # 14 | #[Notification] 15 | #smtp_host = 16 | #smtp_user = 17 | #smtp_pass = 18 | #smtp_from = 19 | #smtp_to = 20 | 21 | [Pyami] 22 | scripts = boto.services.sonofmmm.SonOfMMM 23 | 24 | [SonOfMMM] 25 | # id of the AMI to be launched 26 | ami_id = ami-dc799cb5 27 | # number of times service will read an empty queue before exiting 28 | # a negative value will cause the service to run forever 29 | retry_count = 5 30 | # seconds to wait after empty queue read before reading again 31 | loop_delay = 10 32 | # average time it takes to process a transaction 33 | # controls invisibility timeout of messages 34 | processing_time = 60 35 | ffmpeg_args = -y -i %%s -f mov -r 29.97 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -ar 48000 -ab 19200 -s 320x240 -vcodec mpeg4 -acodec libfaac %%s 36 | output_mimetype = video/quicktime 37 | output_ext = .mov 38 | input_bucket = 39 | output_bucket = 40 | output_domain = 41 | output_queue = 42 | input_queue = 43 | 44 | -------------------------------------------------------------------------------- /boto/ses/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2011 Harry Marr http://hmarr.com/ 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | 23 | from connection import SESConnection 24 | from boto.regioninfo import RegionInfo 25 | 26 | def regions(): 27 | """ 28 | Get all available regions for the SES service. 29 | 30 | :rtype: list 31 | :return: A list of :class:`boto.regioninfo.RegionInfo` instances 32 | """ 33 | return [RegionInfo(name='us-east-1', 34 | endpoint='email.us-east-1.amazonaws.com', 35 | connection_cls=SESConnection)] 36 | 37 | def connect_to_region(region_name, **kw_params): 38 | """ 39 | Given a valid region name, return a 40 | :class:`boto.sns.connection.SESConnection`. 41 | 42 | :type: str 43 | :param region_name: The name of the region to connect to. 44 | 45 | :rtype: :class:`boto.sns.connection.SESConnection` or ``None`` 46 | :return: A connection to the given region, or None if an invalid region 47 | name is given 48 | """ 49 | for region in regions(): 50 | if region.name == region_name: 51 | return region.connect(**kw_params) 52 | return None 53 | 54 | def get_region(region_name, **kw_params): 55 | """ 56 | Find and return a :class:`boto.regioninfo.RegionInfo` object 57 | given a region name. 58 | 59 | :type: str 60 | :param: The name of the region. 61 | 62 | :rtype: :class:`boto.regioninfo.RegionInfo` 63 | :return: The RegionInfo object for the given region or None if 64 | an invalid region name is provided. 65 | """ 66 | for region in regions(**kw_params): 67 | if region.name == region_name: 68 | return region 69 | return None 70 | -------------------------------------------------------------------------------- /boto/ses/exceptions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Various exceptions that are specific to the SES module. 3 | """ 4 | from boto.exception import BotoServerError 5 | 6 | class SESAddressNotVerifiedError(BotoServerError): 7 | """ 8 | Raised when a "Reply-To" address has not been validated in SES yet. 9 | """ 10 | pass 11 | 12 | 13 | class SESAddressBlacklistedError(BotoServerError): 14 | """ 15 | After you attempt to send mail to an address, and delivery repeatedly 16 | fails, said address is blacklisted for at least 24 hours. The blacklisting 17 | eventually expires, and you are able to attempt delivery again. If you 18 | attempt to send mail to a blacklisted email, this is raised. 19 | """ 20 | pass 21 | 22 | 23 | class SESDailyQuotaExceededError(BotoServerError): 24 | """ 25 | Your account's daily (rolling 24 hour total) allotment of outbound emails 26 | has been exceeded. 27 | """ 28 | pass 29 | 30 | 31 | class SESMaxSendingRateExceededError(BotoServerError): 32 | """ 33 | Your account's requests/second limit has been exceeded. 34 | """ 35 | pass 36 | 37 | 38 | class SESDomainEndsWithDotError(BotoServerError): 39 | """ 40 | Recipient's email address' domain ends with a period/dot. 41 | """ 42 | pass -------------------------------------------------------------------------------- /boto/sqs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2011 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | # 22 | 23 | from regioninfo import SQSRegionInfo 24 | 25 | def regions(): 26 | """ 27 | Get all available regions for the SQS service. 28 | 29 | :rtype: list 30 | :return: A list of :class:`boto.ec2.regioninfo.RegionInfo` 31 | """ 32 | return [SQSRegionInfo(name='us-east-1', 33 | endpoint='sqs.us-east-1.amazonaws.com'), 34 | SQSRegionInfo(name='eu-west-1', 35 | endpoint='sqs.eu-west-1.amazonaws.com'), 36 | SQSRegionInfo(name='us-west-1', 37 | endpoint='sqs.us-west-1.amazonaws.com'), 38 | SQSRegionInfo(name='us-west-2', 39 | endpoint='sqs.us-west-2.amazonaws.com'), 40 | SQSRegionInfo(name='sa-east-1', 41 | endpoint='sqs.sa-east-1.amazonaws.com'), 42 | SQSRegionInfo(name='ap-northeast-1', 43 | endpoint='sqs.ap-northeast-1.amazonaws.com'), 44 | SQSRegionInfo(name='ap-southeast-1', 45 | endpoint='sqs.ap-southeast-1.amazonaws.com') 46 | ] 47 | 48 | def connect_to_region(region_name, **kw_params): 49 | for region in regions(): 50 | if region.name == region_name: 51 | return region.connect(**kw_params) 52 | return None 53 | -------------------------------------------------------------------------------- /boto/sqs/attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents an SQS Attribute Name/Value set 24 | """ 25 | 26 | class Attributes(dict): 27 | 28 | def __init__(self, parent): 29 | self.parent = parent 30 | self.current_key = None 31 | self.current_value = None 32 | 33 | def startElement(self, name, attrs, connection): 34 | pass 35 | 36 | def endElement(self, name, value, connection): 37 | if name == 'Attribute': 38 | self[self.current_key] = self.current_value 39 | elif name == 'Name': 40 | self.current_key = value 41 | elif name == 'Value': 42 | self.current_value = value 43 | else: 44 | setattr(self, name, value) 45 | 46 | 47 | -------------------------------------------------------------------------------- /boto/sqs/jsonmessage.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | from boto.sqs.message import MHMessage 23 | from boto.exception import SQSDecodeError 24 | import base64 25 | try: 26 | import simplejson as json 27 | except ImportError: 28 | import json 29 | 30 | class JSONMessage(MHMessage): 31 | """ 32 | Acts like a dictionary but encodes it's data as a Base64 encoded JSON payload. 33 | """ 34 | 35 | def decode(self, value): 36 | try: 37 | value = base64.b64decode(value) 38 | value = json.loads(value) 39 | except: 40 | raise SQSDecodeError('Unable to decode message', self) 41 | return value 42 | 43 | def encode(self, value): 44 | value = json.dumps(value) 45 | return base64.b64encode(value) 46 | -------------------------------------------------------------------------------- /boto/sqs/regioninfo.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 | # All rights reserved. 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a 6 | # copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, dis- 9 | # tribute, sublicense, and/or sell copies of the Software, and to permit 10 | # persons to whom the Software is furnished to do so, subject to the fol- 11 | # lowing conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included 14 | # in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 18 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | # 24 | 25 | from boto.regioninfo import RegionInfo 26 | 27 | class SQSRegionInfo(RegionInfo): 28 | 29 | def __init__(self, connection=None, name=None, endpoint=None): 30 | from boto.sqs.connection import SQSConnection 31 | RegionInfo.__init__(self, connection, name, endpoint, 32 | SQSConnection) 33 | -------------------------------------------------------------------------------- /boto/sts/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010-2011 Mitch Garnaat http://garnaat.org/ 2 | # Copyright (c) 2010-2011, Eucalyptus Systems, Inc. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a 5 | # copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, dis- 8 | # tribute, sublicense, and/or sell copies of the Software, and to permit 9 | # persons to whom the Software is furnished to do so, subject to the fol- 10 | # lowing conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included 13 | # in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | # IN THE SOFTWARE. 22 | 23 | from connection import STSConnection 24 | from boto.regioninfo import RegionInfo 25 | 26 | def regions(): 27 | """ 28 | Get all available regions for the STS service. 29 | 30 | :rtype: list 31 | :return: A list of :class:`boto.regioninfo.RegionInfo` instances 32 | """ 33 | return [RegionInfo(name='us-east-1', 34 | endpoint='sts.amazonaws.com', 35 | connection_cls=STSConnection) 36 | ] 37 | 38 | def connect_to_region(region_name, **kw_params): 39 | """ 40 | Given a valid region name, return a 41 | :class:`boto.sts.connection.STSConnection`. 42 | 43 | :type: str 44 | :param region_name: The name of the region to connect to. 45 | 46 | :rtype: :class:`boto.sts.connection.STSConnection` or ``None`` 47 | :return: A connection to the given region, or None if an invalid region 48 | name is given 49 | """ 50 | for region in regions(): 51 | if region.name == region_name: 52 | return region.connect(**kw_params) 53 | return None 54 | 55 | def get_region(region_name, **kw_params): 56 | """ 57 | Find and return a :class:`boto.regioninfo.RegionInfo` object 58 | given a region name. 59 | 60 | :type: str 61 | :param: The name of the region. 62 | 63 | :rtype: :class:`boto.regioninfo.RegionInfo` 64 | :return: The RegionInfo object for the given region or None if 65 | an invalid region name is provided. 66 | """ 67 | for region in regions(**kw_params): 68 | if region.name == region_name: 69 | return region 70 | return None 71 | -------------------------------------------------------------------------------- /boto/vpc/customergateway.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents a Customer Gateway 24 | """ 25 | 26 | from boto.ec2.ec2object import TaggedEC2Object 27 | 28 | class CustomerGateway(TaggedEC2Object): 29 | 30 | def __init__(self, connection=None): 31 | TaggedEC2Object.__init__(self, connection) 32 | self.id = None 33 | self.type = None 34 | self.state = None 35 | self.ip_address = None 36 | self.bgp_asn = None 37 | 38 | def __repr__(self): 39 | return 'CustomerGateway:%s' % self.id 40 | 41 | def endElement(self, name, value, connection): 42 | if name == 'customerGatewayId': 43 | self.id = value 44 | elif name == 'ipAddress': 45 | self.ip_address = value 46 | elif name == 'type': 47 | self.type = value 48 | elif name == 'state': 49 | self.state = value 50 | elif name == 'bgpAsn': 51 | self.bgp_asn = value 52 | else: 53 | setattr(self, name, value) 54 | 55 | -------------------------------------------------------------------------------- /boto/vpc/dhcpoptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents a DHCP Options set 24 | """ 25 | 26 | from boto.ec2.ec2object import TaggedEC2Object 27 | 28 | class DhcpValueSet(list): 29 | 30 | def startElement(self, name, attrs, connection): 31 | pass 32 | 33 | def endElement(self, name, value, connection): 34 | if name == 'value': 35 | self.append(value) 36 | 37 | class DhcpConfigSet(dict): 38 | 39 | def startElement(self, name, attrs, connection): 40 | if name == 'valueSet': 41 | if not self.has_key(self._name): 42 | self[self._name] = DhcpValueSet() 43 | return self[self._name] 44 | 45 | def endElement(self, name, value, connection): 46 | if name == 'key': 47 | self._name = value 48 | 49 | class DhcpOptions(TaggedEC2Object): 50 | 51 | def __init__(self, connection=None): 52 | TaggedEC2Object.__init__(self, connection) 53 | self.id = None 54 | self.options = None 55 | 56 | def __repr__(self): 57 | return 'DhcpOptions:%s' % self.id 58 | 59 | def startElement(self, name, attrs, connection): 60 | retval = TaggedEC2Object.startElement(self, name, attrs, connection) 61 | if retval is not None: 62 | return retval 63 | if name == 'dhcpConfigurationSet': 64 | self.options = DhcpConfigSet() 65 | return self.options 66 | 67 | def endElement(self, name, value, connection): 68 | if name == 'dhcpOptionsId': 69 | self.id = value 70 | else: 71 | setattr(self, name, value) 72 | 73 | -------------------------------------------------------------------------------- /boto/vpc/internetgateway.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents an Internet Gateway 24 | """ 25 | 26 | from boto.ec2.ec2object import TaggedEC2Object 27 | from boto.resultset import ResultSet 28 | 29 | class InternetGateway(TaggedEC2Object): 30 | def __init__(self, connection=None): 31 | TaggedEC2Object.__init__(self, connection) 32 | self.id = None 33 | self.attachments = [] 34 | 35 | def __repr__(self): 36 | return 'InternetGateway:%s' % self.id 37 | 38 | def startElement(self, name, attrs, connection): 39 | result = super(InternetGateway, self).startElement(name, attrs, connection) 40 | 41 | if result is not None: 42 | # Parent found an interested element, just return it 43 | return result 44 | 45 | if name == 'attachmentSet': 46 | self.attachments = ResultSet([('item', InternetGatewayAttachment)]) 47 | return self.attachments 48 | else: 49 | return None 50 | 51 | def endElement(self, name, value, connection): 52 | if name == 'internetGatewayId': 53 | self.id = value 54 | else: 55 | setattr(self, name, value) 56 | 57 | class InternetGatewayAttachment(object): 58 | def __init__(self, connection=None): 59 | self.vpc_id = None 60 | self.state = None 61 | 62 | def __repr__(self): 63 | return 'InternetGatewayAttachment:%s' % self.vpc_id 64 | 65 | def startElement(self, name, attrs, connection): 66 | return None 67 | 68 | def endElement(self, name, value, connection): 69 | if name == 'vpcId': 70 | self.vpc_id = value 71 | elif name == 'state': 72 | self.state = value 73 | -------------------------------------------------------------------------------- /boto/vpc/subnet.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents a Subnet 24 | """ 25 | 26 | from boto.ec2.ec2object import TaggedEC2Object 27 | 28 | class Subnet(TaggedEC2Object): 29 | 30 | def __init__(self, connection=None): 31 | TaggedEC2Object.__init__(self, connection) 32 | self.id = None 33 | self.vpc_id = None 34 | self.state = None 35 | self.cidr_block = None 36 | self.available_ip_address_count = 0 37 | self.availability_zone = None 38 | 39 | def __repr__(self): 40 | return 'Subnet:%s' % self.id 41 | 42 | def endElement(self, name, value, connection): 43 | if name == 'subnetId': 44 | self.id = value 45 | elif name == 'vpcId': 46 | self.vpc_id = value 47 | elif name == 'state': 48 | self.state = value 49 | elif name == 'cidrBlock': 50 | self.cidr_block = value 51 | elif name == 'availableIpAddressCount': 52 | self.available_ip_address_count = int(value) 53 | elif name == 'availabilityZone': 54 | self.availability_zone = value 55 | else: 56 | setattr(self, name, value) 57 | 58 | -------------------------------------------------------------------------------- /boto/vpc/vpc.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents a Virtual Private Cloud. 24 | """ 25 | 26 | from boto.ec2.ec2object import TaggedEC2Object 27 | 28 | class VPC(TaggedEC2Object): 29 | 30 | def __init__(self, connection=None): 31 | TaggedEC2Object.__init__(self, connection) 32 | self.id = None 33 | self.dhcp_options_id = None 34 | self.state = None 35 | self.cidr_block = None 36 | 37 | def __repr__(self): 38 | return 'VPC:%s' % self.id 39 | 40 | def endElement(self, name, value, connection): 41 | if name == 'vpcId': 42 | self.id = value 43 | elif name == 'dhcpOptionsId': 44 | self.dhcp_options_id = value 45 | elif name == 'state': 46 | self.state = value 47 | elif name == 'cidrBlock': 48 | self.cidr_block = value 49 | else: 50 | setattr(self, name, value) 51 | 52 | def delete(self): 53 | return self.connection.delete_vpc(self.id) 54 | 55 | -------------------------------------------------------------------------------- /boto/vpc/vpnconnection.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents a VPN Connectionn 24 | """ 25 | 26 | from boto.ec2.ec2object import EC2Object 27 | 28 | class VpnConnection(EC2Object): 29 | 30 | def __init__(self, connection=None): 31 | EC2Object.__init__(self, connection) 32 | self.id = None 33 | self.state = None 34 | self.customer_gateway_configuration = None 35 | self.type = None 36 | self.customer_gateway_id = None 37 | self.vpn_gateway_id = None 38 | 39 | def __repr__(self): 40 | return 'VpnConnection:%s' % self.id 41 | 42 | def endElement(self, name, value, connection): 43 | if name == 'vpnConnectionId': 44 | self.id = value 45 | elif name == 'state': 46 | self.state = value 47 | elif name == 'CustomerGatewayConfiguration': 48 | self.customer_gateway_configuration = value 49 | elif name == 'type': 50 | self.type = value 51 | elif name == 'customerGatewayId': 52 | self.customer_gateway_id = value 53 | elif name == 'vpnGatewayId': 54 | self.vpn_gateway_id = value 55 | else: 56 | setattr(self, name, value) 57 | 58 | def delete(self): 59 | return self.connection.delete_vpn_connection(self.id) 60 | 61 | -------------------------------------------------------------------------------- /boto/vpc/vpngateway.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2010 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | """ 23 | Represents a Vpn Gateway 24 | """ 25 | 26 | from boto.ec2.ec2object import TaggedEC2Object 27 | 28 | class Attachment(object): 29 | 30 | def __init__(self, connection=None): 31 | self.vpc_id = None 32 | self.state = None 33 | 34 | def startElement(self, name, attrs, connection): 35 | pass 36 | 37 | def endElement(self, name, value, connection): 38 | if name == 'vpcId': 39 | self.vpc_id = value 40 | elif name == 'state': 41 | self.state = value 42 | else: 43 | setattr(self, name, value) 44 | 45 | class VpnGateway(TaggedEC2Object): 46 | 47 | def __init__(self, connection=None): 48 | TaggedEC2Object.__init__(self, connection) 49 | self.id = None 50 | self.type = None 51 | self.state = None 52 | self.availability_zone = None 53 | self.attachments = [] 54 | 55 | def __repr__(self): 56 | return 'VpnGateway:%s' % self.id 57 | 58 | def startElement(self, name, attrs, connection): 59 | retval = TaggedEC2Object.startElement(self, name, attrs, connection) 60 | if retval is not None: 61 | return retval 62 | if name == 'item': 63 | att = Attachment() 64 | self.attachments.append(att) 65 | return att 66 | 67 | def endElement(self, name, value, connection): 68 | if name == 'vpnGatewayId': 69 | self.id = value 70 | elif name == 'type': 71 | self.type = value 72 | elif name == 'state': 73 | self.state = value 74 | elif name == 'availabilityZone': 75 | self.availability_zone = value 76 | elif name == 'attachments': 77 | pass 78 | else: 79 | setattr(self, name, value) 80 | 81 | def attach(self, vpc_id): 82 | return self.connection.attach_vpn_gateway(self.id, vpc_id) 83 | 84 | -------------------------------------------------------------------------------- /botornado/s3/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # vim:set ft=python sw=4 : 4 | -------------------------------------------------------------------------------- /botornado/sqs/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import boto.sqs 4 | import boto.regioninfo 5 | import botornado.sqs.connection 6 | 7 | def regions(): 8 | def f(r): 9 | return boto.regioninfo.RegionInfo(connection=r.connection, name=r.name, endpoint=r.endpoint, 10 | connection_cls=botornado.sqs.connection.AsyncSQSConnection) 11 | return map(f, boto.sqs.regions()) 12 | 13 | def connect_to_region(region_name, **kwargs): 14 | for region in regions(): 15 | if region.name == region_name: 16 | return region.connect(**kwargs) 17 | return None 18 | 19 | # vim:set ft=python sw=4 : 20 | -------------------------------------------------------------------------------- /botornado/sqs/jsonmessage.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/ 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, dis- 7 | # tribute, sublicense, and/or sell copies of the Software, and to permit 8 | # persons to whom the Software is furnished to do so, subject to the fol- 9 | # lowing conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included 12 | # in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 | # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 | # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | # IN THE SOFTWARE. 21 | 22 | from boto.sqs.message import MHMessage 23 | from boto.exception import SQSDecodeError 24 | import base64 25 | try: 26 | import simplejson as json 27 | except ImportError: 28 | import json 29 | 30 | from boto.sqs.jsonmessage import * 31 | import botornado.sqs.message 32 | 33 | class AsyncJSONMessage(botornado.sqs.message._AsyncMessage, JSONMessage): 34 | """ 35 | Acts like a dictionary but encodes it's data as a Base64 encoded JSON payload. 36 | """ 37 | 38 | # vim:set ft=python sw=4 : 39 | -------------------------------------------------------------------------------- /botornado/test/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # vim:set ft=python sw=4 : 4 | -------------------------------------------------------------------------------- /botornado/test/s3/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # vim:set ft=python sw=4 : 4 | -------------------------------------------------------------------------------- /botornado/test/s3/connection_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tornado.testing 4 | import tornado.web 5 | 6 | from botornado.s3 import * 7 | from botornado.s3.connection import * 8 | 9 | class S3Handler(tornado.web.RequestHandler): 10 | @tornado.web.asynchronous 11 | def delete(self): 12 | self.write("deleted") 13 | self.finish() 14 | 15 | @tornado.web.asynchronous 16 | def head(self): 17 | self.write("headed") 18 | self.finish() 19 | 20 | @tornado.web.asynchronous 21 | def get(self): 22 | # http://docs.amazonwebservices.com/AmazonS3/2006-03-01/API/RESTServiceGET.html 23 | self.write(""" 24 | 25 | 26 | bcaf1ffd86f461ca5fb16fd081034f 27 | webfile 28 | 29 | 30 | 31 | quotes 32 | 2006-02-03T16:45:09.000Z 33 | 34 | 35 | samples 36 | 2006-02-03T16:41:58.000Z 37 | 38 | 39 | 40 | """) 41 | self.finish() 42 | 43 | @tornado.web.asynchronous 44 | def post(self): 45 | self.write("posted") 46 | self.finish() 47 | 48 | @tornado.web.asynchronous 49 | def put(self): 50 | self.write("put") 51 | self.finish() 52 | 53 | class AsyncHTTPClientStub(object): 54 | def __init__(self, async_test_case): 55 | self.async_test_case = async_test_case 56 | 57 | def fetch(self, path, callback=None, **kwargs): 58 | def fetched(response): 59 | self.async_test_case.stop() 60 | callback(response) 61 | self.async_test_case.http_client.fetch(path, callback=fetched, **kwargs) 62 | return self.async_test_case.wait() 63 | 64 | class S3TestCase(tornado.testing.AsyncHTTPTestCase, tornado.testing.LogTrapTestCase): 65 | def get_app(self): 66 | return tornado.web.Application([(r'.*', S3Handler)]) 67 | 68 | def setUp(self): 69 | super(S3TestCase, self).setUp() 70 | self.s3_client = AsyncS3Connection(aws_access_key_id='public', aws_secret_access_key='secret', 71 | host='127.0.0.1', port=self.get_http_port(), 72 | is_secure=False, http_client=AsyncHTTPClientStub(self)) 73 | 74 | def test_get_all_buckets(self): 75 | def got(buckets): 76 | self.assertTrue(buckets) 77 | self.assertTrue(buckets, list) 78 | self.assertTrue(['quotes', 'samples'], map(lambda bucket: bucket.name, buckets)) 79 | self.s3_client.get_all_buckets(callback=got) 80 | 81 | if __name__ == '__main__': 82 | tornado.testing.main() 83 | 84 | # vim:set ft=python sw=4 : 85 | -------------------------------------------------------------------------------- /botornado/test/sqs/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # vim:set ft=python sw=4 : 4 | -------------------------------------------------------------------------------- /examples/s3_get_all_buckets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import time 6 | import tornado.ioloop 7 | import tornado.options 8 | 9 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) # FIXME 10 | import botornado.s3 11 | from botornado.s3.connection import AsyncS3Connection 12 | 13 | tornado.options.parse_command_line(sys.argv) 14 | 15 | s3 = AsyncS3Connection(aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), 16 | aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY')) 17 | 18 | def get_all_buckets(): 19 | def cb(response): 20 | print response 21 | sys.exit(0) 22 | s3.get_all_buckets(callback=cb) 23 | 24 | ioloop = tornado.ioloop.IOLoop.instance() 25 | ioloop.add_timeout(time.time(), get_all_buckets) 26 | ioloop.start() 27 | 28 | # vim:set ft=python : 29 | -------------------------------------------------------------------------------- /examples/sqs_get_all_queues.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import time 6 | import tornado.ioloop 7 | import tornado.options 8 | 9 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) # FIXME 10 | import botornado.sqs 11 | from botornado.sqs.connection import AsyncSQSConnection 12 | 13 | tornado.options.parse_command_line(sys.argv) 14 | 15 | sqs = botornado.sqs.connect_to_region('ap-northeast-1', 16 | aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), 17 | aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY')) 18 | 19 | def get_all_queues(): 20 | def cb(response): 21 | print response 22 | sys.exit(0) 23 | sqs.get_all_queues(callback=cb) 24 | 25 | ioloop = tornado.ioloop.IOLoop.instance() 26 | ioloop.add_timeout(time.time(), get_all_queues()) 27 | ioloop.start() 28 | 29 | # vim:set ft=python : 30 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | tornado>=2.1.1 2 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import with_statement 4 | import contextlib 5 | import re 6 | 7 | try: 8 | from setuptools import setup, find_packages 9 | except ImportError: 10 | from ez_setup import use_setuptools 11 | use_setuptools() 12 | from setuptools import setup, find_packages 13 | 14 | setup( 15 | name='botornado', 16 | version='0.0.5git', 17 | description='boto on tornado - an asynchronous Amazon Web Service (AWS) client', 18 | author='Yamashita, Yuu', 19 | author_email='peek824545201@gmail.com', 20 | url='https://github.com/yyuu/botornado', 21 | install_requires=[ 22 | # "boto==2.2.2", # current version of botornado includes tested version of boto in source tree 23 | "tornado>=2.1.1", 24 | ], 25 | packages=find_packages(), 26 | test_suite='botornado.test', 27 | license='MIT', 28 | platforms="Posix; MacOS X; Windows", 29 | classifiers=[ 30 | "Development Status :: 3 - Alpha", 31 | "Environment :: Web Environment", 32 | "Intended Audience :: Developers", 33 | "License :: OSI Approved :: MIT License", 34 | "Operating System :: OS Independent", 35 | "Topic :: Internet" 36 | ], 37 | ) 38 | 39 | # vim:set ft=python sw=4 : 40 | --------------------------------------------------------------------------------