#NEWLINE# def _ensure_console_pid_dir_exists( ) : #NEWLINE# #INDENT# "Ensure that the console PID directory exists\n\n    Checks that the directory for the console PID file exists\n    and if not, creates it.\n\n    :raises: ConsoleError if the directory doesn't exist and cannot be created\n    " #NEWLINE# dir = _get_console_pid_dir ( ) #NEWLINE# if ( not os . path . exists ( dir ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# os . makedirs ( dir ) #NEWLINE# #UNINDENT# except OSError as exc : #NEWLINE# #INDENT# msg = ( _ ( "Cannot create directory '%(path)s' for console PID file. Reason: %(reason)s." ) % { #NEWLINE# #INDENT# 'path' : dir , #NEWLINE# 'reason' : exc , #NEWLINE# #UNINDENT# } ) #NEWLINE# LOG . error ( dir ) #NEWLINE# raise exception . ConsoleError ( message = msg )