#NEWLINE# def need_deployment( ) : #NEWLINE# #INDENT# '\n    Salt thin needs to be deployed - prep the target directory and emit the\n    delimeter and exit code that signals a required deployment.\n    ' #NEWLINE# if os . path . exists ( OPTIONS . saltdir ) : #NEWLINE# #INDENT# shutil . rmtree ( OPTIONS . saltdir ) #NEWLINE# #UNINDENT# old_umask = os . umask ( 63 ) #NEWLINE# os . makedirs ( OPTIONS . saltdir ) #NEWLINE# os . umask ( old_umask ) #NEWLINE# euid = os . geteuid ( ) #NEWLINE# dstat = os . stat ( OPTIONS . saltdir ) #NEWLINE# if ( dstat . st_uid != euid ) : #NEWLINE# #INDENT# need_deployment ( ) #NEWLINE# #UNINDENT# if ( dstat . st_mode != 16832 ) : #NEWLINE# #INDENT# need_deployment ( ) #NEWLINE# #UNINDENT# sudo_gid = os . environ . get ( 'SUDO_GID' ) #NEWLINE# if sudo_gid : #NEWLINE# #INDENT# os . chown ( OPTIONS . saltdir , ( - 1 ) , int ( sudo_gid ) ) #NEWLINE# stt = os . stat ( OPTIONS . saltdir ) #NEWLINE# os . chmod ( OPTIONS . saltdir , ( ( ( stt . st_mode | stat . S_IWGRP ) | stat . S_IRGRP ) | stat . S_IXGRP ) ) #NEWLINE# #UNINDENT# sys . stdout . write ( '{0}\ndeploy\n' . format ( OPTIONS . delimiter ) ) #NEWLINE# sys . exit ( EX_THIN_DEPLOY )