Пример #1
0
def setup_dbus(force=True):
    """ Initialize DBus. """
    global daemon, wireless, wired, DBUS_AVAIL, lost_dbus_id
    print("Connecting to daemon...")
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        if force:
            print(("Can't connect to the daemon, trying to start it " + \
                "automatically..."))
            misc.PromptToStartDaemon()
            try:
                dbusmanager.connect_to_dbus()
            except DBusException:
                error(
                    None,
                    _("Could not connect to wicd's D-Bus interface. Check "
                      "the wicd log for error messages."))
                return False
        else:
            return False

    if lost_dbus_id:
        gobject.source_remove(lost_dbus_id)
        lost_dbus_id = None
    dbus_ifaces = dbusmanager.get_dbus_ifaces()
    daemon = dbus_ifaces['daemon']
    wireless = dbus_ifaces['wireless']
    wired = dbus_ifaces['wired']
    DBUS_AVAIL = True
    print("Connected.")
    return True
Пример #2
0
Файл: gui.py Проект: wmak/wicd
def setup_dbus(force=True):
    """ Initialize DBus. """
    global bus, daemon, wireless, wired, DBUS_AVAIL
    try:
        dbusmanager.connect_to_dbus()
    except DBusException:
        if force:
            print "Can't connect to the daemon, ' + \
                'trying to start it automatically..."

            if not misc.PromptToStartDaemon():
                print "Failed to find a graphical sudo program, ' + \
                    'cannot continue."

                return False
            try:
                dbusmanager.connect_to_dbus()
            except DBusException:
                error(
                    None,
                    _("Could not connect to wicd's D-Bus interface. "
                      "Check the wicd log for error messages."))
                return False
        else:
            return False
    prefs.setup_dbus()
    netentry.setup_dbus()
    bus = dbusmanager.get_bus()
    dbus_ifaces = dbusmanager.get_dbus_ifaces()
    daemon = dbus_ifaces['daemon']
    wireless = dbus_ifaces['wireless']
    wired = dbus_ifaces['wired']
    DBUS_AVAIL = True

    return True