-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSYS-WIN.FS.WATCHDOG.py
50 lines (50 loc) · 3.12 KB
/
SYS-WIN.FS.WATCHDOG.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#-- !/usr/bin/env python3
#-- -*- coding: utf-8 -*-
#--
#-- *************************************************************************************************************:
#-- ********************************************* MON WIN FILE SYSTEM *******************************************:
#-- *************************************************************************************************************:
#-- Author: JBallard (JEB) :
#-- Date: 2024.1.02 :
#-- Script: SYS-WIN.FS.WATCHDOG.py :
#-- Purpose: A python script that monitors the File System of a Windows System. :
#-- Class: python -m pip install watchdog :
#-- Class: python -m pip install watchdog.observers :
#-- Class: python -m pip install Observer :
#-- Class: python -m pip install watchdog.events :
#-- Class: python -m pip install FileSystemEvent :
#-- Class: python -m pip install FileSystemEventHandler :
#-- Ver: 1.0 :
#-- *************************************************************************************************************:
#-- *************************************************************************************************************:
#--
#-- ********************************************************:
#-- DEFINE PARAMS, CONSTANTS, CONFIG PATHS, CLASSES, & LIBS :
#-- ********************************************************:
import watchdog
from watchdog.observers import Observer
from watchdog.events import FileSystemEvent, FileSystemEventHandler
from watchdog.observers.polling import PollingObserver as Observer
#--
#-- CLASS - CHECK FOR MODS, CREATION, & DELETED FILES:
class MyHandler(FileSystemEventHandler):
#--
#-- FUNCTION - CHECK FILE MODIFICATIONS:
def on_modified(self, event):
print(f'NOTE - FILE {event.src_path} HAS BEEN MODIFIED:')
#--
#-- FUNCTION - CHECK FOR FILE CREATION:
def on_created(self, event):
print(f'NOTE - FILE {event.src_path} HAS BEEN CREATED:')
#--
#-- FUNCTION - CHECK FOR FILE DELETION:
def on_deleted(self, event):
print(f'NOTE - FILE {event.src_path} HAS BEEN DELETED:')
#--
observer = Observer()
observer.schedule(MyHandler(), path='C:/Windows/System32', recursive=True)
observer.start()
#--
#-- ********************************************************:
#-- END OF PYTHON SCRIPT :
#-- ********************************************************: