~ubuntu-branches/ubuntu/precise/oneconf/precise

« back to all changes in this revision

Viewing changes to oneconf/networksync/ssohandler.py

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2011-09-22 14:46:58 UTC
  • Revision ID: package-import@ubuntu.com-20110922144658-0g8bv88hbzi2ils4
Tags: 0.2.6.5
* New release:
  - fix a crash when using --help having utf8 translations
  - fix if you just enable sso login for the first time in software-center,
    oneconf won't sync before restarting (LP: #855373)
  - emitting a last sync accurate date as soon as the sync is done
    (LP: #855345)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from gi.repository import GObject
26
26
import logging
27
27
 
 
28
from oneconf.enums import MIN_TIME_WITHOUT_ACTIVITY
 
29
 
28
30
from gettext import gettext as _
29
 
 
30
31
gettext.textdomain("software-center")
31
32
 
32
33
NO_OP = lambda *args, **kwargs: None
51
52
        self.appname = "Ubuntu Software Center"
52
53
        self.bus = dbus.SessionBus()
53
54
        
 
55
        self.proxy = None
 
56
        self._get_sso_proxy()
54
57
        # try it in a spawn/retry process to avoid ubuntu sso login issues
55
 
        self.proxy = None
56
 
        GObject.timeout_add_seconds(5, self._get_sso_proxy)
57
 
        
 
58
        GObject.timeout_add_seconds(MIN_TIME_WITHOUT_ACTIVITY, self._get_sso_proxy)
58
59
 
59
60
    def _get_sso_proxy(self):
60
61
        '''avoid crashing if ubuntu sso doesn't answer, which seems common'''
61
62
        
62
63
        LOG.debug("Try to get a proxy")
63
64
        try:
 
65
            # recreate a proxy object to respawn the sso daemon
 
66
            # (TODO: migration to gdbus and dbus owner changed should help)
64
67
            self.proxy = self.bus.get_object('com.ubuntu.sso', '/com/ubuntu/sso/credentials')
65
68
            self.proxy.connect_to_signal("CredentialsFound",
66
69
                                         self._on_credentials_found)
72
75
            self.proxy.find_credentials(self.appname, '', reply_handler=NO_OP, error_handler=NO_OP)
73
76
        except dbus.DBusException, e:
74
77
            LOG.debug("No reply from ubuntu sso: %s" % e)
75
 
            return True # try again
76
 
        return False
 
78
        return True # try again
77
79
 
78
80
    def _on_credentials_found(self, app_name, credentials):
79
81
        if app_name != self.appname:
104
106
    login = LoginBackendDbusSSO()
105
107
 
106
108
    loop = GObject.MainLoop()
107
 
    login.get_credential()
108
109
    
109
110
    def print_result(obj, foo):
110
111
        print foo