How to use the devlib.utils.misc.which function in devlib

To help you get started, we’ve selected a few devlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ARM-software / devlib / devlib / utils / android.py View on Github external
def _initialize_without_android_home(env):
    adb_full_path = which('adb')
    if adb_full_path:
        env.adb = 'adb'
    else:
        raise HostError('ANDROID_HOME is not set and adb is not in PATH. '
                        'Have you installed Android SDK?')
    logger.debug('Discovering ANDROID_HOME from adb path.')
    env.platform_tools = os.path.dirname(adb_full_path)
    env.android_home = os.path.dirname(env.platform_tools)
    _init_common(env)
    return env
github ARM-software / devlib / devlib / utils / ssh.py View on Github external
def _check_env():
    global ssh, scp, sshpass  # pylint: disable=global-statement
    if not ssh:
        ssh = which('ssh')
        scp = which('scp')
        sshpass = which('sshpass')
    if not (ssh and scp):
        raise HostError('OpenSSH must be installed on the host.')
github ARM-software / devlib / devlib / utils / android.py View on Github external
# Use the aapt version discoverted from build tools.
        if aapt_path:
            logger.debug('Using {} for version {}'.format(aapt_path, version))
            env.aapt = aapt_path
            env.aapt_version = aapt_version
            return

    # Try detecting aapt2 and aapt from PATH
    if not env.aapt:
            aapt2_path = which('aapt2')
            if _check_supported_aapt2(aapt2_path):
                env.aapt = aapt2_path
                env.aapt_version = 2
            else:
                env.aapt = which('aapt')
                env.aapt_version = 1

    if not env.aapt:
        raise HostError('aapt/aapt2 not found. Please make sure it is avaliable in PATH'
                        ' or at least one Android platform is installed')
github ARM-software / devlib / devlib / utils / android.py View on Github external
# Use aapt2 only if present and we have a suitable version
        if aapt2_path and _check_supported_aapt2(aapt2_path):
            aapt_path = aapt2_path
            aapt_version = 2

        # Use the aapt version discoverted from build tools.
        if aapt_path:
            logger.debug('Using {} for version {}'.format(aapt_path, version))
            env.aapt = aapt_path
            env.aapt_version = aapt_version
            return

    # Try detecting aapt2 and aapt from PATH
    if not env.aapt:
            aapt2_path = which('aapt2')
            if _check_supported_aapt2(aapt2_path):
                env.aapt = aapt2_path
                env.aapt_version = 2
            else:
                env.aapt = which('aapt')
                env.aapt_version = 1

    if not env.aapt:
        raise HostError('aapt/aapt2 not found. Please make sure it is avaliable in PATH'
                        ' or at least one Android platform is installed')
github ARM-software / devlib / devlib / collector / ftrace.py View on Github external
# pylint: disable=bad-whitespace
        # Setup tracing paths
        self.available_events_file    = self.target.path.join(self.tracing_path, 'available_events')
        self.available_functions_file = self.target.path.join(self.tracing_path, 'available_filter_functions')
        self.buffer_size_file         = self.target.path.join(self.tracing_path, 'buffer_size_kb')
        self.current_tracer_file      = self.target.path.join(self.tracing_path, 'current_tracer')
        self.function_profile_file    = self.target.path.join(self.tracing_path, 'function_profile_enabled')
        self.marker_file              = self.target.path.join(self.tracing_path, 'trace_marker')
        self.ftrace_filter_file       = self.target.path.join(self.tracing_path, 'set_ftrace_filter')
        self.trace_clock_file         = self.target.path.join(self.tracing_path, 'trace_clock')
        self.save_cmdlines_size_file  = self.target.path.join(self.tracing_path, 'saved_cmdlines_size')
        self.available_tracers_file  = self.target.path.join(self.tracing_path, 'available_tracers')

        self.host_binary = which('trace-cmd')
        self.kernelshark = which('kernelshark')

        if not self.target.is_rooted:
            raise TargetStableError('trace-cmd instrument cannot be used on an unrooted device.')
        if self.autoreport and not self.report_on_target and self.host_binary is None:
            raise HostError('trace-cmd binary must be installed on the host if autoreport=True.')
        if self.autoview and self.kernelshark is None:
            raise HostError('kernelshark binary must be installed on the host if autoview=True.')
        if not no_install:
            host_file = os.path.join(PACKAGE_BIN_DIRECTORY, self.target.abi, 'trace-cmd')
            self.target_binary = self.target.install(host_file)
        else:
            if not self.target.is_installed('trace-cmd'):
                raise TargetStableError('No trace-cmd found on device and no_install=True is specified.')
            self.target_binary = 'trace-cmd'

        # Validate required events to be traced
github ARM-software / devlib / devlib / utils / ssh.py View on Github external
def _check_env():
    global ssh, scp, sshpass  # pylint: disable=global-statement
    if not ssh:
        ssh = which('ssh')
        scp = which('scp')
        sshpass = which('sshpass')
    if not (ssh and scp):
        raise HostError('OpenSSH must be installed on the host.')
github ARM-software / devlib / devlib / instrument / acmecape.py View on Github external
def __init__(self, target,
                 iio_capture=which('iio-capture'),
                 host='baylibre-acme.local',
                 iio_device='iio:device0',
                 buffer_size=256,
                 keep_raw=False):
        super(AcmeCapeInstrument, self).__init__(target)
        self.iio_capture = iio_capture
        self.host = host
        self.iio_device = iio_device
        self.buffer_size = buffer_size
        self.keep_raw = keep_raw
        self.sample_rate_hz = 100
        if self.iio_capture is None:
            raise HostError('Missing iio-capture binary')
        self.command = None
        self.process = None
github ARM-software / devlib / devlib / collector / ftrace.py View on Github external
self._reset_needed = True

        # pylint: disable=bad-whitespace
        # Setup tracing paths
        self.available_events_file    = self.target.path.join(self.tracing_path, 'available_events')
        self.available_functions_file = self.target.path.join(self.tracing_path, 'available_filter_functions')
        self.buffer_size_file         = self.target.path.join(self.tracing_path, 'buffer_size_kb')
        self.current_tracer_file      = self.target.path.join(self.tracing_path, 'current_tracer')
        self.function_profile_file    = self.target.path.join(self.tracing_path, 'function_profile_enabled')
        self.marker_file              = self.target.path.join(self.tracing_path, 'trace_marker')
        self.ftrace_filter_file       = self.target.path.join(self.tracing_path, 'set_ftrace_filter')
        self.trace_clock_file         = self.target.path.join(self.tracing_path, 'trace_clock')
        self.save_cmdlines_size_file  = self.target.path.join(self.tracing_path, 'saved_cmdlines_size')
        self.available_tracers_file  = self.target.path.join(self.tracing_path, 'available_tracers')

        self.host_binary = which('trace-cmd')
        self.kernelshark = which('kernelshark')

        if not self.target.is_rooted:
            raise TargetStableError('trace-cmd instrument cannot be used on an unrooted device.')
        if self.autoreport and not self.report_on_target and self.host_binary is None:
            raise HostError('trace-cmd binary must be installed on the host if autoreport=True.')
        if self.autoview and self.kernelshark is None:
            raise HostError('kernelshark binary must be installed on the host if autoview=True.')
        if not no_install:
            host_file = os.path.join(PACKAGE_BIN_DIRECTORY, self.target.abi, 'trace-cmd')
            self.target_binary = self.target.install(host_file)
        else:
            if not self.target.is_installed('trace-cmd'):
                raise TargetStableError('No trace-cmd found on device and no_install=True is specified.')
            self.target_binary = 'trace-cmd'