aptdaemon.client — The client module

Introduction

Aptdaemon comes with a client module which provides a smoother interface on top of the D-Bus interface. It provides GObjects of the daemon and each transaction.

Life cycle of a transaction based action

At first you initialize an AptClient instance.

>>> from aptdaemon import client
>>>
>>> apt_client = client.AptClient()

Secondly you call the whished action, e.g. updating the package cache. It will give you a new transaction instance.

>>> transaction = apt_client.update()

The transaction has not been started yet. So you can make some further adjustements to it, e.g. setting a different language:

>>> transaction.set_locale("de_DE")

... or setup the monitoring of the transaction:

>>> transaction.connect("finished", on_transaction_finished)

You can then put the transaction on the queue by calling its run() method:

>>> transaction.run()

If you don’t need the underlying transcation instance of an action, you can alternatively set the wait argument to True. The AptClient method will return after the transaction is done:

>>> apt_client.update_cache(wait=True)

This can also be used with asynchronous programming, see below.

Asynchronous programming

In the above examples simple synchronous calls have been made to the D-Bus. Until these calls return your whole application is blocked/frozen. In the case of password prompts this can be quite long. So aptdaemon supports the following asynchronous styles:

D-Bus style callbacks

Since the client module is basically a wrapper around D-Bus calls, it provides a pair of reply_handler and error_handler for each method. You are perhaps already familiar with those if you have written a Python D-Bus client before:

>>> def run(trans):
...     trans.run(reply_handler=trans_has_started, error_handler=on_error)
...
>>> def trans_has_started():
...     pass
...
>>> def on_error(error):
...     raise error
...
>>> client = AptClient()
>>> client.update(reply_handler=run, error_handler=on_error)

Deferred callbacks

Aptdaemon uses a simplified version of Twisted deferreds internally, called python-defer. But you can also make use of them in your application.

The inline_callbacks decorator of python-defer allows to write asynchronous code in a synchronous way:

>>> @defer.inline_callbacks
... def update_cache():
...     apt_client = client.AptClient()
...     try:
...         transaction = yield apt_client.update()
...     except errors.NotAuthorizedError:
...         print "You are not allowed to update the cache!"
...         raise StopIteration
...     yield transaction.set_locale("de_DE")
...     yield transaction.run()
...     print "Transaction has started"

Chaining Transactions

It is possible to chain transactions. This allows to add a simple dependency relation, e.g. you want to add a new repository, update the cache and finally install a new package.

>>> client = aptdaemon.client.AptClient()
>>> trans1 = client.add_repository("deb", [...])
>>> trans2 = client.update_cache()
>>> trans3 = client.install_packages(["new-package"])
>>> trans2.run_after(trans1)
>>> trans3.run_after(trans2)
>>> trans1.run()

If a transaction in a chain fails all other ones which follow will fail too with the enums.EXIT_PREVIOUS_FAILED exit state.

Class Reference

class aptdaemon.client.AptClient(bus=None)

Provides a complete client for aptdaemon.

add_license_key(*args, **kwargs)

Install a license key to use a piece of proprietary software.

Parameters:
  • pkg_name – The package which requires the license
  • json_token – The oauth token in json format
  • server_name – The server name (ubuntu-procduction, ubuntu-staging)
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

add_repository(*args, **kwargs)

Create a new transaction to enable a repository.

