def does_chmod_work(dir_to_test):
 if (not os.path.isdir(dir_to_test)):
  return True
 f1 = tempfile.NamedTemporaryFile(dir=dir_to_test)
 try:
  f1_stat = os.stat(f1.name)
  os.chmod(f1.name, (f1_stat.st_mode | stat.S_IRUSR))
  chmod_works = True
  logging.debug(('Detected that chmods work in %r' % dir_to_test))
 except OSError:
  chmod_works = False
  logging.debug(('Detected that chmods do NOT work in %r' % dir_to_test))
 return chmod_works

def does_chmod_work ( dir_to_test ) : if ( not os . path . isdir ( dir_to_test ) ) : return True f1 = tempfile . NamedTemporaryFile ( dir = dir_to_test ) try : f1_stat = os . stat ( f1 . name ) os . chmod ( f1 . name , ( f1_stat . st_mode | stat . S_IRUSR ) ) chmod_works = True logging . debug ( ( 'Detected that chmods work in %r' % dir_to_test ) ) except OSError : chmod_works = False logging . debug ( ( 'Detected that chmods do NOT work in %r' % dir_to_test ) ) return chmod_works
detects if chmod works in a given directory .