You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The filesystem is ext4 so the encoding is UTF-8. But sometimes there are special characters in the filnames. Now python complains:
user@NAS:~$ python3 inotifyscan.py
Traceback (most recent call last):
File "/home/user/inotifyscan.py", line 105, in <module>
inotify.add_watch(data_dir + files_dir, mask, rec=True, auto_add=True, exclude_filter=excl)
File "/usr/lib/python3/dist-packages/pyinotify.py", line 1916, in add_watch
exclude_filter)
File "/usr/lib/python3/dist-packages/pyinotify.py", line 1833, in __add_watch
wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
File "/usr/lib/python3/dist-packages/pyinotify.py", line 153, in inotify_add_watch
return self._inotify_add_watch(fd, pathname, mask)
File "/usr/lib/python3/dist-packages/pyinotify.py", line 246, in _inotify_add_watch
pathname = pathname.encode(sys.getfilesystemencoding())
UnicodeEncodeError: 'utf-8' codec can't encode character '\udc84' in position 81: surrogates not allowed
Watching the filesystem with commandline inotifywatch works without any problem.
It seems that pyinotify.py expects strictly UTF-8 filenames. How can I get around this?
Regards. :-)
The text was updated successfully, but these errors were encountered:
It seems that there is no easy solution to this.
So I decided to change my script to use the output of inotifywait from the commandline.
If someone is interested, here's what I got:
I use this script to trigger a rescan of the corresponding folder by Nextcloud when a file was changed externally.
Maybe it's useful to somebody else :-)
I use a very large filesystem which i want to monitor for changes and trigger a command after a timeout.
I wrote this script to do that:
The filesystem is ext4 so the encoding is UTF-8. But sometimes there are special characters in the filnames. Now python complains:
Watching the filesystem with commandline inotifywatch works without any problem.
It seems that pyinotify.py expects strictly UTF-8 filenames. How can I get around this?
Regards. :-)
The text was updated successfully, but these errors were encountered: