comparison rhodecode/lib/subprocessio.py @ 2572:71fc1c98e02a beta

dont format errors to string in subprocessio
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 07 Jul 2012 19:35:18 +0200
parents 79db9abad657
children 1f4d4b8d72f5
comparison
equal deleted inserted replaced
2571:94a92bd832c5 2572:71fc1c98e02a
365 _p.terminate() 365 _p.terminate()
366 except: 366 except:
367 pass 367 pass
368 bg_out.stop() 368 bg_out.stop()
369 bg_err.stop() 369 bg_err.stop()
370 raise EnvironmentError("Subprocess exited due to an error.\n" + "".join(bg_err)) 370 err = '%r' % ''.join(bg_err)
371 raise EnvironmentError("Subprocess exited due to an error.\n" + err)
371 372
372 self.process = _p 373 self.process = _p
373 self.output = bg_out 374 self.output = bg_out
374 self.error = bg_err 375 self.error = bg_err
375 376
376 def __iter__(self): 377 def __iter__(self):
377 return self 378 return self
378 379
379 def next(self): 380 def next(self):
380 if self.process.poll(): 381 if self.process.poll():
381 raise EnvironmentError("Subprocess exited due to an error:\n" + ''.join(self.error)) 382 err = '%r' % ''.join(self.error)
383 raise EnvironmentError("Subprocess exited due to an error:\n" + err)
382 return self.output.next() 384 return self.output.next()
383 385
384 def throw(self, type, value=None, traceback=None): 386 def throw(self, type, value=None, traceback=None):
385 if self.output.length or not self.output.done_reading: 387 if self.output.length or not self.output.done_reading:
386 raise type(value) 388 raise type(value)