You could check to see if the current traceback is part of a chain of tracebacks:
import sys
try:
import user
except ImportError:
if sys.exc_info()[2].tb_next:
raise
logging.info('No user script loaded.')
If there is an ImportError
in user
, sys.exc_info()[2].tb_next
will point to it.