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

View File

@ -112,6 +112,7 @@ class LyX_Base:
self.textclass = "article" self.textclass = "article"
self.header = [] self.header = []
self.body = [] self.body = []
self.status = 0
def warning(self, message, debug_level= default_debug_level): def warning(self, message, debug_level= default_debug_level):
@ -121,10 +122,13 @@ class LyX_Base:
def error(self, message): 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(message)
self.warning("Quiting.") if not self.try_hard:
sys.exit(1) self.warning("Quiting.")
sys.exit(1)
self.status = 2
def read(self): def read(self):
@ -290,6 +294,7 @@ class LyX_Base:
default_debug_level) default_debug_level)
if not self.try_hard: if not self.try_hard:
raise raise
self.status = 2
else: else:
self.warning("%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)), self.warning("%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)),
default_debug_level + 1) default_debug_level + 1)

View File

@ -84,5 +84,8 @@ def main(argv):
file.convert() file.convert()
file.write() file.write()
return file.status
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv) sys.exit(main(sys.argv))