Procházet zdrojové kódy

stdin_ parameter now it's working

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54556 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli před 12 roky
rodič
revize
038fa22228
1 změnil soubory, kde provedl 9 přidání a 3 odebrání
  1. 9 3
      lib/python/pygrass/modules/__init__.py

+ 9 - 3
lib/python/pygrass/modules/__init__.py

@@ -587,12 +587,18 @@ class Module(object):
 
     def run(self, node=None):
         cmd = self.make_cmd()
+        if self.stdin_:
+            self.stdin = self.stdin_
+            self.stdin_ = subprocess.PIPE
         self.popen = subprocess.Popen(cmd, stdin=self.stdin_,
                                       stdout=self.stdout_,
                                       stderr=self.stderr_)
-        if self.finish_:
-            self.popen.wait()
-        self.stdout, self.stderr = self.popen.communicate()
+        if self.stdin_:
+            self.stdout, self.stderr = self.popen.communicate(input=self.stdin)
+        else:
+            if self.finish_:
+                self.popen.wait()
+            self.stdout, self.stderr = self.popen.communicate()
 
 _CMDS = list(grass.script.core.get_commands()[0])
 _CMDS.sort()