Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- def execute(cmd):
- popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
- for stdout_line in iter(popen.stdout.readline, ""):
- yield stdout_line
- popen.stdout.close()
- return_code = popen.wait()
- if return_code:
- raise subprocess.CalledProcessError(return_code, cmd)
- # Example
- for path in execute(['sudo', 'bash', '/mnt/cephfs/huicheng/dhl-idc/offline-assembly-02.sh']):
- print(path, end="")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement