浏览代码

r.in.wms: write string not bytes to capabilities file (#195)

* write string not bytes

* convert cap to string earlier
Stefan Blumentrath 5 年之前
父节点
当前提交
37e988cadb
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      scripts/r.in.wms/wms_base.py

+ 3 - 4
scripts/r.in.wms/wms_base.py

@@ -261,7 +261,7 @@ class WMSBase(object):
                 grass.fatal(msg)
 
         grass.debug('Fetching capabilities OK')
-        return cap
+        return grass.decode(cap)
 
     def _fetchDataFromServer(self, url, username=None, password=None):
         """!Fetch data from server
@@ -285,9 +285,8 @@ class WMSBase(object):
         # save to file
         if capfile_output:
             try:
-                temp = open(capfile_output, "w")
-                temp.write(cap.read())
-                temp.close()
+                with open(capfile_output, "w") as temp:
+                    temp.write(cap.read())
                 return
             except IOError as error:
                 grass.fatal(_("Unabble to open file '%s'.\n%s\n" % (cap_file, error)))