示例#1
0
 def session(self) -> BaseUrlSession:
     session = BaseUrlSession(
         base_url=(url if (url := self.context.config.get(
             "resource.ampel-ztf/archive", str, raise_exc=True)
                           ).endswith("/") else url + "/"))
     session.auth = BearerAuth(self.archive_token.get())
     return session
示例#2
0
    def __init__(self, api_token: str, account_id: int) -> None:
        self.account_id = account_id

        # Rather than assigning directly to `self`, this is the recommended idiom so atexit.register behaves nicely with GC.
        session = BaseUrlSession(base_url=f'{self.api_domain}/{self.api_version}/{account_id}/')
        session.auth = (api_token, '')
        session.headers.update({"User-Agent": self.drip_py_ua, "Content-Type": 'application/json'})
        register(session.close)
        self.session = session
示例#3
0
    def __init__(self, api_token: str, account_id: int) -> None:
        self.account_id = account_id

        # Rather than assigning directly to `self`, this is the recommended idiom so atexit.register behaves nicely with GC.
        session = BaseUrlSession(
            base_url=f"{self.api_domain}/{self.api_version}/{account_id}/")
        session.auth = (api_token, "")
        session.headers.update({"User-Agent": self.drip_py_ua})
        session.mount(self.api_domain, GzipAdapter())
        register(session.close)
        self.session = session