本文整理汇总了Python中subprocess32.STDOUT属性的典型用法代码示例。如果您正苦于以下问题:Python subprocess32.STDOUT属性的具体用法?Python subprocess32.STDOUT怎么用?Python subprocess32.STDOUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类subprocess32
的用法示例。
在下文中一共展示了subprocess32.STDOUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parent_identical_or_crashes
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def parent_identical_or_crashes(self, crash, parent):
# Base names
cbasename = os.path.basename(crash)
pbasename = os.path.basename(parent)
## Filter queue filenames with sig info
if self.find_crash_parent_regex.match(pbasename):
self.logr("Parent ({}) looks like crashing input!".format(pbasename))
return True
try:
diff_out = subprocess.check_output("diff -q {} {}".format(crash, parent),
stderr=subprocess.STDOUT, shell=True)
except Exception, e:
diff_out = e.output
示例2: fastq_bwa_mem_piped
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def fastq_bwa_mem_piped(fastqs,i,j,t,rg,out_dir,ref_path):
output = ''
bam = out_dir+'/'+fastqs[0].rsplit('/')[-1].rsplit('.fq')[0].rsplit('_')[0]+'.%s.bam'%j
piped_mem = [bwa_mem,'-M','-t %s'%t,'-R',r"'%s'"%rg,ref_path,
'<(%s -f %s -i %s -j %s)'%(route,fastqs[0],i,j),
'<(%s -f %s -i %s -j %s)'%(route,fastqs[1],i,j),
'|',samtools_view,'-Sb','-','-@ %s'%t,
'|',sambamba_sort,'-t %s'%t,'--tmpdir=%s/temp'%out_dir,'-o',bam,'/dev/stdin'] #-@ for threads here
try:#bwa mem call here-------------------------------------------
output += subprocess.check_output(' '.join(piped_mem),
stderr=subprocess.STDOUT,
executable='/bin/bash',
shell=True)
output += subprocess.check_output(['rm','-rf','%s/temp'%out_dir])
except Exception as E:
output += str(E) #error on the call-------------------------
return bam #list of bam files to merge into next step
#|| by number of fastq files presented
示例3: CheckRG
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def CheckRG(samtools,bam,out_name,result):
file = out_name+'.bam.header'
command = [samtools,'view','-SH',bam,'-o',file]
print (' '.join(command))
subprocess.check_output(' '.join(command),stderr=subprocess.STDOUT,shell=True)
result=[]
with open(file,'r') as f:
header = f.readlines()
for l in range(len(header)):
i = 0
if header[l][0:3] == "@RG":
RG = {x.split(':')[0]:x.split(':')[-1].replace('\n','') for x in header[l].split('@RG')[-1].split('\t')[1:]}
result.append(RG)
clean = ['rm','-f',file]
subprocess.check_output(' '.join(clean),stderr=subprocess.STDOUT,shell=True)
return result
示例4: test_should_trigger_on_connect_if_client_connect_valid
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def test_should_trigger_on_connect_if_client_connect_valid(server_with_mocks):
node_script = '''
module.paths.push('{0}')
WebSocket = require('ws')
const SubscriptionClient =
require('subscriptions-transport-ws').SubscriptionClient
new SubscriptionClient('ws://localhost:{1}/socket')
'''.format(
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
try:
subprocess.check_output(
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=.2)
except:
mock = server_with_mocks.get_nowait()
assert mock.name == 'on_connect'
mock.assert_called_once()
示例5: test_should_trigger_on_connect_with_correct_cxn_params
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def test_should_trigger_on_connect_with_correct_cxn_params(server_with_mocks):
node_script = '''
module.paths.push('{0}')
WebSocket = require('ws')
const SubscriptionClient =
require('subscriptions-transport-ws').SubscriptionClient
const connectionParams = {{test: true}}
new SubscriptionClient('ws://localhost:{1}/socket', {{
connectionParams,
}})
'''.format(
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
try:
subprocess.check_output(
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=.2)
except:
mock = server_with_mocks.get_nowait()
assert mock.name == 'on_connect'
mock.assert_called_once()
mock.assert_called_with({'test': True})
示例6: open_process
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def open_process(command, cwd=None, shell=True, _popen_lock=threading.Lock()):
kwargs = {
"shell": shell,
"stdout": subprocess.PIPE,
"stderr": subprocess.STDOUT,
"stdin": subprocess.PIPE,
"bufsize": 1, # Line buffered
"universal_newlines": True,
}
if cwd is not None:
kwargs["cwd"] = cwd
# Prevent signal propagation from parent process
try:
# Windows
kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP
except AttributeError:
# Unix
kwargs["preexec_fn"] = os.setpgrp
with _popen_lock: # Work around Python 2 Popen race condition
return subprocess.Popen(command, **kwargs)
示例7: run_cmd
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def run_cmd(cmd):
out = []
fh = NamedTemporaryFile(delete=False)
es = subprocess.call(cmd, stdin=None,
stdout=fh, stderr=subprocess.STDOUT, shell=True)
fh.close()
with open(fh.name, 'r') as f:
for line in f:
out.append(line.rstrip('\n'))
os.unlink(fh.name)
if (es != 0):
print "[-] Non-zero exit status '%d' for CMD: '%s'" % (es, cmd)
for line in out:
print line
return es, out
示例8: run_cmd_noout
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def run_cmd_noout(cmd_data):
cmd = cmd_data[0]
output = cmd_data[1]
c = cmd[:-1]
timeout = cmd[-1]
display("Executing command: %s" % " ".join(c))
current_time = time.time()
f = open(output, 'w')
if timeout:
process = Popen(c, stdout=f, stderr=STDOUT)
while time.time() < current_time + timeout and process.poll() is None:
time.sleep(5)
if process.poll() is None:
display_error(
"Timeout of %s reached. Aborting thread for command: %s"
% (timeout, " ".join(c))
)
process.terminate()
else:
Popen(c, stdout=f, stderr=STDOUT).wait()
f.close()
return cmd_data
示例9: subproc_call
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def subproc_call(cmd, timeout=None):
try:
output = subprocess.check_output(
cmd, stderr=subprocess.STDOUT,
shell=True, timeout=timeout)
return output
except subprocess.TimeoutExpired as e:
logger.warn("Command timeout!")
logger.warn(e.output)
except subprocess.CalledProcessError as e:
logger.warn("Commnad failed: {}".format(e.returncode))
logger.warn(e.output)
示例10: run_proc_with_quit
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def run_proc_with_quit(proc_id, quit_dict, args, logfile=None, append=False, env=None, cwd=None):
if logfile is None:
logfile = os.devnull
mode = 'ab' if append else 'wb'
with open(logfile, mode) as logf:
if proc_id in quit_dict:
return None
proc = subprocess.Popen(args, stdout=logf, stderr=subprocess.STDOUT,
env=env, cwd=cwd)
retcode = None
num_kill = 0
timeout = 0.05
while retcode is None and num_kill <= 2:
try:
retcode = proc.wait(timeout=timeout)
except subprocess.TimeoutExpired:
if proc_id in quit_dict:
if num_kill == 0:
proc.terminate()
timeout = quit_dict[proc_id]
elif num_kill == 1:
proc.kill()
num_kill += 1
return proc.returncode
示例11: start
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def start(self, args):
cmd = self._get_cmd(args)
self.proc = subprocess.Popen(cmd, stderr=subprocess.STDOUT,
stdout=subprocess.PIPE, preexec_fn=os.setsid,
shell=self.shell)
try:
args = self._ready()
self.msg_ready(args)
except ProcessException, e:
# Ignore errors if process is being killed
if not self.killing:
self._set_error(str(e))
示例12: subproc_call
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def subproc_call(cmd, timeout=None):
"""Execute a command with timeout, and return both STDOUT/STDERR.
Args:
cmd (str): the command to execute.
timeout (float): timeout in seconds.
Returns:
output (bytes), retcode(int): If timeout, retcode is -1.
"""
try:
output = subprocess.check_output(
cmd, stderr=subprocess.STDOUT,
shell=True, timeout=timeout)
return output, 0
except subprocess.TimeoutExpired as e:
print("Command '{}' timeout!".format(cmd))
print(e.output.decode('utf-8'))
return e.output, -1
except subprocess.CalledProcessError as e:
print("Command '{}' failed, return code={}".format(cmd, e.returncode))
print(e.output.decode('utf-8'))
return e.output, e.returncode
except Exception:
print("Command '{}' failed to run.".format(cmd))
return "", -2
示例13: does_dry_run_throw_error
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def does_dry_run_throw_error(self, cmd):
env = os.environ.copy()
if self.sanitizer == 'asan':
spectrum_asan_options(env)
try:
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True, env=env)
except Exception, e:
# OR condition is bug fix for compute shell returning negative instead of positive code
return (e.returncode > 128 or e.returncode < 0)
示例14: run_cmd
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def run_cmd(self, cmd, collect, env=None):
out = []
if self.args.verbose:
self.logr(" CMD: %s" % cmd)
fh = None
if self.args.disable_cmd_redirection or collect == self.Want_Output:
fh = open(self.cov_paths['tmp_out'], 'w')
else:
fh = open(os.devnull, 'w')
if env is None:
subprocess.call(cmd, stdin=None,
stdout=fh, stderr=subprocess.STDOUT, shell=True, executable='/bin/bash')
else:
subprocess.call(cmd, stdin=None,
stdout=fh, stderr=subprocess.STDOUT, shell=True, env=env, executable='/bin/bash')
fh.close()
if self.args.disable_cmd_redirection or collect == self.Want_Output:
with open(self.cov_paths['tmp_out'], 'r') as f:
for line in f:
out.append(line.rstrip('\n'))
return out
示例15: call
# 需要导入模块: import subprocess32 [as 别名]
# 或者: from subprocess32 import STDOUT [as 别名]
def call(command, output):
output = subprocess.check_output(' '.join(command), stderr=subprocess.STDOUT,shell=True)+'\n'
return output
#override this function in each wrapper...
#this is an older pipeline and not for somatic, will do a new somatic