|
Packit Service |
21c75c |
# callbacks.py
|
|
Packit Service |
21c75c |
# Abstract interfaces to communicate progress on tasks.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
# Copyright (C) 2014-2015 Red Hat, Inc.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
# This copyrighted material is made available to anyone wishing to use,
|
|
Packit Service |
21c75c |
# modify, copy, or redistribute it subject to the terms and conditions of
|
|
Packit Service |
21c75c |
# the GNU General Public License v.2, or (at your option) any later version.
|
|
Packit Service |
21c75c |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
21c75c |
# ANY WARRANTY expressed or implied, including the implied warranties of
|
|
Packit Service |
21c75c |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit Service |
21c75c |
# Public License for more details. You should have received a copy of the
|
|
Packit Service |
21c75c |
# GNU General Public License along with this program; if not, write to the
|
|
Packit Service |
21c75c |
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
21c75c |
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
Packit Service |
21c75c |
# source code or documentation are not subject to the GNU General Public
|
|
Packit Service |
21c75c |
# License and may only be used or replicated with the express permission of
|
|
Packit Service |
21c75c |
# Red Hat, Inc.
|
|
Packit Service |
21c75c |
#
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
from __future__ import unicode_literals
|
|
Packit Service |
21c75c |
import dnf.yum.rpmtrans
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
import dnf.transaction
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
PKG_DOWNGRADE = dnf.transaction.PKG_DOWNGRADE # :api
|
|
Packit Service |
21c75c |
PKG_DOWNGRADED = dnf.transaction.PKG_DOWNGRADED # :api
|
|
Packit Service |
21c75c |
PKG_INSTALL = dnf.transaction.PKG_INSTALL # :api
|
|
Packit Service |
21c75c |
PKG_OBSOLETE = dnf.transaction.PKG_OBSOLETE # :api
|
|
Packit Service |
21c75c |
PKG_OBSOLETED = dnf.transaction.PKG_OBSOLETED # :api
|
|
Packit Service |
21c75c |
PKG_REINSTALL = dnf.transaction.PKG_REINSTALL # :api
|
|
Packit Service |
21c75c |
PKG_REINSTALLED = dnf.transaction.PKG_REINSTALLED # :api
|
|
Packit Service |
21c75c |
PKG_REMOVE = dnf.transaction.PKG_ERASE # :api
|
|
Packit Service |
21c75c |
PKG_ERASE = PKG_REMOVE # deprecated, use PKG_REMOVE instead
|
|
Packit Service |
21c75c |
PKG_UPGRADE = dnf.transaction.PKG_UPGRADE # :api
|
|
Packit Service |
21c75c |
PKG_UPGRADED = dnf.transaction.PKG_UPGRADED # :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
PKG_CLEANUP = dnf.transaction.PKG_CLEANUP # :api
|
|
Packit Service |
21c75c |
PKG_VERIFY = dnf.transaction.PKG_VERIFY # :api
|
|
Packit Service |
21c75c |
PKG_SCRIPTLET = dnf.transaction.PKG_SCRIPTLET # :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
TRANS_PREPARATION = dnf.transaction.TRANS_PREPARATION # :api
|
|
Packit Service |
21c75c |
TRANS_POST = dnf.transaction.TRANS_POST # :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
STATUS_OK = None # :api
|
|
Packit Service |
21c75c |
STATUS_FAILED = 1 # :api
|
|
Packit Service |
21c75c |
STATUS_ALREADY_EXISTS = 2 # :api
|
|
Packit Service |
21c75c |
STATUS_MIRROR = 3 # :api
|
|
Packit Service |
21c75c |
STATUS_DRPM = 4 # :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class KeyImport(object):
|
|
Packit Service |
21c75c |
def _confirm(self, id, userid, fingerprint, url, timestamp):
|
|
Packit Service |
21c75c |
"""Ask the user if the key should be imported."""
|
|
Packit Service |
21c75c |
return False
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class Payload(object):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __init__(self, progress):
|
|
Packit Service |
21c75c |
self.progress = progress
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def __str__(self):
|
|
Packit Service |
21c75c |
"""Nice, human-readable representation. :api"""
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
@property
|
|
Packit Service |
21c75c |
def download_size(self):
|
|
Packit Service |
21c75c |
"""Total size of the download. :api"""
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class DownloadProgress(object):
|
|
Packit Service |
21c75c |
# :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def end(self, payload, status, msg):
|
|
Packit Service |
21c75c |
"""Communicate the information that `payload` has finished downloading.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
:api, `status` is a constant denoting the type of outcome, `err_msg` is an
|
|
Packit Service |
21c75c |
error message in case the outcome was an error.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def message(self, msg):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def progress(self, payload, done):
|
|
Packit Service |
21c75c |
"""Update the progress display. :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
`payload` is the payload this call reports progress for, `done` is how
|
|
Packit Service |
21c75c |
many bytes of this payload are already downloaded.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def start(self, total_files, total_size, total_drpms=0):
|
|
Packit Service |
21c75c |
"""Start new progress metering. :api
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
`total_files` the number of files that will be downloaded,
|
|
Packit Service |
21c75c |
`total_size` total size of all files.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
"""
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class NullDownloadProgress(DownloadProgress):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
class Depsolve(object):
|
|
Packit Service |
21c75c |
def start(self):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def pkg_added(self, pkg, mode):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
def end(self):
|
|
Packit Service |
21c75c |
pass
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
TransactionProgress = dnf.yum.rpmtrans.TransactionDisplay # :api
|