Skip to content

Commit 779026f

Browse files
committed
added warnings for non-required (not present in requirements.txt) packages in io.py and ipysliderule.py
1 parent 3774aa1 commit 779026f

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

sliderule/io.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@
2727
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2828
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30+
import sys
3031
import warnings
3132
import datetime
32-
import scipy.io
3333
import geopandas
34-
import h5py
3534
import numpy as np
3635

36+
# imports with warnings if not present
37+
try:
38+
import scipy.io
39+
import h5py
40+
except ModuleNotFoundError as e:
41+
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))
42+
3743
# attributes for ATL06-SR variables
3844
def get_attributes(**kwargs):
3945
# set default keyword arguments

sliderule/ipysliderule.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,28 @@
2828
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

3030
import os
31+
import sys
3132
import copy
3233
import datetime
33-
import ipywidgets
34-
import ipyleaflet
3534
import numpy as np
3635
from traitlets.utils.bunch import Bunch
37-
import tkinter.filedialog
38-
import IPython.display
3936
import sliderule.io
4037

38+
# imports with warnings if not present
39+
try:
40+
import ipywidgets
41+
import tkinter.filedialog
42+
import IPython.display
43+
except ModuleNotFoundError as e:
44+
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))
45+
46+
# imports that raise error if not present
47+
try:
48+
import ipyleaflet
49+
except ModuleNotFoundError as e:
50+
sys.stderr.write("Error: missing required packages. (%s)\n" % (str(e)))
51+
raise
52+
4153
class widgets:
4254
def __init__(self):
4355
# dropdown menu for setting asset

0 commit comments

Comments
 (0)