async def init_client(self, config): basic_auth = BasicAuth(login=config['client']['id'], password=config['client']['secret']) self.client = AsyncFHIRClient('{}'.format(config['box']['base-url']), authorization=basic_auth.encode()) self.sync_client = SyncFHIRClient('{}'.format( config['box']['base-url']), authorization=basic_auth.encode()) await self._create_seed_resources() self._initialized = True if callable(self._on_ready): result = self._on_ready() if asyncio.iscoroutine(result): await self._on_ready()
def __init__(self, config: ConfigParser) -> None: self.config = config self.apiUrl = config.get("default", "apiUrl") self.apiUser = config.get("default", "apiUser") basicPassword = BasicAuth(self.apiUser, config.get("default", "apiPassword")) self._headers = {"Authorization": basicPassword.encode()} self.lists = []
async def _init_aidbox_client(self): basic_auth = BasicAuth( login=self._settings.APP_INIT_CLIENT_ID, password=self._settings.APP_INIT_CLIENT_SECRET, ) self.client = AsyncAidboxClient("{}".format( self._settings.APP_INIT_URL), authorization=basic_auth.encode())
async def negotiate(self): host = self._dest_host port = self._dest_port login = self._username password = self._password # noinspection PyListCreation req = [] req.append('CONNECT {}:{} HTTP/1.1'.format(host, port)) req.append('Host: {}:{}'.format(host, port)) req.append('User-Agent: {}'.format(USER_AGENT)) if login and password: auth = BasicAuth(login, password) req.append('Proxy-Authorization: {}'.format(auth.encode())) req.append(CRLF) data = CRLF.join(req).encode('ascii') await self.write_all(data) res = await self.read_all() if not res: raise ProxyError('Invalid proxy response') # pragma: no cover' line = res.split(CRLF_B, 1)[0] line = line.decode('utf-8', 'surrogateescape') try: version, code, *reason = line.split() except ValueError: # pragma: no cover raise ProxyError('Invalid status line: {}'.format(line)) try: status_code = int(code) except ValueError: # pragma: no cover raise ProxyError('Invalid status code: {}'.format(code)) if status_code != 200: raise ProxyError( # pragma: no cover 'Proxy server error. Status: {}'.format(status_code), status_code)
async def _init_aidbox_client(self, config): basic_auth = BasicAuth(login=config['client']['id'], password=config['client']['secret']) self.client = AsyncAidboxClient('{}'.format(config['box']['base-url']), authorization=basic_auth.encode())