@@ -262,49 +262,18 @@ def compile_qml(output_dir, root, project_dirs, root_manifest, app, platforms =
262
262
wait = False , doc = None , release = False , verbose = False , jobs = 1 , cache_dir = ".cache" ):
263
263
if wait :
264
264
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
292
266
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` " )
294
268
295
269
c = Compiler (output_dir , root , project_dirs , root_manifest , app , platforms , doc = doc , release = release , verbose = verbose , jobs = jobs , cache_dir = cache_dir )
296
270
297
271
notifier = None
298
272
299
273
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 )
308
277
309
278
while True :
310
279
try :
@@ -335,11 +304,9 @@ def pop(self):
335
304
break
336
305
337
306
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
0 commit comments