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
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
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