From ea1d779a8f14178ddf8d79f9c2a9d2cf671eab2c Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 9 Apr 2015 12:30:37 +0200 Subject: [PATCH] Proposed fix for SeattleTestbed/repy_v2#92 This removes two conditional function-level `import`s of `servicelogger.py`. As these could be reached from within a Repy program, and Repy forbids `import`, this caused a misleading error message. (See SeattleTestbed/repy_v2#69 for another similarly-looking problem). --- tracebackrepy.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tracebackrepy.py b/tracebackrepy.py index 2035941b..ebeacba2 100755 --- a/tracebackrepy.py +++ b/tracebackrepy.py @@ -23,7 +23,7 @@ import sys # We need the service logger to log internal errors -Brent -# import servicelogger +import servicelogger # Used to determine whether or not we use the service logger to log internal # errors. Defaults to false. -Brent @@ -54,9 +54,6 @@ def initialize(useservlog=False, logdir = '.'): global servicelog global logdirectory - if useservlog: - import servicelogger - servicelog = useservlog logdirectory = logdir @@ -210,9 +207,6 @@ def handle_internalerror(error_string, exitcode): Shouldn't return because harshexit will always be called. """ - if servicelog: - import servicelogger - try: print >> sys.stderr, "Internal Error" handle_exception() @@ -246,7 +240,8 @@ def handle_internalerror(error_string, exitcode): # Again we want to ensure that even if we fail to log, we still exit. try: - servicelogger.multi_process_log(exceptionstring, identifier, logdirectory) + if servicelog: + servicelogger.multi_process_log(exceptionstring, identifier, logdirectory) except Exception, e: # if an exception occurs, log it (unfortunately, to the user's log) print 'Inner abort of servicelogger'