Пример #1
0
 def run_background(self):
     """Run as a background process."""
     assert self.__indata is None
     try:
         p = subprocess.Popen(self.__prep_cmd(),
                              env=self.__prep_env(),
                              cwd=self.__cwd,
                              stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     except OSError as e:
         raise self.exc('%s failed: %s' % (self.__cmd[0], e))
     if self.__in_encoding:
         if hasattr(p.stdin, 'readable'):
             self.stdin = io.TextIOWrapper(
                 p.stdin, encoding=self.__in_encoding)
         else:
             self.stdin = io.TextIOWrapper(
                 file_wrapper(p.stdin, writable=True),
                 encoding=self.__in_encoding)
     else:
         self.stdin = p.stdin
     self.stdout = p.stdout
     self.stderr = p.stderr
     self.wait = p.wait
     self.pid = lambda: p.pid
     return self
Пример #2
0
Файл: run.py Проект: snits/stgit
 def run_background(self):
     """Run as a background process."""
     assert self.__indata is None
     try:
         p = subprocess.Popen(self.__prep_cmd(),
                              env=self.__prep_env(),
                              cwd=self.__cwd,
                              stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     except OSError as e:
         raise self.exc('%s failed: %s' % (self.__cmd[0], e))
     if self.__in_encoding:
         if hasattr(p.stdin, 'readable'):
             self.stdin = io.TextIOWrapper(
                 p.stdin, encoding=self.__in_encoding)
         else:
             self.stdin = io.TextIOWrapper(
                 file_wrapper(p.stdin, writable=True),
                 encoding=self.__in_encoding)
     else:
         self.stdin = p.stdin
     self.stdout = p.stdout
     self.stderr = p.stderr
     self.wait = p.wait
     self.pid = lambda: p.pid
     return self