Beispiel #1
0
def subscribe(url, host):
    """ subscribe to an hubbub feed. """
    subscribe_args = {
        'hub.callback': urllib.parse.urljoin('https://', host, '/hubbub'),
        'hub.mode': 'subscribe',
        'hub.topic': url,
        'hub.verify': 'async',
        'hub.verify_token': str(uuid.uuid4()),
    }
    headers = {}
    credentials = getcredsmod(doraise=True)
    if credentials.HUB_CREDENTIALS:
      auth_string = "Basic " + str(base64.b64encode(bytes("%s:%s" % tuple(credentials.HUB_CREDENTIALS), "utf-8")), "utf-8")
      headers['Authorization'] = auth_string
    logging.warn("subscribe - trying %s (%s)" % (credentials.HUB_URL, url))
    logging.warn("subscribe - %s" % str(headers))
    response = posturl(credentials.HUB_URL, headers, subscribe_args)
    return response
Beispiel #2
0
def getcreds(datadir=None):
    if not datadir: datadir = getdatadir()
    mod = getcredsmod(datadir)
    if not mod: raise RequireError("credentials.py is needed in %s/config dir. see %s/examples" % (datadir, datadir))
    return mod.CONSUMER_KEY, mod.CONSUMER_SECRET