~ubuntuone-control-tower/ubuntu-sso-client/trunk

« back to all changes in this revision

Viewing changes to ubuntu_sso/utils/__init__.py

  • Committer: Tarmac
  • Author(s): Rodney Dawes, Natalia Bidart
  • Date: 2014-08-14 14:20:29 UTC
  • mfrom: (1035.3.5 no-more-ping)
  • Revision ID: tarmac-20140814142029-phtfnx288m2ddxes
Remove the ping URL usage.
Update the Terms and Privacy URLs to point to login.ubuntu.com.
Update timestamp checking URL to point to login.ubuntu.com.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
from dirspec.basedir import load_config_paths
37
37
from dirspec.utils import get_program_path
38
38
 
39
 
from twisted.internet import defer
40
39
from twisted.python import procutils
41
40
 
42
41
from ubuntu_sso import (BACKEND_EXECUTABLE,
44
43
                        UI_PROXY_CREDS_DIALOG,
45
44
                        UI_SSL_DIALOG)
46
45
from ubuntu_sso.logger import setup_logging
47
 
from ubuntu_sso.utils import compat, webclient
48
46
 
49
47
 
50
48
logger = setup_logging("ubuntu_sso.utils")
166
164
    return ssl_cert_location
167
165
 
168
166
 
169
 
@defer.inlineCallbacks
170
167
def ping_url(url, email, credentials):
171
 
    """Ping the 'url' with the 'email' attached to it.
172
 
 
173
 
    Sign the request with 'credentials'. The url must not be None.
174
 
 
175
 
    """
176
 
    logger.info('Pinging server using url: %r, email: %r.',
177
 
                url, email)
178
 
    assert isinstance(url, compat.text_type), 'Url %r must be unicode' % url
179
 
 
180
 
    target_url = url
181
 
    try:
182
 
        target_url = url.format(email=email)
183
 
    except IndexError:  # tuple index out of range
184
 
        target_url = url.format(email)  # format the first substitution
185
 
 
186
 
    if target_url == url:
187
 
        logger.debug('Original url (%r) could not be formatted, '
188
 
                     'appending email (%r).', url, email)
189
 
        assert url.endswith('/'), 'Url %r must end with /.' % url
190
 
        target_url = url + email
191
 
 
192
 
    wc = webclient.webclient_factory()
193
 
    try:
194
 
        logger.debug('Opening the url %r with webclient.request.', url)
195
 
        response = yield wc.request(target_url, oauth_credentials=credentials)
196
 
        logger.debug('Url %r opened. Response content: %r.',
197
 
                     url, response.content)
198
 
        defer.returnValue(response)
199
 
    finally:
200
 
        wc.shutdown()
 
168
    """Unused -- it was formerly used to let U1 know about new accounts."""