[GRASS-SVN] r66045 - grass-addons/grass7/gui/wxpython/wx.mwprecip
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 27 02:19:04 PDT 2015
Author: krejcmat
Date: 2015-08-27 02:19:03 -0700 (Thu, 27 Aug 2015)
New Revision: 66045
Modified:
grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
Log:
wx.mwprecip addons: use get_lib_path() for import addons lib
Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py 2015-08-27 08:33:31 UTC (rev 66044)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py 2015-08-27 09:19:03 UTC (rev 66045)
@@ -2,12 +2,20 @@
import os
import sys
+from grass.pygrass.utils import get_lib_path
+import grass.script as grass
VERSION = 1.0
+def load_mdlib(libs):
+ for lib in libs:
+ path = get_lib_path(modname=os.path.join( 'etc', 'g.gui.mwprecip') ,libname=lib)
+ if path is not None and path not in sys.path:
+ sys.path.append(path)
+ elif path is None:
+ grass.fatal("Fatal error: library < %s > not found "%lib)
+load_mdlib(['mw3','mw_util'])
-
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'g.gui.mwprecip'))
from mw_util import *
from mw3 import *
import tempfile
Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py 2015-08-27 08:33:31 UTC (rev 66044)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py 2015-08-27 09:19:03 UTC (rev 66045)
@@ -8,6 +8,8 @@
import psycopg2
import time
import math
+import sys
+import os
from subprocess import PIPE
from pgwrapper import pgwrapper as pg
@@ -16,10 +18,16 @@
import numpy as np
-try:
- from grass.script import core as grass
-except ImportError:
- sys.exit("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4")
+from grass.pygrass.utils import get_lib_path
+import grass.script as grass
+def load_mdlib(libs):
+ for lib in libs:
+ path = get_lib_path(modname=os.path.join( 'etc', 'g.gui.mwprecip') ,libname=lib)
+ if path is not None and path not in sys.path:
+ sys.path.append(path)
+ elif path is None:
+ grass.fatal("Fatal error: library < %s > not found "%lib)
+load_mdlib(['mw_util'])
from mw_util import *
More information about the grass-commit
mailing list