示例#1
0
    def setUpClass(cls):
        S3TestBase.setUpClass()
        if not cls.shouldSkip():
            cls.fs = S3FileSystem(cls.s3_connection)

            cls.c = make_logged_in_client(username='******', is_superuser=False)
            grant_access('test', 'test', 'filebrowser')
            add_to_group('test')
示例#2
0
def _make_client(identifier, user):
    client_conf = aws_conf.AWS_ACCOUNTS[
        identifier] if identifier in aws_conf.AWS_ACCOUNTS else None

    client = Client.from_config(client_conf,
                                get_credential_provider(identifier, user))
    return S3FileSystem(
        client.get_s3_connection(),
        client.expiration)  # It would be nice if the connection is lazy loaded
示例#3
0
文件: client.py 项目: ziq211/hue
def _make_client(identifier, user=_DEFAULT_USER):
    config = conf.GC_ACCOUNTS[identifier] if identifier in list(
        conf.GC_ACCOUNTS.keys()) else None
    client = Client.from_config(config, get_credential_provider(config, user))
    return S3FileSystem(client.get_s3_connection(),
                        client.expiration,
                        headers={"x-goog-project-id": client.project},
                        filebrowser_action=conf.PERMISSION_ACTION_GS
                        )  # It would be nice if the connection is lazy loaded
示例#4
0
    def test_rmtree_bucket(self):
        with patch(
                'aws.s3.s3fs.S3FileSystem._delete_bucket') as _delete_bucket:

            fs = S3FileSystem(s3_connection=Mock())

            fs.rmtree(path='s3a://gethue')

            _delete_bucket.assert_called()
示例#5
0
文件: client.py 项目: quyuehui/hue
def _make_client(identifier, user):
  if RAZ.IS_ENABLED.get() and not aws_conf.IS_SELF_SIGNING_ENABLED.get():
    s3_client = RazS3Connection()  # Note: AWS configuration is fully skipped
    s3_client_expiration = None
  else:
    client_conf = aws_conf.AWS_ACCOUNTS[identifier] if identifier in aws_conf.AWS_ACCOUNTS else None

    s3_client_builder = Client.from_config(client_conf, get_credential_provider(identifier, user))
    s3_client = s3_client_builder.get_s3_connection()
    s3_client_expiration = s3_client_builder.expiration

  return S3FileSystem(s3_client, s3_client_expiration)
示例#6
0
文件: client.py 项目: ranade1/hue
def _make_client(identifier, user):
    client_conf = aws_conf.AWS_ACCOUNTS[
        identifier] if identifier in aws_conf.AWS_ACCOUNTS else None

    if aws_conf.is_raz_s3():
        host = aws_conf.get_default_host() or client_conf.HOST.get()
        s3_client = RazS3Connection(
            username=user,
            host=host)  # Note: Remaining AWS configuration is fully skipped
        s3_client_expiration = None
    else:
        s3_client_builder = Client.from_config(
            client_conf, get_credential_provider(identifier, user))
        s3_client = s3_client_builder.get_s3_connection()
        s3_client_expiration = s3_client_builder.expiration

    return S3FileSystem(s3_client, s3_client_expiration)
示例#7
0
    def test_rmtree_empty_dir(self):
        with patch('aws.s3.s3fs.S3FileSystem._get_key') as _get_key:
            with patch('aws.s3.s3fs.S3FileSystem.isdir') as isdir:

                key = Mock(name='data',
                           exists=Mock(return_value=True),
                           bucket=Mock(list=Mock(return_value=[]),
                                       delete_key=Mock()),
                           delete=Mock(return_value=Mock(exists=Mock(
                               return_value=False))))
                _get_key.return_value = key
                isdir.return_value = True

                fs = S3FileSystem(s3_connection=Mock())

                fs.rmtree(path='s3a://gethue/data')

                key.delete.assert_called()
                key.bucket.delete_keys.assert_not_called()
示例#8
0
文件: __init__.py 项目: jwang41/hue
def get_s3fs(identifier='default'):
    connection = get_client(identifier).get_s3_connection()
    return S3FileSystem(connection)
示例#9
0
 def setUpClass(cls):
     S3TestBase.setUpClass()
     if not cls.shouldSkip():
         cls.fs = S3FileSystem(cls.s3_connection)