Blame doc/api_callback.rst

Packit 6f3914
..
Packit 6f3914
  Copyright (C) 2014-2018 Red Hat, Inc.
Packit 6f3914
Packit 6f3914
  This copyrighted material is made available to anyone wishing to use,
Packit 6f3914
  modify, copy, or redistribute it subject to the terms and conditions of
Packit 6f3914
  the GNU General Public License v.2, or (at your option) any later version.
Packit 6f3914
  This program is distributed in the hope that it will be useful, but WITHOUT
Packit 6f3914
  ANY WARRANTY expressed or implied, including the implied warranties of
Packit 6f3914
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit 6f3914
  Public License for more details.  You should have received a copy of the
Packit 6f3914
  GNU General Public License along with this program; if not, write to the
Packit 6f3914
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 6f3914
  02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
Packit 6f3914
  source code or documentation are not subject to the GNU General Public
Packit 6f3914
  License and may only be used or replicated with the express permission of
Packit 6f3914
  Red Hat, Inc.
Packit 6f3914
Packit 6f3914
===================================
Packit 6f3914
 Progress Reporting with Callbacks
Packit 6f3914
===================================
Packit 6f3914
Packit 6f3914
.. module:: dnf.callback
Packit 6f3914
Packit 6f3914
.. class:: Payload
Packit 6f3914
Packit 6f3914
  Represents one item (file) from the download batch.
Packit 6f3914
Packit 6f3914
  .. method:: __str__
Packit 6f3914
Packit 6f3914
    Provide concise, human-readable representation of this Payload.
Packit 6f3914
Packit 6f3914
  .. attribute:: download_size
Packit 6f3914
Packit 6f3914
    Total size of this Payload when transferred (e.g. over network).
Packit 6f3914
Packit 6f3914
.. class:: DownloadProgress
Packit 6f3914
Packit 6f3914
  Base class providing callbacks to receive information about an ongoing download.
Packit 6f3914
Packit 6f3914
  .. method:: start(total_files, total_size, total_drpms=0)
Packit 6f3914
Packit 6f3914
    Report start of a download batch. `total_files` is the total number of payloads in the batch.
Packit 6f3914
    `total_size` is the total number of bytes to be downloaded. `total_drpms` is the total number
Packit 6f3914
    of drpms payloads in the batch.
Packit 6f3914
Packit 6f3914
  .. method:: progress(payload, done)
Packit 6f3914
Packit 6f3914
    Report ongoing progress on the given `payload`. `done` is the number of bytes already downloaded from `payload`.
Packit 6f3914
Packit 6f3914
  .. method:: end(payload, status, msg)
Packit 6f3914
Packit 6f3914
    Report finished download of a `payload`, :class:`.Payload` instance. `status` is a constant with the following meaning:
Packit 6f3914
Packit 6f3914
    ====================== =======================================================
Packit 6f3914
    `status` value         meaning
Packit 6f3914
    ====================== =======================================================
Packit 6f3914
    STATUS_OK              Download finished successfully.
Packit 6f3914
    STATUS_DRPM            DRPM rebuilt successfully.
Packit 6f3914
    STATUS_ALREADY_EXISTS  Download skipped because the local file already exists.
Packit 6f3914
    STATUS_MIRROR          Download failed on the current mirror, will try to use
Packit 6f3914
                           next mirror in the list.
Packit 6f3914
    STATUS_FAILED          Download failed because of another error.
Packit 6f3914
    ====================== =======================================================
Packit 6f3914
Packit 6f3914
    `msg` is an optional string error message further explaining the `status`.
Packit 6f3914
Packit 6f3914
.. class:: TransactionProgress
Packit 6f3914
Packit 6f3914
  Base class providing callbacks to receive information about an ongoing transaction.
Packit 6f3914
Packit 6f3914
  .. method:: error(message)
Packit 6f3914
Packit 6f3914
    Report an error that occurred during the transaction. `message` is a string which describes the error.
Packit 6f3914
Packit 6f3914
  .. method:: progress(package, action, ti_done, ti_total, ts_done, ts_total)
Packit 6f3914
Packit 6f3914
    Report ongoing progress on the given transaction item. `package` is the :class:`dnf.package.Package` being processed and `action` is a constant with the following meaning:
Packit 6f3914
Packit 6f3914
    ================== ================================================================================= ===========
Packit 6f3914
    `action` value     meaning                                                                           Appearance*
Packit 6f3914
    ================== ================================================================================= ===========
Packit 6f3914
    PKG_CLEANUP        `package` cleanup is being performed.                                             3
Packit 6f3914
    PKG_DOWNGRADE      `package` is being installed as a downgrade.                                      2
Packit 6f3914
    PKG_DOWNGRADED     installed `package` is being downgraded.                                          2
Packit 6f3914
    PKG_INSTALL        `package` is being installed.                                                     2
Packit 6f3914
    PKG_OBSOLETE       `package` is obsoleting another package.                                          2
Packit 6f3914
    PKG_OBSOLETED      installed `package` is being obsoleted.                                           2
Packit 6f3914
    PKG_REINSTALL      `package` is installed as a reinstall.                                            2
Packit 6f3914
    PKG_REINSTALLED    installed `package` is being reinstalled.                                         2
Packit 6f3914
    PKG_REMOVE         `package` is being removed.                                                       2
Packit 6f3914
    PKG_UPGRADE        `package` is installed as an upgrade.                                             2
Packit 6f3914
    PKG_UPGRADED       installed `package` is being upgraded.                                            2
Packit 6f3914
    PKG_VERIFY         `package` is being verified.                                                      5
Packit 6f3914
    PKG_SCRIPTLET      `package` scriptlet is being performed.                                           Anytime
Packit 6f3914
    TRANS_PREPARATION  `transaction` is being prepared.                                                  1
Packit 6f3914
    TRANS_POST         The post-trans phase started. In this case, all the other arguments are ``None``. 4
Packit 6f3914
    ================== ================================================================================= ===========
Packit 6f3914
Packit 6f3914
  \*\ This is order in which state of transaction which callback action can appear. Only PKG_SCRIPTLET
Packit 6f3914
  can appear anytime during transaction even before transaction starts.
Packit 6f3914
Packit 6f3914
  `ti_done` is the number of processed bytes of the transaction item, `ti_total` is the total number of bytes of the transaction item, `ts_done` is the number of actions processed in the whole transaction and `ts_total` is the total number of actions in the whole transaction.