def demo(key, feed_id): client = HTTPClient() try: if feed_id: # request feed details for the supplied identifier only logging.info("Requesting feed details for feed: %s" % feed_id) dataStructure = yield client.read_feed(api_key=key, feed_id=feed_id) else: # request feed details for all feeds visible to the key supplied logging.info("Requesting a feed listing") dataStructure = yield client.list_feeds(api_key=key, parameters={'per_page': 5, 'status': 'live'}) logging.info("Received response from Cosm:\n%s\n" % dataStructure) reactor.callLater(0.1, reactor.stop) defer.returnValue(True) except Exception, ex: logging.exception(ex) reactor.callLater(0.1, reactor.stop) defer.returnValue(False)