def start_watching(plex_sql_path, backup_path, plex_metadata_path,
                   metadata_backup_path, enable_metadata, logging_level):
    logger = setup_logging(logging_level)
    loop = asyncio.get_event_loop()
    logger.info("Using PLEX_DB_PATH %s", plex_sql_path)
    logger.info("Using DB_BACKUP_PATH %s", backup_path)
    logger.info("Using PLEX_METADATA_PATH %s", plex_metadata_path)
    logger.info("Using METADATA_BACKUP_PATH %s", metadata_backup_path)
    db_handler = PlexLocalFileBackupHandler(plex_sql_path, backup_path,
                                            "SQLite")
    db_watcher = AIOWatchdog(plex_sql_path, event_handler=db_handler)
    if enable_metadata:
        metadata_handler = PlexLocalFileBackupHandler(plex_metadata_path,
                                                      metadata_backup_path,
                                                      "Metadata")
        metadata_watcher = AIOWatchdog(plex_metadata_path,
                                       event_handler=metadata_handler)
    try:
        logger.info("Starting Watchers")
        loop.create_task(start_watcher(db_watcher))
        if enable_metadata:
            loop.create_task(start_watcher(metadata_watcher))
        loop.run_forever()
    except KeyboardInterrupt:
        logger.info("Stopping Watchers")
        db_watcher.stop()
        if enable_metadata:
            metadata_watcher.stop()
    finally:
        loop.close()
Exemplo n.º 2
0
def watch_fs():
    watch = AIOWatchdog('/home/ymq/tst')
    watch.start()
    while 1:
        yield from asyncio.sleep(1)
    print('watch stoped .....')
    watch.stop()
Exemplo n.º 3
0
 async def watch_fs():
     event_handler = SubclassEventHandler()  # hachinko style event handler
     watcher = AIOWatchdog(WATCH_DIRECTORY, event_handler=event_handler)
     watcher.start()
     await check_output_is_expected(WATCH_DIRECTORY, capsys)
     # Stop the directory watcher
     watcher.stop()
Exemplo n.º 4
0
async def watch_fs(watch_dir):
    evh = MyEventHandler()
    watch = AIOWatchdog(watch_dir, event_handler=evh)
    watch.start()
    for _ in range(20):
        await asyncio.sleep(1)
    watch.stop()
Exemplo n.º 5
0
async def watch_fs(watch_dir):
    patterns = "*"
    ignore_patterns = ""
    ignore_directories = False
    case_sensitive = True
    evh = MyEventHandler()
    watch = AIOWatchdog(watch_dir, event_handler=evh, recursive=True)
    watch.start()
    while True:
        await asyncio.sleep(1)
    watch.stop()
Exemplo n.º 6
0
async def watch_fs(path):
    watch = AIOWatchdog(path, event_handler=NegmasMonitorFile(log_folder=path))
    watch.start()
    import threading
        
    print('monitor threading is {}'. format(threading.current_thread()))
    import os

    print("monitor process id is {}".format(os.getpid()))
    for _ in range(100):
        await asyncio.sleep(1)
    watch.stop()
    print("Finish monitoring task")
def start_watching(plex_sql_path, backup_path):
    logger = setup_logging()
    loop = asyncio.get_event_loop()
    logger.info("Using PLEX_DB_PATH %s", plex_sql_path)
    logger.info("Using DB_BACKUP_PATH %s", backup_path)
    handler = PlexSQLiteBackupHandler(plex_sql_path, backup_path)
    watcher = AIOWatchdog(plex_sql_path, event_handler=handler)
    try:
        logger.info("Starting Watcher")
        loop.create_task(start_watcher(watcher))
        loop.run_forever()
    except KeyboardInterrupt:
        logger.info("Stopping Watcher")
        watcher.stop()
    finally:
        loop.close()
Exemplo n.º 8
0
    async def run(self):
        print("run()")
        evh = Handler()
        watch = AIOWatchdog(WATCH_DIRECTORY, event_handler=evh)
        watch.start()

        #self.observer.schedule(event_handler, WATCH_DIRECTORY, recursive=True)
        #self.observer.start()

        print("Observer started")

        try:
            while True:
                await asyncio.sleep(1)
        except:
            watch.stop()
            print("Observer Stopped")
Exemplo n.º 9
0
def watch_fs():
    watch = AIOWatchdog('/Users/jbiesnecker/temp/forks/test')
    watch.start()
    for _ in range(20):
        yield from asyncio.sleep(1)
    watch.stop()
Exemplo n.º 10
0
def watch_fs(path):
    watch = AIOWatchdog(path, event_handler=Handler())
    watch.start()
    while True:
        yield from asyncio.sleep(10)
    watch.stop()
Exemplo n.º 11
0
    async def on_deleted(self, event):
        if event.src_path in self._active_events:
            self._active_events.pop(event.src_path)

    async def on_moved(self, event):
        if event.src_path in self._active_events:
            self._active_events.pop(event.src_path)
        await self._dispatch_work(event)


if __name__ == "__main__":
    from argparse import ArgumentParser
    args_parser = ArgumentParser(__name__)
    args_parser.add_argument('path', help='path to observing')
    args = args_parser.parse_args()

    class MyEventHandler(ReadyFilesEventHandlerWrapper):
        async def on_file_ready(self, file_path):
            print('received %s' % file_path)

    loop = asyncio.get_event_loop()
    watch = AIOWatchdog(args.path, event_handler=MyEventHandler())
    watch.start()

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        print('Stop loop...')
        watch.stop()
        loop.stop()