generated from NOAA-GFDL/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef86c6d
commit 78897ff
Showing
1 changed file
with
22 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
def check_import(): | ||
try: | ||
from intakebuilder import getinfo, localcrawler, CSVwriter | ||
print("Imported intakebuilder and getinfo, localcrawler, CSVwriter ") | ||
except ImportError: | ||
raise ImportError('Error importing intakebuilder and other packages') | ||
return -97 | ||
return True | ||
from intakebuilder import gfdlcrawler, CSVwriter, configparser | ||
print("Imported intakebuilder, gfdlcrawler, CSVwriter, configparser") | ||
return True | ||
except ModuleNotFoundError: | ||
print("The module intakebuilder is not installed. Do you have intakebuilder in your sys.path or have you activated the conda environment with the intakebuilder package in it? ") | ||
print("Attempting again with adjusted sys.path ") | ||
try: | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
except: | ||
print("Unable to adjust sys.path") | ||
#print(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
try: | ||
from intakebuilder import gfdlcrawler, CSVwriter, builderconfig, configparser | ||
print("Imported, and relied on sys.path") | ||
return True | ||
except ModuleNotFoundError: | ||
sys.exit("The module 'intakebuilder' is still not installed. Do you have intakebuilder in your sys.path or have you activated the conda environment with the intakebuilder package in it? ") | ||
raise ImportError('Error importing intakebuilder and other packages') | ||
return -97 | ||
|
||
def test_import(): | ||
assert check_import() == True | ||
|
||
|