HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.35k stars 605 forks source link

更新色图报错 #1366

Closed RWGLQJ closed 1 year ago

RWGLQJ commented 1 year ago

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/updatesetu/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

正常下载了几十张之后就报错了,报错如上

YueLinXieK commented 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 sys.exit(main()) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke return __callback(args, *kwargs) File "/home/nb-cli/.local/lib/python3.9/site-packages/nb_cli/commands/main.py", line 30, in run run_bot(file, app) File "/home/nb-cli/.local/lib/python3.9/site-packages/nb_cli/handlers/deploy.py", line 23, in run_bot nonebot.run() File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/init.py", line 273, in run get_driver().run(args, **kwargs) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 187, in run uvicorn.run( File "/home/nb-cli/.local/lib/python3.9/site-packages/uvicorn/main.py", line 576, in run server.run() File "/home/nb-cli/.local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/python3/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/message.py", line 141, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

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'

PackageInstaller commented 1 year ago

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

HibiKier commented 1 year ago

b1660bb9d6002a21bd40a82c99a690c385dccd71

YueLinXieK commented 1 year ago

更新后已解决

YueLinXieK commented 1 year ago

代码更新后又碰到了... 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 sys.exit(main()) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/nb-cli/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke return __callback(args, *kwargs) File "/home/nb-cli/.local/lib/python3.9/site-packages/nb_cli/commands/main.py", line 30, in run run_bot(file, app) File "/home/nb-cli/.local/lib/python3.9/site-packages/nb_cli/handlers/deploy.py", line 23, in run_bot nonebot.run() File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/init.py", line 273, in run get_driver().run(args, **kwargs) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 187, in run uvicorn.run( File "/home/nb-cli/.local/lib/python3.9/site-packages/uvicorn/main.py", line 576, in run server.run() File "/home/nb-cli/.local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/python3/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/home/nb-cli/.local/lib/python3.9/site-packages/nonebot/message.py", line 141, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

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

HibiKier commented 1 year ago

数据库中有相同pid和img_url的数据