On Monday 04 July 2005 17:35, Angus Leeming wrote: > > Whatever. I don't think that parsing a string that's output to stderr > or to a temporary file is the right thing to do here. Jean-Marc's > error codes will do the job and are the 'expected' way to signal > failure.
Follows attached a patch that implements this: 0 - Everything OK. 1 - Irrecoverable error. 2 - Recovered from error(s). > I don't think that communicating with a child process through its > standard streams is 'must have' functionality for LyX 1.4 or that > it's needed in order to obtain better communication with lyx2lyx. The errors from the standard error are more descriptive than those from lyx and it is tedious and error prone to have them synchronized, that is why I have chosen a simple scheme like the previous. -- José Abílio
Index: LyX.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/LyX.py,v retrieving revision 1.13 diff -u -p -r1.13 LyX.py --- LyX.py 5 Jul 2005 11:14:13 -0000 1.13 +++ LyX.py 5 Jul 2005 11:48:01 -0000 @@ -112,6 +112,7 @@ class LyX_Base: self.textclass = "article" self.header = [] self.body = [] + self.status = 0 def warning(self, message, debug_level= default_debug_level): @@ -123,8 +124,11 @@ class LyX_Base: def error(self, message): " Emits a warning and exist incondicionally." self.warning(message) - self.warning("Quiting.") - sys.exit(1) + if not self.try_hard: + self.warning("Quiting.") + sys.exit(1) + + self.status = 2 def read(self): @@ -290,6 +294,7 @@ class LyX_Base: default_debug_level) if not self.try_hard: raise + self.status = 2 else: self.warning("%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)), default_debug_level + 1) Index: lyx2lyx =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx2lyx,v retrieving revision 1.34 diff -u -p -r1.34 lyx2lyx --- lyx2lyx 5 Jul 2005 11:14:13 -0000 1.34 +++ lyx2lyx 5 Jul 2005 11:48:01 -0000 @@ -84,5 +84,8 @@ def main(argv): file.convert() file.write() + return file.status + + if __name__ == "__main__": - main(sys.argv) + sys.exit(main(sys.argv))