Commit 2fe06b17ffecf8d348c17cb16a799ec05f373a2b

Authored by Goutte
1 parent 129181a6

Move the ENV directives *before* the first try to import spacepy.

Showing 1 changed file with 9 additions and 2 deletions   Show diff stats
@@ -132,6 +132,12 @@ PARAMETERS = { @@ -132,6 +132,12 @@ PARAMETERS = {
132 } 132 }
133 133
134 134
  135 +# ENV #########################################################################
  136 +
  137 +environ['SPACEPY'] = CACHE_DIR
  138 +environ['CDF_LIB'] = CDF_LIB
  139 +
  140 +
135 # SETUP FLASK ENGINE ########################################################## 141 # SETUP FLASK ENGINE ##########################################################
136 142
137 app = Flask(__name__, root_path=THIS_DIRECTORY) 143 app = Flask(__name__, root_path=THIS_DIRECTORY)
@@ -896,8 +902,6 @@ def update_spacepy(): @@ -896,8 +902,6 @@ def update_spacepy():
896 """ 902 """
897 Importing pydcf will fail if the toolbox is not up to date. 903 Importing pydcf will fail if the toolbox is not up to date.
898 """ 904 """
899 - environ['SPACEPY'] = CACHE_DIR  
900 - environ['CDF_LIB'] = CDF_LIB  
901 try: 905 try:
902 log.info("Updating spacepy's toolbox…") 906 log.info("Updating spacepy's toolbox…")
903 import spacepy.toolbox 907 import spacepy.toolbox
@@ -1233,6 +1237,9 @@ def download_targets_cdf(targets, inp, started_at, stopped_at): @@ -1233,6 +1237,9 @@ def download_targets_cdf(targets, inp, started_at, stopped_at):
1233 except ImportError as e: 1237 except ImportError as e:
1234 log.error("Failed to import pycdf from spacepy : %s" % e) 1238 log.error("Failed to import pycdf from spacepy : %s" % e)
1235 raise 1239 raise
  1240 + except Exception as e:
  1241 + log.error("Failed to import pycdf from spacepy : %s" % e)
  1242 + raise
1236 1243
1237 try: 1244 try:
1238 cdf_handle = pycdf.CDF(cdf_path, masterpath='') 1245 cdf_handle = pycdf.CDF(cdf_path, masterpath='')