def __init__(self, *args, **kwargs): """Initialize this instance.""" super(WebClient, self).__init__(*args, **kwargs) # pylint: disable=E0611,F0401 from gi.repository import Soup, SoupGNOME self.soup = Soup self.session = Soup.SessionAsync() self.session.add_feature(SoupGNOME.ProxyResolverGNOME()) self.session.connect("authenticate", self._on_authenticate)
import gi from contextlib import contextmanager gi.require_version('SoupGNOME', '2.4') from gi.repository import Gio, Soup, SoupGNOME from urllib.parse import urlencode from friends.errors import FriendsError log = logging.getLogger(__name__) # Global libsoup session instance. _soup = Soup.SessionSync() # Enable this for full requests and responses dumped to STDOUT. #_soup.add_feature(Soup.Logger.new(Soup.LoggerLogLevel.BODY, -1)) _soup.add_feature(SoupGNOME.ProxyResolverGNOME()) def _get_charset(message): """Extract charset from Content-Type header in a Soup Message.""" type_header = message.response_headers.get_content_type()[1] if not type_header: return None return type_header.get('charset') class BaseRateLimiter: """Base class for the rate limiting API. By default, this class does no rate limiting. Subclass from this and override the `wait()` and `update()` methods for protocol specific