Example of sub process use:
import argparse
import os
import subprocess
parser = argparse.ArgumentParser(description='initialize electric trace weights')
parser.add_argument('--env', help='target environment: dev, test , or prod', default='dev')
args = parser.parse_args()
env = args.env
database = {'dev': 'dev', 'test': 'test', 'prod': 'prod'}[env]
working_dir = os.path.dirname(os.path.realpath(__file__))
password = xxxx
trace_weight_exe = os.path.join(working_dir, 'ElectricTraceWeightInit.exe')
command = '"{exe}" {db} {pw}'.format(exe=trace_weight_exe, db=database, pw=password)
process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
exit_code = process.wait()