Client API for Python 2.x and 3.x

This is a Python 2.x & 3.x client API for the yum-daemon Dbus Service

This module gives a simple pythonic interface to doing Yum package action using the yum-daemon Dbus service.

It use async call to the yum-daemon, so signal can be catched and a Gtk gui dont get unresonsive

There is 2 classes YumDaemonClient & YumDaemonReadOnlyClient

YumDaemonClient uses a system DBus service running as root and can make chages to the system.

YumDaemonReadOnlyClient uses a session DBus service running as current user and can only do readonly actions.

Usage: (Make your own subclass based on yumdaemon.YumDaemonClient and overload the signal handlers):

from yumdaemon import YumDaemonClient

class MyClient(YumDaemonClient):

    def __init(self):
        YumDaemonClient.__init__(self)
        # Do your stuff here

    def on_UpdateProgress(self,name,frac,fread,ftime):
        # Do your stuff here
        pass

    def on_TransactionEvent(self,event, data):
        # Do your stuff here
        pass

    def on_RPMProgress(self, package, action, te_current, te_total, ts_current, ts_total):
        # Do your stuff here
        pass

    def on_GPGImport(self, pkg_id, userid, hexkeyid, keyurl,  timestamp ):
       # do stuff here   
       pass

Usage: (Make your own subclass based on yumdaemon.YumDaemonReadOnlyClient and overload the signal handlers):

from yumdaemon import YumDaemonReadOnlyClient

class MyClient(YumDaemonReadOnlyClient):

    def __init(self):
        YumDaemonClient.__init__(self)
        # Do your stuff here

    def on_UpdateProgress(self,name,frac,fread,ftime):
        # Do your stuff here
        pass

Classes

System API

class yumdaemon.YumDaemonClient

A class to communicate with the yumdaemon DBus services in a easy way

Exit()

End the daemon

Lock()

Get the yum lock, this give exclusive access to the daemon and yum this must always be called before doing other actions

Unlock()

Release the yum lock

SetWatchdogState(state)

Set the Watchdog state

Parameters:state (boolean (b)) – True = Watchdog active, False = Watchdog disabled
GetPackageWithAttributes(pkg_filter, fields)

Get a list of pkg list for a given package filter each pkg list contains [pkg_id, field,....] where field is a atrribute of the package object Ex. summary, size etc.

Parameters:
  • pkg_filter (string) – package filter (‘installed’,’available’,’updates’,’obsoletes’,’recent’,’extras’)
  • fields (list of strings) – yum package objects attributes to get.
GetConfig(setting)

Read a config setting from yum.conf

Parameters:setting (string) – setting to read
SetConfig(setting, value)

set a yum config setting

Parameters:
  • setting – yum conf setting to set
  • value – value to set
GetAttribute(pkg_id, attr)

Get yum package attribute (description, filelist, changelog etc)

Parameters:
  • pkg_id – pkg_id to get attribute from
  • attr – name of attribute to get
GetUpdateInfo(pkg_id)

Get Updateinfo for a package

Parameters:pkg_id – pkg_id to get update info from
GetPackages(pkg_filter)

Get a list of pkg ids for a given filter (installed, updates ..)

Parameters:pkg_filter (string) – package filter (‘installed’,’available’,’updates’,’obsoletes’,’recent’,’extras’)
Returns:list of pkg_id’s
Return type:list of strings
GetPackagesByName(name, newest_only=True)

Get a list of pkg ids for starts with name

Parameters:
  • name (string) – name prefix to match
  • newest_only (boolean) – show only the newest match or every match.
Returns:

list of pkg_is’s

GetHistoryByDays(start_days, end_days)

Get History transaction in a interval of days from today

Parameters:start_days (integer) – start of interval in days from now (0 = today)

:param end_days:end of interval in days from now :type end_days: integer :return: a list of (transaction is, date-time) pairs :type sender: json encoded string

HistorySearch(pattern)

Search the history for transaction matching a pattern

Parameters:pattern (list (strings)) – patterne to match
Returns:list of (tid,isodates)
GetHistoryPackages(tid)

Get packages from a given yum history transaction id

Parameters:tid (integer) – history transaction id
Returns:list of (pkg_id, state, installed) pairs
Return type:list
GetGroups()

Get list of Groups

Search(fields, keys, match_all, newest_only, tags)

Search for packages where keys is matched in fields

