# Path: bts_tools/core.py
# def run(cmd, capture_io=False, verbose=True, log_on_fail=True,
#         run_dir=None, forward_signals=False, pidfile=None, shell=False):
#     r = _run(cmd, capture_io=capture_io, verbose=verbose,
#              run_dir=run_dir, forward_signals=forward_signals, pidfile=pidfile, shell=shell)
#     if r.status != 0:
#         if log_on_fail:
#             log.warning('Failed running: %s' % cmd)
#             if capture_io:
#                 log.warning('\nSTDOUT:\n{}\nSTDERR:\n:{}'.format(r.stdout, r.stderr))
#         raise RuntimeError('Failed running: %s' % cmd)
#     return r
# 
# def get_bin_name(client=None, build_env=None):
#     return os.path.basename(get_full_bin_name(client, build_env))


from .core import run, get_bin_name
import psutil
import logging
        log.warning('Process pid={} listening on port {} doesn\'t seem to have the correct filename: '
                    'expected={}, actual={}'.format(pid, port, bin_name, proc.name()))

    _process_cache[port] = proc
    return proc


def bts_binary_running(node):
    """Return whether an instance of the bts binary could be found that is
    running or in a runnable state.
    """
    p = witness_process(node)
    if p is not None:
        return p.status() not in {psutil.STATUS_STOPPED,
                                  psutil.STATUS_TRACING_STOP,
                                  psutil.STATUS_ZOMBIE,
                                  psutil.STATUS_DEAD}
    return False


def binary_description(node):
    """Return a human readable version description of the running binary,
    either tag version or git revision.
    """
    client_version = node.about()['client_version']
    p = witness_process(node)
    if p is None:
        return client_version
    # if client is running locally, extract info from filename, usually more precise
    try:

# Path: bts_tools/core.py
# def run(cmd, capture_io=False, verbose=True, log_on_fail=True,
#         run_dir=None, forward_signals=False, pidfile=None, shell=False):
#     r = _run(cmd, capture_io=capture_io, verbose=verbose,
#              run_dir=run_dir, forward_signals=forward_signals, pidfile=pidfile, shell=shell)
#     if r.status != 0:
#         if log_on_fail:
#             log.warning('Failed running: %s' % cmd)
#             if capture_io:
#                 log.warning('\nSTDOUT:\n{}\nSTDERR:\n:{}'.format(r.stdout, r.stderr))
#         raise RuntimeError('Failed running: %s' % cmd)
#     return r
# 
# def get_bin_name(client=None, build_env=None):
#     return os.path.basename(get_full_bin_name(client, build_env))


# Path: bts_tools/process.py
from .core import run, get_bin_name
import psutil
import logging

        log.warning('Process pid={} listening on port {} doesn\'t seem to have the correct filename: '
                    'expected={}, actual={}'.format(pid, port, bin_name, proc.name()))

    _process_cache[port] = proc
    return proc


def bts_binary_running(node):
    """Return whether an instance of the bts binary could be found that is
    running or in a runnable state.
    """
    p = witness_process(node)
    if p is not None:
        return p.status() not in {psutil.STATUS_STOPPED,
                                  psutil.STATUS_TRACING_STOP,
                                  psutil.STATUS_ZOMBIE,
                                  psutil.STATUS_DEAD}
    return False


def binary_description(node):
    """Return a human readable version description of the running binary,
    either tag version or git revision.
    """
    client_version = node.about()['client_version']
    p = witness_process(node)
    if p is None:
        return client_version
    # if client is running locally, extract info from filename, usually more precise
    try:

        bin_name = node.build_env().get('witness_filename') or get_bin_name(node.client_name)