當前位置: 首頁>>代碼示例>>Python>>正文


Python subprocess32.STDOUT屬性代碼示例

本文整理匯總了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 
開發者ID:test-pipeline,項目名稱:orthrus,代碼行數:18,代碼來源:afl_sancov.py

示例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 
開發者ID:TheJacksonLaboratory,項目名稱:SVE,代碼行數:22,代碼來源:bwa_split.py

示例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 
開發者ID:TheJacksonLaboratory,項目名稱:SVE,代碼行數:21,代碼來源:CheckGenerateRG.py

示例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() 
開發者ID:hballard,項目名稱:graphql-python-subscriptions,代碼行數:18,代碼來源:test_subscription_transport.py

示例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}) 
開發者ID:hballard,項目名稱:graphql-python-subscriptions,代碼行數:22,代碼來源:test_subscription_transport.py

示例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) 
開發者ID:niklasf,項目名稱:fishnet,代碼行數:25,代碼來源:fishnet.py

示例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 
開發者ID:mrash,項目名稱:Wireguard-macOS-LinuxVM,代碼行數:20,代碼來源:wg-routes.py

示例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 
開發者ID:depthsecurity,項目名稱:armory,代碼行數:28,代碼來源:ModuleTemplate.py

示例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) 
開發者ID:anonymous-author1,項目名稱:DDRL,代碼行數:14,代碼來源:concurrency.py

示例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 
開發者ID:ucb-art,項目名稱:BAG_framework,代碼行數:28,代碼來源:process.py

示例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)) 
開發者ID:blissland,項目名稱:blissflixx,代碼行數:14,代碼來源:processpipe.py

示例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 
開發者ID:blue-oil,項目名稱:blueoil,代碼行數:29,代碼來源:tune_ray.py

示例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) 
開發者ID:test-pipeline,項目名稱:orthrus,代碼行數:13,代碼來源:afl_sancov.py

示例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 
開發者ID:test-pipeline,項目名稱:orthrus,代碼行數:30,代碼來源:afl_sancov.py

示例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 
開發者ID:TheJacksonLaboratory,項目名稱:SVE,代碼行數:8,代碼來源:delly.py


注:本文中的subprocess32.STDOUT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。