소스 검색

libraster: link against GDAL 2.2 (OSGeo4W)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71275 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 7 년 전
부모
커밋
8c3493007b
3개의 변경된 파일19개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 1
      lib/python/script/core.py
  2. 17 10
      lib/python/script/task.py
  3. 1 0
      lib/raster/gdal.c

+ 1 - 1
lib/python/script/core.py

@@ -473,7 +473,7 @@ def read_command(*args, **kwargs):
     returncode = process.poll()
     if _capture_stderr and returncode:
         sys.stderr.write(stderr)
-    return handle_errors(returncode, stdout, args, kwargs)
+    return handle_errors(returncode, stdout.decode('utf-8'), args, kwargs)
 
 
 def parse_command(*args, **kwargs):

+ 17 - 10
lib/python/script/task.py

@@ -434,7 +434,7 @@ class processTask:
         """Get node text"""
         p = node.find(tag)
         if p is not None:
-            return string.join(string.split(p.text), ' ')
+            return ' '.join(p.text.split())
 
         return default
 
@@ -448,18 +448,29 @@ def convert_xml_to_utf8(xml_text):
 
     # modify: fetch encoding from the interface description text(xml)
     # e.g. <?xml version="1.0" encoding="GBK"?>
-    pattern = re.compile('<\?xml[^>]*\Wencoding="([^"]*)"[^>]*\?>')
+    pattern = re.compile(b'<\?xml[^>]*\Wencoding="([^"]*)"[^>]*\?>')
     m = re.match(pattern, xml_text)
     if m is None:
         return xml_text
-    #
-    enc = m.groups()[0]
 
     # modify: change the encoding to "utf-8", for correct parsing
-    xml_text_utf8 = xml_text.decode(enc).encode("utf-8")
+    if (sys.version_info > (3, 0)): # Python 3
+        enc = m.groups()[0].decode()
+        xml_text_utf8 = xml_text.decode(enc)
+    else:                           # Python 2
+        enc = m.groups()[0]
+        xml_text_utf8 = xml_text.decode(enc).encode("utf-8")
+        
     p = re.compile('encoding="' + enc + '"', re.IGNORECASE)
     xml_text_utf8 = p.sub('encoding="utf-8"', xml_text_utf8)
 
+    xml_text_utf8 = xml_text_utf8.replace(
+        'grass-interface.dtd',
+        os.path.join(os.getenv('GISBASE'),
+                     'gui', 'xml',
+                     'grass-interface.dtd')
+    )
+
     return xml_text_utf8
 
 
@@ -504,11 +515,7 @@ def get_interface_description(cmd):
         raise ScriptError(_("Unable to fetch interface description for command '%(cmd)s'."
                              "\n\nDetails: %(det)s") % {'cmd': cmd, 'det': e})
 
-    desc = cmdout.replace('grass-interface.dtd',
-                          os.path.join(os.getenv('GISBASE'),
-                                       'gui', 'xml',
-                                       'grass-interface.dtd'))
-    return convert_xml_to_utf8(desc)
+    return convert_xml_to_utf8(cmdout)
 
 
 def parse_interface(name, parser=processTask, blackList=None):

+ 1 - 0
lib/raster/gdal.c

@@ -114,6 +114,7 @@ static void load_library(void)
 	"libgdal1.7.0.so",
 # endif
 # ifdef _WIN32
+	"gdal202.dll",        
 	"gdal201.dll",
 	"gdal200.dll",
 	"gdal111.dll",