Esempio n. 1
0
 def __init__(self, name=None, base_url=None, timeout=None, secure=False):
     if sinastorage.getDefaultAppInfo() is not None :
         self.access_key = sinastorage.getDefaultAppInfo().access_key
         self.secret_key = sinastorage.getDefaultAppInfo().secret_key
         secure = sinastorage.getDefaultAppInfo().secure
     else :
         import os
         if 'S3_ACCESS_KEY_ID' in os.environ and 'S3_SECRET_ACCESS_KEY' in os.environ:
             self.access_key = os.environ.get('S3_ACCESS_KEY_ID')
             self.secret_key = os.environ.get('S3_SECRET_ACCESS_KEY')
             secure = True
         else:
             raise ValueError("access_key and secret_key must not be None! \n\
             Please set sinastorage.setDefaultAppInfo('access_key', 'secret_key') \n\
             or set S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY in Environment first!")
     
     scheme = ("http", "https")[int(bool(secure))]
     if not base_url:
         base_url = "%s://%s" % (scheme, sinastorage_domain)
         if name:
             base_url += "/%s" % aws_urlquote(name)
     elif secure is not None:
         if not base_url.startswith(scheme + "://"):
             raise ValueError("secure=%r, url must use %s"
                              % (secure, scheme))
     self.opener = self.build_opener()
     self.name = name
     
     self.base_url = base_url
     self.timeout = 30
     self.timeout = timeout
    def __init__(self, name=None, base_url=None, timeout=None, secure=False):
        if sinastorage.getDefaultAppInfo() is not None:
            self.access_key = sinastorage.getDefaultAppInfo().access_key
            self.secret_key = sinastorage.getDefaultAppInfo().secret_key
            secure = sinastorage.getDefaultAppInfo().secure
        else:
            import os
            if 'S3_ACCESS_KEY_ID' in os.environ and 'S3_SECRET_ACCESS_KEY' in os.environ:
                self.access_key = os.environ.get('S3_ACCESS_KEY_ID')
                self.secret_key = os.environ.get('S3_SECRET_ACCESS_KEY')
                secure = True
            else:
                raise ValueError(
                    "access_key and secret_key must not be None! \n\
                Please set sinastorage.setDefaultAppInfo('access_key', 'secret_key') \n\
                or set S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY in Environment first!"
                )

        scheme = ("http", "https")[int(bool(secure))]
        if not base_url:
            base_url = "%s://%s" % (scheme, sinastorage_domain)
            if name:
                base_url += "/%s" % aws_urlquote(name)
        elif secure is not None:
            if not base_url.startswith(scheme + "://"):
                raise ValueError("secure=%r, url must use %s" %
                                 (secure, scheme))
        self.opener = self.build_opener()
        self.name = name

        self.base_url = base_url
        self.timeout = 30
        self.timeout = timeout
Esempio n. 3
0
 def __init__(self, name=None, base_url=None, timeout=None, secure=False):
     if sinastorage.getDefaultAppInfo() is None :
         raise ValueError("access_key and secret_key must not be None! Please set sinastorage.setDefaultAppInfo('access_key', 'secret_key') first!")
     self.access_key = sinastorage.getDefaultAppInfo().access_key
     self.secret_key = sinastorage.getDefaultAppInfo().secret_key
     secure = sinastorage.getDefaultAppInfo().secure
     
     scheme = ("http", "https")[int(bool(secure))]
     if not base_url:
         base_url = "%s://%s" % (scheme, sinastorage_domain)
         if name:
             base_url += "/%s" % aws_urlquote(name)
     elif secure is not None:
         if not base_url.startswith(scheme + "://"):
             raise ValueError("secure=%r, url must use %s"
                              % (secure, scheme))
     self.opener = self.build_opener()
     self.name = name
     
     self.base_url = base_url
     self.timeout = 30
     self.timeout = timeout