Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
class MyHandler(FileSystemEventHandler):

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

def monitor_folders(path):
    event_handler = MyHandler()
    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()

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

folder1 = '/home/bilal/Videos/folder1'

if __name__ == "__main__":
    m1 = monitor_folders(folder1)
    m1.start()
    m1.join()


What I have tried:

In this code, I am monitoring the filesystem. Whenever I modify a file, event.src_path does not show the name of the file. Instead, it shows .goutputstream-CL5N00. I don't know what is wrong?

Given result

event type: modified path : /home/bilal/Videos/folder1/fd/.goutputstream-CL5N00

Expected result

event type: modified path : /home/bilal/Videos/folder1/fd/touch
Posted
Comments
Richard MacCutchan 23-Mar-21 13:02pm    
Take a look in that directory to see where that file is coming from.
Richard MacCutchan 23-Mar-21 13:25pm    
Searching Google for that filename suggests some process is creating them, although it is not clear which. Something to do with Gnome and different versions of Linux. You will need to look at all the links to see if there is a simple solution.
Yvan Rodrigues 24-Mar-21 10:08am    
Are you running `gstreamer` or `pulseaudio`? They would be creating this temporary files, which would mean your code is returning correct results.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900