normcap
normcap copied to clipboard
FileNotFoundError due to the file path wasn't decoded for UTF-8
What happened?
Not to decode file:// scheme URL characters for regular UTF-8 characters will cause FileNotFoundError.
Tried running from:
- pipx
- flatpak
- appimage
Solution: https://stackoverflow.com/a/15048213/8258897
It might should be fixed with:
# In "normcap/screengrab/handlers/dbus_portal.py", function "_synchronized_capture".
uri = result[0]
parsed_uri = urlparse(uri)
parsed_path = unquote(parsed_uri.path)
image_path = Path(parsed_path)
image = QtGui.QImage(image_path)
How did you install NormCap?
Python Package (pip install)
Operating System + Version?
Debian 12
[Linux only] Display Server (DS) + Desktop environment (DE)?
DS: Wayland, DE: KDE Plasma 5
Debug log output?*
16:53:59 - INFO - normcap:50 - Start NormCap v0.5.6
16:53:59 - DEBUG - normcap:100 - Set QT_QPA_PLATFORM=wayland
16:53:59 - DEBUG - normcap.gui.tray:70 - System info:
{'normcap_version': '0.5.6', 'python_version': '3.11.2', 'cli_args': '/home/user/.local/bin/normcap -v debug', 'is_briefcase_package': False, 'is_flatpak_package': False, 'is_appimage_package': False, 'platform': 'linux', 'desktop_environment': <DesktopEnvironment.KDE: 3>, 'display_manager_is_wayland': True, 'pyside6_version': '6.7.0', 'qt_version': '6.7.0', 'qt_library_path': '/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/PySide6/Qt/plugins, /usr/bin', 'locale': 'zh_CN', 'config_directory': PosixPath('/home/user/.config/normcap'), 'resources_path': PosixPath('/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/resources'), 'tesseract_path': PosixPath('/usr/bin/tesseract'), 'tessdata_path': None, 'envs': {'TESSDATA_PREFIX': None, 'LD_LIBRARY_PATH': None}, 'screens': [Screen(left=0, top=0, right=1919, bottom=1079, device_pixel_ratio=1.0, index=0, screenshot=None)]}
16:53:59 - DEBUG - normcap.gui.settings:162 - Skip update of non existing setting (show_introduction: None)
16:53:59 - DEBUG - normcap.gui.settings:162 - Skip update of non existing setting (cli_mode: False)
16:53:59 - DEBUG - normcap.gui.settings:162 - Skip update of non existing setting (background_mode: False)
16:53:59 - DEBUG - normcap.gui.settings:162 - Skip update of non existing setting (clipboard_handler: None)
16:53:59 - DEBUG - normcap.gui.tray:384 - Listen on local socket v0.5.6-normcap.
16:53:59 - DEBUG - normcap.screengrab.permissions:222 - Checking screenshot permission
16:53:59 - DEBUG - normcap.screengrab.handlers.dbus_portal:92 - DBus request message: <PySide6.QtDBus.QDBusMessage(type=MethodReturn, service="", signature="o", contents=([ObjectPath: /org/freedesktop/portal/desktop/request/1_1143/normcap_cebaaeac]) ) at 0x7f9f77ce0f00>
16:53:59 - DEBUG - normcap.screengrab.handlers.dbus_portal:99 - Request accepted
16:53:59 - DEBUG - normcap.ocr.tesseract:24 - Executing '/usr/bin/tesseract --list-langs'
16:53:59 - DEBUG - normcap.ocr.tesseract:37 - Tesseract command output: List of available languages in "/usr/share/tesseract-ocr/5/tessdata/" (5): ¬ chi_tra ¬ chi_tra_vert ¬ eng ¬ jpn ¬ osd ¬
16:53:59 - DEBUG - normcap.screengrab.handlers.dbus_portal:119 - DBus signal message: <PySide6.QtDBus.QDBusMessage(type=Signal, service=":1.73", path="/org/freedesktop/portal/desktop/request/1_1143/normcap_cebaaeac", interface="org.freedesktop.portal.Request", member="Response", signature="ua{sv}", contents=(0, [Argument: a{sv} {"uri" = [Variant(QString): "file:///home/user/%E5%9C%96%E7%89%87/Screenshot_20240513_165359.png"]}]) ) at 0x7f9f77cd3b00>
16:53:59 - DEBUG - normcap.screengrab.handlers.dbus_portal:137 - Parse response
16:53:59 - CRITICAL - normcap:148 - Uncaught exception!
Traceback (most recent call last):
File "/home/user/.local/bin/normcap", line 8, in <module>
sys.exit(run())
^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/app.py", line 102, in run
app, tray = _prepare()
^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/app.py", line 95, in _prepare
tray = SystemTray(app, vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/gui/tray.py", line 111, in __init__
if not self._ensure_screenshot_permission():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/gui/tray.py", line 402, in _ensure_screenshot_permission
if screengrab.has_screenshot_permission():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/screengrab/permissions.py", line 228, in has_screenshot_permission
return _dbus_portal_has_screenshot_permission()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/screengrab/permissions.py", line 200, in _dbus_portal_has_screenshot_permission
result = dbus_portal.capture()
^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/screengrab/handlers/dbus_portal.py", line 241, in capture
image = _synchronized_capture(interactive=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/screengrab/handlers/dbus_portal.py", line 209, in _synchronized_capture
image_path.unlink()
File "/usr/lib/python3.11/pathlib.py", line 1148, in unlink
os.unlink(self)
FileNotFoundError: [Errno 2] 沒有此一檔案或目錄: '/home/user/%E5%9C%96%E7%89%87/Screenshot_20240513_165359.png'
16:53:59 - CRITICAL - normcap:151 - System info: {'normcap_version': '0.5.6', 'python_version': '3.11.2', 'cli_args': '/home/user/.local/bin/normcap -v debug', 'is_briefcase_package': False, 'is_flatpak_package': False, 'is_appimage_package': False, 'platform': 'linux', 'desktop_environment': <DesktopEnvironment.KDE: 3>, 'display_manager_is_wayland': True, 'pyside6_version': '6.7.0', 'qt_version': '6.7.0', 'qt_library_path': '/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/PySide6/Qt/plugins, /usr/bin', 'locale': 'zh_CN', 'config_directory': PosixPath('/home/user/.config/normcap'), 'resources_path': PosixPath('/home/user/.local/pipx/venvs/normcap/lib/python3.11/site-packages/normcap/resources'), 'tesseract_path': PosixPath('/usr/bin/tesseract'), 'tessdata_path': None, 'envs': {'TESSDATA_PREFIX': None, 'LD_LIBRARY_PATH': None}, 'screens': [Screen(left=0, top=0, right=1919, bottom=1079, device_pixel_ratio=1.0, index=0, screenshot=None)]}
16:53:59 - CRITICAL - normcap:152 - Unfortunately, NormCap has to be terminated due to an unknown problem.
Please help improve NormCap by reporting this error, including the output above, on
https://github.com/dynobo/normcap/issues/new
Thanks!
Thanks for the excellent error report and already providing a fix!! :slightly_smiling_face:
Fix is included in the latest release. Feel free to reopen, if the issue persists.