Parameters:
  • src_type – The type of the repository (deb, deb-src).
  • uri – The main repository URI (e.g. http://archive.ubuntu.com/ubuntu)
  • dist – The distribution to use (e.g. stable or lenny-backports).
  • comps – List of components (e.g. main, restricted).
  • comment – A comment which should be added to the sources.list.
  • sourcesfile – (Optoinal) filename in sources.list.d.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

add_vendor_key_from_file(*args, **kwargs)

Create a new transaction to install the key file of a software vendor. The key is used to authenticate packages of the vendor.

Parameters:
  • path – The absolute path to the key file.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

add_vendor_key_from_keyserver(*args, **kwargs)

Create a new transaction to download and install the key of a software vendor. The key is used to authenticate packages of the vendor.

Parameters:
  • keyid – The id of the GnuPG key (e.g. 0x0EB12F05)
  • keyserver – The server to get the key from (e.g. keyserver.ubuntu.com)
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

clean(*args, **kwargs)

Remove all downloaded files.

Parameters:
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

commit_packages(*args, **kwargs)

Create a new transaction to perform a complex package management task which allows to install, remove, upgrade or downgrade several packages at the same time.

The version number and target release of the packages can be specified using the traditional apt-get syntax, e.g. “xterm=281.1” to force installing the version 281.1 of xterm or “xterm/experimental” to force installing xterm from the experimental release.

Parameters:
  • install – List of packages to install.
  • reinstall – List of packages to re-install.
  • remove – List of packages to remove.
  • purge – List of packages to purge.
  • upgrade – List of packages to upgrade.
  • downgrade – List of packages to downgrade. The version of the package has to be appended to the name separated by a “=”, e.g. “xterm=272-1”.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

enable_distro_component(*args, **kwargs)

Create a new transaction to enable the component of the distribution repository.

Parameters:
  • component – The name of the component, e.g. main or universe.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

fix_broken_depends(*args, **kwargs)

Create a new transaction to fix unsatisfied dependencies of already installed packages.

Corresponds to the apt-get -f install call.

Parameters:
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

fix_incomplete_install(*args, **kwargs)

Create a new transaction to complete a previous interrupted installation.

Corresponds to the dpkg --confgiure -a call.

Parameters:
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

get_trusted_vendor_keys(*args, **kwargs)

Get the list of the installed vendor keys which are used to authenticate packages.

Parameters:
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

Fingerprints of all installed vendor keys.

install_file(*args, **kwargs)

Create a new transaction to install a local package file.

Parameters:
  • path – The absolute path to the .deb-file.
  • force – Force the installation of a .deb-file even if it violates the quality standard defined in the packaging policy.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

install_packages(*args, **kwargs)

Create a new transaction to install the given packages from the reporitories.

The version number and target release of the packages can be specified using the traditional apt-get syntax, e.g. “xterm=281.1” to force installing the version 281.1 of xterm or “xterm/experimental” to force installing xterm from the experimental release.

Parameters:
  • package_names – List of names of the packages which should be installed.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

reconfigure(*args, **kwargs)

Create a new transaction to reconfigure already installed packages.

Corresponds to the dpkg-reconfigure call.

Parameters:
  • packages – List of package names which should be reconfigured.
  • priority – The minimum priority of question that will be displayed.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

remove_packages(*args, **kwargs)

Create a new transaction to remove installed packages.

Parameters:
  • package_names – The list of packages which should be removed.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

remove_vendor_key(*args, **kwargs)

Create a new transaction to remove the key of a software vendor from the list of trusted ones.

The key is used to authenticate the origin of packages.

Parameters:
  • fingerprint – The fingerprint of the key.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

update_cache(*args, **kwargs)

Create a new transaction to update the package cache.

The repositories will be queried for installable packages.

Parameters:
  • sources_list – Path to a sources.list which contains repositories that should be updated only. The other repositories will be ignored in this case. Can be either the file name of a snippet in /etc/apt/sources.list.d or an absolute path.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

upgrade_packages(*args, **kwargs)

Create a new transaction to upgrade installed packages.

The version number and target release of the packages can be specified using the traditional apt-get syntax, e.g. “xterm=281.1” to force installing the version 281.1 of xterm or “xterm/experimental” to force installing xterm from the experimental release.

Parameters:
  • package_names – The list of package which should be upgraded.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

upgrade_system(*args, **kwargs)

Create a new transaction to apply all avaibale upgrades.

Parameters:
  • safe_mode – If True only already installed packages will be updated. Updates which require to remove installed packages or to install additional packages will be skipped.
  • wait – if True run the transaction immediately and return its exit state instead of the transaction itself.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

class aptdaemon.client.AptTransaction(tid, bus=None)

Represents an aptdaemon transaction.

Note

This class cannot be inherited since it makes use of a metaclass.

allow-unauthenticated → allow

The signal is emitted when allow_unauthenticated changed.

Param allow:If unauthenticated packages are allowed to be installed.
cancellable-changed → cancellable

The signal is emitted when cancellable changed.

Param cancellable:
 If the transaction can be cancelled now.
config-file-conflict → cur, new

The signal is emitted when config_file_conflict changed.

Param cur:The path to the current configuration file.
Param new:The path to the new configuration file.
debconf-socket-changed → path

The signal is emitted when debconf_socket changed.

Param path:The path to the socket which will be used to forward debconf communication to the user session.
dependencies-changed → installs, re-installs, removals, purges, upgrades, downgrades, kepts

The signal is emitted when dependencies changed.

Most likely after simulate() was called.

Param installs:List of package which will be installed.
Param reinstalls:
 List of package which will be re-installed.
Param removals:List of package which will be removed,
Param purges:List of package which will be removed including configuration files.
Param upgrades:List of package which will be upgraded.
Param downgrades:
 List of package which will be downgraded to an older version.
Param kepts:List of package which will be skipped from upgrading.
download-changed → download

The signal is emitted when download changed.

Param download:Download size integer in Bytes.
error → error_code, error_details

The signal is emitted when an error occured.

Param error_code:
 The error code enumeration, e.g. aptdaemon.enums.ERROR_NO_CACHE.
Param error_details:
 The error description string.
finished → exit_state

The signal is emitted when the transaction is completed or has failed.

Param exit_state:
 The exit status enumeration string.
http-proxy-changed → uri

The signal is emitted when http_proxy changed.

Param uri:The URI of the proxy server, e.g. “http://proxy:8080”.
locale-changed → locale

The signal is emitted when locale changed.

Param locale:The language which should be used for messages, eg. “de_DE”.
meta-data-changed → meta_data

The signal is emitted when meta_data changed.

Param meta_data:
 The latest meta data dictionary.
medium-required → name, device

The signal is emitted when required_medium changed.

Param name:The name of the volume.
Param device:The path of the device in which the volume should be inserted.
remove-obsoleted-depends-changed → remove

The signal is emitted when remove_obsoleted_depends changed.

Param remove:If obsolete dependencies should also be removed.
role-changed → role

The signal is emitted when role changed.

Param role:The new role enum, e.g. ROLE_UPDATE_CACHE.
space-changed → space

The signal is emitted when space changed. Most likely after simulate() was called.

Param space:Required disk space integer in Bytes. Can be negative if disk space will be freed.
packages-changed → installs, re-installs, removals, purges, upgrades, downgrades

The signal is emitted when packages changed.

Param installs:List of package which will be installed.
Param reinstalls:
 List of package which will be re-installed.
Param removals:List of package which will be removed,
Param purges:List of package which will be removed including configuration files.
Param upgrades:List of package which will be upgraded.
Param downgrades:
 List of package which will be downgraded to an older version.
paused

The signal is emitted when the transaction was paused. See paused and resumed.

progress-changed → progress

The signal is emitted when progress changed.

Param progress:The progress integer.
progress-details-changed → current_items, total_items, currenty_bytes, total_bytes, current_cps, eta

The signal is emitted when detailed information of the progress is available.

Param current_items:
 The number of already processed items.
Param total_items:
 The number of all items.
Param current_bytes:
 The number of already downloaded byte.
Param total_bytes:
 The number of bytes which have to be downloaded totally.
Param current_cps:
 The current download speed in bytes per second.
Param eta:The elapsed time in seconds to accomplish the task.
progress-download-changed → uri, short_desc, total_size, current_size, msg

The signal is emitted when progress information about a single download is available.

Param uri:The URI of the file which is downloaded.
Param status:The status of the downloade, e.g. DOWNLOAD_AUTH_FAILED.
Param short_desc:
 A short description of the file.
Param total_size:
 The size of the file in Bytes.
Param current_size:
 How much of the file in Bytes has already be downloaded.
Param msg:The status or error description.
resumed

The signal is emitted when a paused transaction was resumed. See paused and paused.

terminal-changed → path

The signal is emitted when terminal changed.

Param path:The path to the slave end of the controlling terminal for the underlying dpkg call.
terminal-attached-changed → attached

The signal is emitted when term_attached changed.

Param attached:If the controlling terminal can be used.
unauthenticated-changed → unauthenticated

The signal is emitted when unauthenticated changed.

Param unauthenticated:
 List of unauthenticated packages.
cancellable

If the transaction can be currently cancelled.

config_file_conflict

If there is a conflict in the configuration file handling during an installation this attribute contains a tuple of the path to the current and the new temporary configuration file.

The resolve_config_file_conflict() can be used to resolve the conflict and continue the processing of the transaction.

dependencies

List of dependencies lists in the following order: packages to install, to re-install, to remove, to purge, to upgrade, to downgrade and to keep.

You have to call simulate() to calculate the dependencies before the transaction will be executed.

download

The number of Bytes which have to be downloaed.

You have to call simulate() to calculate the download size before the transaction will be executed.

error

In the case of a failed transaction this attribute holds the corresponding errors.TransactionFailed instance.

error_code

In the case of a failed transaction this attribute is set to the underlying error code, e.g. enums.ERROR_PACKAGE_DOWNLOAD_FAILED.

error_details

In the case of a failed transaction this attribute contains a detailed error message in the language of the transaction.

exit

Contains the exit status enum if the transaction has been completed, e.g. enums.EXIT_SUCCESS or enums.EXIT_FAILED.

http_proxy

The URI to the http proxy server which should be used only for this transaction, e.g. “http://proxy:8080”. It is recommended to set the system wide proxy server instead of setting this attribute for every transaction.

See set_http_proxy().

meta_data

Dictionary of optional meta data which can be set by client applications. See set_meta_data().

packages

List of package lists which will be explicitly changed in the following order: packages to install, to re-install, to remove, to purge, to upgrade, to downgrade.

paused

If the transaction is currently paused, e.g. it is required to insert a medium to install from.

progress

An integer ranging from 0 to 101 to describe the progress of the transaction.

Note

A value of 101 indicates that there cannot be made any assumptions on the progress of the transaction.

remove_obsoleted_depends

If dependencies which have been required by a removed package only should be removed, too.

required_medium

If a medium should be inserted to continue the fetch phase of a transaction, this attribute contains a tuple of the device path of of the drive which should be used and secondly of the name of the medium.

The provide_medium() method should be used to notify aptdaemon about an inserted medium and to continue processing the transaction.

role

The kind of action which is performed by the transaction, e.g. enums.ROLE_UPGRADE_SYSTEM.

space

The required disk space in Bytes. Will be negative if space is freed.

You have to call simulate() to calculate the download size before the transaction will be executed.

status

The enum of the current status, e.g. enums.STATUS_DOWNLOADING.

status_details

A string describing the current status of the transaction.

tid

The unique identifier of the transaction. It is also the D-Bus path of the corresponding transaction object.

term_attached

If the the package manager can be controlled using the controlling terminal specified by set_terminal().

unauthenticated

List of packages which are going to be installed but are not downloaded from an authenticated repository.

You have to call simulate() to calculate the dependencies before the transaction will be executed.

cancel(*args, **kwargs)

Cancel the running transaction.

Parameters:
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.NotAuthorizedError, dbus.DBusException

provide_medium(*args, **kwargs)

Continue a paused transaction which waits for a medium to install from.

Parameters:
  • medium – The name of the provided medium.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

resolve_config_file_conflict(*args, **kwargs)

Continue a paused transaction which waits for the resolution of a configuration file conflict.

Parameters:
  • config – The path to the current version of the configuration file.
  • answer – Can be either “keep” or “replace”.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

run(*args, **kwargs)

Queue the transaction for processing.

Parameters:
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.TransactionFailed, dbus.DBusException

run_after(*args, **kwargs)

Chain this transaction after the given one. The transaction will fail if the previous one fails.

To start processing of the chain you have to call run() of the first transaction. The others will be queued after it automatically.

Parameters:
  • transaction – An AptTransaction on which this one depends.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

set_allow_unauthenticated(*args, **kwargs)

Allow to install unauthenticated packages.

Unauthenticated packages are from the repository of a vendor whose key hasn’t been installed. By default this is not allowed.

Parameters:
  • allow_unauthenticated – If unauthenticated packages can be installed.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

set_debconf_frontend(*args, **kwargs)

Setup a debconf frontend to answer questions of the maintainer scripts.

Debian allows packages to interact with the user during installation, configuration and removal phase via debconf. Aptdaemon forwards the communication to a debconf instance running as the user of the client application.

Parameters:
  • frontend – The name of the debconf frontend which should be launched, e.g. gnome or kde. Defaults to gnome.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

set_http_proxy(*args, **kwargs)

Use the given http proxy for downloading packages in this transaction.

Parameters:
  • proxy – The URL of the proxy server, e.g. “http://proxy:8080
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.NotAuthorizedError, dbus.DBusException aptdaemon.errors.ForeignTransaction,

set_locale(*args, **kwargs)

Set the language for status and error messages.

Parameters:
  • locale – The locale name, e.g. de_DE@UTF-8.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

set_meta_data(*args, **kwargs)

Store additional meta information of the transaction in the MetaData property of the transaction.

The method accepts key=value pairs. The key has to be prefixed with an underscore separated identifier of the client application.

In the following example Software-Center sets an application name and icon:

>>> Transaction.set_meta_data(sc_icon="shiny", sc_app="xterm")
Parameters:
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

set_remove_obsoleted_depends(*args, **kwargs)

Include no longer required dependencies which have been installed automatically when removing packages.

Parameters:
  • remove_obsoleted_depends – If obsolete dependencies should be also removed.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

set_terminal(*args, **kwargs)

Allow to set a controlling terminal for the underlying dpkg call.

See the source code of gtkwidgets.AptTerminal or console.ConsoleClient as example.

>>> master, slave = pty.openpty()
>>> transaction.set_terminal(os.ttyname(slave))
Parameters:
  • terminal – The slave end of a tty.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.ForeignTransaction, dbus.DBusException

simulate(*args, **kwargs)

Simulate the transaction to calculate the dependencies, the required download size and the required disk space.

The corresponding properties of the AptTransaction will be updated.

Parameters:
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

aptdaemon.errors.TransactionFailed, dbus.DBusException

sync(*args, **kwargs)

Sync the properties of the transaction with the daemon.

This method is called automatically on the creation of the AptTransaction instance.

Parameters:
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Function Reference

aptdaemon.client.get_transaction(*args, **kwargs)

Get an existing transaction by its identifier.

Parameters:
  • tid – The identifer and D-Bus path of the transaction e.g. /org/debian/apt/transaction/78904e5f9fa34098879e768032789109
  • bus – Optionally the D-Bus on which aptdaemon listens. Defaults to the system bus.
  • reply_handler – Callback function. If specified in combination with error_handler the method will be called asynchrounsouly.
  • error_handler – Errback function. In case of an error the given callback gets the corresponding exception instance.
  • defer – Run the method asynchrounsly and return a defer.Deferred. This options is only available as an keyword.
Raises :

dbus.DBusException

Returns:

An AptTransaction instance.

aptdaemon.client.get_aptdaemon(bus=None)

Get the daemon D-Bus interface.

Parameters:bus – Optionally the D-Bus on which aptdaemon listens. Defaults to the system bus.
Raises :dbus.DBusException
Returns:An dbus.Interface instance.