浏览代码

Fix Popen using grass.script.core.Popen instead of subprocess.Popen

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58932 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 11 年之前
父节点
当前提交
3201b38841
共有 1 个文件被更改,包括 8 次插入10 次删除
  1. 8 10
      lib/python/pygrass/modules/interface/module.py

+ 8 - 10
lib/python/pygrass/modules/interface/module.py

@@ -49,12 +49,11 @@ Created on Tue Apr  2 18:41:27 2013
 """
 
 from __future__ import print_function
-import subprocess
 from itertools import izip_longest
 from xml.etree.ElementTree import fromstring
 import time
 
-
+from grass.script.core import Popen, PIPE
 from grass.pygrass.errors import GrassError, ParameterError
 from parameter import Parameter
 from flag import Flag
@@ -240,8 +239,7 @@ class Module(object):
         self.name = cmd
         try:
             # call the command with --interface-description
-            get_cmd_xml = subprocess.Popen([cmd, "--interface-description"],
-                                           stdout=subprocess.PIPE)
+            get_cmd_xml = Popen([cmd, "--interface-description"], stdout=PIPE)
         except OSError as e:
             print("OSError error({0}): {1}".format(e.errno, e.strerror))
             str_err = "Error running: `%s --interface-description`."
@@ -457,18 +455,18 @@ class Module(object):
         """
         if self.inputs['stdin'].value:
             self.stdin = self.inputs['stdin'].value
-            self.stdin_ = subprocess.PIPE
+            self.stdin_ = PIPE
         if self.outputs['stdout'].value:
             self.stdout_ = self.outputs['stdout'].value
         if self.outputs['stderr'].value:
             self.stderr_ = self.outputs['stderr'].value
         cmd = self.make_cmd()
         start = time.time()
-        self.popen = subprocess.Popen(cmd,
-                                      stdin=self.stdin_,
-                                      stdout=self.stdout_,
-                                      stderr=self.stderr_,
-                                      env=self.env_)
+        self.popen = Popen(cmd,
+                           stdin=self.stdin_,
+                           stdout=self.stdout_,
+                           stderr=self.stderr_,
+                           env=self.env_)
         if self.finish_:
             stdout, stderr = self.popen.communicate(input=self.stdin)
             self.outputs['stdout'].value = stdout if stdout else ''