get process id of program
def get_pid(pname):
process = psutil.process_iter()
for pro in process:
str_pro = str(pro)
pat = re.compile(pname)
if pat.search(str_pro):
pid = str_pro.split('pid=')[1].split(',')[0]
return pid