Mercurial > python-cmd2
comparison cmd2.py @ 276:9bcfa4f81825
changes for error reporting complete
author | catherine@cordelia |
---|---|
date | Tue, 02 Jun 2009 07:34:15 -0400 |
parents | f62e9fbb3f90 |
children | b3702f5ed467 |
comparison
equal
deleted
inserted
replaced
275:f62e9fbb3f90 | 276:9bcfa4f81825 |
---|---|
272 | 272 |
273 def poutput(self, msg): | 273 def poutput(self, msg): |
274 self.stdout.write(msg) | 274 self.stdout.write(msg) |
275 if msg[-1] != '\n': | 275 if msg[-1] != '\n': |
276 self.stdout.write('\n') | 276 self.stdout.write('\n') |
277 def perror(self, errmsg): | 277 def perror(self, errmsg, statement=None): |
278 print str(errmsg) | 278 print str(errmsg) |
279 def pfeedback(self, msg): | 279 def pfeedback(self, msg): |
280 """For printing nonessential feedback. Can be silenced with `quiet`. | 280 """For printing nonessential feedback. Can be silenced with `quiet`. |
281 Inclusion in redirected output is controlled by `feedback_to_output`.""" | 281 Inclusion in redirected output is controlled by `feedback_to_output`.""" |
282 if not self.quiet: | 282 if not self.quiet: |
662 timestart = datetime.datetime.now() | 662 timestart = datetime.datetime.now() |
663 stop = func(statement) | 663 stop = func(statement) |
664 if self.timing: | 664 if self.timing: |
665 self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart)) | 665 self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart)) |
666 except Exception, e: | 666 except Exception, e: |
667 self.perror(e) | 667 self.perror(e, statement) |
668 finally: | 668 finally: |
669 if statekeeper: | 669 if statekeeper: |
670 if statement.parsed.output and not statement.parsed.outputTo: | 670 if statement.parsed.output and not statement.parsed.outputTo: |
671 self.stdout.seek(0) | 671 self.stdout.seek(0) |
672 try: | 672 try: |