Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 6 additions & 32 deletions xcp/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import six

from xcp import version, xmlunwrap
from xcp import logger

if TYPE_CHECKING:
from xml.dom.minidom import Element # pytype: disable=pyi-error
Expand All @@ -41,7 +40,7 @@

# pylint: disable=super-init-not-called
class BzippedPackage(Package):
def __init__(self, repository, label, size, md5sum, optional, fname, root):

Check notice on line 43 in xcp/repository.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint R0917: too-many-positional-arguments

Refactor: Too many positional arguments (8/5)
(
self.repository,
self.label,
Expand All @@ -56,7 +55,7 @@
return "<BzippedPackage '%s'>" % self.label

class RPMPackage(Package):
def __init__(self, repository, label, size, md5sum, optional, fname, options):

Check notice on line 58 in xcp/repository.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint R0917: too-many-positional-arguments

Refactor: Too many positional arguments (8/5)
(
self.repository,
self.label,
Expand All @@ -71,7 +70,7 @@
return "<RPMPackage '%s'>" % self.label

class DriverRPMPackage(RPMPackage):
def __init__(self, repository, label, size, md5sum, fname, kernel, options):

Check notice on line 73 in xcp/repository.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint R0917: too-many-positional-arguments

Refactor: Too many positional arguments (8/5)
(
self.repository,
self.label,
Expand All @@ -86,7 +85,7 @@
return "<DriverRPMPackage '%s', kernel '%s'>" % (self.label, self.kernel)

class DriverPackage(Package):
def __init__(self, repository, label, size, md5sum, fname, root):

Check notice on line 88 in xcp/repository.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint R0917: too-many-positional-arguments

Refactor: Too many positional arguments (7/5)
(
self.repository,
self.label,
Expand All @@ -100,7 +99,7 @@
return "<DriverPackage '%s'>" % self.label

class FirmwarePackage(Package):
def __init__(self, repository, label, size, md5sum, fname):

Check notice on line 102 in xcp/repository.py

View workflow job for this annotation

GitHub Actions / test (3.11, ubuntu-22.04)

pylint R0917: too-many-positional-arguments

Refactor: Too many positional arguments (6/5)
(
self.repository,
self.label,
Expand Down Expand Up @@ -152,19 +151,6 @@
return YumRepository.getProductVersion(access)
return None

#pylint: disable=invalid-name
@classmethod
def getRequiredUpgradePluginVersion(cls, access):
"""Returns the required upgrade plugin version of the repository."""
access.start()
is_yum = YumRepository.isRepo(access, "")
access.finish()

if is_yum:
return YumRepository.getRequiredUpgradePluginVersion(access)
return None


class YumRepository(BaseRepository):
""" Represents a Yum repository containing packages and associated meta data. """
REPOMD_FILENAME = "repodata/repomd.xml"
Expand All @@ -191,8 +177,7 @@

@classmethod
def _getVersion(cls, access, category):
category_map = {'platform': 'platform_version', 'branding': 'product_version',
'required_upgrade_plugin': 'required_minimal_upgrade_plugin_version'}
category_map = {'platform': 'platform_version', 'branding': 'product_version'}

access.start()
try:
Expand All @@ -201,15 +186,11 @@
with access.openText(cls.TREEINFO_FILENAME) as fp:
treeinfo.read_file(fp)

try:
if treeinfo.has_section('system-v1'):
ver_str = treeinfo.get('system-v1', category_map[category])
else:
ver_str = treeinfo.get(category, 'version')
repo_ver = version.Version.from_string(ver_str)
except configparser.NoOptionError as e:
logger.debug(e)
repo_ver = None
if treeinfo.has_section('system-v1'):
ver_str = treeinfo.get('system-v1', category_map[category])
else:
ver_str = treeinfo.get(category, 'version')
repo_ver = version.Version.from_string(ver_str)

except Exception as e:
six.raise_from(RepoFormatError("Failed to open %s: %s" %
Expand All @@ -229,13 +210,6 @@

return cls._getVersion(access, 'branding')

@classmethod
def getRequiredUpgradePluginVersion(cls, access):
"""Returns the required upgrade plugin version of the repository."""

return cls._getVersion(access, 'required_upgrade_plugin')


class Repository(BaseRepository):
""" Represents a XenSource repository containing packages and associated
meta data. """
Expand Down
Loading