[GRASS-SVN] r66003 - in grass-addons/grass7/gui/wxpython/wx.metadata: db.csw.admin db.csw.harvest g.gui.cswbrowser g.gui.metadata mdlib r.info.iso t.info.iso v.info.iso

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 24 06:36:34 PDT 2015


Author: krejcmat
Date: 2015-08-24 06:36:34 -0700 (Mon, 24 Aug 2015)
New Revision: 66003

Modified:
   grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py
   grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py
   grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py
   grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py
   grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py
   grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.py
   grass-addons/grass7/gui/wxpython/wx.metadata/t.info.iso/t.info.iso.py
   grass-addons/grass7/gui/wxpython/wx.metadata/v.info.iso/v.info.iso.py
Log:
wx.metadata addons: fix import grass libs

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -119,8 +119,17 @@
 import ConfigParser
 
 from grass.script import core as grass
+from grass.pygrass.utils import get_lib_path
 
-sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
+def load_mdlib(libs):
+    for lib in libs:
+        path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,libname=lib)
+        if path is not None and path not in sys.path:
+            sys.path.append(path)
+        else:
+            import grass.script as grass
+            grass.fatal("Fatal error: library < %s > not found "%lib)
+load_mdlib(['cswutil'])
 
 import getopt
 from cswutil import *

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -49,7 +49,6 @@
 import sys
 import os
 
-sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
 from grass.script import core as grass
 
 try:

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -13,7 +13,16 @@
 import sys
 import os
 
-sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
+from grass.pygrass.utils import get_lib_path
+
+def load_mdlib(libs):
+    for lib in libs:
+        path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,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(['cswlib'])
 import wx
 from cswlib import CSWBrowserPanel, CSWConnectionPanel
 import grass.script as grass

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -23,28 +23,37 @@
 
 import sys
 import os
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc','wx.metadata','mdlib'))
-sys.path.insert(2, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
-
-from lxml import etree
-import wx
-from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
-from wx import SplitterWindow
+from grass.pygrass.utils import get_lib_path
 import grass.script as grass
-#from pydispatch import dispatcher
 from grass.pydispatch import dispatcher
+from core.gcmd import RunCommand, GError, GMessage
+import grass.temporal as tgis
+from lmgr import datacatalog
 
-import webbrowser
+def load_mdlib(libs):
+    for lib in libs:
+        path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,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(['mdgrass','mdutil','mdeditorfactory','cswlib','mdpdffactory'])
 
+
 import mdgrass
 import mdutil
 from mdpdffactory import PdfCreator
 from cswlib import CSWConnectionPanel
 from mdeditorfactory import MdMainEditor
 
-from lmgr import datacatalog
-from core.gcmd import RunCommand, GError, GMessage
-import grass.temporal as tgis
+from lxml import etree
+import wx
+from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
+from wx import SplitterWindow
+
+#from pydispatch import dispatcher
+
+import webbrowser
 import tempfile
 #===============================================================================
 # MAIN FRAME
@@ -52,6 +61,9 @@
 MAINFRAME = None
 
 
+
+
+
 class MdMainFrame(wx.Frame):
     '''Main frame of metadata editor
     '''
@@ -222,7 +234,7 @@
 
     def onExportCSW(self, evt):
         self.cswDialog = wx.Dialog(self, id=wx.ID_ANY,
-                                   title='Geometry creator',
+                                   title='Csw publisher',
                                    style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                                    size=wx.DefaultSize,
                                    pos=wx.DefaultPosition)
@@ -1273,6 +1285,7 @@
 
 #----------------------------------------------------------------------
 
+
 def main():
     global MAINFRAME
     app = wx.App(False)

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -15,7 +15,7 @@
 
 @author Matej Krejci <matejkrejci gmail.com> (GSoC 2014)
 """
-import sys
+import sys,os
 try:
     from owslib.iso import *
 except:
@@ -25,10 +25,18 @@
 except:
     sys.exit('jinja2 library is missing. Check requirements on the manual page < https://grasswiki.osgeo.org/wiki/ISO/INSPIRE_Metadata_Support >')
 
+from grass.script import core as grass
+from grass.pygrass.utils import get_lib_path
+def load_mdlib(libs):
+    for lib in libs:
+        path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,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(['mdutil'])
 
 from lxml import etree
-import os
-
 import StringIO
 import uuid
 import mdutil  # metadata lib
@@ -37,10 +45,9 @@
 from grass.script import parse_key_val
 from subprocess import PIPE
 from datetime import date, datetime
-from grass.script import core as grass
+
 from osgeo import osr
 #sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc','wx.metadata','mdlib'))
-sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
 class GrassMD():
 
     '''

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -42,12 +42,11 @@
 
 
 def load_mdlib():
-    path = get_lib_path(modname='mdlib', libname='mdgrass')
+    path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,libname='mdgrass')
     if path is None:
         fatal("Not able to find the metadata library directory")
     sys.path.append(path)
 
-
 def main():
     # load metadata library
     load_mdlib()

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/t.info.iso/t.info.iso.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/t.info.iso/t.info.iso.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/t.info.iso/t.info.iso.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -42,7 +42,7 @@
 
 
 def load_mdlib():
-    path = get_lib_path(modname='mdlib', libname='mdgrass')
+    path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,libname='mdgrass')
     if path is None:
         fatal("Not able to find the metadata library directory")
     sys.path.append(path)

Modified: grass-addons/grass7/gui/wxpython/wx.metadata/v.info.iso/v.info.iso.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/v.info.iso/v.info.iso.py	2015-08-24 12:27:56 UTC (rev 66002)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/v.info.iso/v.info.iso.py	2015-08-24 13:36:34 UTC (rev 66003)
@@ -41,7 +41,7 @@
 
 
 def load_mdlib():
-    path = get_lib_path(modname='mdlib', libname='mdgrass')
+    path = get_lib_path(modname=os.path.join('wx.metadata','mdlib') ,libname='mdgrass')
     if path is None:
         fatal("Not able to find the metadata library directory")
     sys.path.append(path)



More information about the grass-commit mailing list