1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/mirrors-kimchi

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
distroloader.py 2.3 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Aline Manera Отправлено 02.05.2019 00:17 8334268
#
# Project Kimchi
#
# Copyright IBM Corp, 2015-2016
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
import glob
import json
import os
from wok.exception import NotFoundError
from wok.exception import OperationFailed
from wok.plugins.kimchi import config
from wok.utils import wok_log
ARCHS = {'x86_64': ['x86_64', 'amd64', 'i686', 'x86', 'i386'],
'amd64': ['x86_64', 'amd64', 'i686', 'x86', 'i386'],
'ppc64': ['ppc', 'ppc64'],
'ppc64le': ['ppc64', 'ppc64le'],
's390x': ['s390', 's390x']}
class DistroLoader(object):
def __init__(self, location=None):
self.location = location or config.get_distros_store()
def _get_json_info(self, fname):
msg_args = {'filename': fname}
if not os.path.isfile(fname):
msg = 'DistroLoader: failed to find distro file: %s' % fname
wok_log.error(msg)
raise NotFoundError('KCHDL0001E', msg_args)
try:
with open(fname) as f:
data = json.load(f)
return data
except ValueError:
msg = 'DistroLoader: failed to parse distro file: %s' % fname
wok_log.error(msg)
raise OperationFailed('KCHDL0002E', msg_args)
def get(self):
arch_list = ARCHS.get(os.uname()[4])
all_json_files = glob.glob('%s/%s' % (self.location, '*.json'))
distros = []
for f in all_json_files:
distros.extend(self._get_json_info(f))
# Return all remote ISOs arch not found
return dict([(distro['name'], distro) for distro in distros if
(arch_list is None or distro['os_arch'] in arch_list)])

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/mirrors-kimchi.git
git@api.gitlife.ru:oschina-mirror/mirrors-kimchi.git
oschina-mirror
mirrors-kimchi
mirrors-kimchi
master