Python Forum

Full Version: folder sync
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,
i'm somewhat new to python, i have mostly coded in java(eclipse) and autohotkey(AHK Studio)
so i could use some help figuring out how to sync directories once a change was detected which the following script is responsible for:
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')
    path = sys.argv[1] if len(sys.argv) > 1 else '.'
    event_handler = LoggingEventHandler()
    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
link to the source of that code: https://pypi.python.org/pypi/watchdog

any help is greatly appreciated !

Cheers ;)

yawikflame