From 5ec91ac106aa190844c6b6bc3ba62c12f7d4ce7c Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Thu, 29 Oct 2009 14:42:25 +0000 Subject: [PATCH] Some people can't open the log; handle this gracefully. Signed-off-by: Chris Lamb --- dak/dak.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dak/dak.py b/dak/dak.py index 19facc55..f9839ea0 100755 --- a/dak/dak.py +++ b/dak/dak.py @@ -39,6 +39,7 @@ import daklib.utils from daklib.daklog import Logger from daklib.config import Config +from daklib.dak_exceptions import CantOpenError ################################################################################ @@ -156,7 +157,11 @@ Available commands:""" def main(): """Launch dak functionality.""" - logger = Logger(Config(), 'dak top-level', print_starting=False) + + try: + logger = Logger(Config(), 'dak top-level', print_starting=False) + except CantOpenError: + logger = None functionality = init() modules = [ command for (command, _) in functionality ] @@ -200,13 +205,15 @@ def main(): except KeyboardInterrupt: msg = 'KeyboardInterrupt caught; exiting' print msg - logger.log([msg]) + if logger: + logger.log([msg]) sys.exit(1) except SystemExit: pass except: - for line in traceback.format_exc().split('\n')[:-1]: - logger.log(['exception', line]) + if logger: + for line in traceback.format_exc().split('\n')[:-1]: + logger.log(['exception', line]) raise ################################################################################ -- 2.39.5