♻️ Py3: no more need to patch scandir for watchdog
This commit is contained in:
1 parent
21a30001fa
commit
fe87062768
2 files changed
-32
No files matched your search
@@ -333,7 +333,6 @@ class Server:
|
||||
util.tornado.fix_json_encode()
|
||||
util.tornado.fix_websocket_check_origin()
|
||||
util.flask.fix_flask_jsonify()
|
||||
util.watchdog.fix_scandir()
|
||||
|
||||
self._setup_mimetypes()
|
||||
|
||||
|
||||
@@ -15,37 +15,6 @@ import octoprint.filemanager.util
|
||||
import octoprint.util
|
||||
|
||||
|
||||
def fix_scandir():
|
||||
try:
|
||||
from os import scandir
|
||||
|
||||
# nothing to fix, natively available, return
|
||||
return
|
||||
|
||||
except ImportError:
|
||||
# not natively available, use backport
|
||||
import watchdog.utils.dirsnapshot
|
||||
from scandir import scandir
|
||||
|
||||
OriginalDirectorySnapshot = watchdog.utils.dirsnapshot.DirectorySnapshot
|
||||
|
||||
class FixedDirectorySnapshot(OriginalDirectorySnapshot):
|
||||
def __init__(self, listdir=scandir, *args, **kwargs):
|
||||
OriginalDirectorySnapshot.__init__(self, listdir=listdir, *args, **kwargs)
|
||||
|
||||
watchdog.utils.dirsnapshot.DirectorySnapshot = FixedDirectorySnapshot
|
||||
|
||||
import watchdog.observers.polling
|
||||
|
||||
OriginalPollingEmitter = watchdog.observers.polling.PollingEmitter
|
||||
|
||||
class FixedPollingEmitter(OriginalPollingEmitter):
|
||||
def __init__(self, listdir=scandir, *args, **kwargs):
|
||||
OriginalPollingEmitter.__init__(self, listdir=listdir, *args, **kwargs)
|
||||
|
||||
watchdog.observers.polling.PollingEmitter = FixedPollingEmitter
|
||||
|
||||
|
||||
class GcodeWatchdogHandler(watchdog.events.PatternMatchingEventHandler):
|
||||
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user