Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError while trying to test the script #2

Closed
brokenwu opened this issue Aug 17, 2018 · 2 comments
Closed

UnicodeEncodeError while trying to test the script #2

brokenwu opened this issue Aug 17, 2018 · 2 comments

Comments

@brokenwu
Copy link

Hello,

since i moved my Plex to another machine I wanted to give this a shot. However I get this result after trying to run it:
Got Plex libraries: {"/path": 1, "/path2": 2, "/path3": 3} Adding directories to inotify watch Traceback (most recent call last): File "./plex-inotify.py", line 214, in <module> auto_add=True File "/usr/local/lib/python3.5/dist-packages/pyinotify.py", line 1916, in add_watch exclude_filter) File "/usr/local/lib/python3.5/dist-packages/pyinotify.py", line 1833, in __add_watch wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask) File "/usr/local/lib/python3.5/dist-packages/pyinotify.py", line 153, in inotify_add_watch return self._inotify_add_watch(fd, pathname, mask) File "/usr/local/lib/python3.5/dist-packages/pyinotify.py", line 246, in _inotify_add_watch pathname = pathname.encode(sys.getfilesystemencoding()) UnicodeEncodeError: 'utf-8' codec can't encode character '\udcfc' in position 65: surrogates not allowed

Do you have any idea on how to fix this?

@roquint
Copy link

roquint commented Sep 15, 2020

if you're running the script directly from the Synology Task Scheduler (eg : as a triggered event on startup), you should export some variables in order to make python3 work with the correct encoding, in your Task Scheduler userscript must be like this :

export PYTHONIOENCODING=UTF-8
export LANG=en_US.UTF-8
/volume1/@appstore/py3k/usr/local/bin/python3 /usr/local/bin/plex-inotify.py

@talisto
Copy link
Owner

talisto commented Oct 22, 2020

Thanks for the tip, @luckypaste!

It seems that this is actually an issue with pyinotify (which is a library that plex-inotifier uses), and not with plex-inotifier itself. There's an open issue on the pyinotify tracker here:

seb-m/pyinotify#183

There's no "official" way for me to set the encoding to UTF8 in my script (aside from unsupported/hacky methods). The environment variable is the way to go, so I'm going to close this issue.

@talisto talisto closed this as completed Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants