Skip to content

Commit eb89789

Browse files
committed
swap pyinotify (unmaintained and stopped working in latest python) to inotify
1 parent 433b155 commit eb89789

File tree

2 files changed

+12
-45
lines changed

2 files changed

+12
-45
lines changed

compiler/__init__.py

+11-44
Original file line numberDiff line numberDiff line change
@@ -262,49 +262,18 @@ def compile_qml(output_dir, root, project_dirs, root_manifest, app, platforms =
262262
wait = False, doc = None, release = False, verbose = False, jobs = 1, cache_dir = ".cache"):
263263
if wait:
264264
try:
265-
import pyinotify
266-
267-
class EventHandler(pyinotify.ProcessEvent):
268-
def __init__(self):
269-
self.modified = False
270-
271-
def check_file(self, filename):
272-
if not filename or filename[0] == '.':
273-
return False
274-
root, ext = os.path.splitext(filename)
275-
return ext in set([".qml", ".js"])
276-
277-
def check_event(self, event):
278-
if self.check_file(event.name):
279-
self.modified = True
280-
281-
def process_IN_MODIFY(self, event):
282-
self.check_event(event)
283-
def process_IN_CREATE(self, event):
284-
self.check_event(event)
285-
def process_IN_DELETE(self, event):
286-
self.check_event(event)
287-
288-
def pop(self):
289-
r = self.modified
290-
self.modified = False
291-
return r
265+
import inotify
292266
except:
293-
raise Exception("it seems you don't have pyinotify module installed, please install it to run build with -d option")
267+
raise Exception("it seems you don't have inotify module installed, please install it to run `build -d`")
294268

295269
c = Compiler(output_dir, root, project_dirs, root_manifest, app, platforms, doc=doc, release=release, verbose=verbose, jobs=jobs, cache_dir=cache_dir)
296270

297271
notifier = None
298272

299273
if wait:
300-
from pyinotify import WatchManager
301-
wm = WatchManager()
302-
mask = pyinotify.IN_MODIFY | pyinotify.IN_CREATE | pyinotify.IN_DELETE
303-
for dir in project_dirs:
304-
wm.add_watch(dir, mask)
305-
306-
event_handler = EventHandler()
307-
notifier = pyinotify.Notifier(wm, event_handler)
274+
import inotify.adapters
275+
import inotify.constants
276+
notifier = inotify.adapters.InotifyTrees(list(project_dirs), mask=inotify.constants.IN_MODIFY)
308277

309278
while True:
310279
try:
@@ -335,11 +304,9 @@ def pop(self):
335304
break
336305

337306
while True:
338-
if notifier.check_events():
339-
notifier.read_events()
340-
notifier.process_events()
341-
modified = event_handler.pop()
342-
if not modified:
343-
continue
344-
else:
345-
break
307+
modified = False
308+
for _ in notifier.event_gen(yield_nones=False):
309+
modified = True
310+
break
311+
if modified:
312+
break

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
future>=0.17.1
2-
pyparsing>=2.2.0
2+
inotify>=0.2.10

0 commit comments

Comments
 (0)