示例#1
0
    def run_test_command(self, cmd):
        observer = FSEventsObserver()
        shared_queue = Queue.Queue()
        handler = ChangeHandler(shared_queue)
        observer.schedule(handler, self.temp_dir)
        observer.start()

        args = ['./webnull.py'] + cmd
        env = os.environ.copy()
        if 'DEV_MODE' in env:
            del env['DEV_MODE']
        env['HOSTFILE_PATH'] = self.hostfile_path
        env['TEST_DURATION'] = '0.02'
        process = subprocess.Popen(args, env=env)
        process.wait()
        time.sleep(
            .09
        )  # if we just quit, the observer doesn't see the final file action.

        bodies = []
        while not shared_queue.empty():
            bodies.append(shared_queue.get())

        observer.stop()
        observer.join()
        return bodies
示例#2
0
文件: __init__.py 项目: dpereira/-
def monitor_module(module_id, module_info, callback):
  event_handler = _ModuleEventHandler(module_id, module_info, callback)

  for fs_object, recursive in _observable_fs_objects:
    if platform.system() == 'Darwin':
      from watchdog.observers.fsevents import FSEventsObserver
      observer = FSEventsObserver()
    else:
      from watchdog.observers.inotify import InotifyObserver
      observer = InotifyObserver()
    observable = os.sep.join((module_info['path'], fs_object))
    if os.path.exists(observable):
      observer.schedule(event_handler, observable, recursive = recursive)
      observer.start()
      _observers.append(observer)
def initiate_download(PDF,download_folder):
	file_location = download_folder
	global check
	check = 0
	time_passed = 0
	observer = Observer()
	event_handler = MyEventHandler(observer)
	observer.schedule(event_handler, file_location)
	observer.start()
	PDF.click()
	while(check == 0):
		time.sleep(1) # wait for download signal
		time_passed += 1
		if(time_passed > 10):
			observer.stop()
			observer.join()
			return -1
	observer.stop()
	observer.join()
	return 0
def initiate_download(PDF, download_folder):
    file_location = download_folder
    global check
    check = 0
    time_passed = 0
    observer = Observer()
    event_handler = MyEventHandler(observer)
    observer.schedule(event_handler, file_location)
    observer.start()
    PDF.click()
    while (check == 0):
        time.sleep(1)  # wait for download signal
        time_passed += 1
        if (time_passed > 10):
            observer.stop()
            observer.join()
            return -1
    observer.stop()
    observer.join()
    return 0
示例#5
0
文件: loopify.py 项目: straup/loopr
    parser = optparse.OptionParser()
    parser.add_option('-c', '--config', dest='config', action='store', help='path to a loopr config file - see source code for a sample config')
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="enable chatty logging; default is false", default=False)

    # MAYBE: allow CLI flags to override the config file?
    # parser.add_option("-w", "--watch", dest="watch", help="", default=None)
    # parser.add_option("-o", "--out", dest="out", help="", default=None)
    # parser.add_option("-c", "--count", dest="count", help="", default=200)
    # parser.add_option("--gifsicle", dest="gifsicle", help="", default="/usr/local/bin/gifsicle"),    
    # parser.add_option("--max-width", dest="maxwidth", help="", default=None)

    (opts, args) = parser.parse_args()

    if opts.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    observer = Observer()
    event_handler = Eyeballs(observer, opts)

    observer.schedule(event_handler, path=event_handler.watch, recursive=False)
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
示例#6
0
文件: file_watch.py 项目: szagar/ats
# git clone git://github.com/gorakhargosh/watchdog.git
# cd watchdog
# python setup.py install

# watchmedo log --debug-force-fsevents --patterns="*.py;*.txt" --ignore-directories --recursive ~/

#!/usr/bin/python
import time
#from watchdog.observers import Observer
from watchdog.observers.fsevents import FSEventsObserver as Observer
from watchdog.events import FileSystemEventHandler


class MyHandler(FileSystemEventHandler):
    def on_modified(self, event):
        print(f'event type: {event.event_type}  path : {event.src_path}')


if __name__ == "__main__":
    event_handler = MyHandler()
    observer = Observer()
    observer.schedule(event_handler, path='/data/', recursive=False)
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()