~ubuntu-branches/ubuntu/oneiric/ubuntuone-control-panel/oneiric

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/web_client/txwebclient.py

* New upstream release:
  [ Alejandro J. Cura <alecu@canonical.com>]
    - Do not throw a webclient error when closing
      (LP: #845105).
  [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
    - Removed all code related to Bookmarks (LP: #850142).
    - Replaces references to "Evolution" by "Thunderbird" (LP: #849494).
  [ Rodney Dawes <rodney.dawes@canonical.com> ]
    - Don't install a .desktop file for control panel
      (part of LP: #838778).
    - Point the indicator/Unity API at the installer .desktop file
      (part of LP: #838778).
    - Set the WMCLASS so Unity will fall back properly
      (part of LP: #838778).
    - Fix a few grammar mistakes (LP: #835093).
    - Don't show the "Get NGB free!" label on "Join now" button at all
      (LP: #819955).
* debian/control:
  - ubuntuone-control-panel-gtk depends now on ubuntuone-installer >= 2.0.0.
  - require ubuntuone-client >= 2.0.0.
  - require ubuntu-sso-client >= 1.4.0.
  - no longer install a .desktop file (will be installed by ubuntuone-installer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import simplejson
22
22
 
 
23
from twisted.internet import defer, reactor
23
24
from twisted.web import client, error, http
24
25
 
25
26
from ubuntuone.controlpanel import WEBSERVICE_BASE_URL
39
40
        """Initialize the webclient."""
40
41
        self.base_url = base_url
41
42
        self.get_credentials = get_credentials
 
43
        self.running = True
 
44
        # pylint: disable=E1101
 
45
        self.trigger_id = reactor.addSystemEventTrigger("before", "shutdown",
 
46
                                                        self.shutdown)
42
47
 
43
48
    def _handle_response(self, result):
44
49
        """Handle the response of the webservice call."""
74
79
        d = self.get_credentials()
75
80
        d.addErrback(self._handle_error)
76
81
        d.addCallback(self._call_api_with_creds, api_name)
77
 
        return d
 
82
        d2 = defer.Deferred()
 
83
        d.addCallback(d2.callback)
 
84
 
 
85
        def mask_errors_on_shutdown(failure):
 
86
            """Do not fire the errbacks if we are shutting down."""
 
87
            if self.running:
 
88
                d2.errback(failure)
 
89
 
 
90
        d.addErrback(mask_errors_on_shutdown)
 
91
        return d2
78
92
 
79
93
    def shutdown(self):
80
94
        """End the pending webclient calls."""
 
95
        self.running = False
 
96
        # pylint: disable=E1101
 
97
        reactor.removeSystemEventTrigger(self.trigger_id)