From fb1e227a93a394bcc56be0edacd7001679b5044f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Tue, 5 Jul 2005 15:28:44 +0000 Subject: [PATCH] Implement return codes consistently. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10132 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/ChangeLog | 10 ++++++++++ lib/lyx2lyx/LyX.py | 11 ++++++++--- lib/lyx2lyx/lyx2lyx | 5 ++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/lyx2lyx/ChangeLog b/lib/lyx2lyx/ChangeLog index dd974627cd..ee07c0f5ed 100644 --- a/lib/lyx2lyx/ChangeLog +++ b/lib/lyx2lyx/ChangeLog @@ -1,3 +1,13 @@ +2005-07-05 José Matos + + * LyX.py (LyX_Base): + * LyX.py (error): + * LyX.py (convert): + * lyx2lyx: Implement return codes consistently: + 0 - OK. + 1 - Irrecoverable error. + 2 - Recovered from error(s). + 2005-07-05 José Matos * LyX.py (LyX_Base): diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 4b5dadcf0d..33edd48f0c 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -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): @@ -121,10 +122,13 @@ class LyX_Base: def error(self, message): - " Emits a warning and exist incondicionally." + " Emits a warning and exits if not in try_hard mode." 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) diff --git a/lib/lyx2lyx/lyx2lyx b/lib/lyx2lyx/lyx2lyx index 5c63e64ba2..ce0e45278d 100755 --- a/lib/lyx2lyx/lyx2lyx +++ b/lib/lyx2lyx/lyx2lyx @@ -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))