You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 10:37:04 UTC
svn commit: r1132068 [7/8] - in /incubator/mesos/trunk: ec2/
third_party/boto-1.9b/ third_party/boto-1.9b/bin/
third_party/boto-1.9b/boto.egg-info/ third_party/boto-1.9b/boto/
third_party/boto-1.9b/boto/cloudfront/ third_party/boto-1.9b/boto/contrib/
t...
Added: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/sequence.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/sequence.py?rev=1132068&view=auto
==============================================================================
--- incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/sequence.py (added)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/sequence.py Sun Jun 5 08:36:52 2011
@@ -0,0 +1,224 @@
+# Copyright (c) 2010 Chris Moyer http://coredumped.org/
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+from boto.exception import SDBResponseError
+
+class SequenceGenerator(object):
+ """Generic Sequence Generator object, this takes a single
+ string as the "sequence" and uses that to figure out
+ what the next value in a string is. For example
+ if you give "ABC" and pass in "A" it will give you "B",
+ and if you give it "C" it will give you "AA".
+
+ If you set "rollover" to True in the above example, passing
+ in "C" would give you "A" again.
+
+ The Sequence string can be a string or any iterable
+ that has the "index" function and is indexable.
+ """
+ __name__ = "SequenceGenerator"
+
+ def __init__(self, sequence_string, rollover=False):
+ """Create a new SequenceGenerator using the sequence_string
+ as how to generate the next item.
+
+ :param sequence_string: The string or list that explains
+ how to generate the next item in the sequence
+ :type sequence_string: str,iterable
+
+ :param rollover: Rollover instead of incrementing when
+ we hit the end of the sequence
+ :type rollover: bool
+ """
+ self.sequence_string = sequence_string
+ self.sequence_length = len(sequence_string[0])
+ self.rollover = rollover
+ self.last_item = sequence_string[-1]
+ self.__name__ = "%s('%s')" % (self.__class__.__name__, sequence_string)
+
+ def __call__(self, val, last=None):
+ """Get the next value in the sequence"""
+ # If they pass us in a string that's not at least
+ # the lenght of our sequence, then return the
+ # first element in our sequence
+ if val == None or len(val) < self.sequence_length:
+ return self.sequence_string[0]
+ last_value = val[-self.sequence_length:]
+ if (not self.rollover) and (last_value == self.last_item):
+ val = "%s%s" % (self(val[:-self.sequence_length]), self._inc(last_value))
+ else:
+ val = "%s%s" % (val[:-self.sequence_length], self._inc(last_value))
+ return val
+
+ def _inc(self, val):
+ """Increment a single value"""
+ assert(len(val) == self.sequence_length)
+ return self.sequence_string[(self.sequence_string.index(val)+1) % len(self.sequence_string)]
+
+
+
+#
+# Simple Sequence Functions
+#
+def increment_by_one(cv=None, lv=None):
+ if cv == None:
+ return 0
+ return cv + 1
+
+def double(cv=None, lv=None):
+ if cv == None:
+ return 1
+ return cv * 2
+
+def fib(cv=1, lv=0):
+ """The fibonacci sequence, this incrementer uses the
+ last value"""
+ if cv == None:
+ cv = 1
+ if lv == None:
+ lv = 0
+ return cv + lv
+
+increment_string = SequenceGenerator("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+
+
+
+class Sequence(object):
+ """A simple Sequence using the new SDB "Consistent" features
+ Based largly off of the "Counter" example from mitch garnaat:
+ http://bitbucket.org/mitch/stupidbototricks/src/tip/counter.py"""
+
+
+ def __init__(self, id=None, domain_name=None, fnc=increment_by_one, init_val=None):
+ """Create a new Sequence, using an optional function to
+ increment to the next number, by default we just increment by one.
+ Every parameter here is optional, if you don't specify any options
+ then you'll get a new SequenceGenerator with a random ID stored in the
+ default domain that increments by one and uses the default botoweb
+ environment
+
+ :param id: Optional ID (name) for this counter
+ :type id: str
+
+ :param domain_name: Optional domain name to use, by default we get this out of the
+ environment configuration
+ :type domain_name:str
+
+ :param fnc: Optional function to use for the incrementation, by default we just increment by one
+ There are several functions defined in this module.
+ Your function must accept "None" to get the initial value
+ :type fnc: function, str
+
+ :param init_val: Initial value, by default this is the first element in your sequence,
+ but you can pass in any value, even a string if you pass in a function that uses
+ strings instead of ints to increment
+ """
+ self._db = None
+ self._value = None
+ self.last_value = None
+ self.domain_name = domain_name
+ self.id = id
+ if self.id == None:
+ import uuid
+ self.id = str(uuid.uuid4())
+ if init_val == None:
+ init_val = fnc(init_val)
+ self.val = init_val
+
+ self.item_type = type(fnc(None))
+ self.timestamp = None
+ # Allow us to pass in a full name to a function
+ if type(fnc) == str:
+ from boto.utils import find_class
+ fnc = find_class(fnc)
+ self.fnc = fnc
+
+ def set(self, val):
+ """Set the value"""
+ import time
+ now = time.time()
+ expected_values = []
+ new_val = {}
+ new_val['timestamp'] = now
+ if self._value != None:
+ new_val['last_value'] = self._value
+ expected_values = ['current_value', str(self._value)]
+ new_val['current_value'] = val
+ try:
+ self.db.put_attributes(self.id, new_val, expected_values=expected_values)
+ self.timestamp = new_val['timestamp']
+ except SDBResponseError, e:
+ if e.status == 409:
+ raise ValueError, "Sequence out of sync"
+ else:
+ raise
+
+
+ def get(self):
+ """Get the value"""
+ val = self.db.get_attributes(self.id, consistent_read=True)
+ if val and val.has_key('timestamp'):
+ self.timestamp = val['timestamp']
+ if val and val.has_key('current_value'):
+ self._value = self.item_type(val['current_value'])
+ if val.has_key("last_value") and val['last_value'] != None:
+ self.last_value = self.item_type(val['last_value'])
+ return self._value
+
+ val = property(get, set)
+
+ def __repr__(self):
+ return "%s('%s', '%s', '%s.%s', '%s')" % (
+ self.__class__.__name__,
+ self.id,
+ self.domain_name,
+ self.fnc.__module__, self.fnc.__name__,
+ self.val)
+
+
+ def _connect(self):
+ """Connect to our domain"""
+ if not self._db:
+ if not self.domain_name:
+ import boto
+ sdb = boto.connect_sdb()
+ self.domain_name = boto.config.get("DB", "sequence_db", boto.config.get("DB", "db_name", "default"))
+ try:
+ self._db = sdb.get_domain(self.domain_name)
+ except SDBResponseError, e:
+ if e.status == 400:
+ self._db = sdb.create_domain(self.domain_name)
+ else:
+ raise
+ return self._db
+
+ db = property(_connect)
+
+ def next(self):
+ self.val = self.fnc(self.val, self.last_value)
+ return self.val
+
+ def delete(self):
+ """Remove this sequence"""
+ self.db.delete_attributes(self.id)
+
+ def __del__(self):
+ self.delete()
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/test_db.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/db/test_db.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/test_db.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/test_db.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/db/test_db.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/db/test_db.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/db/test_db.py Sun Jun 5 08:36:52 2011
@@ -1,6 +1,7 @@
from boto.sdb.db.model import Model
-from boto.sdb.db.property import *
-from boto.sdb.db.manager import get_manager
+from boto.sdb.db.property import StringProperty, IntegerProperty, BooleanProperty
+from boto.sdb.db.property import DateTimeProperty, FloatProperty, ReferenceProperty
+from boto.sdb.db.property import PasswordProperty, ListProperty, MapProperty
from datetime import datetime
import time
from boto.exception import SDBPersistenceError
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/domain.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/domain.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/domain.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/domain.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/domain.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/domain.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/domain.py Sun Jun 5 08:36:52 2011
@@ -51,7 +51,8 @@ class Domain:
self._metadata = self.connection.domain_metadata(self)
return self._metadata
- def put_attributes(self, item_name, attributes, replace=True):
+ def put_attributes(self, item_name, attributes,
+ replace=True, expected_values=None):
"""
Store attributes for a given item.
@@ -61,6 +62,21 @@ class Domain:
:type attribute_names: dict or dict-like object
:param attribute_names: The name/value pairs to store as attributes
+ :type expected_value: list
+ :param expected_value: If supplied, this is a list or tuple consisting
+ of a single attribute name and expected value.
+ The list can be of the form:
+ * ['name', 'value']
+ In which case the call will first verify
+ that the attribute "name" of this item has
+ a value of "value". If it does, the delete
+ will proceed, otherwise a ConditionalCheckFailed
+ error will be returned.
+ The list can also be of the form:
+ * ['name', True|False]
+ which will simply check for the existence (True)
+ or non-existencve (False) of the attribute.
+
:type replace: bool
:param replace: Whether the attribute values passed in will replace
existing values or will be added as addition values.
@@ -69,7 +85,8 @@ class Domain:
:rtype: bool
:return: True if successful
"""
- return self.connection.put_attributes(self, item_name, attributes, replace)
+ return self.connection.put_attributes(self, item_name, attributes,
+ replace, expected_values)
def batch_put_attributes(self, items, replace=True):
"""
@@ -92,7 +109,8 @@ class Domain:
"""
return self.connection.batch_put_attributes(self, items, replace)
- def get_attributes(self, item_name, attribute_name=None, item=None):
+ def get_attributes(self, item_name, attribute_name=None,
+ consistent_read=False, item=None):
"""
Retrieve attributes for a given item.
@@ -107,9 +125,11 @@ class Domain:
:rtype: :class:`boto.sdb.item.Item`
:return: An Item mapping type containing the requested attribute name/values
"""
- return self.connection.get_attributes(self, item_name, attribute_name, item)
+ return self.connection.get_attributes(self, item_name, attribute_name,
+ consistent_read, item)
- def delete_attributes(self, item_name, attributes=None):
+ def delete_attributes(self, item_name, attributes=None,
+ expected_values=None):
"""
Delete attributes from a given item.
@@ -123,36 +143,28 @@ class Domain:
of values to delete as the value. If no value is supplied,
all attribute name/values for the item will be deleted.
+ :type expected_value: list
+ :param expected_value: If supplied, this is a list or tuple consisting
+ of a single attribute name and expected value.
+ The list can be of the form:
+ * ['name', 'value']
+ In which case the call will first verify
+ that the attribute "name" of this item has
+ a value of "value". If it does, the delete
+ will proceed, otherwise a ConditionalCheckFailed
+ error will be returned.
+ The list can also be of the form:
+ * ['name', True|False]
+ which will simply check for the existence (True)
+ or non-existencve (False) of the attribute.
+
:rtype: bool
:return: True if successful
"""
- return self.connection.delete_attributes(self, item_name, attributes)
+ return self.connection.delete_attributes(self, item_name, attributes,
+ expected_values)
- def query(self, query='', max_items=None, attr_names=None):
- """
- Returns a list of items within domain that match the query.
-
- :type query: string
- :param query: The SimpleDB query to be performed.
-
- :type max_items: int
- :param max_items: The maximum number of items to return. If not
- supplied, the default is None which returns all
- items matching the query.
-
- :type attr_names: list
- :param attr_names: Either None, meaning return all attributes
- or a list of attribute names which means to return
- only those attributes.
-
- :rtype: iter
- :return: An iterator containing the results. This is actually a generator
- function that will iterate across all search results, not just the
- first page.
- """
- return iter(QueryResultSet(self, query, max_items, attr_names))
-
- def select(self, query='', next_token=None, max_items=None):
+ def select(self, query='', next_token=None, consistent_read=False, max_items=None):
"""
Returns a set of Attributes for item names within domain_name that match the query.
The query must be expressed in using the SELECT style syntax rather than the
@@ -161,16 +173,13 @@ class Domain:
:type query: string
:param query: The SimpleDB query to be performed.
- :type max_items: int
- :param max_items: The maximum number of items to return.
-
:rtype: iter
:return: An iterator containing the results. This is actually a generator
function that will iterate across all search results, not just the
first page.
"""
- return SelectResultSet(self, query, max_items=max_items,
- next_token=next_token)
+ return SelectResultSet(self, query, max_items = max_items, next_token=next_token,
+ consistent_read=consistent_read)
def get_item(self, item_name):
item = self.get_attributes(item_name)
@@ -270,7 +279,7 @@ class DomainDumpParser(ContentHandler):
"""
def __init__(self, domain):
- self.uploader = UploaderThread(domain.name)
+ self.uploader = UploaderThread(domain)
self.item_id = None
self.attrs = {}
self.attribute = None
@@ -300,10 +309,10 @@ class DomainDumpParser(ContentHandler):
self.attrs[attr_name] = [value]
elif name == "Item":
self.uploader.items[self.item_id] = self.attrs
- # Every 40 items we spawn off the uploader
- if len(self.uploader.items) >= 40:
+ # Every 20 items we spawn off the uploader
+ if len(self.uploader.items) >= 20:
self.uploader.start()
- self.uploader = UploaderThread(self.domain.name)
+ self.uploader = UploaderThread(self.domain)
elif name == "Domain":
# If we're done, spawn off our last Uploader Thread
self.uploader.start()
@@ -312,10 +321,8 @@ from threading import Thread
class UploaderThread(Thread):
"""Uploader Thread"""
- def __init__(self, domain_name):
- import boto
- self.sdb = boto.connect_sdb()
- self.db = self.sdb.get_domain(domain_name)
+ def __init__(self, domain):
+ self.db = domain
self.items = {}
Thread.__init__(self)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/item.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/item.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/item.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/item.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/item.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/item.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/item.py Sun Jun 5 08:36:52 2011
@@ -89,6 +89,14 @@ class Item(dict):
def save(self, replace=True):
self.domain.put_attributes(self.name, self, replace)
+ def add_value(self, key, value):
+ if key in self:
+ if not isinstance(self[key], list):
+ self[key] = [self[key]]
+ self[key].append(value)
+ else:
+ self[key] = value
+
def delete(self):
self.domain.delete_item(self)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/__init__.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/__init__.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/__init__.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/checker.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/checker.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/checker.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/checker.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/checker.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/checker.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/checker.py Sun Jun 5 08:36:52 2011
@@ -20,7 +20,6 @@
# IN THE SOFTWARE.
from datetime import datetime
-import boto
from boto.s3.key import Key
from boto.s3.bucket import Bucket
from boto.sdb.persist import revive_object_from_id
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/object.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/object.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/object.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/object.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/object.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/object.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/object.py Sun Jun 5 08:36:52 2011
@@ -21,7 +21,7 @@
from boto.exception import SDBPersistenceError
from boto.sdb.persist import get_manager, object_lister
-from boto.sdb.persist.property import *
+from boto.sdb.persist.property import Property, ScalarProperty
import uuid
class SDBBase(type):
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/property.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/property.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/property.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/property.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/property.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/property.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/property.py Sun Jun 5 08:36:52 2011
@@ -20,7 +20,8 @@
# IN THE SOFTWARE.
from boto.exception import SDBPersistenceError
-from boto.sdb.persist.checker import *
+from boto.sdb.persist.checker import StringChecker, PasswordChecker, IntegerChecker, BooleanChecker
+from boto.sdb.persist.checker import DateTimeChecker, ObjectChecker, S3KeyChecker, S3BucketChecker
from boto.utils import Password
class Property(object):
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/test_persist.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/test_persist.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/test_persist.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/test_persist.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/test_persist.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/persist/test_persist.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/persist/test_persist.py Sun Jun 5 08:36:52 2011
@@ -1,5 +1,8 @@
from boto.sdb.persist.object import SDBObject
-from boto.sdb.persist.property import *
+from boto.sdb.persist.property import StringProperty, PositiveIntegerProperty, IntegerProperty
+from boto.sdb.persist.property import BooleanProperty, DateTimeProperty, S3KeyProperty
+from boto.sdb.persist.property import ObjectProperty, StringListProperty
+from boto.sdb.persist.property import PositiveIntegerListProperty, BooleanListProperty, ObjectListProperty
from boto.sdb.persist import Manager
from datetime import datetime
import time
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/queryresultset.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/queryresultset.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/queryresultset.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/queryresultset.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/queryresultset.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sdb/queryresultset.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/queryresultset.py Sun Jun 5 08:36:52 2011
@@ -19,8 +19,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-from boto.sdb.item import Item
-
def query_lister(domain, query='', max_items=None, attr_names=None):
more_results = True
num_results = 0
@@ -66,9 +64,10 @@ def select_lister(domain, query='', max_
class SelectResultSet(object):
def __init__(self, domain=None, query='', max_items=None,
- next_token=None):
+ next_token=None, consistent_read=False):
self.domain = domain
self.query = query
+ self.consistent_read = consistent_read
self.max_items = max_items
self.next_token = next_token
@@ -77,7 +76,8 @@ class SelectResultSet(object):
num_results = 0
while more_results:
rs = self.domain.connection.select(self.domain, self.query,
- next_token=self.next_token)
+ next_token=self.next_token,
+ consistent_read=self.consistent_read)
for item in rs:
if self.max_items and num_results >= self.max_items:
raise StopIteration
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/regioninfo.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/regioninfo.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/regioninfo.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sdb/regioninfo.py Sun Jun 5 08:36:52 2011
@@ -1,4 +1,6 @@
-# Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2010, Eucalyptus Systems, Inc.
+# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -20,12 +22,11 @@
# IN THE SOFTWARE.
#
-import boto
+from boto.regioninfo import RegionInfo
-boto.check_extensions(__name__, __path__)
+class SDBRegionInfo(RegionInfo):
-from connection import S3Connection as Connection
-from key import Key
-from bucket import Bucket
-
-__all__ = ['Connection', 'Key', 'Bucket']
+ def __init__(self, connection=None, name=None, endpoint=None):
+ from boto.sdb.connection import SDBConnection
+ RegionInfo.__init__(self, connection, name, endpoint,
+ SDBConnection)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/__init__.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/__init__.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/__init__.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/bs.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/bs.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/bs.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/bs.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/bs.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/services/bs.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/bs.py Sun Jun 5 08:36:52 2011
@@ -21,7 +21,6 @@
# IN THE SOFTWARE.
from optparse import OptionParser
from boto.services.servicedef import ServiceDef
-from boto.services.message import ServiceMessage
from boto.services.submit import Submitter
from boto.services.result import ResultProcessor
import boto
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/message.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/message.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/message.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/message.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/message.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/services/message.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/message.py Sun Jun 5 08:36:52 2011
@@ -19,7 +19,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-import boto
from boto.sqs.message import MHMessage
from boto.utils import get_ts
from socket import gethostname
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/result.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/result.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/result.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/result.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/result.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/services/result.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/result.py Sun Jun 5 08:36:52 2011
@@ -20,9 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-import getopt, sys, os, time, mimetypes
+import os
from datetime import datetime, timedelta
-from boto.services.servicedef import ServiceDef
from boto.utils import parse_ts
import boto
@@ -61,7 +60,7 @@ class ResultProcessor:
keys = msg.keys()
keys.sort()
if not self.log_fp:
- self.log_fp = open(os.path.join(path, self.LogFileName), 'w')
+ self.log_fp = open(os.path.join(path, self.LogFileName), 'a')
line = ','.join(keys)
self.log_fp.write(line+'\n')
values = []
@@ -83,9 +82,7 @@ class ResultProcessor:
bucket = boto.lookup('s3', record['Bucket'])
for output in outputs:
if get_file:
- key_name, type = output.split(';')
- if type:
- mimetype = type.split('=')[1]
+ key_name = output.split(';')[0]
key = bucket.lookup(key_name)
file_name = os.path.join(path, key_name)
print 'retrieving file: %s to %s' % (key_name, file_name)
@@ -111,8 +108,8 @@ class ResultProcessor:
if bucket:
print 'No output queue or domain, just retrieving files from output_bucket'
for key in bucket:
- file_name = os.path.join(path, key_name)
- print 'retrieving file: %s to %s' % (key_name, file_name)
+ file_name = os.path.join(path, key)
+ print 'retrieving file: %s to %s' % (key, file_name)
key.get_contents_to_filename(file_name)
self.num_files + 1
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/service.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/service.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/service.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/service.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/service.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/services/service.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/service.py Sun Jun 5 08:36:52 2011
@@ -23,14 +23,12 @@ import boto
from boto.services.message import ServiceMessage
from boto.services.servicedef import ServiceDef
from boto.pyami.scriptbase import ScriptBase
-from boto.exception import S3ResponseError
from boto.utils import get_ts
-import StringIO
import time
import os
-import sys, traceback
import mimetypes
+
class Service(ScriptBase):
# Time required to process a transaction
@@ -155,7 +153,7 @@ class Service(ScriptBase):
else:
empty_reads += 1
time.sleep(self.loop_delay)
- except Exception, e:
+ except Exception:
boto.log.exception('Service Failed')
empty_reads += 1
self.notify('Service: %s Shutting Down' % self.name)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/servicedef.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/servicedef.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/servicedef.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/servicedef.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/servicedef.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/sonofmmm.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/sonofmmm.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/sonofmmm.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/sonofmmm.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/sonofmmm.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/services/sonofmmm.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/sonofmmm.py Sun Jun 5 08:36:52 2011
@@ -22,7 +22,8 @@
import boto
from boto.services.service import Service
from boto.services.message import ServiceMessage
-import os, time, mimetypes
+import os
+import mimetypes
class SonOfMMM(Service):
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/submit.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/services/submit.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/submit.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/submit.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/services/submit.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/services/submit.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/services/submit.py Sun Jun 5 08:36:52 2011
@@ -19,8 +19,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-import boto
-import time, os
+import time
+import os
+
class Submitter:
Added: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sns/__init__.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sns/__init__.py?rev=1132068&view=auto
==============================================================================
--- incubator/mesos/trunk/third_party/boto-2.0b2/boto/sns/__init__.py (added)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sns/__init__.py Sun Jun 5 08:36:52 2011
@@ -0,0 +1,395 @@
+# Copyright (c) 2010 Mitch Garnaat http://garnaat.org/
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+from boto.connection import AWSQueryConnection
+from boto.sdb.regioninfo import SDBRegionInfo
+import boto
+import uuid
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+#boto.set_stream_logger('sns')
+
+class SNSConnection(AWSQueryConnection):
+
+ DefaultRegionName = 'us-east-1'
+ DefaultRegionEndpoint = 'sns.us-east-1.amazonaws.com'
+ APIVersion = '2010-03-31'
+ SignatureVersion = '2'
+
+ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
+ is_secure=True, port=None, proxy=None, proxy_port=None,
+ proxy_user=None, proxy_pass=None, debug=0,
+ https_connection_factory=None, region=None, path='/', converter=None):
+ if not region:
+ region = SDBRegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint)
+ self.region = region
+ AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
+ is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
+ self.region.endpoint, debug, https_connection_factory, path)
+
+ def get_all_topics(self, next_token=None):
+ """
+ :type next_token: string
+ :param next_token: Token returned by the previous call to
+ this method.
+
+ """
+ params = {'ContentType' : 'JSON'}
+ if next_token:
+ params['NextToken'] = next_token
+ response = self.make_request('ListTopics', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def get_topic_attributes(self, topic):
+ """
+ Get attributes of a Topic
+
+ :type topic: string
+ :param topic: The ARN of the topic.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic}
+ response = self.make_request('GetTopicAttributes', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def add_permission(self, topic, label, account_ids, actions):
+ """
+ Adds a statement to a topic's access control policy, granting
+ access for the specified AWS accounts to the specified actions.
+
+ :type topic: string
+ :param topic: The ARN of the topic.
+
+ :type label: string
+ :param label: A unique identifier for the new policy statement.
+
+ :type account_ids: list of strings
+ :param account_ids: The AWS account ids of the users who will be
+ give access to the specified actions.
+
+ :type actions: list of strings
+ :param actions: The actions you want to allow for each of the
+ specified principal(s).
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic,
+ 'Label' : label}
+ self.build_list_params(params, account_ids, 'AWSAccountId')
+ self.build_list_params(params, actions, 'ActionName')
+ response = self.make_request('AddPermission', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def remove_permission(self, topic, label):
+ """
+ Removes a statement from a topic's access control policy.
+
+ :type topic: string
+ :param topic: The ARN of the topic.
+
+ :type label: string
+ :param label: A unique identifier for the policy statement
+ to be removed.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic,
+ 'Label' : label}
+ response = self.make_request('RemovePermission', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def create_topic(self, topic):
+ """
+ Create a new Topic.
+
+ :type topic: string
+ :param topic: The name of the new topic.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'Name' : topic}
+ response = self.make_request('CreateTopic', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def delete_topic(self, topic):
+ """
+ Delete an existing topic
+
+ :type topic: string
+ :param topic: The ARN of the topic
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic}
+ response = self.make_request('DeleteTopic', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+
+
+ def publish(self, topic, message, subject=None):
+ """
+ Get properties of a Topic
+
+ :type topic: string
+ :param topic: The ARN of the new topic.
+
+ :type message: string
+ :param message: The message you want to send to the topic.
+ Messages must be UTF-8 encoded strings and
+ be at most 4KB in size.
+
+ :type subject: string
+ :param subject: Optional parameter to be used as the "Subject"
+ line of the email notifications.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic,
+ 'Message' : message}
+ if subject:
+ params['Subject'] = subject
+ response = self.make_request('Publish', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def subscribe(self, topic, protocol, endpoint):
+ """
+ Subscribe to a Topic.
+
+ :type topic: string
+ :param topic: The name of the new topic.
+
+ :type protocol: string
+ :param protocol: The protocol used to communicate with
+ the subscriber. Current choices are:
+ email|email-json|http|https|sqs
+
+ :type endpoint: string
+ :param endpoint: The location of the endpoint for
+ the subscriber.
+ * For email, this would be a valid email address
+ * For email-json, this would be a valid email address
+ * For http, this would be a URL beginning with http
+ * For https, this would be a URL beginning with https
+ * For sqs, this would be the ARN of an SQS Queue
+
+ :rtype: :class:`boto.sdb.domain.Domain` object
+ :return: The newly created domain
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic,
+ 'Protocol' : protocol,
+ 'Endpoint' : endpoint}
+ response = self.make_request('Subscribe', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def subscribe_sqs_queue(self, topic, queue):
+ """
+ Subscribe an SQS queue to a topic.
+
+ This is convenience method that handles most of the complexity involved
+ in using ans SQS queue as an endpoint for an SNS topic. To achieve this
+ the following operations are performed:
+ * The correct ARN is constructed for the SQS queue and that ARN is
+ then subscribed to the topic.
+ * A JSON policy document is contructed that grants permission to
+ the SNS topic to send messages to the SQS queue.
+ * This JSON policy is then associated with the SQS queue using
+ the queue's set_attribute method. If the queue already has
+ a policy associated with it, this process will add a Statement to
+ that policy. If no policy exists, a new policy will be created.
+
+ :type topic: string
+ :param topic: The name of the new topic.
+
+ :type queue: A boto Queue object
+ :param queue: The queue you wish to subscribe to the SNS Topic.
+ """
+ t = queue.id.split('/')
+ q_arn = 'arn:aws:sqs:%s:%s:%s' % (queue.connection.region.name,
+ t[1], t[2])
+ resp = self.subscribe(topic, 'sqs', q_arn)
+ policy = queue.get_attributes('Policy')
+ if 'Version' not in policy:
+ policy['Version'] = '2008-10-17'
+ if 'Statement' not in policy:
+ policy['Statement'] = []
+ statement = {'Action' : 'SQS:SendMessage',
+ 'Effect' : 'Allow',
+ 'Principal' : {'AWS' : '*'},
+ 'Resource' : q_arn,
+ 'Sid' : str(uuid.uuid4()),
+ 'Condition' : {'StringLike' : {'aws:SourceArn' : topic}}}
+ policy['Statement'].append(statement)
+ queue.set_attribute('Policy', json.dumps(policy))
+ return resp
+
+ def confirm_subscription(self, topic, token,
+ authenticate_on_unsubscribe=False):
+ """
+ Get properties of a Topic
+
+ :type topic: string
+ :param topic: The ARN of the new topic.
+
+ :type token: string
+ :param token: Short-lived token sent to and endpoint during
+ the Subscribe operation.
+
+ :type authenticate_on_unsubscribe: bool
+ :param authenticate_on_unsubscribe: Optional parameter indicating
+ that you wish to disable
+ unauthenticated unsubscription
+ of the subscription.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic,
+ 'Token' : token}
+ if authenticate_on_unsubscribe:
+ params['AuthenticateOnUnsubscribe'] = 'true'
+ response = self.make_request('ConfirmSubscription', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def unsubscribe(self, subscription):
+ """
+ Allows endpoint owner to delete subscription.
+ Confirmation message will be delivered.
+
+ :type subscription: string
+ :param subscription: The ARN of the subscription to be deleted.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'SubscriptionArn' : subscription}
+ response = self.make_request('Unsubscribe', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def get_all_subscriptions(self, next_token=None):
+ """
+ Get list of all subscriptions.
+
+ :type next_token: string
+ :param next_token: Token returned by the previous call to
+ this method.
+
+ """
+ params = {'ContentType' : 'JSON'}
+ if next_token:
+ params['NextToken'] = next_token
+ response = self.make_request('ListSubscriptions', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
+ def get_all_subscriptions_by_topic(self, topic, next_token=None):
+ """
+ Get list of all subscriptions to a specific topic.
+
+ :type topic: string
+ :param topic: The ARN of the topic for which you wish to
+ find subscriptions.
+
+ :type next_token: string
+ :param next_token: Token returned by the previous call to
+ this method.
+
+ """
+ params = {'ContentType' : 'JSON',
+ 'TopicArn' : topic}
+ if next_token:
+ params['NextToken'] = next_token
+ response = self.make_request('ListSubscriptions', params, '/', 'GET')
+ body = response.read()
+ if response.status == 200:
+ return json.loads(body)
+ else:
+ boto.log.error('%s %s' % (response.status, response.reason))
+ boto.log.error('%s' % body)
+ raise self.ResponseError(response.status, response.reason, body)
+
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/__init__.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/__init__.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/__init__.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/__init__.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/__init__.py Sun Jun 5 08:36:52 2011
@@ -22,10 +22,6 @@
import boto
-boto.check_extensions(__name__, __path__)
-
-from queue import Queue
-from message import Message, MHMessage, EncodedMHMessage
from regioninfo import SQSRegionInfo
def regions():
@@ -35,9 +31,15 @@ def regions():
:rtype: list
:return: A list of :class:`boto.ec2.regioninfo.RegionInfo`
"""
- return [SQSRegionInfo(name='us-east-1', endpoint='queue.amazonaws.com'),
- SQSRegionInfo(name='eu-west-1', endpoint='eu-west-1.queue.amazonaws.com'),
- SQSRegionInfo(name='us-west-1', endpoint='us-west-1.queue.amazonaws.com')]
+ return [SQSRegionInfo(name='us-east-1',
+ endpoint='queue.amazonaws.com'),
+ SQSRegionInfo(name='eu-west-1',
+ endpoint='eu-west-1.queue.amazonaws.com'),
+ SQSRegionInfo(name='us-west-1',
+ endpoint='us-west-1.queue.amazonaws.com'),
+ SQSRegionInfo(name='ap-southeast-1',
+ endpoint='ap-southeast-1.queue.amazonaws.com')
+ ]
def connect_to_region(region_name):
for region in regions():
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/attributes.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/attributes.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/attributes.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/attributes.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/attributes.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/connection.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/connection.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/connection.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/connection.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/connection.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/connection.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/connection.py Sun Jun 5 08:36:52 2011
@@ -20,15 +20,13 @@
# IN THE SOFTWARE.
from boto.connection import AWSQueryConnection
-import xml.sax
from boto.sqs.regioninfo import SQSRegionInfo
from boto.sqs.queue import Queue
from boto.sqs.message import Message
from boto.sqs.attributes import Attributes
-from boto import handler
-from boto.resultset import ResultSet
from boto.exception import SQSError
+
class SQSConnection(AWSQueryConnection):
"""
A Connection to the SQS Service.
@@ -138,28 +136,59 @@ class SQSConnection(AWSQueryConnection):
:param visibility_timeout: The number of seconds the message should remain invisible
to other queue readers (default=None which uses the Queues default)
- :type attributes: list of strings
- :param attributes: A list of additional attributes that will be returned
- with the response. Valid values:
+ :type attributes: str
+ :param attributes: The name of additional attribute to return with response
+ or All if you want all attributes. The default is to
+ return no additional attributes. Valid values:
All
SenderId
SentTimestamp
ApproximateReceiveCount
ApproximateFirstReceiveTimestamp
+ :rtype: list
+ :return: A list of :class:`boto.sqs.message.Message` objects.
"""
params = {'MaxNumberOfMessages' : number_messages}
if visibility_timeout:
params['VisibilityTimeout'] = visibility_timeout
if attributes:
- self.build_list_params(self, params, attributes, 'AttributeName')
+ self.build_list_params(params, attributes, 'AttributeName')
return self.get_list('ReceiveMessage', params, [('Message', queue.message_class)],
queue.id, queue)
def delete_message(self, queue, message):
+ """
+ Delete a message from a queue.
+
+ :type queue: A :class:`boto.sqs.queue.Queue` object
+ :param queue: The Queue from which messages are read.
+
+ :type message: A :class:`boto.sqs.message.Message` object
+ :param message: The Message to be deleted
+
+ :rtype: bool
+ :return: True if successful, False otherwise.
+ """
params = {'ReceiptHandle' : message.receipt_handle}
return self.get_status('DeleteMessage', params, queue.id)
+ def delete_message_from_handle(self, queue, receipt_handle):
+ """
+ Delete a message from a queue, given a receipt handle.
+
+ :type queue: A :class:`boto.sqs.queue.Queue` object
+ :param queue: The Queue from which messages are read.
+
+ :type receipt_handle: str
+ :param receipt_handle: The receipt handle for the message
+
+ :rtype: bool
+ :return: True if successful, False otherwise.
+ """
+ params = {'ReceiptHandle' : receipt_handle}
+ return self.get_status('DeleteMessage', params, queue.id)
+
def send_message(self, queue, message_content):
params = {'MessageBody' : message_content}
return self.get_object('SendMessage', params, Message, queue.id, verb='POST')
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/jsonmessage.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/jsonmessage.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/jsonmessage.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/jsonmessage.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/jsonmessage.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/message.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/message.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/message.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/message.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/message.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/queue.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/queue.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/queue.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/queue.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/queue.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/sqs/queue.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/queue.py Sun Jun 5 08:36:52 2011
@@ -23,12 +23,9 @@
Represents an SQS Queue
"""
-import xml.sax
import urlparse
-from boto.exception import SQSError
-from boto.handler import XmlHandler
from boto.sqs.message import Message
-from boto.resultset import ResultSet
+
class Queue:
@@ -229,14 +226,16 @@ class Queue:
:type visibility_timeout: int
:param visibility_timeout: The VisibilityTimeout for the messages read.
- :type attributes: list of strings
- :param attributes: A list of additional attributes that will be returned
- with the response. Valid values:
+ :type attributes: str
+ :param attributes: The name of additional attribute to return with response
+ or All if you want all attributes. The default is to
+ return no additional attributes. Valid values:
All
SenderId
SentTimestamp
ApproximateReceiveCount
ApproximateFirstReceiveTimestamp
+
:rtype: list
:return: A list of :class:`boto.sqs.message.Message` objects.
"""
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/regioninfo.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/regioninfo.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/regioninfo.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/s3/__init__.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/sqs/regioninfo.py Sun Jun 5 08:36:52 2011
@@ -1,4 +1,6 @@
-# Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2010, Eucalyptus Systems, Inc.
+# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -20,12 +22,11 @@
# IN THE SOFTWARE.
#
-import boto
+from boto.regioninfo import RegionInfo
-boto.check_extensions(__name__, __path__)
+class SQSRegionInfo(RegionInfo):
-from connection import S3Connection as Connection
-from key import Key
-from bucket import Bucket
-
-__all__ = ['Connection', 'Key', 'Bucket']
+ def __init__(self, connection=None, name=None, endpoint=None):
+ from boto.sqs.connection import SQSConnection
+ RegionInfo.__init__(self, connection, name, endpoint,
+ SQSConnection)
Added: incubator/mesos/trunk/third_party/boto-2.0b2/boto/storage_uri.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/storage_uri.py?rev=1132068&view=auto
==============================================================================
--- incubator/mesos/trunk/third_party/boto-2.0b2/boto/storage_uri.py (added)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/storage_uri.py Sun Jun 5 08:36:52 2011
@@ -0,0 +1,346 @@
+# Copyright 2010 Google Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish, dis-
+# tribute, sublicense, and/or sell copies of the Software, and to permit
+# persons to whom the Software is furnished to do so, subject to the fol-
+# lowing conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+import os
+from boto.exception import BotoClientError
+from boto.exception import InvalidUriError
+
+
+class StorageUri(object):
+ """
+ Base class for representing storage provider-independent bucket and
+ object name with a shorthand URI-like syntax.
+
+ This is an abstract class: the constructor cannot be called (throws an
+ exception if you try).
+ """
+
+ connection = None
+
+ def __init__(self):
+ """Uncallable constructor on abstract base StorageUri class.
+ """
+ raise BotoClientError('Attempt to instantiate abstract StorageUri '
+ 'class')
+
+ def __repr__(self):
+ """Returns string representation of URI."""
+ return self.uri
+
+ def equals(self, uri):
+ """Returns true if two URIs are equal."""
+ return self.uri == uri.uri
+
+ def check_response(self, resp, level, uri):
+ if resp is None:
+ raise InvalidUriError('Attempt to get %s for "%s" failed. This '
+ 'probably indicates the URI is invalid.' %
+ (level, uri))
+
+ def connect(self, access_key_id=None, secret_access_key=None, **kwargs):
+ """
+ Opens a connection to appropriate provider, depending on provider
+ portion of URI. Requires Credentials defined in boto config file (see
+ boto/pyami/config.py).
+ @type storage_uri: StorageUri
+ @param storage_uri: StorageUri specifying a bucket or a bucket+object
+ @rtype: L{AWSAuthConnection<boto.gs.connection.AWSAuthConnection>}
+ @return: A connection to storage service provider of the given URI.
+ """
+
+ if not self.connection:
+ if self.scheme == 's3':
+ from boto.s3.connection import S3Connection
+ self.connection = S3Connection(access_key_id,
+ secret_access_key, **kwargs)
+ elif self.scheme == 'gs':
+ from boto.gs.connection import GSConnection
+ self.connection = GSConnection(access_key_id,
+ secret_access_key, **kwargs)
+ elif self.scheme == 'file':
+ from boto.file.connection import FileConnection
+ self.connection = FileConnection(self)
+ else:
+ raise InvalidUriError('Unrecognized scheme "%s"' %
+ self.scheme)
+ self.connection.debug = self.debug
+ return self.connection
+
+ def delete_key(self, validate=True, headers=None, version_id=None,
+ mfa_token=None):
+ if not self.object_name:
+ raise InvalidUriError('delete_key on object-less URI (%s)' %
+ self.uri)
+ bucket = self.get_bucket(validate, headers)
+ return bucket.delete_key(self.object_name, headers, version_id,
+ mfa_token)
+
+ def get_all_keys(self, headers=None, **params):
+ bucket = self.get_bucket(validate, headers)
+ return bucket.get_all_keys(headers, params)
+
+ def get_bucket(self, validate=True, headers=None):
+ if self.bucket_name is None:
+ raise InvalidUriError('get_bucket on bucket-less URI (%s)' %
+ self.uri)
+ conn = self.connect()
+ bucket = conn.get_bucket(self.bucket_name, validate, headers)
+ self.check_response(bucket, 'bucket', self.uri)
+ return bucket
+
+ def get_key(self, validate=True, headers=None, version_id=None):
+ if not self.object_name:
+ raise InvalidUriError('get_key on object-less URI (%s)' % self.uri)
+ bucket = self.get_bucket(validate, headers)
+ key = bucket.get_key(self.object_name, headers, version_id)
+ self.check_response(key, 'key', self.uri)
+ return key
+
+ def new_key(self, validate=True, headers=None):
+ if not self.object_name:
+ raise InvalidUriError('new_key on object-less URI (%s)' % self.uri)
+ bucket = self.get_bucket(validate, headers)
+ return bucket.new_key(self.object_name)
+
+ def get_contents_as_string(self, validate=True, headers=None, cb=None,
+ num_cb=10, torrent=False, version_id=None):
+ if not self.object_name:
+ raise InvalidUriError('get_contents_as_string on object-less URI '
+ '(%s)' % self.uri)
+ key = self.get_key(validate, headers)
+ return key.get_contents_as_string(headers, cb, num_cb, torrent,
+ version_id)
+
+ def acl_class(self):
+ if self.bucket_name is None:
+ raise InvalidUriError('acl_class on bucket-less URI (%s)' %
+ self.uri)
+ conn = self.connect()
+ acl_class = conn.provider.acl_class
+ self.check_response(acl_class, 'acl_class', self.uri)
+ return acl_class
+
+ def canned_acls(self):
+ if self.bucket_name is None:
+ raise InvalidUriError('canned_acls on bucket-less URI (%s)' %
+ self.uri)
+ conn = self.connect()
+ canned_acls = conn.provider.canned_acls
+ self.check_response(canned_acls, 'canned_acls', self.uri)
+ return canned_acls
+
+
+class BucketStorageUri(StorageUri):
+ """
+ StorageUri subclass that handles bucket storage providers.
+ Callers should instantiate this class by calling boto.storage_uri().
+ """
+
+ def __init__(self, scheme, bucket_name=None, object_name=None,
+ debug=False):
+ """Instantiate a BucketStorageUri from scheme,bucket,object tuple.
+
+ @type scheme: string
+ @param scheme: URI scheme naming the storage provider (gs, s3, etc.)
+ @type bucket_name: string
+ @param bucket_name: bucket name
+ @type object_name: string
+ @param object_name: object name
+ @type debug: bool
+ @param debug: whether to turn on debugging on calls to this class
+
+ After instantiation the components are available in the following
+ fields: uri, scheme, bucket_name, object_name.
+ """
+
+ self.scheme = scheme
+ self.bucket_name = bucket_name
+ self.object_name = object_name
+ if self.bucket_name and self.object_name:
+ self.uri = ('%s://%s/%s' % (self.scheme, self.bucket_name,
+ self.object_name))
+ elif self.bucket_name:
+ self.uri = ('%s://%s/' % (self.scheme, self.bucket_name))
+ else:
+ self.uri = ('%s://' % self.scheme)
+ self.debug = debug
+
+ def clone_replace_name(self, new_name):
+ """Instantiate a BucketStorageUri from the current BucketStorageUri,
+ but replacing the object_name.
+
+ @type new_name: string
+ @param new_name: new object name
+ """
+ if not self.bucket_name:
+ raise InvalidUriError('clone_replace_name() on bucket-less URI %s' %
+ self.uri)
+ return BucketStorageUri(self.scheme, self.bucket_name, new_name,
+ self.debug)
+
+ def get_acl(self, validate=True, headers=None, version_id=None):
+ if not self.bucket_name:
+ raise InvalidUriError('get_acl on bucket-less URI (%s)' % self.uri)
+ bucket = self.get_bucket(validate, headers)
+ # This works for both bucket- and object- level ACLs (former passes
+ # key_name=None):
+ acl = bucket.get_acl(self.object_name, headers, version_id)
+ self.check_response(acl, 'acl', self.uri)
+ return acl
+
+ def add_email_grant(self, permission, email_address, recursive=False,
+ validate=True, headers=None):
+ if not self.bucket_name:
+ raise InvalidUriError('add_email_grant on bucket-less URI (%s)' %
+ self.uri)
+ if not self.object_name:
+ bucket = self.get_bucket(validate, headers)
+ bucket.add_email_grant(permission, email_address, recursive,
+ headers)
+ else:
+ key = self.get_key(validate, headers)
+ key.add_email_grant(permission, email_address)
+
+ def add_user_grant(self, permission, user_id, recursive=False,
+ validate=True, headers=None):
+ if not self.bucket_name:
+ raise InvalidUriError('add_user_grant on bucket-less URI (%s)' % self.uri)
+ if not self.object_name:
+ bucket = self.get_bucket(validate, headers)
+ bucket.add_user_grant(permission, user_id, recursive, headers)
+ else:
+ key = self.get_key(validate, headers)
+ key.add_user_grant(permission, user_id)
+
+ def list_grants(self, headers=None):
+ if not self.bucket_name:
+ raise InvalidUriError('list_grants on bucket-less URI (%s)' % self.uri)
+ bucket = self.get_bucket(headers)
+ return bucket.list_grants(headers)
+
+ def names_container(self):
+ """Returns True if this URI names a bucket (vs. an object).
+ """
+ return self.object_name is None or self.object_name == ''
+
+ def names_singleton(self):
+ """Returns True if this URI names an object (vs. a bucket).
+ """
+ return self.object_name is not None and self.object_name != ''
+
+ def is_file_uri(self):
+ return False
+
+ def is_cloud_uri(self):
+ return True
+
+ def create_bucket(self, headers=None, location='', policy=None):
+ if self.bucket_name is None:
+ raise InvalidUriError('create_bucket on bucket-less URI (%s)' %
+ self.uri)
+ conn = self.connect()
+ return conn.create_bucket(self.bucket_name, headers, location, policy)
+
+ def delete_bucket(self, headers=None):
+ if self.bucket_name is None:
+ raise InvalidUriError('delete_bucket on bucket-less URI (%s)' %
+ self.uri)
+ conn = self.connect()
+ return conn.delete_bucket(self.bucket_name, headers)
+
+ def get_all_buckets(self, headers=None):
+ conn = self.connect()
+ return conn.get_all_buckets(headers)
+
+ def get_provider(self):
+ conn = self.connect()
+ provider = conn.provider
+ self.check_response(provider, 'provider', self.uri)
+ return provider
+
+ def set_acl(self, acl_or_str, key_name='', validate=True, headers=None,
+ version_id=None):
+ if not self.bucket_name:
+ raise InvalidUriError('set_acl on bucket-less URI (%s)' %
+ self.uri)
+ self.get_bucket(validate, headers).set_acl(acl_or_str, key_name, headers,
+ version_id)
+
+ def set_canned_acl(self, acl_str, validate=True, headers=None,
+ version_id=None):
+ if not self.object_name:
+ raise InvalidUriError('set_canned_acl on object-less URI (%s)' %
+ self.uri)
+ key = self.get_key(validate, headers)
+ key.set_canned_acl(acl_str, headers, version_id)
+
+
+class FileStorageUri(StorageUri):
+ """
+ StorageUri subclass that handles files in the local file system.
+ Callers should instantiate this class by calling boto.storage_uri().
+
+ See file/README about how we map StorageUri operations onto a file system.
+ """
+
+ def __init__(self, object_name, debug):
+ """Instantiate a FileStorageUri from a path name.
+
+ @type object_name: string
+ @param object_name: object name
+ @type debug: boolean
+ @param debug: whether to enable debugging on this StorageUri
+
+ After instantiation the components are available in the following
+ fields: uri, scheme, bucket_name (always blank for this "anonymous"
+ bucket), object_name.
+ """
+
+ self.scheme = 'file'
+ self.bucket_name = ''
+ self.object_name = object_name
+ self.uri = 'file://' + object_name
+ self.debug = debug
+
+ def clone_replace_name(self, new_name):
+ """Instantiate a FileStorageUri from the current FileStorageUri,
+ but replacing the object_name.
+
+ @type new_name: string
+ @param new_name: new object name
+ """
+ return FileStorageUri(new_name, self.debug)
+
+ def names_container(self):
+ """Returns True if this URI names a directory.
+ """
+ return os.path.isdir(self.object_name)
+
+ def names_singleton(self):
+ """Returns True if this URI names a file.
+ """
+ return os.path.isfile(self.object_name)
+
+ def is_file_uri(self):
+ return True
+
+ def is_cloud_uri(self):
+ return False
Propchange: incubator/mesos/trunk/third_party/boto-2.0b2/boto/storage_uri.py
------------------------------------------------------------------------------
svn:executable = *
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/__init__.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/__init__.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/__init__.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/__init__.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/__init__.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/devpay_s3.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/devpay_s3.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/devpay_s3.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/devpay_s3.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/devpay_s3.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
(empty)
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/test.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/test.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/test.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test.py Sun Jun 5 08:36:52 2011
@@ -24,18 +24,20 @@
do the unit tests!
"""
-import sys, os, unittest
-import getopt, sys
-import boto
+import sys
+import unittest
+import getopt
from boto.tests.test_sqsconnection import SQSConnectionTest
from boto.tests.test_s3connection import S3ConnectionTest
+from boto.tests.test_s3versioning import S3VersionTest
+from boto.tests.test_gsconnection import GSConnectionTest
from boto.tests.test_ec2connection import EC2ConnectionTest
from boto.tests.test_sdbconnection import SDBConnectionTest
def usage():
print 'test.py [-t testsuite] [-v verbosity]'
- print ' -t run specific testsuite (s3|sqs|ec2|sdb|all)'
+ print ' -t run specific testsuite (s3|s3ver|s3nover|gs|sqs|ec2|sdb|all)'
print ' -v verbosity (0|1|2)'
def main():
@@ -66,6 +68,13 @@ def main():
suite.addTest(unittest.makeSuite(SDBConnectionTest))
elif testsuite == 's3':
suite.addTest(unittest.makeSuite(S3ConnectionTest))
+ suite.addTest(unittest.makeSuite(S3VersionTest))
+ elif testsuite == 's3ver':
+ suite.addTest(unittest.makeSuite(S3VersionTest))
+ elif testsuite == 's3nover':
+ suite.addTest(unittest.makeSuite(S3ConnectionTest))
+ elif testsuite == 'gs':
+ suite.addTest(unittest.makeSuite(GSConnectionTest))
elif testsuite == 'sqs':
suite.addTest(unittest.makeSuite(SQSConnectionTest))
elif testsuite == 'ec2':
Copied: incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test_ec2connection.py (from r1132067, incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/test_ec2connection.py)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test_ec2connection.py?p2=incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test_ec2connection.py&p1=incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/test_ec2connection.py&r1=1132067&r2=1132068&rev=1132068&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/boto-1.9b/boto/tests/test_ec2connection.py (original)
+++ incubator/mesos/trunk/third_party/boto-2.0b2/boto/tests/test_ec2connection.py Sun Jun 5 08:36:52 2011
@@ -1,6 +1,8 @@
#!/usr/bin/env python
-# Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/
+# Copyright (c) 2009, Eucalyptus Systems, Inc.
+# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -27,7 +29,6 @@ Some unit tests for the EC2Connection
import unittest
import time
-import os
from boto.ec2.connection import EC2Connection
import telnetlib
import socket
@@ -37,7 +38,7 @@ class EC2ConnectionTest (unittest.TestCa
def test_1_basic(self):
# this is my user_id, if you want to run these tests you should
# replace this with yours or they won't work
- user_id = '084307701560'
+ user_id = '963068290131'
print '--- running EC2Connection tests ---'
c = EC2Connection()
# get list of private AMI's
@@ -114,7 +115,7 @@ class EC2ConnectionTest (unittest.TestCa
except socket.error:
pass
# now kill the instance and delete the security group
- instance.stop()
+ instance.terminate()
# unfortunately, I can't delete the sg within this script
#sg.delete()