~mvo/software-center/lp959612

« back to all changes in this revision

Viewing changes to softwarecenter/utils.py

  • Committer: Michael Vogt
  • Date: 2012-04-26 07:22:36 UTC
  • mfrom: (2989.1.7 trunk)
  • Revision ID: michael.vogt@ubuntu.com-20120426072236-owk79xvu7tl89sid
mergedĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
418
418
    return ""
419
419
 
420
420
 
421
 
def clear_token_from_ubuntu_sso(appname):
 
421
def clear_token_from_ubuntu_sso_sync(appname):
422
422
    """ send a dbus signal to the com.ubuntu.sso service to clear
423
423
        the credentials for the given appname, e.g. _("Ubuntu Software Center")
 
424
        and wait for it to finish (or 2s)
424
425
    """
425
426
    from ubuntu_sso import (
426
427
        DBUS_BUS_NAME,
427
428
        DBUS_CREDENTIALS_IFACE,
428
429
        DBUS_CREDENTIALS_PATH,
429
430
        )
 
431
    # clean
 
432
    loop = GObject.MainLoop()
430
433
    bus = dbus.SessionBus()
431
434
    obj = bus.get_object(bus_name=DBUS_BUS_NAME,
432
435
                         object_path=DBUS_CREDENTIALS_PATH,
433
436
                         follow_name_owner_changes=True)
434
437
    proxy = dbus.Interface(object=obj,
435
438
                           dbus_interface=DBUS_CREDENTIALS_IFACE)
 
439
    proxy.connect_to_signal("CredentialsCleared", loop.quit)
 
440
    proxy.connect_to_signal("CredentialsNotFound", loop.quit)
 
441
    proxy.connect_to_signal("CredentialsError", loop.quit)
436
442
    proxy.clear_credentials(appname, {})
 
443
    # ensure we don't hang forever here
 
444
    GObject.timeout_add_seconds(2, loop.quit)
 
445
    # run the mainloop until the credentials are clear
 
446
    loop.run()
437
447
 
438
448
 
439
449
def get_nice_date_string(cur_t):