#NEWLINE# def setup( fuzzy_path = None , _safe_mode = False ) : #NEWLINE# #INDENT# '\n    Configure IEPY internals,\n        Reads IEPY instance configuration if any path provided.\n        Detects out of dated instances.\n        Returns the absolute path to the IEPY instance if provided, None if not.\n    ' #NEWLINE# if ( not isinstance ( fuzzy_path , ( type ( None ) , str ) ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not settings . configured ) : #NEWLINE# #INDENT# if ( fuzzy_path is None ) : #NEWLINE# #INDENT# if ( not os . getenv ( 'DJANGO_SETTINGS_MODULE' ) ) : #NEWLINE# #INDENT# os . environ [ 'DJANGO_SETTINGS_MODULE' ] = 'iepy.webui.webui.settings' #NEWLINE# #UNINDENT# result = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( path , project_name , old ) = _actual_path ( fuzzy_path ) #NEWLINE# sys . path . insert ( 0 , path ) #NEWLINE# if old : #NEWLINE# #INDENT# django_settings_module = '{0}_settings' . format ( django_settings_module ) #NEWLINE# sys . path . insert ( 0 , os . path . join ( path , project_name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# django_settings_module = '{0}.settings' . format ( project_name ) #NEWLINE# #UNINDENT# os . environ [ 'DJANGO_SETTINGS_MODULE' ] = django_settings_module #NEWLINE# result = os . path . join ( path , project_name ) #NEWLINE# import_instance ( project_name ) #NEWLINE# #UNINDENT# django . setup ( ) #NEWLINE# if ( ( not _safe_mode ) and ( settings . IEPY_VERSION != __version__ ) ) : #NEWLINE# #INDENT# sys . exit ( 'Instance version is {} and current IEPY installation is {}.\nRun iepy --upgrade on the instance.' . format ( settings . IEPY_VERSION , __version__ ) ) #NEWLINE# #UNINDENT# return result