Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.2.1

### [Changed]

* Module `storage` : il est possible de l'utiliser sans avoir la librairie GDAL : seule la fonction `get_osgeo_path` pour du S3 ne sera pas disponible

## 2.2.0

### [Added]
Expand Down
18 changes: 15 additions & 3 deletions src/rok4/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,23 @@
import boto3
import botocore.exceptions
import requests

from osgeo import gdal

# conditional import

try:
from osgeo import gdal

# Enable GDAL/OGR exceptions
gdal.UseExceptions()

GDAL_AVAILABLE: bool = True
except ImportError:
GDAL_AVAILABLE: bool = False
gdal = None


try:
import rados

Expand All @@ -69,8 +83,6 @@

# -- GLOBALS --

# Enable GDAL/OGR exceptions
gdal.UseExceptions()

__CEPH_CLIENT = None
__CEPH_IOCTXS = {}
Expand Down Expand Up @@ -1071,7 +1083,7 @@ def get_osgeo_path(path: str) -> str:

storage_type, unprefixed_path, tray_name, base_name = get_infos_from_path(path)

if storage_type == StorageType.S3:
if storage_type == StorageType.S3 and GDAL_AVAILABLE:
s3_client, bucket_name = __get_s3_client(tray_name)

gdal.SetConfigOption("AWS_SECRET_ACCESS_KEY", s3_client["secret_key"])
Expand Down