diff --git a/modules/performRegionalEventSimulation/regionalGroundMotion/CreateStation.py b/modules/performRegionalEventSimulation/regionalGroundMotion/CreateStation.py index f7e8c5e69..77ad1ef53 100644 --- a/modules/performRegionalEventSimulation/regionalGroundMotion/CreateStation.py +++ b/modules/performRegionalEventSimulation/regionalGroundMotion/CreateStation.py @@ -41,7 +41,6 @@ import json import numpy as np import pandas as pd -import requests def get_label(options, labels, label_name): @@ -407,6 +406,8 @@ def get_zTR_ncm(lat, lon): Output: zTR: list of depth to bedrock """ + import requests + zTR = [] # Looping over sites @@ -439,6 +440,8 @@ def get_vsp_ncm(lat, lon, depth): Output: vsp: list of shear-wave velocity profile """ + import requests + vsp = [] depthMin, depthInc, depthMax = [abs(x) for x in depth] diff --git a/modules/performRegionalEventSimulation/regionalGroundMotion/FetchOpenQuake.py b/modules/performRegionalEventSimulation/regionalGroundMotion/FetchOpenQuake.py index 13a3c827d..22f6e4d98 100644 --- a/modules/performRegionalEventSimulation/regionalGroundMotion/FetchOpenQuake.py +++ b/modules/performRegionalEventSimulation/regionalGroundMotion/FetchOpenQuake.py @@ -80,16 +80,19 @@ def handleError(func, path, exc_info): if not os.path.isdir('./oq-engine'): try: os.system('git clone https://github.com/gem/oq-engine.git') - # switch to the stable version - owd = os.getcwd() - os.chdir('./oq-engine') - os.system('git clean -d -f') - os.system('git checkout '+oq_version) - os.chdir(owd) + try: + # switch to the stable version + owd = os.getcwd() + os.chdir('./oq-engine') + os.system('git clean -d -f') + os.system('git checkout '+oq_version) + os.chdir(owd) + except: + print('FetchOpenQuake: failed to switch to the OpenQuake commit '+oq_version) except: shutil.rmtree('oq-engine', onerror=handleError) print('FetchOpenQuake: could not clone https://github.com/gem/oq-engine.git') - shutil.copytree('./oq-engine/openquake',os.path.dirname(os.path.realpath(__file__))+'/openquake') + shutil.copytree('./oq-engine/openquake',os.path.dirname(os.path.realpath(__file__))+'/openquake',symlinks=True) shutil.rmtree('oq-engine', onerror=handleError) from openquake.baselib import config, version, performance, general, zeromq, hdf5, parallel