Ejemplo n.º 1
0
takes a path to watch as the first Command Line Argument and prints to
stdour every file system event it sees.
"""

import sys

from circuits import Component
from circuits.io import Notify


class FileWatcher(Component):

    channel = "notify"

    def opened(self, filename, path, fullpath, isdir):
        print("File {0:s} opened".format(filename))

    def closed(self, filename, path, fullpath, isdir):
        print("File {0:s} closed".format(filename))


# Configure the system
app = Notify()
FileWatcher().register(app)

# Add the path to watch
app.add_path(sys.argv[1])

# Run the system
app.run()
Ejemplo n.º 2
0
    def write(self, filename, path, fullpath, isdir):
        logger.debug("File {0:s} written".format(fullpath))

    def closed(self, filename, path, fullpath, isdir):
        if not os.path.isdir(fullpath):
            logger.debug("File {0:s} closed".format(filename))

            if fullpath in self.created_files:

                # Find the entry in the list and then delete it
                i = self.created_files.index(fullpath)
                del self.created_files[i]

                fext = fullpath[-4:]
                if fext in processable_extensions:
                    logger.info("File {0:s} ready for processing".format(filename))

if __name__ == "__main__":
            
    # Configure the system
    app = Notify()
    FileWatcher().register(app)

    # Add the path to watch
    for p in watch_paths:
        app.add_path(os.path.join(watch_base_path,p))

    # Run the system
    app.run()
Ejemplo n.º 3
0
be used for real-time monitoring of file system events. The example simply
takes a path to watch as the first Command Line Argument and prints to
stdour every file system event it sees.
"""
import sys

from circuits import Component
from circuits.io import Notify


class FileWatcher(Component):

    channel = "notify"

    def opened(self, filename, path, fullpath, isdir):
        print("File {0:s} opened".format(filename))

    def closed(self, filename, path, fullpath, isdir):
        print("File {0:s} closed".format(filename))


# Configure the system
app = Notify()
FileWatcher().register(app)

# Add the path to watch
app.add_path(sys.argv[1])

# Run the system
app.run()