Implement return codes consistently.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10132 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
José Matox 2005-07-05 15:28:44 +00:00
parent 9b4136de38
commit fb1e227a93
3 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2005-07-05 José Matos <jamatos@lyx.org>
* 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 <jamatos@lyx.org>
* LyX.py (LyX_Base):

View File

@ -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,11 +122,14 @@ 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)
if not self.try_hard:
self.warning("Quiting.")
sys.exit(1)
self.status = 2
def read(self):
"""Reads a file into the self.header and self.body parts, from self.input."""
@ -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)

View File

@ -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))