Parameters:
  • fields (list of strings) – yum po attributes to search in
  • keys (list of strings) – keys to search for
  • match_all (boolean) – match all keys or only one
  • newest_only (boolean) – return only the newest version of packages
  • tags (boolean) – search pkgtags
Returns:

list of pkg_id’s

ClearTransaction()

Clear the current transaction

GetTransaction()

Get the current transaction

Returns:the current transaction
AddTransaction(id, action)

Add an package to the current transaction

Parameters:
  • id (string) – package id for the package to add
  • action (string) – the action to perform ( install, update, remove, obsolete, reinstall, downgrade, localinstall )
Install(pattern)

Do a install <pattern string>, same as yum install <pattern string>

Parameters:pattern (string) – package pattern to install
Remove(pattern)

Do a install <pattern string>, same as yum remove <pattern string>

Parameters:pattern (string) – package pattern to remove
Update(pattern)

Do a update <pattern string>, same as yum update <pattern string>

Parameters:pattern (string) – package pattern to update
Downgrade(pattern)

Do a install <pattern string>, same as yum remove <pattern string>

Parameters:pattern (string) – package pattern to downgrade
BuildTransaction()

Get a list of pkg ids for the current availabe updates

RunTransaction()

Get a list of pkg ids for the current availabe updates

GetGroupPackages(grp_id, grp_flt)

Get packages in a group

Parameters:
  • grp_id – the group id to get packages for
  • grp_flt – the filter (‘all’ = all packages ,’default’ = packages to be installed, before the group is installed)
ConfirmGPGImport(hexkeyid, confirmed)

Confirm import of at GPG Key by yum

Parameters:
  • hexkeyid – hex keyid for GPG key
  • confirmed – confirm import of key (True/False)

Session API

class yumdaemon.YumDaemonReadOnlyClient

A class to communicate with the yumdaemon DBus services in a easy way

Exit()

End the daemon

Lock()

Get the yum lock, this give exclusive access to the daemon and yum this must always be called before doing other actions

Unlock()

Release the yum lock

SetWatchdogState(state)

Set the Watchdog state

Parameters:state (boolean (b)) – True = Watchdog active, False = Watchdog disabled
GetPackageWithAttributes(pkg_filter, fields)

Get a list of pkg list for a given package filter each pkg list contains [pkg_id, field,....] where field is a atrribute of the package object Ex. summary, size etc.

Parameters:
  • pkg_filter (string) – package filter (‘installed’,’available’,’updates’,’obsoletes’,’recent’,’extras’)
  • fields (list of strings) – yum package objects attributes to get.
GetConfig(setting)

Read a config setting from yum.conf

Parameters:setting (string) – setting to read
GetAttribute(pkg_id, attr)

Get yum package attribute (description, filelist, changelog etc)

Parameters:
  • pkg_id – pkg_id to get attribute from
  • attr – name of attribute to get
GetUpdateInfo(pkg_id)

Get Updateinfo for a package

Parameters:pkg_id – pkg_id to get update info from
GetPackages(pkg_filter)

Get a list of pkg ids for a given filter (installed, updates ..)

Parameters:pkg_filter (string) – package filter (‘installed’,’available’,’updates’,’obsoletes’,’recent’,’extras’)
Returns:list of pkg_id’s
Return type:list of strings
GetPackagesByName(name, newest_only=True)

Get a list of pkg ids for starts with name

Parameters:
  • name (string) – name prefix to match
  • newest_only (boolean) – show only the newest match or every match.
Returns:

list of pkg_is’s

GetGroups()

Get list of Groups

GetGroupPackages(grp_id, grp_flt)

Get packages in a group

Parameters:
  • grp_id – the group id to get packages for
  • grp_flt – the filter (‘all’ = all packages ,’default’ = packages to be installed, before the group is installed)

Exceptions

class yumdaemon.YumDaemonError(Exception)

Base Exception from the backend

class yumdaemon.AccessDeniedError(YumDaemonError)

PolicyKit access was denied.

Ex. User press cancel button in policykit window

class yumdaemon.YumLockedError(YumDaemonError)

Yum is locked by another application

Ex. yum is running in a another session You have not called the Lock method to grep the Lock

class yumdaemon.YumTransactionError(YumDaemonError)

Error in the yum transaction.

Table Of Contents

Previous topic

DBus service API documentation

Next topic

Examples

This Page