Last active
December 7, 2017 05:58
-
-
Save zhangchunlin/049634ffa265181d74b3b115229717c2 to your computer and use it in GitHub Desktop.
Revisions
-
zhangchunlin revised this gist
Dec 7, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ from subprocess import Popen, PIPE, STDOUT import os def runcmd(cwd,cmd): oldcwd = os.getcwd() -
zhangchunlin created this gist
Dec 6, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ from subprocess import Popen, PIPE, STDOUT def runcmd(cwd,cmd): oldcwd = os.getcwd() os.chdir(cwd) runcmd_timeout = 3600 p = Popen(cmd,stdout=PIPE,stderr=STDOUT,shell=True,preexec_fn=os.setpgrp) p.wait(runcmd_timeout) if p.returncode==None: os.kill(-p.pid,9) out, err = p.communicate() return p.returncode,out