Skip to content

Commit a5ed287

Browse files
authored
Merge pull request #92 from rok4/develop
Release 2.2.1
2 parents 2398f4f + c85d4e8 commit a5ed287

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.2.1
2+
3+
### [Changed]
4+
5+
* 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
6+
17
## 2.2.0
28

39
### [Added]

‎src/rok4/storage.py‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,23 @@
5252
import boto3
5353
import botocore.exceptions
5454
import requests
55+
5556
from osgeo import gdal
5657

5758
# conditional import
59+
60+
try:
61+
from osgeo import gdal
62+
63+
# Enable GDAL/OGR exceptions
64+
gdal.UseExceptions()
65+
66+
GDAL_AVAILABLE: bool = True
67+
except ImportError:
68+
GDAL_AVAILABLE: bool = False
69+
gdal = None
70+
71+
5872
try:
5973
import rados
6074

@@ -69,8 +83,6 @@
6983

7084
# -- GLOBALS --
7185

72-
# Enable GDAL/OGR exceptions
73-
gdal.UseExceptions()
7486

7587
__CEPH_CLIENT = None
7688
__CEPH_IOCTXS = {}
@@ -1071,7 +1083,7 @@ def get_osgeo_path(path: str) -> str:
10711083

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

1074-
if storage_type == StorageType.S3:
1086+
if storage_type == StorageType.S3 and GDAL_AVAILABLE:
10751087
s3_client, bucket_name = __get_s3_client(tray_name)
10761088

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

0 commit comments

Comments
 (0)