瀏覽代碼

winGRASS 7.7svn execute command fails, see https://trac.osgeo.org/grass/ticket/3733

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74010 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 6 年之前
父節點
當前提交
d098565658
共有 2 個文件被更改,包括 9 次插入6 次删除
  1. 8 5
      gui/wxpython/core/gcmd.py
  2. 1 1
      lib/python/script/core.py

+ 8 - 5
gui/wxpython/core/gcmd.py

@@ -163,7 +163,8 @@ class Popen(subprocess.Popen):
 
 
     def __init__(self, args, **kwargs):
     def __init__(self, args, **kwargs):
         if is_mswindows:
         if is_mswindows:
-            args = map(EncodeString, args)
+            # encoding not needed for Python3
+            # args = list(map(EncodeString, args))
 
 
             # The Windows shell (cmd.exe) requires some special characters to
             # The Windows shell (cmd.exe) requires some special characters to
             # be escaped by preceding them with 3 carets (^^^). cmd.exe /?
             # be escaped by preceding them with 3 carets (^^^). cmd.exe /?
@@ -233,13 +234,14 @@ class Popen(subprocess.Popen):
             if not self.stdin:
             if not self.stdin:
                 return None
                 return None
 
 
+            import pywintypes
             try:
             try:
                 x = msvcrt.get_osfhandle(self.stdin.fileno())
                 x = msvcrt.get_osfhandle(self.stdin.fileno())
                 (errCode, written) = WriteFile(x, input)
                 (errCode, written) = WriteFile(x, input)
             except ValueError:
             except ValueError:
                 return self._close('stdin')
                 return self._close('stdin')
-            except (subprocess.pywintypes.error, Exception) as why:
-                if why[0] in (109, errno.ESHUTDOWN):
+            except (pywintypes.error, Exception) as why:
+                if why.winerror in (109, errno.ESHUTDOWN):
                     return self._close('stdin')
                     return self._close('stdin')
                 raise
                 raise
 
 
@@ -250,6 +252,7 @@ class Popen(subprocess.Popen):
             if conn is None:
             if conn is None:
                 return None
                 return None
 
 
+            import pywintypes
             try:
             try:
                 x = msvcrt.get_osfhandle(conn.fileno())
                 x = msvcrt.get_osfhandle(conn.fileno())
                 (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                 (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
@@ -259,8 +262,8 @@ class Popen(subprocess.Popen):
                     (errCode, read) = ReadFile(x, nAvail, None)
                     (errCode, read) = ReadFile(x, nAvail, None)
             except ValueError:
             except ValueError:
                 return self._close(which)
                 return self._close(which)
-            except (subprocess.pywintypes.error, Exception) as why:
-                if why[0] in (109, errno.ESHUTDOWN):
+            except (pywintypes.error, Exception) as why:
+                if why.winerror in (109, errno.ESHUTDOWN):
                     return self._close(which)
                     return self._close(which)
                 raise
                 raise
 
 

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

@@ -274,7 +274,7 @@ def get_real_command(cmd):
         # so, lets remove extension
         # so, lets remove extension
         if os.path.splitext(cmd)[1] == '.py':
         if os.path.splitext(cmd)[1] == '.py':
             cmd = cmd[:-3]
             cmd = cmd[:-3]
-        full_path = shutil_which(cmd + '.py')
+        full_path = shutil_which(encode(cmd) + b'.py')
         if full_path:
         if full_path:
             return full_path
             return full_path