def log(args): """ Subcommand to log file system events to the console. :param args: Command line argument options. """ from watchdog.utils import echo from watchdog.tricks import LoggerTrick if args.trace: echo.echo_class(LoggerTrick) patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) handler = LoggerTrick( patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories ) if args.debug_force_polling: from watchdog.observers.polling import PollingObserver as Observer elif args.debug_force_kqueue: from watchdog.observers.kqueue import KqueueObserver as Observer elif args.debug_force_winapi_async: from watchdog.observers.read_directory_changes_async import WindowsApiAsyncObserver as Observer elif args.debug_force_winapi: from watchdog.observers.read_directory_changes import WindowsApiObserver as Observer elif args.debug_force_inotify: from watchdog.observers.inotify import InotifyObserver as Observer elif args.debug_force_fsevents: from watchdog.observers.fsevents import FSEventsObserver as Observer else: # Automatically picks the most appropriate observer for the platform # on which it is running. from watchdog.observers import Observer observer = Observer(timeout=args.timeout) observe_with(observer, handler, args.directories, args.recursive)
def log(args): """ Command to log file system events to the console. """ from watchdog.utils import echo from watchdog.tricks import LoggerTrick if args.trace: echo.echo_class(LoggerTrick) patterns, ignore_patterns =\ parse_patterns(args.patterns, args.ignore_patterns) handler = LoggerTrick(patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories) if args.debug_force_polling: from watchdog.observers.polling import PollingObserver as Observer elif args.debug_force_kqueue: from watchdog.observers.kqueue import KqueueObserver as Observer elif args.debug_force_winapi: from watchdog.observers.read_directory_changes import\ WindowsApiObserver as Observer elif args.debug_force_inotify: from watchdog.observers.inotify import InotifyObserver as Observer elif args.debug_force_fsevents: from watchdog.observers.fsevents import FSEventsObserver as Observer else: # Automatically picks the most appropriate observer for the platform # on which it is running. from watchdog.observers import Observer observer = Observer(timeout=args.timeout) observe_with(observer, handler, args.directories, args.recursive)
def log(args): """ Subcommand to log file system events to the console. :param args: Command line argument options. """ from watchdog.utils import echo from watchdog.tricks import LoggerTrick if args.trace: echo.echo_class(LoggerTrick) patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) handler = LoggerTrick(patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories) if args.debug_force_polling: from watchdog.observers.polling import PollingObserver as Observer elif args.debug_force_kqueue: from watchdog.observers.kqueue import KqueueObserver as Observer elif args.debug_force_winapi_async: from watchdog.observers.read_directory_changes_async import WindowsApiAsyncObserver as Observer elif args.debug_force_winapi: from watchdog.observers.read_directory_changes import WindowsApiObserver as Observer elif args.debug_force_inotify: from watchdog.observers.inotify import InotifyObserver as Observer elif args.debug_force_fsevents: from watchdog.observers.fsevents import FSEventsObserver as Observer else: from watchdog.observers import Observer observer = Observer(timeout=args.timeout) observe_with(observer, handler, args.directories, args.recursive)
def log(args): from watchdog.utils import echo from watchdog.tricks import LoggerTrick if args.trace: echo.echo_class(LoggerTrick) patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) handler = LoggerTrick(patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories) if args.debug_force_polling: from watchdog.observers.polling import PollingObserver as Observer elif args.debug_force_kqueue: from watchdog.observers.kqueue import KqueueObserver as Observer elif args.debug_force_winapi_async: from watchdog.observers.read_directory_changes_async import WindowsApiAsyncObserver as Observer elif args.debug_force_winapi: from watchdog.observers.read_directory_changes import WindowsApiObserver as Observer elif args.debug_force_inotify: from watchdog.observers.inotify import InotifyObserver as Observer elif args.debug_force_fsevents: from watchdog.observers.fsevents import FSEventsObserver as Observer else: from watchdog.observers import Observer observer = Observer(timeout=args.timeout) observe_with(observer, handler, args.directories, args.recursive)
def log(args): """ Subcommand to log file system events to the console. :param args: Command line argument options. """ from watchdog.utils import echo from watchdog.tricks import LoggerTrick if args.trace: echo.echo_class(LoggerTrick) patterns, ignore_patterns = parse_patterns(args.patterns, args.ignore_patterns) handler = LoggerTrick( patterns=patterns, ignore_patterns=ignore_patterns, ignore_directories=args.ignore_directories ) if args.debug_force_polling: print "debug_force_polling" from watchdog.observers.polling import PollingObserver as Observer elif args.debug_force_kqueue: print "debug_force_kqueue" from watchdog.observers.kqueue import KqueueObserver as Observer elif args.debug_force_winapi_async: print "debug_force_winapi_async" from watchdog.observers.read_directory_changes_async import WindowsApiAsyncObserver as Observer elif args.debug_force_winapi: print "debug_force_winapi" from watchdog.observers.read_directory_changes import WindowsApiObserver as Observer elif args.debug_force_inotify: print "debug_force_inotify" from watchdog.observers.inotify import InotifyObserver as Observer elif args.debug_force_fsevents: print "debug_force_fsevents" from watchdog.observers.fsevents import FSEventsObserver as Observer else: # Automatically picks the most appropriate observer for the platform # on which it is running. from watchdog.observers import Observer from utils.collector import File_Inspector print "Starting the processing." # inspector = File_Inspector(False, False) # inspector.walktree(args.directories[0], inspector.add_file_metadata) # print "Starting the data files generation." # inspector.generate_data_files() # print "Terminated data files generation." print "Terminated processing File_Inspector" if args.directories.__len__() == 1: count_files_dir(str(args.directories[0]), 0, 0) dirs_list = [] directories = [] files_observed = 0 for dirname, files in dict_dirs_files.iteritems(): files_observed += files if files_observed < OBSERVE_MAX_CAPACITY: directories.append(dirname) else: files_observed = 0 dirs_list.append(directories) directories = [] directories.append(dirname) if files_observed < OBSERVE_MAX_CAPACITY and files_observed > 0: dirs_list.append(directories) pool_manager = Pool(processes=dirs_list.__len__()) print "Creating Pool of Observers.." process_counter = 0 for dirs in dirs_list: observer = Observer(timeout=args.timeout) process_counter += 1 if process_counter == dirs_list.__len__(): print "Creating last Observer.." Thread(target=observe_with(observer, handler, dirs, args.recursive)).start() print "Last Observer has been created." # pool_manager.apply(observe_with, (observer, handler, dirs, args.recursive)) else: pool_manager.apply_async(observe_with, (observer, handler, dirs, args.recursive)) # observe_with(observer, handler, args.directories, args.recursive) print "Pool of Observers created." else: print "Creating one Observer.." observer = Observer(timeout=args.timeout) observe_with(observer, handler, args.directories, args.recursive) print "Observer created."