Closed RWGLQJ closed 1 year ago
我这个功能也有报错,麻烦大大帮忙一起看下 04-12 15:50:23 [INFO] services | 更新色图 8245.jpg 已存在 04-12 15:50:26 [INFO] services | 下载 https://i.pixiv.re/img-original/img/2022/03/23/19/01/22/97121323_p0.jpg 成功.. Path:/home/nb-cli/zhenxun_bot/resources/temp/8244.jpg 04-12 15:50:26 [INFO] services | 不需要压缩,移动图片resources/temp/8244.jpg --> /resources/image/_setu/8244.jpg 04-12 15:50:26 [INFO] nonebot | Matcher(type='message', module=plugins.sendsetu.update_setu) running complete 04-12 15:50:26 [ERROR] nonebot | Running Matcher(type='message', module=plugins.sendsetu.update_setu) failed. Traceback (most recent call last): File "./plugins/sendsetu/update_setu/data_source.py", line 148, in update_setu_img img_hash = str(get_img_hash(f"{path}/{image.local_id}.jpg")) File "./utils/image_utils.py", line 63, in get_img_hash hash_value = imagehash.average_hash(Image.open(fp)) File "/home/nb-cli/.local/lib/python3.9/site-packages/PIL/Image.py", line 3147, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='resources/image/_setu/8244.jpg'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nb-cli/.local/bin/nb", line 8, in
File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/message.py", line 187, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/internal/matcher/matcher.py", line 732, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/internal/matcher/matcher.py", line 707, in simple_run await handler( File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/dependencies/init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "./plugins/sendsetu/updatesetu/init.py", line 33, in await update_setu_img(True) File "./plugins/sendsetu/update_setu/data_source.py", line 161, in update_setu_img os.rename(path / f"{max_num}.jpg", local_image) FileNotFoundError: [Errno 2] No such file or directory: 'resources/image/_setu/-1.jpg' -> 'resources/image/_setu/8244.jpg'
04-12 00:21:32 [INFO] services | 下载 https://i.pixiv.re/img-original/img/2023/04/01/21/25/43/106769687_p0.png 成功.. Path:/home/zhenxun_bot/resources/temp/30.jpg 04-12 00:21:32 [INFO] services | 不需要压缩,移动图片resources/temp/30.jpg --> /resources/image/_r18/30.jpg 04-12 00:21:32 [INFO] nonebot | Matcher(type='message', module=plugins.sendsetu.update_setu) running complete 04-12 00:21:32 [ERROR] nonebot | Running Matcher(type='message', module=plugins.sendsetu.update_setu) failed. Traceback (most recent call last): File "/home/zhenxun_bot/plugins/sendsetu/update_setu/data_source.py", line 148, in update_setu_img img_hash = str(get_img_hash(f"{path}/{image.local_id}.jpg")) File "/home/zhenxun_bot/utils/image_utils.py", line 63, in get_img_hash hash_value = imagehash.average_hash(Image.open(fp)) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/PIL/Image.py", line 3186, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='resources/image/_r18/30.jpg'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/zhenxun_bot/bot.py", line 21, in nonebot.run() File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 273, in run get_driver().run(*args, **kwargs) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run uvicorn.run( File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run server.run() File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run await handler( File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(values) File "/home/zhenxun_bot/plugins/sendsetu/update_setu/init**.py", line 33, in _ await update_setu_img(True) File "/home/zhenxun_bot/plugins/sendsetu/update_setu/data_source.py", line 160, in update_setu_img max_num = await Setu.delete_image(image.pid) File "/home/zhenxun_bot/plugins/sendsetu/_model.py", line 75, in delete_image query = await cls.get_or_none(pid=pid) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/tortoise/queryset.py", line 1022, in _execute raise MultipleObjectsReturned("Multiple objects returned, expected exactly one") tortoise.exceptions.MultipleObjectsReturned: Multiple objects returned, expected exactly one
正常下载了几十张之后就报错了,报错如上
报错+1
b1660bb9d6002a21bd40a82c99a690c385dccd71
更新后已解决
代码更新后又碰到了... 04-16 10:23:57 [INFO] services | 不需要压缩,移动图片resources/temp/8237.jpg --> /resources/image/_setu/8237.jpg 103055879 04-16 10:23:57 [INFO] nonebot | Matcher(type='message', module=plugins.sendsetu.update_setu) running complete 04-16 10:23:57 [ERROR] nonebot | Running Matcher(type='message', module=plugins.sendsetu.update_setu) failed. Traceback (most recent call last): File "./plugins/sendsetu/update_setu/data_source.py", line 148, in update_setu_img img_hash = str(get_img_hash(f"{path}/{image.local_id}.jpg")) File "./utils/image_utils.py", line 63, in get_img_hash hash_value = imagehash.average_hash(Image.open(fp)) File "/home/nb-cli/.local/lib/python3.9/site-packages/PIL/Image.py", line 3147, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='resources/image/_setu/8237.jpg'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nb-cli/.local/bin/nb", line 8, in
File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/message.py", line 187, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/internal/matcher/matcher.py", line 732, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/internal/matcher/matcher.py", line 707, in simple_run await handler( File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/dependencies/init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "./plugins/sendsetu/updatesetu/init.py", line 33, in await update_setu_img(True) File "./plugins/sendsetu/update_setu/data_source.py", line 160, in update_setu_img max_num = await Setu.delete_image(image.pid, image.img_url) File "./plugins/sendsetu/_model.py", line 78, in delete_image last_image = await cls.get_or_none(is_r18=query.is_r18, local_id=num - 1) File "/home/nb-cli/.local/lib/python3.9/site-packages/tortoise/queryset.py", line 1020, in _execute raise MultipleObjectsReturned("Multiple objects returned, expected exactly one") tortoise.exceptions.MultipleObjectsReturned: Multiple objects returned, expected exactly one
数据库中有相同pid和img_url的数据
04-12 00:21:32 [INFO] services | 下载 https://i.pixiv.re/img-original/img/2023/04/01/21/25/43/106769687_p0.png 成功.. Path:/home/zhenxun_bot/resources/temp/30.jpg 04-12 00:21:32 [INFO] services | 不需要压缩,移动图片resources/temp/30.jpg --> /resources/image/_r18/30.jpg 04-12 00:21:32 [INFO] nonebot | Matcher(type='message', module=plugins.sendsetu.update_setu) running complete 04-12 00:21:32 [ERROR] nonebot | Running Matcher(type='message', module=plugins.sendsetu.update_setu) failed. Traceback (most recent call last): File "/home/zhenxun_bot/plugins/sendsetu/update_setu/data_source.py", line 148, in update_setu_img img_hash = str(get_img_hash(f"{path}/{image.local_id}.jpg")) File "/home/zhenxun_bot/utils/image_utils.py", line 63, in get_img_hash hash_value = imagehash.average_hash(Image.open(fp)) File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/PIL/Image.py", line 3186, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='resources/image/_r18/30.jpg'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/zhenxun_bot/bot.py", line 21, in
nonebot.run()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run
server.run()
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/root/.cache/pypoetry/virtualenvs/zhenxun-bot-UH4sDRIh-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
正常下载了几十张之后就报错了,报错如上