def need_deployment():
 if os.path.exists(OPTIONS.saltdir):
  shutil.rmtree(OPTIONS.saltdir)
 old_umask = os.umask(63)
 os.makedirs(OPTIONS.saltdir)
 os.umask(old_umask)
 euid = os.geteuid()
 dstat = os.stat(OPTIONS.saltdir)
 if (dstat.st_uid != euid):
  need_deployment()
 if (dstat.st_mode != 16832):
  need_deployment()
 sudo_gid = os.environ.get('SUDO_GID')
 if sudo_gid:
  try:
   os.chown(OPTIONS.saltdir, (-1), int(sudo_gid))
   stt = os.stat(OPTIONS.saltdir)
   os.chmod(OPTIONS.saltdir, (((stt.st_mode | stat.S_IWGRP) | stat.S_IRGRP) | stat.S_IXGRP))
  except OSError:
   sys.stdout.write('\n\nUnable to set permissions on thin directory.\nIf sudo_user is set and is not root, be certain the user is in the same group\nas the login user')
   sys.exit(1)
 sys.stdout.write('{0}\ndeploy\n'.format(OPTIONS.delimiter))
 sys.exit(EX_THIN_DEPLOY)

def need_deployment ( ) : if os . path . exists ( OPTIONS . saltdir ) : shutil . rmtree ( OPTIONS . saltdir ) old_umask = os . umask ( 63 ) os . makedirs ( OPTIONS . saltdir ) os . umask ( old_umask ) euid = os . geteuid ( ) dstat = os . stat ( OPTIONS . saltdir ) if ( dstat . st_uid != euid ) : need_deployment ( ) if ( dstat . st_mode != 16832 ) : need_deployment ( ) sudo_gid = os . environ . get ( 'SUDO_GID' ) if sudo_gid : try : os . chown ( OPTIONS . saltdir , ( - 1 ) , int ( sudo_gid ) ) stt = os . stat ( OPTIONS . saltdir ) os . chmod ( OPTIONS . saltdir , ( ( ( stt . st_mode | stat . S_IWGRP ) | stat . S_IRGRP ) | stat . S_IXGRP ) ) except OSError : sys . stdout . write ( '\n\nUnable to set permissions on thin directory.\nIf sudo_user is set and is not root, be certain the user is in the same group\nas the login user' ) sys . exit ( 1 ) sys . stdout . write ( '{0}\ndeploy\n' . format ( OPTIONS . delimiter ) ) sys . exit ( EX_THIN_DEPLOY )
salt thin needs to be deployed - prep the target directory and emit the delimeter and exit code that signals a required deployment .