Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(8)  |  Derive(0)  |  Import(4)
It checks that the given process finishes OK, otherwise raises an Error

        def check_process_finishes(process, binary, stdout=None, stderr=None):
    'It checks that the given process finishes OK, otherwise raises an Error'

    stdout_msg, stderr_msg = process.communicate()

    returncode = process.returncode
    if returncode == 0:
        return
    elif returncode is None:
        msg = 'The process for {:s} is still running with PID'
        msg = msg.format(binary, process.PID)
        raise RuntimeError(msg)

    if stdout and not stdout_msg:
        stdout.flush()
        stdout_msg = open(stdout.name).read()
    if stderr and not stderr_msg:
        stderr.flush()
        stderr_msg = open(stderr.name).read()
    msg = '{:s} had a problem running\n'.format(binary)
    if stdout_msg:
        msg += 'stdout:\n{:s}\n'.format(stdout_msg)
    if stderr_msg:
        msg += 'stderr:\n{:s}\n'.format(stderr_msg)
    raise ExternalBinaryError(msg)
        


src/s/e/seq_crumbs-HEAD/crumbs/mapping.py   seq_crumbs(Download)
from tempfile import NamedTemporaryFile
 
from crumbs.utils.bin_utils import (check_process_finishes, get_binary_path,
                                    popen, get_num_threads)
from crumbs.settings import get_setting
    cmd = [binary, 'index', '-a', algorithm, index_fpath]
    process = popen(cmd, stdout=PIPE, stderr=PIPE)
    check_process_finishes(process, binary=cmd[0])
 
 
        cmd = [binary, '-f', fpath, index_fpath]
        process = popen(cmd, stdout=PIPE, stderr=PIPE)
        check_process_finishes(process, binary=cmd[0])
    return index_fpath
 

src/s/e/seq_crumbs-HEAD/crumbs/annotation.py   seq_crumbs(Download)
from crumbs.utils.optional_modules import SeqFeature, FeatureLocation
 
from crumbs.utils.bin_utils import (get_binary_path, popen,
                                    check_process_finishes)
from crumbs.utils.tags import FIVE_PRIME, THREE_PRIME
           matrix_fpath, seq_fhand.name]
    process = popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    check_process_finishes(process, binary=cmd[0])
    seq_fhand.close()
 

src/s/e/seq_crumbs-HEAD/crumbs/blast.py   seq_crumbs(Download)
from crumbs.utils.optional_modules import NCBIWWW
from crumbs.seqio import seqio, guess_seq_type, write_seqs
from crumbs.utils.bin_utils import (check_process_finishes, popen,
                                    get_binary_path)
from crumbs.utils.tags import NUCL, PROT
        cmd.extend(['-out', outputdb])
    process = popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    check_process_finishes(process, binary=cmd[0])
 
 
            cmd.extend(('-' + key, str(value)))
    process = popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    check_process_finishes(process, binary=cmd[0])
 
 

src/s/e/seq_crumbs-HEAD/test/test_utils.py   seq_crumbs(Download)
from crumbs.utils.file_utils import (TemporaryDir, rel_symlink,
                                     wrap_in_buffered_reader)
from crumbs.utils.bin_utils import check_process_finishes, popen, BIN_DIR
 
from crumbs.exceptions import ExternalBinaryError, MissingBinaryError
        process = Popen([binary, '/directorio_que_no_existe'], stderr=PIPE)
        try:
            check_process_finishes(process, binary)
            self.fail('ExternalBinaryErrorExpected')
        except ExternalBinaryError, error:
        process = Popen([binary, '/directorio_que_no_existe'], stderr=stderr)
        try:
            check_process_finishes(process, binary, stderr=stderr)
        except ExternalBinaryError, error:
            assert binary in str(error)
 
        cmd = [binary]
        process = Popen(cmd, stdout=PIPE)
        check_process_finishes(process, binary)