def run_script_with_context(script_path, cwd, context):
 (_, extension) = os.path.splitext(script_path)
 contents = io.open(script_path, 'r', encoding='utf-8').read()
 with tempfile.NamedTemporaryFile(delete=False, mode='wb', suffix=extension) as temp:
  env = StrictEnvironment(context=context, keep_trailing_newline=True)
  template = env.from_string(contents)
  output = template.render(**context)
  temp.write(output.encode('utf-8'))
 run_script(temp.name, cwd)

def run_script_with_context ( script_path , cwd , context ) : ( _ , extension ) = os . path . splitext ( script_path ) contents = io . open ( script_path , 'r' , encoding = 'utf-8' ) . read ( ) with tempfile . NamedTemporaryFile ( delete = False , mode = 'wb' , suffix = extension ) as temp : env = StrictEnvironment ( context = context , keep_trailing_newline = True ) template = env . from_string ( contents ) output = template . render ( ** context ) temp . write ( output . encode ( 'utf-8' ) ) run_script ( temp . name , cwd )
execute a script after rendering it with jinja .