Merge pull request #3931 from c1728p9/arm_pack_manager_improvements

Arm pack manager improvements
pull/3939/head
Anna Bridge 2017-03-14 14:47:35 +00:00 committed by GitHub
commit 63fb7bd58d
3 changed files with 12 additions and 7 deletions

View File

@ -13,6 +13,7 @@ from json import dump, load
from zipfile import ZipFile from zipfile import ZipFile
from tempfile import gettempdir from tempfile import gettempdir
import warnings import warnings
from distutils.version import LooseVersion
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
@ -31,7 +32,7 @@ def strip_protocol(url) :
def largest_version(content) : def largest_version(content) :
return sorted([t['version'] for t in content.package.releases('release')], return sorted([t['version'] for t in content.package.releases('release')],
reverse=True, key=lambda v: map(int, v.split(".")))[0] reverse=True, key=lambda v: LooseVersion(v))[0]
def do_queue(Class, function, interable) : def do_queue(Class, function, interable) :
q = Queue() q = Queue()
@ -246,19 +247,23 @@ class Cache () :
self.counter += 1 self.counter += 1
self.display_counter("Scanning for Aliases") self.display_counter("Scanning for Aliases")
def get_flash_algorthim_binary(self, device_name) : def get_flash_algorthim_binary(self, device_name, all=False) :
"""Retrieve the flash algorithm file for a particular part. """Retrieve the flash algorithm file for a particular part.
Assumes that both the PDSC and the PACK file associated with that part are in the cache. Assumes that both the PDSC and the PACK file associated with that part are in the cache.
:param device_name: The exact name of a device :param device_name: The exact name of a device
:param all: Return an iterator of all flash algos for this device
:type device_name: str :type device_name: str
:return: A file-like object that, when read, is the ELF file that describes the flashing algorithm :return: A file-like object that, when read, is the ELF file that describes the flashing algorithm
:rtype: ZipExtFile :return: A file-like object that, when read, is the ELF file that describes the flashing algorithm.
When "all" is set to True then an iterator for file-like objects is returned
:rtype: ZipExtFile or ZipExtFile iterator if all is True
""" """
device = self.index[device_name] device = self.index[device_name]
pack = self.pack_from_cache(device) pack = self.pack_from_cache(device)
return pack.open(device['algorithm'].keys()[0]) algo_itr = (pack.open(path) for path in device['algorithm'].keys())
return algo_itr if all else algo_itr.next()
def get_svd_file(self, device_name) : def get_svd_file(self, device_name) :
"""Retrieve the flash algorithm file for a particular part. """Retrieve the flash algorithm file for a particular part.
@ -352,7 +357,7 @@ class Cache () :
""" """
if not self._aliases : if not self._aliases :
with open(join(self.data_path, "aliases.json")) as i : with open(LocalPackAliases) as i :
self._aliases = load(i) self._aliases = load(i)
return self._aliases return self._aliases

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long