From dff2acea47d4aab85c41a4da9089396c8a01bb8b Mon Sep 17 00:00:00 2001 From: HashSplat Date: Thu, 6 Oct 2016 16:06:32 -0400 Subject: [PATCH] Added the ability to import geomag in an executable. Frozen executables (using cx_Freeze) do not have a __file__ attribute. If you are running an executable point the __file__ attribute to the executable path. --- geomag/geomag/geomag.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/geomag/geomag/geomag.py b/geomag/geomag/geomag.py index d546d55..6f0d77c 100644 --- a/geomag/geomag/geomag.py +++ b/geomag/geomag/geomag.py @@ -18,6 +18,12 @@ import math, os, unittest from datetime import date +# Allow finding the default WMM.COF by the frozen executable path +import sys +if hasattr(sys, "frozen"): + __file__ = os.path.relpath(sys.executable) + + class GeoMag: def GeoMag(self, dlat, dlon, h=0, time=date.today()): # latitude (decimal degrees), longitude (decimal degrees), altitude (feet), date