Skip to main content

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.

Metadata

Release files for pycnysr 0.0.2

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

Source distribution (sdist)

Source distribution for pycnysr 0.0.2
File Size Uploaded
pycnysr-0.0.2.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycnysr 0.0.2
File Interpreter ABI Platform
pycnysr-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / pycnysr-0.0.2.tar.gz

Download URL pycnysr-0.0.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a2f18898bc288bfb49145c8025724d1f8b5c732a980d51aa3246023fee17d906
BLAKE2b-256 checksum
How to use checksums
f266a58bb885ba9c6c7cae23d18f8c85c5dd414f192f3f4b8acbf085a9849289
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / pycnysr-0.0.2-py3-none-any.whl

Download URL pycnysr-0.0.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcb67de08133bedd57b92cbf6f39c5060a8b8bf3e64a8ab7946c53f1a617df8a
BLAKE2b-256 checksum
How to use checksums
38dd9536751530c7b03f3117f483b204379675d0b10c64e1e0c401c4836c941c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

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