From d900b9de7074d5d2298139406835d2ebf75028fa Mon Sep 17 00:00:00 2001 From: DivineOmega Date: Mon, 15 Jul 2013 10:49:01 +0100 Subject: [PATCH 1/2] Added check for logger global before attempting to log in places where logging may occur before the logger is ready --- src/shared.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shared.py b/src/shared.py index 5abeeb96..ddedf3d0 100644 --- a/src/shared.py +++ b/src/shared.py @@ -118,8 +118,9 @@ def lookupAppdataFolder(): if "HOME" in environ: dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/' else: - logger.critical('Could not find home folder, please report this message and your ' - 'OS X version to the BitMessage Github.') + if 'logger' in globals(): + logger.critical('Could not find home folder, please report this message and your ' + 'OS X version to the BitMessage Github.') sys.exit() elif 'win32' in sys.platform or 'win64' in sys.platform: @@ -133,7 +134,8 @@ def lookupAppdataFolder(): # Migrate existing data to the proper location if this is an existing install try: - logger.info("Moving data folder to %s" % (dataFolder)) + if 'logger' in globals(): + logger.info("Moving data folder to %s" % (dataFolder)) move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder) except IOError: pass From 3107150ace725a4928e1d05e8e2b94af4ba20729 Mon Sep 17 00:00:00 2001 From: DivineOmega Date: Mon, 15 Jul 2013 10:56:13 +0100 Subject: [PATCH 2/2] Added fall back print statements in case logger is unavailable --- src/shared.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/shared.py b/src/shared.py index ddedf3d0..ff39ea2e 100644 --- a/src/shared.py +++ b/src/shared.py @@ -118,9 +118,11 @@ def lookupAppdataFolder(): if "HOME" in environ: dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/' else: + stringToLog = 'Could not find home folder, please report this message and your OS X version to the BitMessage Github.' if 'logger' in globals(): - logger.critical('Could not find home folder, please report this message and your ' - 'OS X version to the BitMessage Github.') + logger.critical(stringToLog) + else: + print stringToLog sys.exit() elif 'win32' in sys.platform or 'win64' in sys.platform: @@ -134,8 +136,11 @@ def lookupAppdataFolder(): # Migrate existing data to the proper location if this is an existing install try: + stringToLog = "Moving data folder to %s" % (dataFolder) if 'logger' in globals(): - logger.info("Moving data folder to %s" % (dataFolder)) + logger.info(stringToLog) + else: + print stringToLog move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder) except IOError: pass