Example #1
0
    def _loop_darwin(self):  # pragma: no cover
        """loop implementation for darwin platform"""
        from fsevents import Observer  #pylint: disable=F0401
        from fsevents import Stream  #pylint: disable=F0401
        from fsevents import IN_MODIFY  #pylint: disable=F0401

        observer = Observer()
        handler = self._handle

        def fsevent_callback(event):
            if event.mask == IN_MODIFY:
                handler(event)

        for watch_this in self.watch_dirs:
            stream = Stream(fsevent_callback, watch_this, file_events=True)
            observer.schedule(stream)

        observer.daemon = True
        observer.start()
        try:
            # hack to keep main thread running...
            import time
            while True:
                time.sleep(99999)
        except (SystemExit, KeyboardInterrupt):
            pass
Example #2
0
    def _loop_darwin(self): # pragma: no cover
        """loop implementation for darwin platform"""
        from fsevents import Observer #pylint: disable=F0401
        from fsevents import Stream #pylint: disable=F0401
        from fsevents import IN_MODIFY #pylint: disable=F0401

        observer = Observer()
        handler = self._handle
        def fsevent_callback(event):
            if event.mask == IN_MODIFY:
                handler(event)

        for watch_this in self.watch_dirs:
            stream = Stream(fsevent_callback, watch_this, file_events=True)
            observer.schedule(stream)

        observer.daemon = True
        observer.start()
        try:
            # hack to keep main thread running...
            import time
            while True:
                time.sleep(99999)
        except (SystemExit, KeyboardInterrupt):
            pass
Example #3
0
def watch_files(paths):
    global observer
    observer = Observer()
    stream = Stream(update_file, file_events=True, *paths)
    observer.schedule(stream)
    log.info("Starting observer")
    observer.daemon = True
    observer.start()
    log.info("Observer started")
Example #4
0
def watch_files(paths):
    global observer
    observer = Observer()
    stream = Stream(update_file, file_events=True, *paths)
    observer.schedule(stream)
    log.info("Starting observer")
    observer.daemon = True
    observer.start()
    log.info("Observer started")
Example #5
0
 def loop(self):
     observer = Observer()
     observer.schedule(self.stream)
     observer.daemon = True
     observer.start()
     try:
         while True:
             # Cannot use observer.join() as it is not interrupted by
             # Ctrl-C
             time.sleep(10000)
     finally:
         observer.unschedule(self.stream)
         observer.stop()
Example #6
0
 def loop(self):
     observer = Observer()
     observer.schedule(self.stream)
     observer.daemon = True
     observer.start()
     try:
         while True:
             # Cannot use observer.join() as it is not interrupted by
             # Ctrl-C
             time.sleep(10000)
     finally:
         observer.unschedule(self.stream)
         observer.stop()
Example #7
0
 def loop(self):
     observer = Observer()
     observer.schedule(self.stream)
     observer.daemon = True
     observer.start()
     try:
         while True:
             try:
                 # Cannot use blocking get() as it is not interrupted by
                 # Ctrl-C
                 if self.wait_queue.get(10000) is True:
                     self.force_restart()
             except Empty:
                 pass
     finally:
         observer.unschedule(self.stream)
         observer.stop()
Example #8
0
 def loop(self):
     observer = Observer()
     observer.schedule(self.stream)
     observer.daemon = True
     observer.start()
     try:
         while True:
             try:
                 # Cannot use blocking get() as it is not interrupted by
                 # Ctrl-C
                 if self.wait_queue.get(10000) is True:
                     self.force_restart()
             except Empty:
                 pass
     finally:
         observer.unschedule(self.stream)
         observer.stop()
Example #9
0
    def _loop_darwin(self): # pragma: no cover
        """loop implementation for darwin platform"""
        from fsevents import Observer #pylint: disable=F0401
        from fsevents import Stream #pylint: disable=F0401
        from fsevents import IN_MODIFY #pylint: disable=F0401

        observer = Observer()
        handler = self._handle
        def fsevent_callback(event):
            if event.mask == IN_MODIFY:
                handler(event)

        for watch_this in self.watch_dirs:
            stream = Stream(fsevent_callback, watch_this, file_events=True)
            observer.schedule(stream)

        observer.daemon = True
        observer.run()
Example #10
0
    def _loop_darwin(self):  # pragma: no cover
        """loop implementation for darwin platform"""
        from fsevents import Observer  #pylint: disable=F0401
        from fsevents import Stream  #pylint: disable=F0401
        from fsevents import IN_MODIFY  #pylint: disable=F0401

        observer = Observer()
        handler = self._handle

        def fsevent_callback(event):
            if event.mask == IN_MODIFY:
                handler(event)

        for watch_this in self.watch_dirs:
            stream = Stream(fsevent_callback, watch_this, file_events=True)
            observer.schedule(stream)

        observer.daemon = True
        observer.run()
Example #11
0
import os
import sys

from fsevents import Observer, Stream

observer = Observer()
observer.daemon = True

def callback(event):
	observer.stop()
	print(event.name, 'changed, reloading...')
	os.execv(sys.argv[0], sys.argv)

def init():
	paths = []
	for module in sys.modules.values():
		try:
			pathname = os.path.dirname(module.__file__)
		except AttributeError:
			continue
		paths.append(pathname)

	observer.start()
	stream = Stream(callback, *paths, file_events=True)
	observer.schedule(stream)