@memoize
def try_write(dir_path, heavy=False):
 log.trace(u'checking user write access for %s', dir_path)
 if (not isdir(dir_path)):
  return False
 if (on_win or heavy):
  temp_filename = join(dir_path, (u'.conda-try-write-%d' % getpid()))
  try:
   with open(temp_filename, mode=u'wb') as fo:
    fo.write('This is a test file.\n')
   backoff_unlink(temp_filename)
   return True
  except (IOError, OSError):
   return False
  finally:
   backoff_unlink(temp_filename)
 else:
  return access(dir_path, W_OK)

@ memoize def try_write ( dir_path , heavy = False ) : log . trace ( u'checking user write access for %s' , dir_path ) if ( not isdir ( dir_path ) ) : return False if ( on_win or heavy ) : temp_filename = join ( dir_path , ( u'.conda-try-write-%d' % getpid ( ) ) ) try : with open ( temp_filename , mode = u'wb' ) as fo : fo . write ( 'This is a test file.\n' ) backoff_unlink ( temp_filename ) return True except ( IOError , OSError ) : return False finally : backoff_unlink ( temp_filename ) else : return access ( dir_path , W_OK )
test write access to a directory .