~didrocks/oneconf/oneconf-test

« back to all changes in this revision

Viewing changes to oneconf/networksync/__init__.py

  • Committer: Didier Roche
  • Date: 2012-06-04 11:25:38 UTC
  • Revision ID: didrocks@ubuntu.com-20120604112538-zwxap5zlx2cjuylg
  - fix some tests to be able to pass on others machines
  - prevent crashes on mint and elementary which doesn't ship a file
    for their distro. Added test cases for it (LP: #1006701)

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
    def _refresh_can_sync(self):
67
67
        '''compute current syncable state before asking for refresh the value'''
68
 
        new_can_sync = (self.credential is not None) and self._netstate.connected
 
68
        new_can_sync = (self.credential is not None) and (self.infraclient is not None) and self._netstate.connected
69
69
        if self._can_sync == new_can_sync:
70
70
            return
71
71
        self._can_sync = new_can_sync
72
72
 
73
73
        # we can now start syncing (as it's a new status), adding the timeout
 
74
        # TODO: self.infraclient should be built here
74
75
        if self._can_sync:
75
76
            self.process_sync()
76
77
            # adding the timeout only if we are not on a single sync
87
88
            from piston_mini_client.auth import OAuthAuthorizer
88
89
            from infraclient_pristine import WebCatalogAPI
89
90
            from oneconf.distributor import get_distro
90
 
            service_root = get_distro().ONECONF_SERVER
 
91
            distro = get_distro()
 
92
            # No update if not supported distribution
 
93
            if not distro:
 
94
               return
 
95
            service_root = distro.ONECONF_SERVER
91
96
            authorizer = OAuthAuthorizer(token_key=credential['token'],
92
97
                token_secret=credential['token_secret'],
93
98
                consumer_key=credential['consumer_key'],