__init__.py 739 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import os.path

def backend_factory(*args, **kwargs):
    " get a matching backend "
    # try the synaptic interface first
    if os.path.exists("/usr/sbin/synaptic"):
        import InstallBackendSynaptic
        return InstallBackendSynaptic.InstallBackendSynaptic(*args, **kwargs)
    else:
        raise Exception("No working backend found, please try installing synaptic or aptdaemon")

    # then aptdaemon
    if os.path.exists("/usr/sbin/aptd"):
        # check if the gtkwidgets are installed as well
        try:
            import aptdaemon.gtkwidgets
            import InstallBackendAptdaemon
            return InstallBackendAptdaemon.InstallBackendAptdaemon(*args, **kwargs)
        except ImportError, e:
            pass