Skip to main content

folderspy

image image

Watch folders for file/directory events with a simple API.

Supports

  • Linux, Windows, Mac
  • Python 2.7 & 3.4-3.7

Installation

pipenv

pipenv install folderspy

pip

pip install folderspy

Example

Create a WatchableFolder class for each of folders you want to watch then simply start watching them with FolderSpy:

import pyinotify  # Linux Only
from folderspy import WatchableFolder, FolderSpy


class SaveFolder(WatchableFolder):

    def __init__(self):
        super(SaveFolder, self).__init__()

        self.path = '/path/to/this/folder'

        # Note: Only used in Linux for pyinotify bitmasks
        # Can be excluded for Windows/Mac
        self.listen_to = pyinotify.IN_CREATE

    def process_IN_CREATE(self, event):
        print('An item was created in this folder!')


FolderSpy.watch(SaveFolder())

Available Folder Events

Linux

    def process_IN_ACCESS(self, event):
        """A file was accessed."""

    def process_IN_ATTRIB(self, event):
        """Metadata changed for a file."""

    def process_IN_CLOSE_NOWRITE(self, event):
        """An unwritable file was closed."""

    def process_IN_CLOSE_WRITE(self, event):
        """A writable file was closed."""

    def process_IN_CREATE(self, event):
        """A file/directory was created in watched directory."""

    def process_IN_DELETE(self, event):
        """A file/directory was deleted in watched directory."""

    def process_IN_DELETE_SELF(self, event):
        """The watched item itself was deleted."""

    def process_IN_ISDIR(self, event):
        """Any event occurred that was on a directory."""

    def process_IN_MODIFY(self, event):
        """A file was modified."""

    def process_IN_MOVE_SELF(self, event):
        """The watched item itself was moved somewhere."""

    def process_IN_MOVED_FROM(self, event):
        """A file/directory was moved away from the current watched directory."""

    def process_IN_MOVED_TO(self, event):
        """A file/directory was moved into the current watched directory."""

    def process_IN_OPEN(self, event):
        """A file was opened."""

    def process_IN_UNMOUNT(self, event):
        """The file system the watched directory is associated with was unmounted."""

Windows

    def process_IN_CREATE(self, event):
        """A file/directory was created in watched directory."""

    def process_IN_DELETE(self, event):
        """A file/directory was deleted in watched directory."""

    def process_IN_MODIFY(self, event):
        """A file was modified."""

    def process_IN_RENAMED_FROM(self, event):
        """The name the file/directory was renamed from."""

    def process_IN_RENAMED_TO(self, event):
        """The name the file/directory was renamed to."""

    def process_IN_ISDIR(self, event):
        """An event occurred that was on a directory."""

Mac

    def process_IN_ATTRIB(self, event):
        """Metadata changed for a file."""

    def process_IN_CREATE(self, event):
        """A file/directory was created in watched directory."""

    def process_IN_DELETE(self, event):
        """A file/directory was deleted in watched directory."""

    def process_IN_MODIFY(self, event):
        """A file was modified."""

    def process_IN_MOVED_FROM(self, event):
        """A file/directory was moved away from the current watched directory."""

    def process_IN_MOVED_TO(self, event):
        """A file/directory was moved into the current watched directory."""

Dependencies

  • Linux: pyinotify
  • Windows: pypiwin32
  • Mac: macfsevents

To-Do

  • Start/Exit Events
  • Tests
  • Clean-up

Contribute

Pull requests are welcome to add in functionality or fix bugs!

Release files for folderspy 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for folderspy 0.0.5
File Size Uploaded
folderspy-0.0.5.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for folderspy 0.0.5
File Interpreter ABI Platform
folderspy-0.0.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.2 kB

Release files / folderspy-0.0.5.tar.gz

Download URL folderspy-0.0.5.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8e9cadddbc9e187d7740ddbe6c6eea3ba1a239d57054e084ec066872f1fe9cb4
BLAKE2b-256 checksum
How to use checksums
f7c4b2073fc26ba017ef21c266a1a084986c489dcee786d2b40e6d5952a707d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / folderspy-0.0.5-py2.py3-none-any.whl

Download URL folderspy-0.0.5-py2.py3-none-any.whl
Size 9.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2f7933c9f38e52edd109d289c6b837020d3d760cfdda0847df613b4586257756
BLAKE2b-256 checksum
How to use checksums
71fda4daf472a1c27058ce3b7bd785b6a77d03ed0b2f960947a4ffaaf7382cba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page