How to use the devlib.exception.TargetError 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 / module / vexpress.py View on Github external
def __call__(self):
        try:
            if self.target.is_connected:
                self.target.execute('sync')
        except (TargetError, CalledProcessError):
            pass
        with open_serial_connection(port=self.port,
                                    baudrate=self.baudrate,
                                    timeout=self.timeout,
                                    init_dtr=0,
                                    get_conn=True) as (_, conn):
            pulse_dtr(conn, state=True, duration=0.1)  # TRM specifies a pulse of >=100ms
github ARM-software / devlib / devlib / exception.py View on Github external
"""Exceptions inheriting from ``DevlibTransientError`` represent random
    transient events that are usually related to issues in the environment, as
    opposed to programming errors, for example network failures or
    timeout-related exceptions. When the error could come from
    indistinguishable transient or non-transient issue, it can generally be
    assumed that the configuration is correct and therefore, a transient
    exception is raised."""
    pass


class TargetError(DevlibError):
    """An error has occured on the target"""
    pass


class TargetTransientError(TargetError, DevlibTransientError):
    """Transient target errors that can happen randomly when everything is
    properly configured."""
    pass


class TargetStableError(TargetError, DevlibStableError):
    """Non-transient target errors that can be linked to a programming error or
    a configuration issue, and is not influenced by non-controllable parameters
    such as network issues."""
    pass


class TargetNotRespondingError(TargetTransientError):
    """The target is unresponsive."""
    pass
github ARM-software / workload-automation / wa / framework / target / runtime_config.py View on Github external
def configure_frequency(self, cpu, freq=None, min_freq=None, max_freq=None, governor=None):
        if freq and (min_freq or max_freq):
            msg = 'Cannot specify both frequency and min/max frequency'
            raise ConfigError(msg)

        if cpu not in self.target.list_online_cpus():
            msg = 'Cannot configure frequencies for CPU{} as no CPUs are online.'
            raise TargetError(msg.format(cpu))

        if freq:
            self._set_frequency(cpu, freq, governor)
        else:
            self._set_min_max_frequencies(cpu, min_freq, max_freq)
github ARM-software / workload-automation / wa / framework / target / runtime_config.py View on Github external
def configure_governor(self, cpu, governor=None, gov_tunables=None):
        if not governor and not gov_tunables:
            return
        if cpu not in self.target.list_online_cpus():
            msg = 'Cannot configure governor for {} as no CPUs are online.'
            raise TargetError(msg.format(cpu))
        if not governor:
            governor = self.target.get_governor(cpu)
        if not gov_tunables:
            gov_tunables = {}
        self.target.cpufreq.set_governor(cpu, governor, **gov_tunables)
github ARM-software / workload-automation / wa / framework / target / runtime_config.py View on Github external
def check_target(self):
        if not self.target.has('hotplug'):
            raise TargetError('Target does not appear to support hotplug')
github ARM-software / workload-automation / wa / framework / target / runtime_config.py View on Github external
def __call__(self, value):
        '''
        `self.values` can be `None` if the device's supported values could not be retrieved
        for some reason e.g. the cluster was offline, in this case we assume
        the user values will be available and allow any integer values.
        '''
        if self.values is None:
            if isinstance(value, int):
                return value
            else:
                msg = 'CPU frequency values could not be retrieved, cannot resolve "{}"'
                raise TargetError(msg.format(value))
        elif isinstance(value, int) and value in self.values:
            return value
        elif isinstance(value, str):
            value = caseless_string(value)
            if value in ['min', 'max']:
                return value

        msg = 'Invalid frequency value: {}; Must be in {}'
        raise ValueError(msg.format(value, self.values))
github ARM-software / workload-automation / wa / framework / target / runtime_config.py View on Github external
def __init__(self, target, **kwargs):
        super(RuntimeConfig, self).__init__(**kwargs)
        self.target = target
        self._target_checked = False
        self._runtime_params = {}
        try:
            self.initialize()
        except TargetError:
            msg = 'Failed to initialize: "{}"'
            self.logger.debug(msg.format(self.name))
            self._runtime_params = {}
github ARM-software / workload-automation / wa / framework / target / runtime_config.py View on Github external
def check_target(self):
        if not self.target.has('cpufreq'):
            raise TargetError('Target does not appear to support cpufreq')
github ARM-software / devlib / devlib / exception.py View on Github external
exception is raised."""
    pass


class TargetError(DevlibError):
    """An error has occured on the target"""
    pass


class TargetTransientError(TargetError, DevlibTransientError):
    """Transient target errors that can happen randomly when everything is
    properly configured."""
    pass


class TargetStableError(TargetError, DevlibStableError):
    """Non-transient target errors that can be linked to a programming error or
    a configuration issue, and is not influenced by non-controllable parameters
    such as network issues."""
    pass


class TargetNotRespondingError(TargetTransientError):
    """The target is unresponsive."""
    pass


class HostError(DevlibError):
    """An error has occured on the host"""
    pass

github ARM-software / workload-automation / wa / utils / misc.py View on Github external
def resolve_unique_domain_cpus(name, target):
    """
    Same as `resolve_cpus` above but only returns only the first cpu
    in each of the different frequency domains. Requires cpufreq.
    """
    cpus = resolve_cpus(name, target)
    if not target.has('cpufreq'):
        msg = 'Device does not appear to support cpufreq; ' \
              'Cannot obtain cpu domain information'
        raise TargetError(msg)

    unique_cpus = []
    domain_cpus = []
    for cpu in cpus:
        if cpu not in domain_cpus:
            domain_cpus = target.cpufreq.get_related_cpus(cpu)
        if domain_cpus[0] not in unique_cpus:
            unique_cpus.append(domain_cpus[0])
    return unique_cpus