Skip to content

Commit 7728a45

Browse files
authored
[watchmedo] Add the --debug-force-* arguments to tricks (#783)
* Add the `--debug-force-*` arguments to `watchmedo tricks` This allows the configuring of the observer in the same manner as the shell-command, log, and auto-restart functions. * Update changelog.rst
1 parent 1c67997 commit 7728a45

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Changelog
99
2021-0x-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v2.0.3...master>`__
1010

1111
- [mac] Add support for non-recursive watches in FSEventsEmitter (`#779 <https://github.com/gorakhargosh/watchdog/pull/779>`_)
12-
- Thanks to our beloved contributors: @CCP-Aporia, @
12+
- Add support for `--debug-force-*` arguments to `watchmedo tricks` (`#781 <https://github.com/gorakhargosh/watchdog/pull/781>`_)
13+
- Thanks to our beloved contributors: @CCP-Aporia, @aodj, @
1314

1415

1516
2.0.3

src/watchdog/watchmedo.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ def schedule_tricks(observer, tricks, pathname, recursive):
154154
@arg('--recursive',
155155
default=True,
156156
help='recursively monitor paths')
157+
@arg('--debug-force-polling',
158+
default=False,
159+
help='[debug] forces polling')
160+
@arg('--debug-force-kqueue',
161+
default=False,
162+
help='[debug] forces BSD kqueue(2)')
163+
@arg('--debug-force-winapi',
164+
default=False,
165+
help='[debug] forces Windows API')
166+
@arg('--debug-force-winapi-async',
167+
default=False,
168+
help='[debug] forces Windows API + I/O completion')
169+
@arg('--debug-force-fsevents',
170+
default=False,
171+
help='[debug] forces Mac OS X FSEvents')
172+
@arg('--debug-force-inotify',
173+
default=False,
174+
help='[debug] forces Linux inotify(7)')
157175
@expects_obj
158176
def tricks_from(args):
159177
"""
@@ -162,7 +180,24 @@ def tricks_from(args):
162180
:param args:
163181
Command line argument options.
164182
"""
165-
from watchdog.observers import Observer
183+
if args.debug_force_polling:
184+
from watchdog.observers.polling import PollingObserver as Observer
185+
elif args.debug_force_kqueue:
186+
from watchdog.observers.kqueue import KqueueObserver as Observer
187+
elif args.debug_force_winapi_async:
188+
from watchdog.observers.read_directory_changes_async import\
189+
WindowsApiAsyncObserver as Observer
190+
elif args.debug_force_winapi:
191+
from watchdog.observers.read_directory_changes import\
192+
WindowsApiObserver as Observer
193+
elif args.debug_force_inotify:
194+
from watchdog.observers.inotify import InotifyObserver as Observer
195+
elif args.debug_force_fsevents:
196+
from watchdog.observers.fsevents import FSEventsObserver as Observer
197+
else:
198+
# Automatically picks the most appropriate observer for the platform
199+
# on which it is running.
200+
from watchdog.observers import Observer
166201

167202
add_to_sys_path(path_split(args.python_path))
168203
observers = []

0 commit comments

Comments
 (0)