26
26
from gettext import gettext as _
28
class PackageUpdateInfo(object):
30
Unified update information object.
31
This object contains all information needed by the frontend to provide
32
sensible information about updated packages to the user.
33
The UPDATE_CATEGORY_* values are assigned by priority, making security
34
updates the most important ones and backports the least important ones.
36
TODO: the exact priorities are up to discussion.
38
UPDATE_CATEGORY_SECURITY = 0
39
""" Security updates category. """
40
UPDATE_CATEGORY_RECOMMENDED = 1
41
""" Recommended updates category. """
42
UPDATE_CATEGORY_DEFAULT = 2
43
""" Default/distribution updates category. """
44
UPDATE_CATEGORY_PROPOSED = 3
45
""" Proposed updates category. """
46
UPDATE_CATEGORY_BACKPORT = 4
47
""" Backport updates category. """
49
UPDATE_CATEGORY_MAP = {
50
UPDATE_CATEGORY_SECURITY: _("Important security updates"),
51
UPDATE_CATEGORY_RECOMMENDED: _("Recommended updates"),
52
UPDATE_CATEGORY_DEFAULT: _("Distribution updates"),
53
UPDATE_CATEGORY_PROPOSED: _("Proposed updates"),
54
UPDATE_CATEGORY_BACKPORT: _("Backports"),
56
""" Identifier to localized name map for categories. See UPDATE_CATEGORY_*
57
for information about available categories."""
59
def __init__(self, package_name, short_description, installed_version,
60
update_candidate_version, update_category, download_size):
62
Initialize PackageUpdateInfo object.
64
The update_category parameter is an integer value,
65
see UPDATE_CATEGORY_* for details.
67
self._package_name = package_name
68
self._short_description = short_description
69
self._installed_version = installed_version
70
self._update_candidate_version = update_candidate_version
71
self._update_category = update_category
72
self._download_size = download_size
75
def package_name(self):
77
The package's name (property).
79
return self._package_name
82
def short_description(self):
84
The package's short description (property).
86
return self._short_description
89
def installed_version(self):
91
The currently installed version of the package (property).
93
return self._installed_version
96
def update_candidate_version(self):
98
The update candidate's version (property).
100
return self._update_candidate_version
103
def update_category(self):
105
The update's category (see UPDATE_CATEGORY_* for details, property).
107
return self._update_category
110
def update_category_name(self):
112
The update category's localized name (property).
114
return PackageUpdateInfo.UPDATE_CATEGORY_MAP[self._update_category]
117
def download_size(self):
119
The download size in bytes (property).
121
return self._download_size
123
class BackendBase(object):
125
Base class for update-manager backends.
127
This class forms the API available to update-manager's core and *must*
128
be subclassed by all classes implementing this interface. Also, all
129
methods of this base class must be overwritten in the implementation.
28
from zope.interface import Interface
30
UPDATE_CATEGORY_SECURITY = 0
31
""" Security updates category. """
32
UPDATE_CATEGORY_RECOMMENDED = 1
33
""" Recommended updates category. """
34
UPDATE_CATEGORY_DEFAULT = 2
35
""" Default/distribution updates category. """
36
UPDATE_CATEGORY_PROPOSED = 3
37
""" Proposed updates category. """
38
UPDATE_CATEGORY_BACKPORT = 4
39
""" Backport updates category. """
41
UPDATE_CATEGORY_MAP = {
42
UPDATE_CATEGORY_SECURITY: _("Important security updates"),
43
UPDATE_CATEGORY_RECOMMENDED: _("Recommended updates"),
44
UPDATE_CATEGORY_DEFAULT: _("Distribution updates"),
45
UPDATE_CATEGORY_PROPOSED: _("Proposed updates"),
46
UPDATE_CATEGORY_BACKPORT: _("Backports"),
49
A mapping of update category identifiers to their (localized)
50
names. See UPDATE_CATEGORY_* for details.
53
def update_category_id_to_name(category_id):
54
""" Converts the given update category ID to a localized name. """
55
if not UPDATE_CATEGORY_MAP.has_key(category_id):
56
return UPDATE_CATEGORY_MAP[UPDATE_CATEGORY_DEFAULT]
57
return UPDATE_CATEGORY_MAP[category_id]
59
class IPackageUpdateInfo(Interface):
61
Package update info interface.
63
This interface is intended to provide all information to a package
64
that could be needed by the UI or update-manager itself.
66
def __init__(self, backend_package_obj, dist_obj):
68
The constructor accepts a backend-specific package object
69
and an object of the distribution-specific interface.
71
The latter is needed for things like detecting the category a package
75
def get_package_name(self):
76
""" Return the package name as a string. """
78
def get_installed_version(self):
79
""" The currently installed version as a string. """
81
def get_candidate_version(self):
82
""" The candidate's version as a string. """
84
def get_update_category(self):
85
""" The update's category as an integer. """
87
def get_download_size(self):
88
""" The download size in bytes as an integer. """
90
def get_summary(self):
92
The package summary (aka. short description) as a string.
95
def get_candidate_archive_name(self):
96
""" The candidate's repository archive name. """
98
def get_candidate_origin_name(self):
99
""" The candidate's repository origin name. """
101
def get_candidate_component_name(self):
102
""" The candidate's repository component name. """
104
def candidate_origin_is_trusted(self):
106
Return boolean indicating whether the repository we found the candidate
110
# Backend special status constants.
111
RELOAD_CACHE_STATUS_DONE = -1
112
""" Cache reload status: done. """
114
RELOAD_LIST_STATUS_HIT = -1
115
""" Package list reload status: hit. """
116
RELOAD_LIST_STATUS_FAILED = -2
117
""" Package list reload status: failed. """
118
RELOAD_LIST_STATUS_FINISHED = -3
119
""" Package list reload status: done/finished. """
120
RELOAD_LIST_STATUS_QUEUED = -4
121
""" Package list reload status: queued. """
122
RELOAD_LIST_STATUS_IGNORED = -5
123
""" Package list reload status: ignored. """
125
DOWNLOAD_STATUS_BEGIN = -1
126
""" Download status: begin/initialization. """
127
DOWNLOAD_STATUS_FINISHED = -2
128
""" Download status: finished/finalization. """
129
DOWNLOAD_STATUS_PACKAGE_BEGIN = -3
130
""" Download status: package begin. """
131
DOWNLOAD_STATUS_PACKAGE_FINISHED = -4
132
""" Download status: package finished. """
133
DOWNLOAD_STATUS_PACKAGE_ERROR = -5
134
""" Download status: package error. """
136
INSTALL_STATUS_BEGIN = -1
137
""" Installation status: begin/initialization. """
138
INSTALL_STATUS_FINISHED = -2
139
""" Installation status: finished/finalization. """
140
INSTALL_STATUS_PACKAGE_BEGIN = -3
141
""" Installation status: package begin. """
142
INSTALL_STATUS_PACKAGE_UNPACK = -4
143
""" Installation status: package unpack. """
144
INSTALL_STATUS_PACKAGE_SETUP = -5
145
""" Installation status: package setup. """
146
INSTALL_STATUS_PACKAGE_FINISHED = -6
147
""" Installation status: package finished. """
148
INSTALL_STATUS_ERROR = -7
149
""" Installation status: error. """
151
class IBackend(Interface):
153
Interface class for update-manager backends.
155
This class forms the public interface to Update Manager backends.
131
158
def get_available_updates(self):
133
160
Returns a list containing PackageUpdateInfo objects of available
136
raise NotImplementedError
138
RELOAD_CACHE_STATUS_DONE = -1
139
""" Cache reload status: done. """
141
164
def reload_cache(self, cache_progress_callback):
143
166
Reloads the package cache.