summaryrefslogtreecommitdiff
path: root/src/s3ql/backends/s3c.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/s3ql/backends/s3c.py')
-rw-r--r--src/s3ql/backends/s3c.py36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/s3ql/backends/s3c.py b/src/s3ql/backends/s3c.py
index ea0d209..53077ae 100644
--- a/src/s3ql/backends/s3c.py
+++ b/src/s3ql/backends/s3c.py
@@ -41,15 +41,16 @@ class Bucket(AbstractBucket):
The bucket guarantees only immediate get after create consistency.
"""
- def __init__(self, storage_url, login, password):
+ def __init__(self, storage_url, login, password, use_ssl):
super(Bucket, self).__init__()
- (host, port, bucket_name, prefix) = self._parse_storage_url(storage_url)
+ (host, port, bucket_name, prefix) = self._parse_storage_url(storage_url, use_ssl)
self.bucket_name = bucket_name
self.prefix = prefix
self.hostname = host
self.port = port
+ self.use_ssl = use_ssl
self.conn = self._get_conn()
self.password = password
@@ -57,7 +58,7 @@ class Bucket(AbstractBucket):
self.namespace = 'http://s3.amazonaws.com/doc/2006-03-01/'
@staticmethod
- def _parse_storage_url(storage_url):
+ def _parse_storage_url(storage_url, use_ssl):
'''Extract information from storage URL
Return a tuple * (host, port, bucket_name, prefix) * .
@@ -73,7 +74,12 @@ class Bucket(AbstractBucket):
raise QuietError('Invalid storage URL')
hostname = hit.group(1)
- port = int(hit.group(2) or '80')
+ if hit.group(2):
+ port = int(hit.group(2))
+ elif use_ssl:
+ port = 443
+ else:
+ port = 80
bucketname = hit.group(3)
prefix = hit.group(4) or ''
@@ -82,7 +88,7 @@ class Bucket(AbstractBucket):
def _get_conn(self):
'''Return connection to server'''
- return http_connection(self.hostname, self.port, ssl=False)
+ return http_connection(self.hostname, self.port, self.use_ssl)
def is_temp_failure(self, exc): #IGNORE:W0613
'''Return true if exc indicates a temporary error
@@ -408,8 +414,7 @@ class Bucket(AbstractBucket):
"""Delete all objects in bucket
Note that this method may not be able to see (and therefore also not
- delete) recently uploaded objects if `is_list_create_consistent` is
- False.
+ delete) recently uploaded objects.
"""
# We have to cache keys, because otherwise we can't use the
@@ -423,23 +428,6 @@ class Bucket(AbstractBucket):
# Ignore missing objects when clearing bucket
self.delete(s3key, True)
- def is_get_consistent(self):
- '''If True, objects retrievals are guaranteed to be up-to-date
-
- If this method returns True, then creating, deleting, or overwriting an
- object is guaranteed to be immediately reflected in subsequent object
- retrieval attempts.
- '''
- return False
-
- def is_list_create_consistent(self):
- '''If True, new objects are guaranteed to show up in object listings
-
- If this method returns True, creation of objects will immediately be
- reflected when retrieving the list of available objects.
- '''
- return False
-
def __str__(self):
return 's3c://%s/%s/%s' % (self.hostname, self.bucket_name, self.prefix)