#NEWLINE# def ensure_latest_globals_in_git( ) : #NEWLINE# #INDENT# if in_servi_code_dir ( ) : #NEWLINE# #INDENT# debug ( 'In source tree - not copying globals.' ) #NEWLINE# return True #NEWLINE# #UNINDENT# if ( not os . path . exists ( c . SERVIFILE_GLOBAL_FULL ) ) : #NEWLINE# #INDENT# info ( '{0} not found.' . format ( c . SERVIFILE_GLOBAL_FULL ) ) #NEWLINE# return True #NEWLINE# #UNINDENT# with open ( c . SERVIFILE_GLOBAL_FULL ) as fp : #NEWLINE# #INDENT# new_text = fp . read ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# root = subprocess . check_output ( 'git rev-parse --show-toplevel' , shell = True , universal_newlines = True ) #NEWLINE# if ( root [ ( - 1 ) ] == '\n' ) : #NEWLINE# #INDENT# root = root [ : ( len ( root ) - 1 ) ] #NEWLINE# #UNINDENT# cur_text = '' #NEWLINE# dest_path = os . path . join ( root , c . SERVIFILE_GLOBAL ) #NEWLINE# if os . path . exists ( dest_path ) : #NEWLINE# #INDENT# with open ( dest_path ) as fp : #NEWLINE# #INDENT# cur_text = fp . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( cur_text == new_text ) : #NEWLINE# #INDENT# info ( 'Servifile_globals.yml unchanged' ) #NEWLINE# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# shutil . copy2 ( src = c . SERVIFILE_GLOBAL_FULL , dst = dest_path ) #NEWLINE# info ( 'Servifile_globals.yml changed - copying to {0}' . format ( dest_path ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# #UNINDENT# except subprocess . CalledProcessError : #NEWLINE# #INDENT# raise ServiError ( 'Not currently in a git directory.' )