コード例 #1
0
ファイル: sql.py プロジェクト: Curezhang/odo
    def redshit_to_s3_bucket(bucket, selectable, dshape=None, bind=None,
                             **kwargs):
        s3_conn_kwargs = filter_kwargs(get_s3_connection, kwargs)
        s3 = get_s3_connection(**s3_conn_kwargs)

        unload_kwargs = filter_kwargs(UnloadFromSelect, kwargs)
        unload_kwargs['unload_location'] = bucket.path
        unload_kwargs['access_key_id'] = s3.access_key
        unload_kwargs['secret_access_key'] = s3.secret_key

        unload = UnloadFromSelect(selectable.select(), **unload_kwargs)

        with getbind(selectable, bind).begin() as conn:
            conn.execute(unload)
        return bucket.path
コード例 #2
0
    def redshit_to_s3_bucket(bucket, selectable, dshape=None, bind=None,
                             **kwargs):
        s3_conn_kwargs = filter_kwargs(get_s3_connection, kwargs)
        s3 = get_s3_connection(**s3_conn_kwargs)

        unload_kwargs = filter_kwargs(UnloadFromSelect, kwargs)
        unload_kwargs['unload_location'] = bucket.path
        unload_kwargs['access_key_id'] = s3.access_key
        unload_kwargs['secret_access_key'] = s3.secret_key

        unload = UnloadFromSelect(selectable.select(), **unload_kwargs)

        with getbind(selectable, bind).begin() as conn:
            conn.execute(unload)
        return bucket.path
コード例 #3
0
ファイル: test_aws.py プロジェクト: gyenney/Tools
def conn():
    # requires that you have a config file or envars defined for credentials
    # this code makes me hate exceptions
    try:
        conn = get_s3_connection()
    except S3ResponseError:
        pytest.skip("unable to connect to s3")
    else:
        try:
            grants = conn.get_bucket(test_bucket_name).get_acl().acl.grants
        except S3ResponseError:
            pytest.skip("no permission to read on bucket %s" % test_bucket_name)
        else:
            if not any(g.permission == "FULL_CONTROL" or g.permission == "READ" for g in grants):
                pytest.skip("no permission to read on bucket %s" % test_bucket_name)
            else:
                yield conn
コード例 #4
0
ファイル: test_s3.py プロジェクト: zhangshoug/odo
def conn():
    # requires that you have a config file or envars defined for credentials
    # this code makes me hate exceptions
    try:
        conn = get_s3_connection()
    except S3ResponseError:
        pytest.skip('unable to connect to s3')
    else:
        try:
            grants = conn.get_bucket(test_bucket_name).get_acl().acl.grants
        except S3ResponseError:
            pytest.skip('no permission to read on bucket %s' %
                        test_bucket_name)
        else:
            if not any(g.permission == 'FULL_CONTROL' or g.permission == 'READ'
                       for g in grants):
                pytest.skip('no permission to read on bucket %s' %
                            test_bucket_name)
            else:
                yield conn