telegram_avatar/open_weather_map_api.py
async def _get_weather_image(self, image_name: str) -> None:
        """
        Method which downloads a weather icon from OpenWeatherMap API.
        Args:
            image_name: name of weather icon (w/o extension).
        Raises:
            ImageDownloadError: if OpenWeatherMap API returns response
                with status code different from 200 or request raises
                aiohttp.ClientError.
        Returns:
            None.
        """
        url = self._api_image_url.format(image_name)
        self._logger.info(f"Loading image with name: {image_name}...")
        try:
            resp = await self._client_session.get(url=url)
        except ClientError as request_error:
            self._logger.exception(request_error)
            raise ImageDownloadError(
                "Couldn't download weather icon from OpenWeatherMap..."
            )
        self._logger.info(f"Getting response with status: {resp.status}")
        if resp.status != 200:
            raise ImageDownloadError(
                "Couldn't download weather icon from OpenWeatherMap..."
            )
        data = await resp.read()
        new_image_path = os.path.join(
            os.getcwd(),
            WEATHER_ICONS_FOLDER_NAME,
            image_name + ".png",
        )
        with open(new_image_path, "wb") as image_file:
            image_file.write(data)
        self._logger.info(f"Saving new image ({len(data)} bytes)")
        return

        Method which downloads a weather icon from OpenWeatherMap API.
        Args:
            image_name: name of weather icon (w/o extension).
        Raises:
            ImageDownloadError: if OpenWeatherMap API returns response
                with status code different from 200 or request raises
                aiohttp.ClientError.
        Returns:
            None.
        
Method which downloads a weather icon from OpenWeatherMap API.
Method which downloads a weather icon from OpenWeatherMap API .
async def _get_weather_image(self, image_name: str) -> None:
        url = self._api_image_url.format(image_name)
        self._logger.info(f"Loading image with name: {image_name}...")
        try:
            resp = await self._client_session.get(url=url)
        except ClientError as request_error:
            self._logger.exception(request_error)
            raise ImageDownloadError(
                "Couldn't download weather icon from OpenWeatherMap..."
            )
        self._logger.info(f"Getting response with status: {resp.status}")
        if resp.status != 200:
            raise ImageDownloadError(
                "Couldn't download weather icon from OpenWeatherMap..."
            )
        data = await resp.read()
        new_image_path = os.path.join(
            os.getcwd(),
            WEATHER_ICONS_FOLDER_NAME,
            image_name + ".png",
        )
        with open(new_image_path, "wb") as image_file:
            image_file.write(data)
        self._logger.info(f"Saving new image ({len(data)} bytes)")
        return
async def _get_weather_image ( self , image_name : str ) -> None : url = self . _api_image_url . format ( image_name ) self . _logger . info ( f"Loading image with name: {image_name}..." ) try : resp = await self . _client_session . get ( url = url ) except ClientError as request_error : self . _logger . exception ( request_error ) raise ImageDownloadError ( "Couldn't download weather icon from OpenWeatherMap..." ) self . _logger . info ( f"Getting response with status: {resp.status}" ) if resp . status != 200 : raise ImageDownloadError ( "Couldn't download weather icon from OpenWeatherMap..." ) data = await resp . read ( ) new_image_path = os . path . join ( os . getcwd ( ) , WEATHER_ICONS_FOLDER_NAME , image_name + ".png" , ) with open ( new_image_path , "wb" ) as image_file : image_file . write ( data ) self . _logger . info ( f"Saving new image ({len(data)} bytes)" ) return
Method which downloads a weather icon from OpenWeatherMap API.
Method which downloads a weather icon from OpenWeatherMap API .
"""
        Method which downloads a weather icon from OpenWeatherMap API.
        Args:
            image_name: name of weather icon (w/o extension).
        Raises:
            ImageDownloadError: if OpenWeatherMap API returns response
                with status code different from 200 or request raises
                aiohttp.ClientError.
        Returns:
            None.
        """
None
if OpenWeatherMap API returns response
with status code different from 200 or request raises
aiohttp.ClientError.
if OpenWeatherMap API returns response with status code different from 200 or request raises aiohttp . ClientError .
ImageDownloadError
self
image_name
str
name of weather icon (w/o extension).
name of weather icon ( w / o extension ) .