Skip to main content

a simple multi directory watcher and syncer

Project description

pycnysr

A simple directory watcher and syncer

usage

Based on a YAML config file (see the example configuration file), this module synchronizes a local directory to one or more local or remote directories, using rsync as the underlying backend.

It uses two levels of exclusion and inclusion in order to avoid useless expensive rsync calls. At a first level, files that don't need to be monitored can be excluded at a cheap cost. At a second level, only files that need to be really rsynced can be configured and fine tuned.

It should be able to run on Windows, Linux and macOS and generate optional notifications.

in practice

my-repository:
  destinations: [
    "my-host:~/my-repository/"
  ]
  event_handler:
    excludes: [
      ".*tmp.*"
    ]
    includes: [
      ".*/api/.*",
      ".*/conf/.*",
    ]
  notify: true
  rsync:
    filters: [
      "- ***/*.pyc",
      "- ***/__pycache__/",
      "+ api/***",
      "+ conf/***",
      "- *"
    ]
    options: [
      '--archive',
      '--delete',
      '--rsh=ssh'
    ]
  source: ~/Sites/my-repository/

Given this config.yaml file, changes in the source directory ~/Sites/my-repository/ will be propagated to my-host:~/my-repository/ via SSH with options eventually passed in the rsync.options list.

First, only files not excluded in the event_handler.excludes (by default: []) and included by the event_handler.includes (by default: ['.*']) will be passed to the rsync process.

Then, rsync is called with the filter rules built from the rsync.filters list.

Tet's run the watcher:

❯ pycnysr --config config.yaml
2022-10-13 21:03:17 INFO set log level to INFO
2022-10-13 21:03:17 INFO rsync binary is /opt/homebrew/bin/rsync
2022-10-13 21:03:17 INFO using config /Users/laurent/Sites/pycnysr/config.yaml
2022-10-13 21:03:17 INFO syncing repository named my-repository located in /Users/laurent/Sites/pycnysr to ['/Users/laurent/Downloads/dest/']
2022-10-13 21:03:17 INFO observers all initialized

On another console, create a file:

touch api/new-file.txt

See the file synchronized:

2022-10-13 21:03:23 INFO synchronizing /Users/laurent/Sites/pycnysr/new-file.txt

warning

Use with care. early development.

license

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycnysr-0.0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycnysr-0.0.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pycnysr-0.0.2.tar.gz.

File metadata

  • Download URL: pycnysr-0.0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for pycnysr-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a2f18898bc288bfb49145c8025724d1f8b5c732a980d51aa3246023fee17d906
MD5 302215d640e29c295f5fa33c3475202e
BLAKE2b-256 f266a58bb885ba9c6c7cae23d18f8c85c5dd414f192f3f4b8acbf085a9849289

See more details on using hashes here.

File details

Details for the file pycnysr-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pycnysr-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for pycnysr-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dcb67de08133bedd57b92cbf6f39c5060a8b8bf3e64a8ab7946c53f1a617df8a
MD5 2bf348d105baf19d3c369255d7bdd261
BLAKE2b-256 38dd9536751530c7b03f3117f483b204379675d0b10c64e1e0c401c4836c941c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page