mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-04 20:32:36 +01:00
fw: cache target info
Cache target info after pulling it from the device. Attempt to retrieve from cache before querying target.
This commit is contained in:
committed by
Marc Bonnici
parent
770d2b2f0e
commit
e8f545861d
@@ -14,12 +14,16 @@
|
||||
#
|
||||
# pylint: disable=protected-access
|
||||
|
||||
import os
|
||||
from copy import copy
|
||||
|
||||
from devlib import AndroidTarget, TargetError
|
||||
from devlib.target import KernelConfig, KernelVersion, Cpuinfo
|
||||
from devlib.utils.android import AndroidProperties
|
||||
|
||||
from wa.framework.configuration.core import settings
|
||||
from wa.utils.serializer import read_pod, write_pod
|
||||
|
||||
|
||||
def cpuinfo_from_pod(pod):
|
||||
cpuinfo = Cpuinfo('')
|
||||
@@ -226,6 +230,36 @@ def get_target_info(target):
|
||||
return info
|
||||
|
||||
|
||||
def read_target_info_cache():
|
||||
if not os.path.exists(settings.cache_directory):
|
||||
os.makedirs(settings.cache_directory)
|
||||
if not os.path.isfile(settings.target_info_cache_file):
|
||||
return {}
|
||||
return read_pod(settings.target_info_cache_file)
|
||||
|
||||
|
||||
def write_target_info_cache(cache):
|
||||
if not os.path.exists(settings.cache_directory):
|
||||
os.makedirs(settings.cache_directory)
|
||||
write_pod(cache, settings.target_info_cache_file)
|
||||
|
||||
|
||||
def get_target_info_from_cache(system_id):
|
||||
cache = read_target_info_cache()
|
||||
pod = cache.get(system_id, None)
|
||||
if not pod:
|
||||
return None
|
||||
return TargetInfo.from_pod(pod)
|
||||
|
||||
|
||||
def cache_target_info(target_info, overwrite=False):
|
||||
cache = read_target_info_cache()
|
||||
if target_info.system_id in cache and not overwrite:
|
||||
raise ValueError('TargetInfo for {} is already in cache.'.format(target_info.system_id))
|
||||
cache[target_info.system_id] = target_info.to_pod()
|
||||
write_target_info_cache(cache)
|
||||
|
||||
|
||||
class TargetInfo(object):
|
||||
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user