def do_step(context):

    call("mkdir -p ./bosh", shell=True)
    call("mkdir -p ./bosh/manifests", shell=True)

    # Generate the private key and certificate
    call("sh create_cert.sh", shell=True)
    call("cp bosh.key ./bosh/bosh", shell=True)
    with open ('bosh_cert.pem', 'r') as tmpfile:
        ssh_cert = tmpfile.read()
    ssh_cert = "|\n" + ssh_cert
    ssh_cert="\n        ".join([line for line in ssh_cert.split('\n')])

    context.meta['settings']['SSH_CERTIFICATE'] = ssh_cert
    
    return context

from subprocess import call
from os import makedirs
from shutil import copy

def do_step(context):

    makedirs("bosh/manifests")

    # Generate the private key and certificate
    call("sh create_cert.sh", shell=True)
    copy("bosh.key", "./bosh/bosh")
    with open ('bosh_cert.pem', 'r') as tmpfile:
        ssh_cert = tmpfile.read()
    ssh_cert = "|\n" + ssh_cert
    ssh_cert="\n        ".join([line for line in ssh_cert.split('\n')])

    context.meta['settings']['SSH_CERTIFICATE'] = ssh_cert

    return context

Use python libs to do file operations
Use python libs to do file operations

+ from subprocess import call
+ from os import makedirs
+ from shutil import copy
+ 
  def do_step(context):
  
+     makedirs("bosh/manifests")
-     call("mkdir -p ./bosh", shell=True)
-     call("mkdir -p ./bosh/manifests", shell=True)
  
      # Generate the private key and certificate
      call("sh create_cert.sh", shell=True)
-     call("cp bosh.key ./bosh/bosh", shell=True)
+     copy("bosh.key", "./bosh/bosh")
      with open ('bosh_cert.pem', 'r') as tmpfile:
          ssh_cert = tmpfile.read()
      ssh_cert = "|\n" + ssh_cert
      ssh_cert="\n        ".join([line for line in ssh_cert.split('\n')])
  
      context.meta['settings']['SSH_CERTIFICATE'] = ssh_cert
-     
+ 
      return context
  
Use python libs to do file operations
## Code Before:
def do_step(context):

    call("mkdir -p ./bosh", shell=True)
    call("mkdir -p ./bosh/manifests", shell=True)

    # Generate the private key and certificate
    call("sh create_cert.sh", shell=True)
    call("cp bosh.key ./bosh/bosh", shell=True)
    with open ('bosh_cert.pem', 'r') as tmpfile:
        ssh_cert = tmpfile.read()
    ssh_cert = "|\n" + ssh_cert
    ssh_cert="\n        ".join([line for line in ssh_cert.split('\n')])

    context.meta['settings']['SSH_CERTIFICATE'] = ssh_cert
    
    return context

## Instruction:
Use python libs to do file operations
## Code After:
from subprocess import call
from os import makedirs
from shutil import copy

def do_step(context):

    makedirs("bosh/manifests")

    # Generate the private key and certificate
    call("sh create_cert.sh", shell=True)
    copy("bosh.key", "./bosh/bosh")
    with open ('bosh_cert.pem', 'r') as tmpfile:
        ssh_cert = tmpfile.read()
    ssh_cert = "|\n" + ssh_cert
    ssh_cert="\n        ".join([line for line in ssh_cert.split('\n')])

    context.meta['settings']['SSH_CERTIFICATE'] = ssh_cert

    return context
