Detect File System changes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lukas Meyer

    #1

    Detect File System changes

    Hello,

    I'm trying to detect changes in a directory. E.g if someone crates a
    file, i'll execute another function on this file.

    I tried to solve this by creating a loop that permanently checks the
    contents of this directory with os.listdir() and compares it with the
    one before. But this isn't really working properly.

    Can anyone give me a hint to get this working?

    best regards,

    Lukas

  • Fuzzyman

    #2
    Re: Detect File System changes

    The proper way to do this is to use the facilities provided by the
    operating system. This means the solution is going to be different for
    different platforms. I've *not* done this before - but certainly for
    Windows I've seen discussions about this in this group previously.

    The win32 extensions expose this capability for windows. I hope this
    helps your googling.

    All the best,

    Fuzzyman
    http://www.voidspace.org.uk/python/index.shtml

    Comment

    • Noah

      #3
      Re: Detect File System changes

      In the UNIX world the common tool is FAM -- File Allocation Monitor.
      This is a daemon that will report filesystem changes to clients.
      There is a Python interface to libfam called "Python FAM" here:

      It looks mature, but I have never used it.

      There are also some alternatives to FAM, but I don't remember the names
      of them right now.

      Yours,
      Noah

      Comment

      • Kent Johnson

        #4
        Re: Detect File System changes

        Lukas Meyer wrote:[color=blue]
        > Hello,
        >
        > I'm trying to detect changes in a directory. E.g if someone crates a
        > file, i'll execute another function on this file.
        >
        > I tried to solve this by creating a loop that permanently checks the
        > contents of this directory with os.listdir() and compares it with the
        > one before. But this isn't really working properly.
        >
        > Can anyone give me a hint to get this working?[/color]

        We just had a thread on this topic:


        Kent

        Comment

        • Lukas Meyer

          #5
          Re: Detect File System changes

          Hello,

          Thank you for your assistance. I could manage it using your link to the
          already discussed thread.

          best regards,

          Lukas

          Comment

          • Lawrence Oluyede

            #6
            Re: Detect File System changes

            Il 2005-12-23, Lukas Meyer <lukasmeyer1@gm ail.com> ha scritto:[color=blue]
            > Hello,
            >
            > I'm trying to detect changes in a directory. E.g if someone crates a
            > file, i'll execute another function on this file.[/color]

            pyinotify (wrapper of inotify) is for you (it's not portable however)

            Download pyinotify for free. None


            --
            Lawrence - http://www.oluyede.org/blog
            "Anyone can freely use whatever he wants but the light at the end
            of the tunnel for most of his problems is Python"

            Comment

            Working...