From 8cf297870400ae2b72e74bd85a2afd3f4339a078 Mon Sep 17 00:00:00 2001 From: dsdanielpark Date: Mon, 29 Apr 2024 17:42:19 +0900 Subject: [PATCH] build: 2.4.10 after qa --- gemini/__init__.py | 3 +-- gemini/src/model/image.py | 6 ++++-- tests/gemini_image.py | 29 +++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gemini/__init__.py b/gemini/__init__.py index a0919b6..76d31a4 100644 --- a/gemini/__init__.py +++ b/gemini/__init__.py @@ -30,9 +30,8 @@ except ImportError as e: pass -gemini_api_key = environ.get("GEMINI_COOKIES") -__version__ = "2.4.9" +__version__ = "2.4.10" __author__ = ( "daniel park , antonio cheang , " "HanaokaYuzu, CBoYXD, veonua, thewh1teagle, jjkoh95, yihong0618, nishantchauhan949, MeemeeLab, kota113, " diff --git a/gemini/src/model/image.py b/gemini/src/model/image.py index bc55d77..55e2f76 100644 --- a/gemini/src/model/image.py +++ b/gemini/src/model/image.py @@ -112,7 +112,9 @@ async def fetch_bytes( Optional[bytes]: The bytes of the image, or None if fetching fails. """ try: - async with httpx.AsyncClient(follow_redirects=True, cookies=cookies, proxies=proxies) as client: + async with httpx.AsyncClient( + follow_redirects=True, cookies=cookies, proxies=proxies + ) as client: response = await client.get(str(url)) response.raise_for_status() return response.content @@ -220,4 +222,4 @@ def save_images_sync( filepath.write_bytes(data) except: pass - print(f"Saved {title} to {save_path}") \ No newline at end of file + print(f"Saved {title} to {save_path}") diff --git a/tests/gemini_image.py b/tests/gemini_image.py index b6f6e4b..3c9a9a3 100644 --- a/tests/gemini_image.py +++ b/tests/gemini_image.py @@ -2,12 +2,27 @@ from pydantic import HttpUrl from ..gemini import GeminiImage + def parse_args(): - parser = argparse.ArgumentParser(description="Test the GeminiImage class functionality") - parser.add_argument("--url", type=str, required=True, help="URL of the image to test", default="https://upload.wikimedia.org/wikipedia/commons/c/cf/Harvard_Yard_in_autumn%2C_Boston%2C_Massachusetts%2C_2015.jpg") - parser.add_argument("--title", type=str, default="[Image]", help="Title of the image") - parser.add_argument("--save_path", type=str, default="cached", help="Directory to save the images") - parser.add_argument("--async", action="store_true", help="Use asynchronous methods for testing") + parser = argparse.ArgumentParser( + description="Test the GeminiImage class functionality" + ) + parser.add_argument( + "--url", + type=str, + required=True, + help="URL of the image to test", + default="https://upload.wikimedia.org/wikipedia/commons/c/cf/Harvard_Yard_in_autumn%2C_Boston%2C_Massachusetts%2C_2015.jpg", + ) + parser.add_argument( + "--title", type=str, default="[Image]", help="Title of the image" + ) + parser.add_argument( + "--save_path", type=str, default="cached", help="Directory to save the images" + ) + parser.add_argument( + "--async", action="store_true", help="Use asynchronous methods for testing" + ) return parser.parse_args() @@ -15,12 +30,14 @@ async def test_async(url, title, save_path, cookies): images = [GeminiImage(url=HttpUrl(url), title=title)] await GeminiImage.save(images, save_path, cookies) + def test_sync(url, title, save_path, cookies): images = [GeminiImage(url=HttpUrl(url), title=title)] GeminiImage.save_sync(images, cookies, save_path) + if __name__ == "__main__": args = parse_args() - + test_sync(args.url, args.title, args.save_path) test_async(args.url, args.title, args.save_path)