7373}
7474
7575# Use this image for cleanup actions
76- DEBIAN_IMAGE = 'gcr.io/google-appengine/debian8'
76+ DEBIAN_IMAGE = 'gcr.io/google-appengine/debian8'
7777
7878# File template
7979BUILD_SCRIPT_TEMPLATE = """\
9090 if [ "${{HOST_WORKSPACE}}" != '/' -a -d "${{HOST_WORKSPACE}}" ]; then
9191 # Expect a single error message about /workspace busy
9292 {cleanup_str} 2>/dev/null || true
93- # Do not expect error messages here. Display but ignore any that happen .
93+ # Do not expect error messages here. Display but ignore.
9494 rmdir "${{HOST_WORKSPACE}}" || true
9595 fi
9696}}
108108
109109
110110# Validated cloudbuild recipe + flags
111- CloudBuild = collections .namedtuple ('CloudBuild' , 'output_script run steps substitutions' )
111+ CloudBuild = collections .namedtuple ('CloudBuild' ,
112+ 'output_script run steps substitutions' )
112113
113114# Single validated step in a cloudbuild recipe
114115Step = collections .namedtuple ('Step' , 'args dir_ env name' )
@@ -136,8 +137,7 @@ def sub(match):
136137 # Variables must be set
137138 raise ValueError (
138139 'Variable "{}" used without being defined. Try adding '
139- 'it to the --substitutions flag' .format (
140- variable_name ))
140+ 'it to the --substitutions flag' .format (variable_name ))
141141 else :
142142 value = substitutions .get (variable_name )
143143 substitutions_used .add (variable_name )
@@ -272,8 +272,9 @@ def generate_script(cloudbuild):
272272 if user_subs_unused :
273273 nice_list = '"' + '", "' .join (sorted (user_subs_unused )) + '"'
274274 raise ValueError (
275- 'User substitution variables {} were defined in the --substitution '
276- 'flag but never used in the cloudbuild file.' .format (nice_list ))
275+ 'User substitution variables {} were defined in the '
276+ '--substitution flag but never used in the cloudbuild file.' .
277+ format (nice_list ))
277278
278279 cleanup_str = ' ' .join (cleanup_command )
279280 docker_lines = []
@@ -298,7 +299,7 @@ def make_executable(path):
298299def write_script (cloudbuild , contents ):
299300 """Write a shell script to a file."""
300301 print ('Writing build script to {}' .format (cloudbuild .output_script ))
301- with open (cloudbuild .output_script , 'w' , encoding = 'utf8' ) as outfile :
302+ with io . open (cloudbuild .output_script , 'w' , encoding = 'utf8' ) as outfile :
302303 outfile .write (contents )
303304 make_executable (cloudbuild .output_script )
304305
@@ -310,7 +311,7 @@ def local_cloudbuild(args):
310311 args: command line flags as per parse_args
311312 """
312313 # Load and parse cloudbuild.yaml
313- with open (args .config , 'r' , encoding = 'utf8' ) as cloudbuild_file :
314+ with io . open (args .config , 'r' , encoding = 'utf8' ) as cloudbuild_file :
314315 raw_config = yaml .safe_load (cloudbuild_file )
315316
316317 # Determine configuration
0 commit comments