1.. 2 Copyright (C) 2014-2018 Red Hat, Inc. 3 4 This copyrighted material is made available to anyone wishing to use, 5 modify, copy, or redistribute it subject to the terms and conditions of 6 the GNU General Public License v.2, or (at your option) any later version. 7 This program is distributed in the hope that it will be useful, but WITHOUT 8 ANY WARRANTY expressed or implied, including the implied warranties of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10 Public License for more details. You should have received a copy of the 11 GNU General Public License along with this program; if not, write to the 12 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 13 02110-1301, USA. Any Red Hat trademarks that are incorporated in the 14 source code or documentation are not subject to the GNU General Public 15 License and may only be used or replicated with the express permission of 16 Red Hat, Inc. 17 18=================================== 19 Progress Reporting with Callbacks 20=================================== 21 22.. module:: dnf.callback 23 24.. class:: Payload 25 26 Represents one item (file) from the download batch. 27 28 .. method:: __str__ 29 30 Provide concise, human-readable representation of this Payload. 31 32 .. attribute:: download_size 33 34 Total size of this Payload when transferred (e.g. over network). 35 36.. class:: DownloadProgress 37 38 Base class providing callbacks to receive information about an ongoing download. 39 40 .. method:: start(total_files, total_size, total_drpms=0) 41 42 Report start of a download batch. `total_files` is the total number of payloads in the batch. 43 `total_size` is the total number of bytes to be downloaded. `total_drpms` is the total number 44 of drpms payloads in the batch. 45 46 .. method:: progress(payload, done) 47 48 Report ongoing progress on the given `payload`. `done` is the number of bytes already downloaded from `payload`. 49 50 .. method:: end(payload, status, msg) 51 52 Report finished download of a `payload`, :class:`.Payload` instance. `status` is a constant with the following meaning: 53 54 ====================== ======================================================= 55 `status` value meaning 56 ====================== ======================================================= 57 STATUS_OK Download finished successfully. 58 STATUS_DRPM DRPM rebuilt successfully. 59 STATUS_ALREADY_EXISTS Download skipped because the local file already exists. 60 STATUS_MIRROR Download failed on the current mirror, will try to use 61 next mirror in the list. 62 STATUS_FAILED Download failed because of another error. 63 ====================== ======================================================= 64 65 `msg` is an optional string error message further explaining the `status`. 66 67.. class:: TransactionProgress 68 69 Base class providing callbacks to receive information about an ongoing transaction. 70 71 .. method:: error(message) 72 73 Report an error that occurred during the transaction. `message` is a string which describes the error. 74 75 .. method:: progress(package, action, ti_done, ti_total, ts_done, ts_total) 76 77 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: 78 79 ================== ================================================================================= =========== 80 `action` value meaning Appearance* 81 ================== ================================================================================= =========== 82 PKG_CLEANUP `package` cleanup is being performed. 3 83 PKG_DOWNGRADE `package` is being installed as a downgrade. 2 84 PKG_DOWNGRADED installed `package` is being downgraded. 2 85 PKG_INSTALL `package` is being installed. 2 86 PKG_OBSOLETE `package` is obsoleting another package. 2 87 PKG_OBSOLETED installed `package` is being obsoleted. 2 88 PKG_REINSTALL `package` is installed as a reinstall. 2 89 PKG_REINSTALLED installed `package` is being reinstalled. 2 90 PKG_REMOVE `package` is being removed. 2 91 PKG_UPGRADE `package` is installed as an upgrade. 2 92 PKG_UPGRADED installed `package` is being upgraded. 2 93 PKG_VERIFY `package` is being verified. 5 94 PKG_SCRIPTLET `package` scriptlet is being performed. Anytime 95 TRANS_PREPARATION `transaction` is being prepared. 1 96 TRANS_POST The post-trans phase started. In this case, all the other arguments are ``None``. 4 97 ================== ================================================================================= =========== 98 99 \*\ This is order in which state of transaction which callback action can appear. Only PKG_SCRIPTLET 100 can appear anytime during transaction even before transaction starts. 101 102 `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. 103