comparison cmd2.py @ 49:8926b72d828e

first success with pipe
author catherine@localhost
date Fri, 06 Jun 2008 16:51:09 -0400
parents 34fb41095451
children dccf27f52f51
comparison
equal deleted inserted replaced
48:34fb41095451 49:8926b72d828e
242 statement, redirect = self.findPipe(statement) 242 statement, redirect = self.findPipe(statement)
243 if redirect: 243 if redirect:
244 statekeeper = Statekeeper(self, ('stdout',)) 244 statekeeper = Statekeeper(self, ('stdout',))
245 redirect = subprocess.Popen(redirect, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) 245 redirect = subprocess.Popen(redirect, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
246 self.stdout = redirect.stdin 246 self.stdout = redirect.stdin
247 stop = cmd.Cmd.onecmd(self, statement) 247 stop = cmd.Cmd.onecmd(self, statement)
248 statekeeper.restore() 248 statekeeper.restore()
249 self.stdout.write(redirect.stdout.read()) 249 for result in redirect.communicate():
250 self.stdout.write(result or '')
250 return stop # didn't record in history 251 return stop # didn't record in history
251 else: 252 else:
252 statement, redirect, mode = self.parseRedirectors(statement) 253 statement, redirect, mode = self.parseRedirectors(statement)
253 if redirect == self._TO_PASTE_BUFFER: 254 if redirect == self._TO_PASTE_BUFFER:
254 try: 255 try: