pid = int(subprocess.check_output(['pidof', app]))
pid = int(subprocess.Popen(['pidof', app], stdout=subprocess.PIPE).
    communicate()[0])
pid = int(os.popen('pidof ' + app).read())
Taking the results of a bash command and using it in python