def __init__(self, client_id, client_secret=None, token=None, token_secret=None, redirect_uri=None, rsa_key=None, verifier=None, signature_method=SIGNATURE_HMAC_SHA1, signature_type=SIGNATURE_TYPE_HEADER, force_include_body=False, **kwargs): Session.__init__(self) OAuth1Client.__init__(self, session=self, client_id=client_id, client_secret=client_secret, token=token, token_secret=token_secret, redirect_uri=redirect_uri, rsa_key=rsa_key, verifier=verifier, signature_method=signature_method, signature_type=signature_type, force_include_body=force_include_body, **kwargs)
def __init__(self, client_id=None, client_secret=None, token_endpoint_auth_method=None, refresh_token_url=None, refresh_token_params=None, scope=None, redirect_uri=None, token=None, token_placement='header', state=None, token_updater=None, **kwargs): Session.__init__(self) OAuth2Client.__init__(self, session=self, client_id=client_id, client_secret=client_secret, client_auth_method=token_endpoint_auth_method, refresh_token_url=refresh_token_url, refresh_token_params=refresh_token_params, scope=scope, redirect_uri=redirect_uri, token=token, token_placement=token_placement, state=state, token_updater=token_updater, **kwargs) self.token_endpoint_auth_method = token_endpoint_auth_method
def __init__(self): Session.__init__(self) self.headers = { "User-Agent": "Oruga Amarilla transmit API", "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } with myfile.db('config.mod', ':') as p: for k in p: if k[0] == 'base': self.myID = k[1] debug.out2('This site name', self.myID) elif k[0] == 'remote': self.server = k[1] debug.out2('Sending to server', self.server) elif k[0] == 'header': self.headers[k[1]] = k[2] debug.out2('Adding POST header', '{}:{}'.format(k[1], k[2])) elif k[0] in {'interval', 'pause'}: self.interval = int(k[1]) debug.out2('Interval set to', self.interval) elif k[0] in {'iters', 'repeat'}: i = int(k[1]) self.repeat = int(i) if not i: i = 'infinity' debug.out2('Setting iterations to', i) self.auth = (self.myID, self.passwd)
def __init__(self, host=None): Session.__init__(self) self.logger = create_logger("UnsterblichAPIClient") if os.getenv('GATEWAY_HOST', None) is None and host is None: raise ValueError("gateway_host is not defined!") self.host = host if host else os.getenv('GATEWAY_HOST', None)
def __init__(self): Session.__init__(self) self.headers = { "User-Agent": "Oruga Amarilla transmit API", "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } with myfile.db('config.mod',':') as p: for k in p: if k[0]=='base': self.myID = k[1] debug.out2('This site name',self.myID) elif k[0]=='remote': self.server = k[1] debug.out2('Sending to server',self.server) elif k[0]=='header': self.headers[k[1]] = k[2] debug.out2('Adding POST header','{}:{}'.format(k[1],k[2])) elif k[0] in {'interval','pause'}: self.interval = int(k[1]) debug.out2('Interval set to',self.interval) elif k[0] in {'iters','repeat'}: i = int(k[1]) self.repeat = int(i) if not i: i = 'infinity' debug.out2('Setting iterations to',i) self.auth = (self.myID,self.passwd)
def __init__(self, *args, **kwargs): Session.__init__(self, *args, **kwargs) if self.headers['User-Agent'].startswith('python-requests'): self.headers['User-Agent'] = useragents.FIREFOX self.timeout = 20.0
def __init__(self, entrypoint_url: str, namespace: str = '/sync') -> None: """Initialize the Agent :param entrypoint_url: Entrypoint URL for the hydrus server :param namespace: Namespace endpoint to listen for updates :return: None """ self.entrypoint_url = entrypoint_url.strip().rstrip('/') url_parse = urlparse(entrypoint_url) self.entrypoint = url_parse.scheme + "://" + url_parse.netloc self.api_name = url_parse.path.rstrip('/') self.redis_proxy = RedisProxy() self.redis_connection = self.redis_proxy.get_connection() Session.__init__(self) self.fetch_apidoc() self.initialize_graph() self.graph_operations = GraphOperations(self.entrypoint_url, self.api_doc, self.redis_proxy) # Declaring Socket Rules and instantiation Synchronization Socket socketio.ClientNamespace.__init__(self, namespace) socketio.Client.__init__(self, logger=True) socketio.Client.register_namespace(self, self) socketio.Client.connect(self, self.entrypoint_url, namespaces=namespace) self.last_job_id = ""
def __init__(self, client_id=None, client_secret=None, token_endpoint_auth_method=None, revocation_endpoint_auth_method=None, scope=None, redirect_uri=None, token=None, token_placement='header', update_token=None, **kwargs): Session.__init__(self) OAuth2Client.__init__( self, session=self, client_id=client_id, client_secret=client_secret, token_endpoint_auth_method=token_endpoint_auth_method, revocation_endpoint_auth_method=revocation_endpoint_auth_method, scope=scope, redirect_uri=redirect_uri, token=token, token_placement=token_placement, update_token=update_token, **kwargs)
def __init__(self, access_token: Optional[str] = None) -> None: """Initialize the authentication. Args: access_token: a string containing the authentication token for the REST API. """ self.access_token = access_token or METEOFRANCE_API_TOKEN Session.__init__(self)
def __init__(self, *args, **kwargs): Session.__init__(self, *args, **kwargs) self.timeout = 20.0 if TIMEOUT_ADAPTER_NEEDED: self.mount("http://", HTTPAdapterWithReadTimeout()) self.mount("https://", HTTPAdapterWithReadTimeout())
def __init__(self, source_address: str=None): Session.__init__(self) self.logger = create_logger('UpbitAPIClient') if source_address: self.logger.info("mounted at source address: %s" % source_address) new_source = source.SourceAddressAdapter(source_address) self.mount('http://', new_source) self.mount('https://', new_source)
def __init__(self, options, *args, **kwargs): Session.__init__(self, *args, **kwargs) adapter = HTTPAdapter(max_retries=retry) self.mount('http://', adapter) self.mount('https://', adapter) self.verify = options.ssl_verify self.proxy = options.proxy if options.http_headers: self.headers.update(self.split_header(options.http_headers)) self.headers.update({"User-Agent": FIREFOX_UA})
def __init__(self, config=dict(), *args, **kwargs): Session.__init__(self, *args, **kwargs) adapter = HTTPAdapter(max_retries=retry) self.mount('http://', adapter) self.mount('https://', adapter) self.verify = config.get("ssl_verify") self.proxy = config.get("proxy") if config.get("http_headers"): self.headers.update(self.split_header(config.get("http_headers"))) self.headers.update({"User-Agent": FIREFOX_UA})
def __init__(self, *args, **kwargs): Session.__init__(self, *args, **kwargs) if self.headers['User-Agent'].startswith('python-requests'): self.headers['User-Agent'] = useragents.FIREFOX self.timeout = 20.0 if TIMEOUT_ADAPTER_NEEDED: self.mount("http://", HTTPAdapterWithReadTimeout()) self.mount("https://", HTTPAdapterWithReadTimeout()) self.mount('file://', FileAdapter())
def __init__(self, pool=None, minthreads=1, maxthreads=4, **kwargs): """Creates a twisted aware Session Notes ~~~~~ * If you provide both `pool` and `max_workers`, the latter is ignored and provided threadpool is used as is. """ requestsSession.__init__(self, **kwargs) if pool is None: pool = ThreadPool(minthreads=minthreads, maxthreads=maxthreads) self.pool = pool pool.start()
def __init__(self, ns, parsers, multi=False, **kwargs): '''''' self.prompt = "(%s) > " % self.name self.ns = ns self.parsers = parsers self.payload = None self.action_help = {} self.action_types = {} for parser in self.parsers: for a in parser._actions: self.action_help[a.dest] = a.help self.action_types[a.dest] = a.type self.multi = multi self.payload = None if not ns.host: ns.__dict__['host'] = " " ## if not hasattr(ns, "mode") or not ns.mode: ns.__dict__['mode'] = self.modes[0] ## for key in ns.__dict__: if not ns.__dict__[key] and hasattr(self, key): ns.__dict__[key] = getattr(self, key) self.log = logging.getLogger(self.name) if not os.path.isdir("/current/down"): self.logdir = "logs" if not os.path.isdir(self.logdir): os.makedirs(self.logdir) self.logbase = strftime("%Y-%m-%d-%H%M%S") self.logbase = os.path.join(self.logdir, self.logbase) hndl = logging.FileHandler(self.logbase + ".log") hndl.setLevel(logging.DEBUG) self.log.addHandler(hndl) logging.getLogger( "fosho.requests.packages.urllib3.connectionpool").addHandler(hndl) self.httplog = open(self.logbase + "_http.log", "w") Session.__init__(self, **kwargs) self._apply_settings() Cmd.__init__(self)
def __init__(self, token_endpoint, issuer, subject, audience=None, grant_type=None, claims=None, token_placement='header', scope=None, **kwargs): Session.__init__(self) token_url = kwargs.pop('token_url', None) if token_url: deprecate('Use "token_endpoint" instead of "token_url"', '1.0') token_endpoint = token_url AssertionClient.__init__( self, session=self, token_endpoint=token_endpoint, issuer=issuer, subject=subject, audience=audience, grant_type=grant_type, claims=claims, token_placement=token_placement, scope=scope, **kwargs )
def __init__(self, *args, **kwargs): self.validator = kwargs.pop("validator", self.DEFAULT_VALIDATOR) adapter_kwargs = kwargs.pop("_adapter_kwargs", {}) # `Session.__init__()` calls `mount()` internally, so we need to allow # it temporarily self.__mountAllowed = True RequestsSession.__init__(self, *args, **kwargs) # Drop any existing adapters self.adapters = OrderedDict() self.mount("http://", ValidatingHTTPAdapter(validator=self.validator, **adapter_kwargs)) self.mount("https://", ValidatingHTTPAdapter(validator=self.validator, **adapter_kwargs)) self.__mountAllowed = False
def __init__(self): Session.__init__(self) headerstr = '''User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Mobile Safari/537.36 Accept: text/html,application/json,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Referer: https://www.google.com/ Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,zh;q=0.6''' headers = { item.split(':')[0].replace(' ', ''): item.split(':')[1].replace(' ', '') for item in headerstr.split('\n') } self.headers.update(headers) self.mount('http://', HTTPAdapter(max_retries=2)) self.mount('https://', HTTPAdapter(max_retries=2))
def __init__(self, *args, **kwargs): headers = kwargs.pop("headers", { "User-Agent": USER_AGENT, "Referer": HOST + "/", "Origin": HOST, "Sec-Fetch-Site": "same-site", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Dest": "empty", "Accept": "application/json, text/plain, */*", "sec-ch-ua": '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"', "sec-ch-ua-mobile": "?0" } ) Session.__init__(self, *args, **kwargs) self.headers.update(headers) self.timeout = 60
def __init__(self, pool=None, minthreads=1, maxthreads=4, **kwargs): """Creates a twisted aware Session Notes ~~~~~ * If you provide both `pool` and `max_workers`, the latter is ignored and provided threadpool is used as is. """ requestsSession.__init__(self, **kwargs) self.ownPool = False if pool is None: self.ownPool = True pool = ThreadPool(minthreads=minthreads, maxthreads=maxthreads) # unclosed ThreadPool leads to reactor hangs at shutdown # this is a problem in many situation, so better enforce pool stop here reactor.addSystemEventTrigger("before", "shutdown", lambda:pool.stop()) self.pool = pool if self.ownPool: pool.start()
def __init__(self, url=None, username='******', password=False, verify=False, cert=False, **kwargs): Session.__init__(self, **kwargs) self.url = url self.resolution = 300 self.size = 'a4' self.compression = 35 self.brightness = 1000 self.contrast = 1000 self.color_mode = 'RGB24' self.document_format_ext = 'application/pdf' self.username = username self.password = password self.verify = verify self.cert = cert
def __init__(self, pool=None, minthreads=1, maxthreads=4, **kwargs): """Creates a twisted aware Session Notes ~~~~~ * If you provide both `pool` and `max_workers`, the latter is ignored and provided threadpool is used as is. """ requestsSession.__init__(self, **kwargs) self.ownPool = False if pool is None: self.ownPool = True pool = ThreadPool(minthreads=minthreads, maxthreads=maxthreads) # unclosed ThreadPool leads to reactor hangs at shutdown # this is a problem in many situation, so better enforce pool stop here reactor.addSystemEventTrigger("after", "shutdown", lambda: pool.stop() if pool.started else None) self.pool = pool if self.ownPool: pool.start()
def __init__(self, token_url, issuer, subject, audience, grant_type=None, claims=None, token_placement='header', scope=None, **kwargs): Session.__init__(self) AssertionClient.__init__(self, session=self, token_url=token_url, issuer=issuer, subject=subject, audience=audience, grant_type=grant_type, claims=claims, token_placement=token_placement, scope=scope, **kwargs)
def __init__(self, token_endpoint, issuer, subject, audience=None, grant_type=None, claims=None, token_placement='header', scope=None, **kwargs): Session.__init__(self) update_session_configure(self, kwargs) AssertionClient.__init__(self, session=self, token_endpoint=token_endpoint, issuer=issuer, subject=subject, audience=audience, grant_type=grant_type, claims=claims, token_placement=token_placement, scope=scope, **kwargs)
def __init__(self, username: str, password: str) -> None: """Initialize and authenticate. Args: username: the flipr registered user password: the flipr user's password """ Session.__init__(self) # Authenticate with user and pass and store bearer token payload_token = ( "grant_type=password&username="******"&password="******"Content-Type": "application/x-www-form-urlencoded", "Cache-Control": "no-cache", } response = super().request( "POST", FLIPR_AUTH_URL, data=payload_token, headers=headers_token ) response.raise_for_status() # print(response.text) self.bearerToken = str(response.json()["access_token"])
def __init__(self, client_id=None, client_secret=None, authorization_endpoint=None, token_endpoint=None, token_endpoint_auth_method=None, revocation_endpoint=None, revocation_endpoint_auth_method=None, scope=None, redirect_uri=None, token=None, token_placement='header', token_updater=None, **kwargs): refresh_token_url = kwargs.pop('refresh_token_url', None) if refresh_token_url is not None and token_endpoint is None: token_endpoint = refresh_token_url Session.__init__(self) OAuth2Client.__init__( self, session=self, client_id=client_id, client_secret=client_secret, authorization_endpoint=authorization_endpoint, token_endpoint=token_endpoint, token_endpoint_auth_method=token_endpoint_auth_method, revocation_endpoint=revocation_endpoint, revocation_endpoint_auth_method=revocation_endpoint_auth_method, scope=scope, redirect_uri=redirect_uri, token=token, token_placement=token_placement, token_updater=token_updater, **kwargs)
def __init__(self, baseUrl): Session.__init__(self) self.baseUrl = baseUrl
def __init__(self, base_url): self.base_url = base_url Session.__init__(self)
def __init__(self, options, *args, **kwargs): Session.__init__(self, *args, **kwargs) self.verify = options.ssl_verify if options.http_headers: self.headers.update(self.split_header(options.http_headers)) self.headers.update({"User-Agent": FIREFOX_UA})
def __init__(self, *args, **kwargs): Session.__init__(self, *args, **kwargs) self.referer = None
def __init__(self, access_token: Optional[str] = None): """Initialize the auth.""" self.access_token = access_token or METEOFRANCE_API_TOKEN Session.__init__(self)
def __init__(self, username, password, url): Session.__init__(self) self.username = username self.password = password self.url = url self.auth = (self.username, self.password)
def __init__(self, service): self.service = service Session.__init__(self)
def __init__(self, *args, **kwargs): Session.__init__(self, *args, **kwargs)