From 0c2857d3c041b85c06cb23d3f209b772b825bb14 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Wed, 11 Feb 2015 12:12:27 -0700 Subject: [PATCH] Update how main scripts ensure geomagio is on include path --- bin/main.py | 9 ++++++--- bin/xyz.py | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/main.py b/bin/main.py index 7b4ee81ac..5bc990d5c 100755 --- a/bin/main.py +++ b/bin/main.py @@ -2,10 +2,13 @@ from os import path + # ensure geomag is on the path before importing -script_dir = path.dirname(path.abspath(__file__)) -if __file__ != 'bin/main.py': - import sys +try: + import geomagio +except: + from os import path + script_dir = path.dirname(path.abspath(__file__)) sys.path.append(path.normpath(path.join(script_dir, '..'))) import geomagio.iaga2002 as iaga2002 diff --git a/bin/xyz.py b/bin/xyz.py index eb97beb53..bfef7ea24 100755 --- a/bin/xyz.py +++ b/bin/xyz.py @@ -23,8 +23,11 @@ import argparse import sys + # ensure geomag is on the path before importing -if __file__ != 'bin/xyz.py': +try: + import geomagio +except: from os import path script_dir = path.dirname(path.abspath(__file__)) sys.path.append(path.normpath(path.join(script_dir, '..'))) -- GitLab