monsterxcn / nonebot-plugin-gspanel

🤖 NoneBot2 原神游戏内角色展柜数据展示插件,参考 @yoimiya-kokomi/miao-plugin
https://pypi.python.org/pypi/nonebot-plugin-gspanel
MIT License
97 stars 8 forks source link

查询角色报错 TypeError multiple values for keyword argument 'device_scale_factor' #55

Closed ElainaFanBoy closed 1 year ago

ElainaFanBoy commented 1 year ago

运行环境

报错详情

场景

日志

07-02 10:25:03 [ERROR] nonebot | Running Matcher(type='message', module=src.plugins.nonebot_plugin_gspanel) failed.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\multiprocessing\spawn.py", line 129, in _main
    return self._bootstrap(parent_sentinel)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\src\lastload\nonebot_plugin_reboot\reloader.py", line 27, in _run
    _nb_run(*args, **kwargs)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\__init__.py", line 309, in run
    get_driver().run(*args, **kwargs)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\drivers\fastapi.py", line 198, in run
    uvicorn.run(
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\uvicorn\main.py", line 578, in run
    server.run()
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\uvicorn\server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\asyncio\base_events.py", line 634, in run_until_complete
    self.run_forever()
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\asyncio\base_events.py", line 601, in run_forever
    self._run_once()
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\asyncio\base_events.py", line 1905, in _run_once
    handle._run()
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\message.py", line 467, in check_and_run_matcher
    await _run_matcher(
> File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\message.py", line 419, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\internal\matcher\matcher.py", line 753, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\internal\matcher\matcher.py", line 728, in simple_run
    await handler(
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\src\plugins\nonebot_plugin_gspanel\__init__.py", line 51, in panel_handle
    rt = await getPanel(uid, char)
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\src\plugins\nonebot_plugin_gspanel\data_source.py", line 300, in getPanel
    return await template_to_pic(
  File "D:\Desktop\0\software\wbushu\Bot\IRONY\env\lib\site-packages\nonebot_plugin_htmlrender\data_source.py", line 241, in template_to_pic
    return await html_to_pic(
TypeError: nonebot_plugin_htmlrender.data_source.html_to_pic() got multiple values for keyword argument 'device_scale_factor'

额外信息

monsterxcn commented 1 year ago

nonebot_plugin_htmlrender 版本太高了,刚去看了下 https://github.com/kexue-z/nonebot-plugin-htmlrender/commit/8af13b6b70d7b54bf2152a7389a910d96f45c250 改了东西。device_scale_factor 设置的方法和旧版不兼容了。他们 6 月 26 日发了新版 0.2.1,这个插件只支持到前一个版本 0.2.0.3。

手动降一下 nonebot_plugin_htmlrender 版本吧,插件这边功能不会受影响:

pip install nonebot-plugin-htmlrender==0.2.0.3
ElainaFanBoy commented 1 year ago

nonebot_plugin_htmlrender 版本太高了,刚去看了下他们那边 https://github.com/kexue-z/nonebot-plugin-htmlrender/commit/8af13b6b70d7b54bf2152a7389a910d96f45c250 改了东西,device_scale_factor 设置的方法和旧版不兼容了。

手动降一下 nonebot_plugin_htmlrender 版本吧,插件这边功能不会受影响:

pip install nonebot-plugin-htmlrender==0.2.0.3

草,这样跟我另一个插件的htmlrender版本冲突了,我再考虑考虑吧()

monsterxcn commented 1 year ago

建议卸载 gspanel,辣鸡插件

ElainaFanBoy commented 1 year ago

建议卸载 gspanel,辣鸡插件

不垃圾,我感觉挺好用的呀

monsterxcn commented 1 year ago

要用 0.2.1 版本的 nonebot-plugin-htmlrender 话就改一下下面这两个地方的 device_scale_factor 设置方法:

https://github.com/monsterxcn/nonebot-plugin-gspanel/blob/7571371a61752b11680ac1b16f1b7dd939db1afa/nonebot_plugin_gspanel/data_source.py#L299-L312

https://github.com/monsterxcn/nonebot-plugin-gspanel/blob/7571371a61752b11680ac1b16f1b7dd939db1afa/nonebot_plugin_gspanel/data_source.py#L384-L396

把原来 pagesdevice_scale_factor 移到外面,大概像这样:

    return await template_to_pic(
        template_path=htmlBase,
        template_name=f"team-{TEAM_TPL_VER}.html",
        templates={"css": TEAM_TPL_VER, "data": data, "detail": showDetail},
        pages={
-           "device_scale_factor": SCALE_FACTOR,
            "viewport": {"width": 600, "height": 300},
            "base_url": f"file://{htmlBase}",
        },
+       device_scale_factor=SCALE_FACTOR,
        wait=2,
        type="jpeg",
        quality=100,
    )
ElainaFanBoy commented 1 year ago

感谢,辛苦了