How to use the devlib.utils.misc.memoized 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 / target.py View on Github external
    @memoized
    def android_id(self):
        """
        Get the device's ANDROID_ID. Which is

            "A 64-bit number (as a hex string) that is randomly generated when the user
            first sets up the device and should remain constant for the lifetime of the
            user's device."

        .. note:: This will get reset on userdata erasure.

        """
        output = self.execute('content query --uri content://settings/secure --projection value --where "name=\'android_id\'"').strip()
        return output.split('value=')[-1]
github ARM-software / devlib / devlib / target.py View on Github external
    @memoized
    def get_cpu_features(self, cpuid=0):
        global_features = []
        for section in self.sections:
            if 'processor' in section:
                if int(section.get('processor')) != cpuid:
                    continue
                if 'Features' in section:
                    return section.get('Features').split()
                elif 'flags' in section:
                    return section.get('flags').split()
            elif 'Features' in section:
                global_features = section.get('Features').split()
            elif 'flags' in section:
                global_features = section.get('flags').split()
        return global_features
github ARM-software / devlib / devlib / module / cpufreq.py View on Github external
    @memoized
    def list_frequencies(self, cpu):
        """Returns a sorted list of frequencies supported by the cpu or an empty list
        if not could be found."""
        if isinstance(cpu, int):
            cpu = 'cpu{}'.format(cpu)
        try:
            cmd = 'cat /sys/devices/system/cpu/{}/cpufreq/scaling_available_frequencies'.format(cpu)
            output = self.target.execute(cmd)
            available_frequencies = list(map(int, output.strip().split()))  # pylint: disable=E1103
        except TargetStableError:
            # On some devices scaling_frequencies  is not generated.
            # http://adrynalyne-teachtofish.blogspot.co.uk/2011/11/how-to-enable-scalingavailablefrequenci.html
            # Fall back to parsing stats/time_in_state
            path = '/sys/devices/system/cpu/{}/cpufreq/stats/time_in_state'.format(cpu)
            try:
                out_iter = iter(self.target.read_value(path).split())
github ARM-software / devlib / devlib / target.py View on Github external
    @memoized
    def system_id(self):
        return self._execute_util('get_android_system_id').strip()
github ARM-software / workload-automation / wlauto / core / configuration / plugin_cache.py View on Github external
    @memoized
    def get_plugin_parameters(self, name):
        params = self.loader.get_plugin_class(name).parameters
        return {param.name: param for param in params}
github ARM-software / devlib / devlib / module / devfreq.py View on Github external
    @memoized
    def list_devices(self):
        """Returns a list of devfreq devices supported by the target platform."""
        sysfile = '/sys/class/devfreq/'
        return self.target.list_directory(sysfile)
github ARM-software / devlib / devlib / collector / ftrace.py View on Github external
    @memoized
    def available_functions(self):
        """
        List of functions whose tracing/profiling is supported by the target's kernel.
        """
        return self.target.read_value(self.available_functions_file).splitlines()
github ARM-software / devlib / devlib / target.py View on Github external
    @memoized
    def list_nodes_cpus(self):
        nodes_cpus = []
        for node in range(self.number_of_nodes):
            path = self.path.join('/sys/devices/system/node/node{}/cpulist'.format(node))
            output = self.read_value(path)
            nodes_cpus.append(ranges_to_list(output))
        return nodes_cpus
github ARM-software / devlib / devlib / utils / ssh.py View on Github external
    @memoized
    def _get_prompt_length(self):
        self.conn.sendline()
        self.conn.prompt()
        return len(self.conn.after)
github ARM-software / devlib / devlib / target.py View on Github external
    @memoized
    def user(self):
        return self.getenv('USER')